revlogio: speed up parsing
- precalcuate ending offset
- pull some variables into local scope
- separate inline and out of line code paths
--- 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])