changeset 4990:4491125c0f21

revlogio: speed up parsing - precalcuate ending offset - pull some variables into local scope - separate inline and out of line code paths
author Matt Mackall <mpm@selenic.com>
date Mon, 23 Jul 2007 20:44:08 -0500
parents 1aaed3d69772
children 9c8c42bcf17a
files mercurial/revlog.py
diffstat 1 files changed, 16 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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])