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.
--- 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