changeset 16873:37e081609828

util: simplify queue management in chunkbuffer This also fixes a small wire protocol performance regression.
author Bryan O'Sullivan <bryano@fb.com>
date Tue, 05 Jun 2012 16:52:20 -0700
parents 40d930848fd0
children 8017ac7a0e8f
files mercurial/util.py
diffstat 1 files changed, 2 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Sun May 27 18:25:04 2012 +0200
+++ b/mercurial/util.py	Tue Jun 05 16:52:20 2012 -0700
@@ -870,14 +870,14 @@
                 else:
                     yield chunk
         self.iter = splitbig(in_iter)
-        self._queue = []
+        self._queue = deque()
 
     def read(self, l):
         """Read L bytes of data from the iterator of chunks of data.
         Returns less than L bytes if the iterator runs dry."""
         left = l
         buf = ''
-        queue = deque(self._queue)
+        queue = self._queue
         while left > 0:
             # refill the queue
             if not queue:
@@ -897,7 +897,6 @@
                 buf += chunk[:left]
             else:
                 buf += chunk
-        self._queue = list(queue)
 
         return buf