Patchwork [3,of,4] dirstate.walk: fast path match-always case during traversal

login
register
mail settings
Submitter Siddharth Agarwal
Date March 23, 2013, 2:37 a.m.
Message ID <c7d166d7e6f33d7888b2.1364006223@sid0x220>
Download mbox | patch
Permalink /patch/1171/
State Superseded
Commit 1413ba4102448cebc47e2c97512dc63eb7c87f47
Headers show

Comments

Siddharth Agarwal - March 23, 2013, 2:37 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1363996980 25200
#      Fri Mar 22 17:03:00 2013 -0700
# Node ID c7d166d7e6f33d7888b2980977c8d32d4bfbd87f
# Parent  90293fb6b3d77c76a5985f7003bdeac8d60878e0
dirstate.walk: fast path match-always case during traversal

This case is a common one -- e.g. `hg status`.

For a repository with 170,000 files, this speeds up perfstatus --unknown from
2.15 seconds to 2.09.

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -577,6 +577,7 @@  class dirstate(object):
             dirignore = util.always
 
         matchfn = match.matchfn
+        matchalways = match.always()
         badfn = match.bad
         dmap = self._map
         normpath = util.normpath
@@ -684,15 +685,15 @@  class dirstate(object):
                         if not ignore(nf):
                             match.dir(nf)
                             wadd(nf)
-                        if nf in dmap and matchfn(nf):
+                        if nf in dmap and (matchalways or matchfn(nf)):
                             results[nf] = None
                     elif kind == regkind or kind == lnkkind:
                         if nf in dmap:
-                            if matchfn(nf):
+                            if (matchalways or matchfn(nf)):
                                 results[nf] = st
-                        elif matchfn(nf) and not ignore(nf):
+                        elif (matchalways or matchfn(nf)) and not ignore(nf):
                             results[nf] = st
-                    elif nf in dmap and matchfn(nf):
+                    elif nf in dmap and (matchalways or matchfn(nf)):
                         results[nf] = None
 
         for s in subrepos: