Skip to content
Snippets Groups Projects
Commit ef16c92c authored by Dan Villiom Podlaski Christiansen's avatar Dan Villiom Podlaski Christiansen
Browse files

optimise writing the map file

We currently write the map file to a BytesIO buffer, and _then_ write
it to an atomic temporary file. However, the file is opened for atomic
write, so the extra buffering doesn't really add anything other than
overhead.
parent cc59977f
No related branches found
No related tags found
1 merge request!47optimise writing the map file
Pipeline #12974 passed with warnings
......@@ -217,5 +217,4 @@
def save_map(self, map_file):
wlock = self.repo.wlock()
try:
file = self.vfs(map_file, b'w+', atomictemp=True)
map_hg = self._map_hg
......@@ -221,12 +220,8 @@
map_hg = self._map_hg
buf = io.BytesIO()
bwrite = buf.write
for hgsha, gitsha in compat.iteritems(map_hg):
bwrite(b"%s %s\n" % (gitsha, hgsha))
file.write(buf.getvalue())
buf.close()
# If this complains, atomictempfile no longer has close
file.close()
with self.vfs(map_file, b'wb+', atomictemp=True) as buf:
bwrite = buf.write
for hgsha, gitsha in compat.iteritems(map_hg):
bwrite(b"%s %s\n" % (gitsha, hgsha))
finally:
wlock.release()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment