Fix same performance bug as
c3654cfaa77 but for httprepo.py instead.
--- 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