revlog: more efficient implementation for issnapshot
authorBoris Feld <boris.feld@octobus.net>
Mon, 17 Dec 2018 10:51:36 +0100
changeset 41084 84491ae0b3f0
parent 41083 cbc3cbd9ff93
child 41085 a6556b09bf83
revlog: more efficient implementation for issnapshot We avoid multiple method calls and tuple creation, this provides a significant speedup in some case: example affected manifest write before: 0.815520s after: 0.487767s (-40%)
mercurial/revlog.py
--- a/mercurial/revlog.py	Sun Dec 30 16:14:42 2018 +0100
+++ b/mercurial/revlog.py	Mon Dec 17 10:51:36 2018 +0100
@@ -1535,15 +1535,19 @@
         """
         if rev == nullrev:
             return True
-        deltap = self.deltaparent(rev)
-        if deltap == nullrev:
+        entry = self.index[rev]
+        base = entry[3]
+        if base == rev:
             return True
         elif not self._sparserevlog:
             return False
-        p1, p2 = self.parentrevs(rev)
-        if deltap in (p1, p2):
+        if base == nullrev:
+            return True
+        p1 = entry[5]
+        p2 = entry[6]
+        if base == p1 or base == p2:
             return False
-        return self.issnapshot(deltap)
+        return self.issnapshot(base)
 
     def snapshotdepth(self, rev):
         """number of snapshot in the chain before this one"""