From 2ecef504147871585ea05b6003bd56794af90ddc Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 2 Jun 2014 22:28:55 -0400 Subject: Avoid filling the fnmatch cache --- coverage/files.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'coverage/files.py') diff --git a/coverage/files.py b/coverage/files.py index 94388f96..08ce1e84 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -1,7 +1,7 @@ """File wrangling.""" from coverage.backward import to_string -from coverage.misc import CoverageException +from coverage.misc import CoverageException, join_regex import fnmatch, os, os.path, re, sys import ntpath, posixpath @@ -177,6 +177,7 @@ class FnmatchMatcher(object): """A matcher for files by filename pattern.""" def __init__(self, pats): self.pats = pats[:] + self.re = re.compile(join_regex([fnmatch.translate(p) for p in pats])) def __repr__(self): return "" % self.pats @@ -187,10 +188,7 @@ class FnmatchMatcher(object): def match(self, fpath): """Does `fpath` match one of our filename patterns?""" - for pat in self.pats: - if fnmatch.fnmatch(fpath, pat): - return True - return False + return self.re.match(fpath) is not None def sep(s): -- cgit v1.2.1 From 357d789ddf413a55326623aed47ad816b3f78071 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 3 Jun 2014 06:37:27 -0400 Subject: Fix the new FnmatchMatcher for >100 patterns --- coverage/files.py | 1 + 1 file changed, 1 insertion(+) (limited to 'coverage/files.py') diff --git a/coverage/files.py b/coverage/files.py index 08ce1e84..80b69572 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -188,6 +188,7 @@ class FnmatchMatcher(object): def match(self, fpath): """Does `fpath` match one of our filename patterns?""" + #print("Matching %r against %r" % (self.re.pattern, fpath)) return self.re.match(fpath) is not None -- cgit v1.2.1 From 6af2c3995a87c8c7ab45add31b39504b8695f6c0 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 3 Jun 2014 06:38:25 -0400 Subject: Remove debugging --- coverage/files.py | 1 - 1 file changed, 1 deletion(-) (limited to 'coverage/files.py') diff --git a/coverage/files.py b/coverage/files.py index 80b69572..08ce1e84 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -188,7 +188,6 @@ class FnmatchMatcher(object): def match(self, fpath): """Does `fpath` match one of our filename patterns?""" - #print("Matching %r against %r" % (self.re.pattern, fpath)) return self.re.match(fpath) is not None -- cgit v1.2.1