Make lazyindex load slightly faster
authormpm@selenic.com
Fri, 20 May 2005 17:34:04 -0800
changeset 115 39b438eeb25a
parent 114 82fb6d09f911
child 116 e484cd5ec282
Make lazyindex load slightly faster
mercurial/revlog.py
--- a/mercurial/revlog.py	Fri May 20 17:33:24 2005 -0800
+++ b/mercurial/revlog.py	Fri May 20 17:34:04 2005 -0800
@@ -77,12 +77,11 @@
         self.p = parser
     def __len__(self):
         return len(self.p.index)
+    def load(self, pos):
+        self.p.load(pos)
+        return self.p.index[pos]
     def __getitem__(self, pos):
-        i = self.p.index[pos]
-        if not i:
-            self.p.load(pos)
-            return self.p.index[pos]
-        return i
+        return self.p.index[pos] or self.load(pos)
     def append(self, e):
         self.p.index.append(e)