Fix same performance bug as c3654cfaa77 but for httprepo.py instead.
authorEric Hopper <hopper@omnifarious.org>
Mon, 03 Oct 2005 15:06:46 -0700
changeset 1376 524ca4a06f70
parent 1375 f2b00be33e2c
child 1377 854775b27d1a
Fix same performance bug as c3654cfaa77 but for httprepo.py instead.
mercurial/httprepo.py
--- a/mercurial/httprepo.py	Mon Oct 03 14:45:14 2005 -0700
+++ b/mercurial/httprepo.py	Mon Oct 03 15:06:46 2005 -0700
@@ -123,23 +123,13 @@
         f = self.do_cmd("changegroup", roots=n)
         bytes = 0
 
-        class zread:
-            def __init__(self, f):
-                self.zd = zlib.decompressobj()
-                self.f = f
-                self.buf = ""
-            def read(self, l):
-                while l > len(self.buf):
-                    r = self.f.read(4096)
-                    if r:
-                        self.buf += self.zd.decompress(r)
-                    else:
-                        self.buf += self.zd.flush()
-                        break
-                d, self.buf = self.buf[:l], self.buf[l:]
-                return d
+        def zgenerator(f):
+            zd = zlib.decompressobj()
+            for chnk in f:
+                yield zd.decompress(chnk)
+            yield zd.flush()
 
-        return zread(f)
+        return util.chunkbuffer(zgenerator(util.filechunkiter(f)))
 
 class httpsrepository(httprepository):
     pass