[PATCH 3 of 3] flagprocessor: add a fast path when flags is 0

Jun Wu quark at fb.com
Wed May 10 21:47:35 EDT 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1494458278 25200
#      Wed May 10 16:17:58 2017 -0700
# Node ID ffac07761a9b7e5277948c5a6572de125b23d296
# Parent  a5a22d616f981e8c220f1c2fd4eae098e104a11c
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r ffac07761a9b
flagprocessor: add a fast path when flags is 0

When flags is 0, _processflags could be a no-op instead of iterating through
the flag bits.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1353,4 +1353,7 @@ class revlog(object):
         operation and will only update the value of ``validatehash``.
         """
+        # fast path: no flag processors will run
+        if flags == 0:
+            return text, True
         if not operation in ('read', 'write'):
             raise ProgrammingError(_("invalid '%s' operation ") % (operation))


More information about the Mercurial-devel mailing list