# HG changeset patch # User Alexis S. L. Carvalho # Date 1173578462 10800 # Node ID ec932167c3a7dcb99cb1c5ef5f93c6d88d2443fc # Parent 9e3121017fb22ccf4101b9b11d1319ff22cb447b Optimize return value of util._matcher for hgignore case diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -509,9 +509,13 @@ def _matcher(canonroot, cwd, names, inc, dummy, exckinds, dummy = normalizepats(exc, 'glob') excmatch = matchfn(exckinds, '(?:/|$)') - return (roots, - lambda fn: (incmatch(fn) and not excmatch(fn) and patmatch(fn)), - (inc or exc or anypats) and True) + if not names and inc and not exc: + # common case: hgignore patterns + match = incmatch + else: + match = lambda fn: incmatch(fn) and not excmatch(fn) and patmatch(fn) + + return (roots, match, (inc or exc or anypats) and True) def system(cmd, environ={}, cwd=None, onerr=None, errprefix=None): '''enhanced shell command execution.