changeset 31802:ac9a5e89113a

revlog: avoid calculating "flags" twice in revision() This is more consistent with other code in "revision()" - prefer performance to code length.
author Jun Wu <quark@fb.com>
date Sun, 02 Apr 2017 18:25:12 -0700
parents d22f29abeb42
children 2be73f9720a8
files mercurial/revlog.py
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Sun Apr 02 18:57:03 2017 -0700
+++ b/mercurial/revlog.py	Sun Apr 02 18:25:12 2017 -0700
@@ -1267,6 +1267,7 @@
             rev = None
 
         cachedrev = None
+        flags = None
         if node == nullid:
             return ""
         if self._cache:
@@ -1277,8 +1278,10 @@
                 # duplicated, but good for perf
                 if rev is None:
                     rev = self.rev(node)
+                if flags is None:
+                    flags = self.flags(rev)
                 # no extra flags set, no flag processor runs, text = rawtext
-                if self.flags(rev) == REVIDX_DEFAULT_FLAGS:
+                if flags == REVIDX_DEFAULT_FLAGS:
                     return self._cache[2]
 
             cachedrev = self._cache[1]
@@ -1302,8 +1305,10 @@
 
         rawtext = mdiff.patches(rawtext, bins)
 
-        text, validatehash = self._processflags(rawtext, self.flags(rev),
-                                                'read', raw=raw)
+        if flags is None:
+            flags = self.flags(rev)
+
+        text, validatehash = self._processflags(rawtext, flags, 'read', raw=raw)
         if validatehash:
             self.checkhash(text, node, rev=rev)