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

login
register
mail settings
Submitter Jun Wu
Date May 11, 2017, 1:47 a.m.
Message ID <ffac07761a9b7e527794.1494467255@x1c>
Download mbox | patch
Permalink /patch/20565/
State Accepted
Headers show

Comments

Jun Wu - May 11, 2017, 1:47 a.m.
# HG changeset patch
# User Jun Wu <quark@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.
Yuya Nishihara - May 15, 2017, 1:47 p.m.
On Wed, 10 May 2017 18:47:35 -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@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

Queued this, thanks.

Patch

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))