Mercurial > hg-stable
changeset 1376:524ca4a06f70
Fix same performance bug as c3654cfaa77 but for httprepo.py instead.
author | Eric Hopper <hopper@omnifarious.org> |
---|---|
date | Mon, 03 Oct 2005 15:06:46 -0700 |
parents | f2b00be33e2c |
children | 854775b27d1a |
files | mercurial/httprepo.py |
diffstat | 1 files changed, 6 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- 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