Cache generated regex for each path (#891)

This commit is contained in:
JoeSmithStarkers
2020-10-26 15:57:58 +11:00
committed by GitHub
parent b3906f4b97
commit 47468fe122
2 changed files with 14 additions and 9 deletions

View File

@@ -38,15 +38,20 @@ func excludeFiles(files []string, patterns []string) ([]string, int) {
}
}
func matchFileRegex(file string, fileRegexps []*regexp.Regexp) bool {
for _, regPattern := range fileRegexps {
if regPattern.MatchString(strings.ToLower(file)) {
return true
}
}
return false
}
func matchFile(file string, patterns []string) bool {
if patterns != nil {
fileRegexps := generateRegexps(patterns)
for _, regPattern := range fileRegexps {
if regPattern.MatchString(strings.ToLower(file)) {
return true
}
}
return matchFileRegex(file, fileRegexps)
}
return false