[PATCH 5 of 5 v6] revset: use faster branchcache branchfast function without autoload and close
Mads Kiilerich
mads at kiilerich.com
Sat Oct 18 18:43:37 UTC 2014
# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1413657790 -7200
# Sat Oct 18 20:43:10 2014 +0200
# Node ID 60419932a5a7ff04a4c5f396d778b489d41a62e9
# Parent 16f60e8b47b29373d18d74ab35e673aef3aebfa5
revset: use faster branchcache branchfast function without autoload and close
This gives some code duplication, but perfrevset 'branch(mobile)' on
mozilla-central shows 10% improvement:
Before:
! wall 0.659279 comb 0.660000 user 0.660000 sys 0.000000 (best of 15)
After:
! wall 0.605124 comb 0.610000 user 0.610000 sys 0.000000 (best of 17)
diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -396,6 +396,22 @@ class revbranchcache(object):
return self.branchinfo(rev)[0]
+ def branchfast(self, rev):
+ """Return branch name for rev, using and updating persistent cache.
+ The cache must be loaded first."""
+ node = self._repo.changelog.node(rev)
+ cachenode, branchidx = struct.unpack_from(bcrecfmt, self._records,
+ rev * bcrecsize)
+ branchidx &= bcbranchidxmask
+ if cachenode == node and branchidx < len(self._nameslocal):
+ b = self._nameslocal[branchidx]
+ if b:
+ return b
+ b = encoding.tolocal(self._namesutf8[branchidx])
+ self._nameslocal[branchidx] = b
+ return b
+ return self.branchinfo(rev)[0]
+
def save(self):
"""Save branch cache if it is dirty."""
if self._dirty:
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -478,7 +478,8 @@ def branch(repo, subset, x):
a regular expression. To match a branch that actually starts with `re:`,
use the prefix `literal:`.
"""
- branch = repo.revbranchcache.branch
+ branch = repo.revbranchcache.load()
+ branch = repo.revbranchcache.branchfast
try:
b = getstring(x, '')
except error.ParseError:
More information about the Mercurial-devel
mailing list