Mercurial > hg
changeset 40710:50a64c321c1e
branchmap: build the revbranchcache._namesreverse() only when required
On big repositories with a lot of named branches and that also increasing over
time, building of this dict can be expensive and shows up in profile.
For our internal repository, this saves ~0.05 seconds.
Thanks to Yuya for suggesting using util.propertycache() and
util.clearcachedproperty().
Differential Revision: https://phab.mercurial-scm.org/D5291
author | Pulkit Goyal <pulkit@yandex-team.ru> |
---|---|
date | Wed, 21 Nov 2018 17:17:26 +0300 |
parents | 39d29542fe40 |
children | 72d88a975655 |
files | mercurial/branchmap.py |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/branchmap.py Thu Nov 15 11:11:38 2018 +0100 +++ b/mercurial/branchmap.py Wed Nov 21 17:17:26 2018 +0300 @@ -397,15 +397,18 @@ self._names = [] self._rbcnamescount = len(self._names) # number of names read at # _rbcsnameslen - self._namesreverse = dict((b, r) for r, b in enumerate(self._names)) def _clear(self): self._rbcsnameslen = 0 del self._names[:] self._rbcnamescount = 0 - self._namesreverse.clear() self._rbcrevslen = len(self._repo.changelog) self._rbcrevs = bytearray(self._rbcrevslen * _rbcrecsize) + util.clearcachedproperty(self, '_namesreverse') + + @util.propertycache + def _namesreverse(self): + return dict((b, r) for r, b in enumerate(self._names)) def branchinfo(self, rev): """Return branch name and close flag for rev, using and updating