Skip to content

Commit aa0666e

Browse files
committed
Avoid allocating bytes slice in encoding pre-parse
1 parent 6ae4109 commit aa0666e

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

html5lib/_inputstream.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,7 @@ def matchBytes(self, bytes):
658658
"""Look for a sequence of bytes at the start of a string. If the bytes
659659
are found return True and advance the position to the byte after the
660660
match. Otherwise return False and leave the position alone"""
661-
p = self.position
662-
data = self[p:p + len(bytes)]
663-
rv = data.startswith(bytes)
661+
rv = self.startswith(bytes, self.position)
664662
if rv:
665663
self.position += len(bytes)
666664
return rv

0 commit comments

Comments
 (0)