changeset 880:10e61cd25e67

git_handler.save_map: don't sort list of tuples Sorting a list of tuples is much more expensive than sorting a list of strings. For a mapfile with 1.5 million entries, this speeds up save_map from 6 seconds to 3.5.
author Siddharth Agarwal <sid0@fb.com>
date Thu, 09 Apr 2015 20:39:53 -0700
parents 99c42969417f
children 95c0f46a6150
files hggit/git_handler.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -187,8 +187,11 @@
 
     def save_map(self, map_file):
         file = self.repo.opener(map_file, 'w+', atomictemp=True)
-        for hgsha, gitsha in sorted(self._map_hg.iteritems()):
-            file.write("%s %s\n" % (gitsha, hgsha))
+        map_hg = self._map_hg
+        hgshas = map_hg.keys()
+        hgshas.sort()
+        for hgsha in hgshas:
+            file.write("%s %s\n" % (map_hg[hgsha], hgsha))
         # If this complains, atomictempfile no longer has close
         file.close()