Skip to content

Commit

Permalink
Avoid allocating bytes slice in encoding pre-parse
Browse files Browse the repository at this point in the history
  • Loading branch information
gsnedders committed Jun 17, 2020
1 parent 0db23a3 commit f1b28b0
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions html5lib/_inputstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,9 +658,7 @@ def matchBytes(self, bytes):
"""Look for a sequence of bytes at the start of a string. If the bytes
are found return True and advance the position to the byte after the
match. Otherwise return False and leave the position alone"""
p = self.position
data = self[p:p + len(bytes)]
rv = data.startswith(bytes)
rv = self.startswith(bytes, self.position)
if rv:
self.position += len(bytes)
return rv
Expand Down

0 comments on commit f1b28b0

Please sign in to comment.