revlog: avoid calculating "flags" twice in revision()
authorJun Wu <quark@fb.com>
Sun, 02 Apr 2017 18:25:12 -0700
changeset 31802 ac9a5e89113a
parent 31801 d22f29abeb42
child 31803 2be73f9720a8
revlog: avoid calculating "flags" twice in revision() This is more consistent with other code in "revision()" - prefer performance to code length.
mercurial/revlog.py
--- 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)