Mercurial > public > mercurial-scm > hg
diff mercurial/revlog.py @ 41086:a28833d79aca
revlog: use the native implementation of issnapshot
In some sparserevlog case where a lot of the history has to be searched for a
snapshot, the cost of issnashot cost becomes significant. The computation done
by the method is fairly low level, a native implementation provide a very
significant speedup.
example affected manifest write
before: 0.490375s
after: 0.114989s (-76%)
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Fri, 21 Dec 2018 05:27:38 +0100 |
parents | 84491ae0b3f0 |
children | 536c83535cbd |
line wrap: on
line diff
--- a/mercurial/revlog.py Mon Dec 17 10:57:13 2018 +0100 +++ b/mercurial/revlog.py Fri Dec 21 05:27:38 2018 +0100 @@ -1533,14 +1533,18 @@ def issnapshot(self, rev): """tells whether rev is a snapshot """ + if not self._sparserevlog: + return self.deltaparent(rev) == nullrev + elif util.safehasattr(self.index, 'issnapshot'): + # directly assign the method to cache the testing and access + self.issnapshot = self.index.issnapshot + return self.issnapshot(rev) if rev == nullrev: return True entry = self.index[rev] base = entry[3] if base == rev: return True - elif not self._sparserevlog: - return False if base == nullrev: return True p1 = entry[5]