summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleh Prypin <oleh@pryp.in>2020-12-21 02:14:56 +0100
committerWaylan Limberg <waylan.limberg@icloud.com>2020-12-21 14:19:15 -0500
commit4b836201f0dbf1ce763dae3688dee38f1a39a558 (patch)
tree18e24e157642b2e514dbc8fb5ceba7b9b152720e
parentca43456f901abc3706f29f12c3c67ab5c5c4d264 (diff)
downloadpython-markdown-4b836201f0dbf1ce763dae3688dee38f1a39a558.tar.gz
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.
-rw-r--r--markdown/treeprocessors.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/markdown/treeprocessors.py b/markdown/treeprocessors.py
index 055d8ac..eb6bf41 100644
--- a/markdown/treeprocessors.py
+++ b/markdown/treeprocessors.py
@@ -126,7 +126,8 @@ class InlineProcessor(Treeprocessor):
"""
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
)