dirstate.walk: inline imatch
authorMatt Mackall <mpm@selenic.com>
Tue, 22 Jul 2008 13:03:25 -0500
changeset 6832 643ff33812f8
parent 6831 2b663f542bd3
child 6833 6be5edab824c
dirstate.walk: inline imatch This lets us carefully avoid calling ignore and match where possible in the fast path.
mercurial/dirstate.py
--- a/mercurial/dirstate.py	Tue Jul 22 13:03:24 2008 -0500
+++ b/mercurial/dirstate.py	Tue Jul 22 13:03:25 2008 -0500
@@ -434,14 +434,10 @@
             self._ui.warn(_('%s: unsupported file type (type is %s)\n')
                           % (self.pathto(f), kind))
 
-        def imatch(f):
-            return (f in dmap or not ignore(f)) and match(f)
-
         # TODO: don't walk unknown directories if unknown and ignored are False
         ignore = self._ignore
         dirignore = self._dirignore
         if ignored:
-            imatch = match
             ignore = util.never
             dirignore = util.never
 
@@ -493,8 +489,9 @@
                 if not keep:
                     if inst.errno != errno.ENOENT:
                         fwarn(ff, inst.strerror)
-                    elif badfn(ff, inst.strerror) and imatch(nf):
-                        results[nf] = None
+                    elif badfn(ff, inst.strerror):
+                        if (nf in dmap or not ignore(nf)) and match(nf):
+                            results[nf] = None
 
         # step 2: visit subdirectories
         while work:
@@ -520,11 +517,14 @@
                             wadd(nf)
                         if nf in dmap and match(nf):
                             results[nf] = None
-                    elif imatch(nf):
-                        if kind == regkind or kind == lnkkind:
+                    elif kind == regkind or kind == lnkkind:
+                        if nf in dmap:
+                            if match(nf):
+                                results[nf] = st
+                        elif match(nf) and not ignore(nf):
                             results[nf] = st
-                        elif nf in dmap:
-                            results[nf] = None
+                    elif nf in dmap and match(nf):
+                        results[nf] = None
 
         # step 3: report unseen items in the dmap hash
         for nf in util.sort(dmap):