changeset 1254:d07ccad28b1a

maps.RevMap: avoid O(revs) property lookups on dict Loading a million-entry revmap goes from 3.72 seconds to 3.65.
author Siddharth Agarwal <sid0@fb.com>
date Sun, 02 Nov 2014 01:34:34 -0800
parents c54214bb6c4e
children 139a44a63090 bc3d0e496424
files hgsubversion/maps.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/maps.py
+++ b/hgsubversion/maps.py
@@ -224,6 +224,7 @@ class RevMap(dict):
     def _load(self):
         lastpulled = self.meta.lastpulled
         firstpulled = self.meta.firstpulled
+        setitem = dict.__setitem__
         for l in self.readmapfile(self.meta.revmap_file):
             revnum, ha, branch = l.split(' ', 2)
             if branch == '\n':
@@ -235,7 +236,7 @@ class RevMap(dict):
                 lastpulled = revnum
             if revnum < firstpulled or not firstpulled:
                 firstpulled = revnum
-            dict.__setitem__(self, (revnum, branch), bin(ha))
+            setitem(self, (revnum, branch), bin(ha))
         self.meta.lastpulled = lastpulled
         self.meta.firstpulled = firstpulled