Mercurial > hg
changeset 40425:5e5c8f2a1eb5
branchmap: do not specify changelog as an argument
Since (unfiltered)repo.changelog lookup gets as fast as __dict__ lookup,
there's no point to pass in changelog instance.
$ hg perfbranchmap --clear-revbranch -R mozilla-central
! base
(orig) wall 20.593091 comb 20.600000 user 20.520000 sys 0.080000 (best of 3)
(this) wall 20.129126 comb 20.130000 user 20.020000 sys 0.110000 (best of 3)
This backs out most of the changes in 76d4272bd57b and 47c03042cd1d.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 23 Oct 2018 21:11:13 +0900 |
parents | 7caf632e30c3 |
children | 59a870a4ad6e |
files | mercurial/branchmap.py |
diffstat | 1 files changed, 10 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/branchmap.py Sat Oct 20 17:56:00 2018 +0900 +++ b/mercurial/branchmap.py Tue Oct 23 21:11:13 2018 +0900 @@ -281,7 +281,7 @@ newbranches = {} getbranchinfo = repo.revbranchcache().branchinfo for r in revgen: - branch, closesbranch = getbranchinfo(r, changelog=cl) + branch, closesbranch = getbranchinfo(r) newbranches.setdefault(branch, []).append(r) if closesbranch: self._closednodes.add(cl.node(r)) @@ -407,10 +407,10 @@ self._rbcrevslen = len(self._repo.changelog) self._rbcrevs = bytearray(self._rbcrevslen * _rbcrecsize) - def branchinfo(self, rev, changelog=None): + def branchinfo(self, rev): """Return branch name and close flag for rev, using and updating persistent cache.""" - changelog = changelog or self._repo.changelog + changelog = self._repo.changelog rbcrevidx = rev * _rbcrecsize # avoid negative index, changelog.read(nullrev) is fast without cache @@ -419,7 +419,7 @@ # if requested rev isn't allocated, grow and cache the rev info if len(self._rbcrevs) < rbcrevidx + _rbcrecsize: - return self._branchinfo(rev, changelog=changelog) + return self._branchinfo(rev) # fast path: extract data from cache, use it if node is matching reponode = changelog.node(rev)[:_rbcnodelen] @@ -447,11 +447,11 @@ self._rbcrevslen = min(self._rbcrevslen, truncate) # fall back to slow path and make sure it will be written to disk - return self._branchinfo(rev, changelog=changelog) + return self._branchinfo(rev) - def _branchinfo(self, rev, changelog=None): + def _branchinfo(self, rev): """Retrieve branch info from changelog and update _rbcrevs""" - changelog = changelog or self._repo.changelog + changelog = self._repo.changelog b, close = changelog.branchinfo(rev) if b in self._namesreverse: branchidx = self._namesreverse[b] @@ -462,7 +462,7 @@ reponode = changelog.node(rev) if close: branchidx |= _rbccloseflag - self._setcachedata(rev, reponode, branchidx, changelog) + self._setcachedata(rev, reponode, branchidx) return b, close def setdata(self, branch, rev, node, close): @@ -485,16 +485,14 @@ if r'branchinfo' in vars(self): del self.branchinfo - def _setcachedata(self, rev, node, branchidx, changelog=None): + def _setcachedata(self, rev, node, branchidx): """Writes the node's branch data to the in-memory cache data.""" if rev == nullrev: return - - changelog = changelog or self._repo.changelog rbcrevidx = rev * _rbcrecsize if len(self._rbcrevs) < rbcrevidx + _rbcrecsize: self._rbcrevs.extend('\0' * - (len(changelog) * _rbcrecsize - + (len(self._repo.changelog) * _rbcrecsize - len(self._rbcrevs))) pack_into(_rbcrecfmt, self._rbcrevs, rbcrevidx, node, branchidx) self._rbcrevslen = min(self._rbcrevslen, rev)