Skip to content

Commit 86bb6ad

Browse files
[PR #10088/29c3ca93 backport][3.11] Avoid calling len on the same data in the stream reader twice (#10090)
Co-authored-by: J. Nick Koston <nick@koston.org>
1 parent ae2b050 commit 86bb6ad

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

aiohttp/streams.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,9 @@ def _read_nowait_chunk(self, n: int) -> bytes:
517517
else:
518518
data = self._buffer.popleft()
519519

520-
self._size -= len(data)
521-
self._cursor += len(data)
520+
data_len = len(data)
521+
self._size -= data_len
522+
self._cursor += data_len
522523

523524
chunk_splits = self._http_chunk_splits
524525
# Prevent memory leak: drop useless chunk splits

0 commit comments

Comments
 (0)