Patchwork [2,of,5] branchmap: stop membership test in update logic

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 7, 2014, 1:38 a.m.
Message ID <96ce837f46741b946414.1389058704@marginatus.fb.com>
Download mbox | patch
Permalink /patch/3262/
State Accepted
Commit 0d7d800eed769406c630a421651e8e5e39505d87
Headers show

Comments

Pierre-Yves David - Jan. 7, 2014, 1:38 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1358276652 -3600
#      Tue Jan 15 20:04:12 2013 +0100
# Node ID 96ce837f46741b94641452b48fec41c540a59231
# Parent  4dcd2535942b73c76560a8be6b679dedbc0f2cb7
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.

Patch

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -232,18 +232,12 @@  class branchcache(dict):
         # 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():
             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
             # was already a head (because they're on different branches).
             bheadrevs = sorted(set(bheadrevs).union(newheadrevs))