# HG changeset patch # User Siddharth Agarwal # Date 1428637193 25200 # Node ID 10e61cd25e67a291c466f10deba290204281b484 # Parent 99c42969417f9b3a7ba63afba676408a9a8a04e3 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. diff --git a/hggit/git_handler.py b/hggit/git_handler.py --- 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()