# HG changeset patch # User Eric Hopper # Date 2005-10-03 22:06:46 # Node ID 524ca4a06f708a3ae9d3dd5138d9b589029d8400 # Parent f2b00be33e2c586daae8a778ea1587af3dd00e7e Fix same performance bug as c3654cfaa77 but for httprepo.py instead. diff --git a/mercurial/httprepo.py b/mercurial/httprepo.py --- a/mercurial/httprepo.py +++ b/mercurial/httprepo.py @@ -123,23 +123,13 @@ class httprepository(remoterepository): 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