changeset 41678:9d0d8793e847

branchmap: decode a label only once This moves decoding of a label out of for loop. Minor speed up expected in cases when one branch has multiple heads. For example: someone using bookmarks as branches and hence ending up with multiple heads on default branch. Differential Revision: https://phab.mercurial-scm.org/D5932
author Pulkit Goyal <pulkit@yandex-team.ru>
date Mon, 11 Feb 2019 15:41:08 +0300
parents bfc49f1df615
children 91701785c2c5
files mercurial/branchmap.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/branchmap.py	Mon Feb 11 15:34:35 2019 +0300
+++ b/mercurial/branchmap.py	Mon Feb 11 15:41:08 2019 +0300
@@ -280,14 +280,14 @@
             f.write(" ".join(cachekey) + '\n')
             nodecount = 0
             for label, nodes in sorted(self.iteritems()):
+                label = encoding.fromlocal(label)
                 for node in nodes:
                     nodecount += 1
                     if node in self._closednodes:
                         state = 'c'
                     else:
                         state = 'o'
-                    f.write("%s %s %s\n" % (hex(node), state,
-                                            encoding.fromlocal(label)))
+                    f.write("%s %s %s\n" % (hex(node), state, label))
             f.close()
             repo.ui.log('branchcache',
                         'wrote %s branch cache with %d labels and %d nodes\n',