# HG changeset patch # User Siddharth Agarwal # Date 1428639320 25200 # Node ID b56d4f4faf79b93fd11baddde12600d3a84f9154 # Parent 8b51d737f949058355a6394415b22f558dbaa933 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. diff --git a/hggit/git_handler.py b/hggit/git_handler.py --- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -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)) file.write(buf.getvalue()) buf.close() # If this complains, atomictempfile no longer has close