Permalink
Browse files

fallback: _fb_read: add fast-path

  • Loading branch information...
1 parent d91a0d3 commit 4cde7f080c16fd396d758930faf9ebf15b138047 @bwesterb bwesterb committed Jan 29, 2013
Showing with 5 additions and 0 deletions.
  1. +5 −0 msgpack/fallback.py
View
@@ -222,6 +222,11 @@ def _fb_get_extradata(self):
return ''.join(bufs)
def _fb_read(self, n, write_bytes=None):
+ if (write_bytes is None and self._fb_buf_i < len(self._fb_buffers)
+ and self._fb_buf_o + n < len(self._fb_buffers[self._fb_buf_i])):
+ self._fb_buf_o += n
+ return self._fb_buffers[self._fb_buf_i][
+ self._fb_buf_o-n:self._fb_buf_o]
ret = ''
while len(ret) != n:
if self._fb_buf_i == len(self._fb_buffers):

0 comments on commit 4cde7f0

Please sign in to comment.