mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-27 14:47: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:
@ -2,15 +2,21 @@ package data
|
||||
|
||||
import "github.com/go-enry/go-enry/v2/regex"
|
||||
|
||||
{{define "mustCompile" -}}
|
||||
{{ if isRE2 . -}}
|
||||
regex.MustCompile({{ . | stringVal }})
|
||||
{{- else -}}
|
||||
regex.MustCompileRuby({{ . | stringVal }})
|
||||
{{- end -}}
|
||||
{{end}}
|
||||
|
||||
var VendorMatchers = []regex.EnryRegexp{
|
||||
{{range $re := . -}}
|
||||
{{ if isRE2 $re -}}
|
||||
regex.MustCompile({{ $re | stringVal }}),
|
||||
{{- else -}}
|
||||
regex.MustCompileRuby({{ $re | stringVal }}),
|
||||
{{ end }}
|
||||
{{ template "mustCompile" $re }},
|
||||
{{end -}}
|
||||
}
|
||||
|
||||
// FastVendorMatcher is equivalent to matching any of the VendorMatchers.
|
||||
var FastVendorMatcher = regex.MustCompile(`{{ optimize . }}`)
|
||||
{{with $singleRE := collateAllRegexps . -}}
|
||||
var FastVendorMatcher = {{template "mustCompile" $singleRE}}
|
||||
{{end}}
|
Reference in New Issue
Block a user