Skip to content

Commit

Permalink
[PR #10088/29c3ca93 backport][3.11] Avoid calling len on the same dat…
Browse files Browse the repository at this point in the history
…a in the stream reader twice (#10090)

Co-authored-by: J. Nick Koston <nick@koston.org>
  • Loading branch information
patchback[bot] and bdraco authored Dec 2, 2024
1 parent ae2b050 commit 86bb6ad
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 @@ -517,8 +517,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 86bb6ad

Please sign in to comment.