changeset 883:b56d4f4faf79

git_mapfile.save_map: stop sorting the keys entirely There really is no point to this -- the sorting is expensive to compute and the structure is never actually used. For a mapfile with 1.5 million entries, this speeds up save_map from 3.6 seconds to 0.87. This is probably the limit of the speedups we can get with pure-Python code. Any further speedups will have to be made by rewriting these bits in C.
author Siddharth Agarwal <>
date Thu, 09 Apr 2015 21:15:20 -0700
parents 8b51d737f949
children 4d67686c0e64
files hggit/
diffstat 1 files changed, 2 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/
+++ b/hggit/
@@ -188,12 +188,10 @@
     def save_map(self, map_file):
         file = self.repo.opener(map_file, 'w+', atomictemp=True)
         map_hg = self._map_hg
-        hgshas = map_hg.keys()
-        hgshas.sort()
         buf = cStringIO.StringIO()
         bwrite = buf.write
-        for hgsha in hgshas:
-            bwrite("%s %s\n" % (map_hg[hgsha], hgsha))
+        for hgsha, gitsha in map_hg.iteritems():
+            bwrite("%s %s\n" % (gitsha, hgsha))
         # If this complains, atomictempfile no longer has close