Patchwork D5291: branchmap: build the revbranchcache._namesreverse() only when required

login
register
mail settings
Submitter phabricator
Date Nov. 24, 2018, 3:27 a.m.
Message ID <ebd61ddd00abf9b8557b54ce347a776b@localhost.localdomain>
Download mbox | patch
Permalink /patch/36756/
State Not Applicable
Headers show

Comments

phabricator - Nov. 24, 2018, 3:27 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG50a64c321c1e: branchmap: build the revbranchcache._namesreverse() only when required (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5291?vs=12586&id=12592

REVISION DETAIL
  https://phab.mercurial-scm.org/D5291

AFFECTED FILES
  mercurial/branchmap.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: yuja, mercurial-devel

Patch

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -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