Skip to content

Commit

Permalink
Avoid calling len on the same data in the stream reader twice (aio-li…
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Dec 2, 2024
1 parent ca193c7 commit 29c3ca9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions aiohttp/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,9 @@ def _read_nowait_chunk(self, n: int) -> bytes:
else:
data = self._buffer.popleft()

self._size -= len(data)
self._cursor += len(data)
data_len = len(data)
self._size -= data_len
self._cursor += data_len

chunk_splits = self._http_chunk_splits
# Prevent memory leak: drop useless chunk splits
Expand Down

0 comments on commit 29c3ca9

Please sign in to comment.