# HG changeset patch # User Matt Mackall # Date 1185241448 18000 # Node ID 4491125c0f2142b3b4be15e2320ac51c4586daf5 # Parent 1aaed3d69772c3df60971d79d323bf6301f8686a revlogio: speed up parsing - precalcuate ending offset - pull some variables into local scope - separate inline and out of line code paths diff -r 1aaed3d69772 -r 4491125c0f21 mercurial/revlog.py --- a/mercurial/revlog.py Mon Jul 23 20:44:08 2007 -0500 +++ b/mercurial/revlog.py Mon Jul 23 20:44:08 2007 -0500 @@ -360,19 +360,26 @@ n = off = 0 # if we're not using lazymap, always read the whole index data = fp.read() - l = len(data) + l = len(data) - s + unpack = struct.unpack + append = index.append if inline: cache = (0, data) - while off + s <= l: - e = struct.unpack(indexformatng, data[off:off + s]) - index.append(e) - nodemap[e[7]] = n - n += 1 - off += s - if inline: + while off <= l: + e = unpack(indexformatng, data[off:off + s]) + nodemap[e[7]] = n + append(e) + n += 1 if e[1] < 0: break - off += e[1] + off += e[1] + s + else: + while off <= l: + e = unpack(indexformatng, data[off:off + s]) + nodemap[e[7]] = n + append(e) + n += 1 + off += s e = list(index[0]) type = gettype(e[0])