util: simplify queue management in chunkbuffer
authorBryan O'Sullivan <bryano@fb.com>
Tue, 05 Jun 2012 16:52:20 -0700
changeset 16873 37e081609828
parent 16872 40d930848fd0
child 16874 8017ac7a0e8f
util: simplify queue management in chunkbuffer This also fixes a small wire protocol performance regression.
mercurial/util.py
--- 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