From 4b8a1cdb083a63b2c1560f89351845c1f949b0cb Mon Sep 17 00:00:00 2001 From: gVisor bot 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