changeset 115:39b438eeb25a

Make lazyindex load slightly faster
author mpm@selenic.com
date Fri, 20 May 2005 17:34:04 -0800
parents 82fb6d09f911
children e484cd5ec282
files mercurial/revlog.py
diffstat 1 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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)