summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas Westerbaan <bas@westerbaan.name>2013-01-29 03:46:07 +0100
committerBas Westerbaan <bas@westerbaan.name>2013-01-29 03:46:07 +0100
commit4cde7f080c16fd396d758930faf9ebf15b138047 (patch)
treec93ffefe22f3f29a6fc9ead28c0cd733cc64ec23
parentd91a0d3d68bef38be667ba8e931e3f53cf90be6f (diff)
downloadmsgpack-python-4cde7f080c16fd396d758930faf9ebf15b138047.tar.gz
fallback: _fb_read: add fast-path
-rw-r--r--msgpack/fallback.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/msgpack/fallback.py b/msgpack/fallback.py
index 2f83a20..bd50b47 100644
--- a/msgpack/fallback.py
+++ b/msgpack/fallback.py
@@ -222,6 +222,11 @@ class Unpacker(object):
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):