Chore: remove reduce regex compile (#1855)

This commit is contained in:
Kr328 2021-12-26 20:47:12 +08:00 committed by GitHub
parent ee6fc12709
commit 14ae87fcd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -97,7 +97,8 @@ func stopProxyProvider(pd *ProxySetProvider) {
}
func NewProxySetProvider(name string, interval time.Duration, filter string, vehicle types.Vehicle, hc *HealthCheck) (*ProxySetProvider, error) {
if _, err := regexp.Compile(filter); err != nil {
filterReg, err := regexp.Compile(filter)
if err != nil {
return nil, fmt.Errorf("invalid filter regex: %w", err)
}
@ -127,7 +128,6 @@ func NewProxySetProvider(name string, interval time.Duration, filter string, veh
}
proxies := []C.Proxy{}
filterReg := regexp.MustCompile(filter)
for idx, mapping := range schema.Proxies {
if name, ok := mapping["name"]; ok && len(filter) > 0 && !filterReg.MatchString(name.(string)) {
continue