Patchwork [3,of,5] branchmap: stop useless rev -> node -> rev round trip

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 7, 2014, 1:38 a.m.
Message ID <30aff651beece3d31ab3.1389058705@marginatus.fb.com>
Download mbox | patch
Permalink /patch/3263/
State Accepted
Commit 9ab0b704836f97be9524ce13e3524a666c53f188
Headers show

Comments

Pierre-Yves David - Jan. 7, 2014, 1:38 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1388796263 28800
#      Fri Jan 03 16:44:23 2014 -0800
# Node ID 30aff651beece3d31ab3eb70b6cb40bd6b8bdf88
# Parent  96ce837f46741b94641452b48fec41c540a59231
branchmap: stop useless rev -> node -> rev round trip

We never use the node of new revisions unless in the very specific case of
closed heads. So we can just use the revision number.

So give another handfull of percent speedup.

Patch

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -223,21 +223,19 @@  class branchcache(dict):
         # collect new branch entries
         newbranches = {}
         getbranchinfo = cl.branchinfo
         for r in revgen:
             branch, closesbranch = getbranchinfo(r)
-            node = cl.node(r)
-            newbranches.setdefault(branch, []).append(node)
+            newbranches.setdefault(branch, []).append(r)
             if closesbranch:
-                self._closednodes.add(node)
+                self._closednodes.add(cl.node(r))
         # if older branchheads are reachable from new ones, they aren't
         # really branchheads. Note checking parents is insufficient:
         # 1 (branch a) -> 2 (branch b) -> 3 (branch a)
-        for branch, newnodes in newbranches.iteritems():
+        for branch, newheadrevs in newbranches.iteritems():
             bheads = self.setdefault(branch, [])
             bheadrevs = [cl.rev(node) for node in bheads]
-            newheadrevs = [cl.rev(node) for node in newnodes]
             ctxisnew = bheadrevs and min(newheadrevs) > max(bheadrevs)
             # Remove duplicates - nodes that are in newheadrevs and are already
             # in bheadrevs.  This can happen if you strip a node whose parent
             # was already a head (because they're on different branches).
             bheadrevs = sorted(set(bheadrevs).union(newheadrevs))