From 14ae87fcd0ec1d02c5d0b89250b38ba07b0a6d63 Mon Sep 17 00:00:00 2001 From: Kr328 Date: Sun, 26 Dec 2021 20:47:12 +0800 Subject: [PATCH] Chore: remove reduce regex compile (#1855) --- adapter/provider/provider.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adapter/provider/provider.go b/adapter/provider/provider.go index 6a5e3052..6e27d2cc 100644 --- a/adapter/provider/provider.go +++ b/adapter/provider/provider.go @@ -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