Skip to content

Commit 4b83620

Browse files
oprypinwaylan
authored andcommitted
Optimize away a len call in InlineProcessor
- 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.
1 parent ca43456 commit 4b83620

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

markdown/treeprocessors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ def __handleInline(self, data, patternIndex=0):
126126
"""
127127
if not isinstance(data, util.AtomicString):
128128
startIndex = 0
129-
while patternIndex < len(self.inlinePatterns):
129+
count = len(self.inlinePatterns)
130+
while patternIndex < count:
130131
data, matched, startIndex = self.__applyPattern(
131132
self.inlinePatterns[patternIndex], data, patternIndex, startIndex
132133
)

0 commit comments

Comments
 (0)