changeset 881: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
files hggit/git_handler.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -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()