mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-27 22:57:50 -03:00
heuristics regexp engine configurable #3, adapt IsVendor optimization & tests
Regex collation optimization for IsVendor now fails gracefully. Tests that are affected by non-RE2 syntax are explicitly marked.
This commit is contained in:
16
utils.go
16
utils.go
@ -63,7 +63,21 @@ func IsDotFile(path string) bool {
|
||||
|
||||
// IsVendor returns whether or not path is a vendor path.
|
||||
func IsVendor(path string) bool {
|
||||
return data.FastVendorMatcher.MatchString(path)
|
||||
// fast path: single collatated regex, if the engine supports its syntax
|
||||
if data.FastVendorMatcher != nil {
|
||||
return data.FastVendorMatcher.MatchString(path)
|
||||
}
|
||||
|
||||
// slow path: skip individual rules with unsupported syntax
|
||||
for _, matcher := range data.VendorMatchers {
|
||||
if matcher == nil {
|
||||
continue
|
||||
}
|
||||
if matcher.MatchString(path) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsTest returns whether or not path is a test path.
|
||||
|
Reference in New Issue
Block a user