Skip to content

Commit

Permalink
Optimize away a len call in InlineProcessor
Browse files Browse the repository at this point in the history
- just get the length once at the beginning.

The gains are tiny but when the total number of calls to these is in the hundreds of thousands, it makes a sizeable difference.
  • Loading branch information
oprypin authored and waylan committed Dec 21, 2020
1 parent ca43456 commit 4b83620
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion markdown/treeprocessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ def __handleInline(self, data, patternIndex=0):
"""
if not isinstance(data, util.AtomicString):
startIndex = 0
while patternIndex < len(self.inlinePatterns):
count = len(self.inlinePatterns)
while patternIndex < count:
data, matched, startIndex = self.__applyPattern(
self.inlinePatterns[patternIndex], data, patternIndex, startIndex
)
Expand Down

0 comments on commit 4b83620

Please sign in to comment.