match: optimize matcher when all patterns are of rootfilesin kind...
match: optimize matcher when all patterns are of rootfilesin kind
Internally at Google, we use narrowspecs with only rootfilesin-kind
patterns. Sometimes there are thousands of such patterns
(i.e. thousands of tracked directories). In such cases, it can take
quite long to build and evaluate the resulting matcher.
This patch optimizes matchers that have only patterns of rootfilesin
so it instead of creating a regular expression, it matches the given
file's directory against the set of directories.
In a repo with ~3600 tracked directories, it takes about 1.35 s to
build the matcher and 2.7 s to walk the dirstate before this
patch. After, it takes 0.04 s to create the matcher and 0.87 s to walk
the dirstate.
It may be worthwhile to do similar optimizations for e.g. patterns of
type "kind:", but that's not a priority for us right now.
Differential Revision:
https://phab.mercurial-scm.org/D5058