marmoute created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers.
REVISION SUMMARY Having faster access to `null` is cuteā¦ but limited. We want to speedup access to more useful revision, like `.`. We start with turning the fast path for `null` into something more generic. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D7488 AFFECTED FILES mercurial/localrepo.py CHANGE DETAILS diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1514,6 +1514,19 @@ narrowspec.save(self, newincludes, newexcludes) self.invalidate(clearfilecache=True) + @util.propertycache + def _quick_access_changeid(self): + """an helper dictionnary for __getitem__ calls + + This contains a list of symbol we can recognise right away without + further processing. + """ + return { + b'null': (nullrev, nullid), + nullrev: (nullrev, nullid), + nullid: (nullrev, nullid), + } + def __getitem__(self, changeid): # dealing with special cases if changeid is None: @@ -1531,8 +1544,10 @@ ] # dealing with some special values - if changeid == b'null' or changeid == nullrev or changeid == nullid: - return context.changectx(self, nullrev, nullid, False) + quick_access = self._quick_access_changeid.get(changeid) + if quick_access is not None: + rev, node = quick_access + return context.changectx(self, rev, node, False) if changeid == b'tip': node = self.changelog.tip() rev = self.changelog.rev(node) To: marmoute, #hg-reviewers Cc: mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel