# HG changeset patch # User Matt Mackall # Date 2008-07-22 18:03:31 # Node ID cbdfd08eabc96116d801d0e2e7d1856adfdde911 # Parent 6be5edab824c38352146bc04eaf4919b4e791b80 dirstate.walk: speed up calling match function diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -441,6 +441,7 @@ class dirstate(object): ignore = util.never dirignore = util.never + matchfn = match.matchfn dmap = self._map normpath = util.normpath normalize = self.normalize @@ -490,7 +491,7 @@ class dirstate(object): if inst.errno != errno.ENOENT: fwarn(ff, inst.strerror) elif badfn(ff, inst.strerror): - if (nf in dmap or not ignore(nf)) and match(nf): + if (nf in dmap or not ignore(nf)) and matchfn(nf): results[nf] = None # step 2: visit subdirectories @@ -515,15 +516,15 @@ class dirstate(object): if kind == dirkind: if not ignore(nf): wadd(nf) - if nf in dmap and match(nf): + if nf in dmap and matchfn(nf): results[nf] = None elif kind == regkind or kind == lnkkind: if nf in dmap: - if match(nf): + if matchfn(nf): results[nf] = st - elif match(nf) and not ignore(nf): + elif matchfn(nf) and not ignore(nf): results[nf] = st - elif nf in dmap and match(nf): + elif nf in dmap and matchfn(nf): results[nf] = None # step 3: report unseen items in the dmap hash diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -6,10 +6,10 @@ class _match(object): self._cwd = cwd self._files = files self._fmap = dict.fromkeys(files) - self._matchfn = mf + self.matchfn = mf self._anypats = ap def __call__(self, fn): - return self._matchfn(fn) + return self.matchfn(fn) def __iter__(self): for f in self._files: yield f