branchmap: stop membership test in update logic
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 15 Jan 2013 20:04:12 +0100
changeset 20261 3fee302a48e6
parent 20260 586ec8fe1c3c
child 20262 cf450ee3f8f7
branchmap: stop membership test in update logic Now that no user try to update the cache on a truncated repo we can drop the extra lookup. Give an handfull percent speedup on big branchmap update.
mercurial/branchmap.py
--- a/mercurial/branchmap.py	Fri Jan 03 17:06:07 2014 -0800
+++ b/mercurial/branchmap.py	Tue Jan 15 20:04:12 2013 +0100
@@ -239,14 +239,8 @@
         # 1 (branch a) -> 2 (branch b) -> 3 (branch a)
         for branch, newnodes in newbranches.iteritems():
             bheads = self.setdefault(branch, [])
-            # Remove candidate heads that no longer are in the repo (e.g., as
-            # the result of a strip that just happened).  Avoid using 'node in
-            # self' here because that dives down into branchcache code somewhat
-            # recursively.
-            bheadrevs = [cl.rev(node) for node in bheads
-                         if cl.hasnode(node)]
-            newheadrevs = [cl.rev(node) for node in newnodes
-                           if cl.hasnode(node)]
+            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