Skip to content

Commit 062a245

Browse files
committed
don't rely on CPython refcounting hack to build result efficiently
decode_chunked_transfer is still O(N^2) because of t.split
1 parent 2675e03 commit 062a245

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

scrapy/utils/http.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ def decode_chunked_transfer(chunked_body):
1414
http://en.wikipedia.org/wiki/Chunked_transfer_encoding
1515
1616
"""
17-
body, h, t = b'', b'', chunked_body
17+
body_parts, h, t = [], b'', chunked_body
1818
while t:
1919
h, t = t.split(b'\r\n', 1)
2020
if h == b'0':
2121
break
2222
size = int(h, 16)
23-
body += t[:size]
23+
body_parts.append(t[:size])
2424
t = t[size+2:]
25-
return body
25+
return b''.join(body_parts)
2626

0 commit comments

Comments
 (0)