diff hggit/git_handler.py @ 880:95c0f46a6150

git_handler.save_map: buffer the output For a mapfile with 1.5 million entries, this speeds up save_map from 3.5 seconds to 3.1.
author Siddharth Agarwal <sid0@fb.com>
date Thu, 09 Apr 2015 20:50:26 -0700
parents 10e61cd25e67
children 8b51d737f949
line wrap: on
line diff
--- a/hggit/git_handler.py	Thu Apr 09 20:39:53 2015 -0700
+++ b/hggit/git_handler.py	Thu Apr 09 20:50:26 2015 -0700
@@ -190,8 +190,13 @@
         map_hg = self._map_hg
         hgshas = map_hg.keys()
         hgshas.sort()
+        import cStringIO
+        buf = cStringIO.StringIO()
+        bwrite = buf.write
         for hgsha in hgshas:
-            file.write("%s %s\n" % (map_hg[hgsha], hgsha))
+            bwrite("%s %s\n" % (map_hg[hgsha], hgsha))
+        file.write(buf.getvalue())
+        buf.close()
         # If this complains, atomictempfile no longer has close
         file.close()