Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 41089: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 |
comparison
equal
deleted
inserted
replaced
41088:a6556b09bf83 | 41089:a28833d79aca |
---|---|
1531 return rev - 1 | 1531 return rev - 1 |
1532 | 1532 |
1533 def issnapshot(self, rev): | 1533 def issnapshot(self, rev): |
1534 """tells whether rev is a snapshot | 1534 """tells whether rev is a snapshot |
1535 """ | 1535 """ |
1536 if not self._sparserevlog: | |
1537 return self.deltaparent(rev) == nullrev | |
1538 elif util.safehasattr(self.index, 'issnapshot'): | |
1539 # directly assign the method to cache the testing and access | |
1540 self.issnapshot = self.index.issnapshot | |
1541 return self.issnapshot(rev) | |
1536 if rev == nullrev: | 1542 if rev == nullrev: |
1537 return True | 1543 return True |
1538 entry = self.index[rev] | 1544 entry = self.index[rev] |
1539 base = entry[3] | 1545 base = entry[3] |
1540 if base == rev: | 1546 if base == rev: |
1541 return True | 1547 return True |
1542 elif not self._sparserevlog: | |
1543 return False | |
1544 if base == nullrev: | 1548 if base == nullrev: |
1545 return True | 1549 return True |
1546 p1 = entry[5] | 1550 p1 = entry[5] |
1547 p2 = entry[6] | 1551 p2 = entry[6] |
1548 if base == p1 or base == p2: | 1552 if base == p1 or base == p2: |