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

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Thu Nov 22 04:44:26 EST 2018


pulkit added a comment.


  In https://phab.mercurial-scm.org/D5291#78794, @yuja wrote:
  
  > > +        if self._namesreverse is None:
  > >  +            self._namesreverse = dict((b, r) for r, b in enumerate(self._names))
  > > 
  > >   if b in self._namesreverse:
  > >       branchidx = self._namesreverse[b]
  > >   else:
  > > 
  > > @@ -467,6 +469,8 @@
  > > 
  > >   def setdata(self, branch, rev, node, close):
  > >       """add new data information to the cache"""
  > > 
  > > +        if self._namesreverse is None:
  > >  +            self._namesreverse = dict((b, r) for r, b in enumerate(self._names))
  >
  > Maybe _namesreverse can be a propertycache, instead of duplicating it.
  >  `del self.__dict__[r'...']` can be used to discard the cache.
  
  
  Hm, I am not sure if I feel good about doing `del self.__dict__[r'...']` thing.

REPOSITORY
  rHG Mercurial

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

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


More information about the Mercurial-devel mailing list