Skip to content

Commit f000f56

Browse files
committed
Made charsUntil a little bit faster when matching extremely short strings
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%401242
1 parent ce43212 commit f000f56

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/html5lib/inputstream.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,13 @@ def charsUntil(self, characters, opposite = False):
337337
regex = u"".join([u"\\x%02x" % ord(c) for c in characters])
338338
if not opposite:
339339
regex = u"^%s" % regex
340-
chars = charsUntilRegEx[(characters, opposite)] = re.compile(u"[%s]*" % regex)
340+
chars = charsUntilRegEx[(characters, opposite)] = re.compile(u"[%s]+" % regex)
341341

342342
while True:
343343
# Find the longest matching prefix
344344
m = chars.match(self.chunk, self.chunkOffset)
345+
if m is None:
346+
break
345347
# If not everything matched, return everything up to the part that didn't match
346348
end = m.end()
347349
if end != self.chunkSize:

0 commit comments

Comments
 (0)