Skip to content

Commit c5931f4

Browse files
cdelerpgjones
authored andcommitted
Fixed PR remarks
Replaced lines.rstrip(...) with `del line[-1]` to avoid extra allocations
1 parent c80c416 commit c5931f4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

h11/_receivebuffer.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ def maybe_extract_lines(self):
127127
# Truncate the buffer and return it.
128128
idx = match.span(0)[-1]
129129
out = self._extract(idx)
130-
lines = [line.rstrip(b"\r") for line in out.split(b"\n")]
130+
lines = out.split(b"\n")
131+
132+
for line in lines:
133+
if line.endswith(b"\r"):
134+
del line[-1]
131135

132136
assert lines[-2] == lines[-1] == b""
133137

0 commit comments

Comments
 (0)