revlog: add a fast path for revision(raw=False)
authorJun Wu <quark@fb.com>
Thu, 30 Mar 2017 21:21:15 -0700
changeset 31756 9ec03d5af48f
parent 31755 ec48d57de110
child 31757 473f2fcc7629
revlog: add a fast path for revision(raw=False) If cache hit and flags are empty, no flag processor runs and "text" equals to "rawtext". So we check flags, and return rawtext. This resolves performance issue introduced by a previous patch.
mercurial/revlog.py
--- a/mercurial/revlog.py	Thu Mar 30 18:38:03 2017 -0700
+++ b/mercurial/revlog.py	Thu Mar 30 21:21:15 2017 -0700
@@ -1274,6 +1274,13 @@
                 # _cache only stores rawtext
                 if raw:
                     return self._cache[2]
+                # duplicated, but good for perf
+                if rev is None:
+                    rev = self.rev(node)
+                # no extra flags set, no flag processor runs, text = rawtext
+                if self.flags(rev) == REVIDX_DEFAULT_FLAGS:
+                    return self._cache[2]
+
             cachedrev = self._cache[1]
 
         # look up what we need to read