8000 fallback: add some comments to _fb_read · didlie/msgpack-python@952eb9f · GitHub
[go: up one dir, main page]

8000 Skip to content

Commit 952eb9f

Browse files
committed
fallback: add some comments to _fb_read
1 parent 7eb371f commit 952eb9f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

msgpack/fallback.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,15 @@ def _fb_get_extradata(self):
252252

253253
def _fb_read(self, n, write_bytes=None):
254254
buffs = self._fb_buffers
255+
# We have a redundant codepath for the most common case, such that
256+
# pypy optimizes it properly. This is the case that the read fits
257+
# in the current buffer.
255258
if (write_bytes is None and self._fb_buf_i < len(buffs) and
256259
self._fb_buf_o + n < len(buffs[self._fb_buf_i])):
257260
self._fb_buf_o += n
258261
return buffs[self._fb_buf_i][self._fb_buf_o - n:self._fb_buf_o]
259262

263+
# The remaining cases.
260264
ret = b''
261265
while len(ret) != n:
262266
if self._fb_buf_i == len(buffs):

0 commit comments

Comments
 (0)
0