From 36160e916eafbdf51287dc8729c71735d8c9452b Mon Sep 17 00:00:00 2001 From: ThinkChaos Date: Mon, 6 Feb 2023 20:13:41 -0500 Subject: [PATCH] refactor: don't use a regex to check a string cache entry is a regex --- cache/stringcache/string_caches.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cache/stringcache/string_caches.go b/cache/stringcache/string_caches.go index aea05af4..88140520 100644 --- a/cache/stringcache/string_caches.go +++ b/cache/stringcache/string_caches.go @@ -179,11 +179,9 @@ type chainedCacheFactory struct { regexCacheFactory CacheFactory } -var regexPattern = regexp.MustCompile("^/.*/$") - func (r *chainedCacheFactory) AddEntry(entry string) { - if regexPattern.MatchString(entry) { - entry = strings.TrimSpace(strings.Trim(entry, "/")) + if strings.HasPrefix(entry, "/") && strings.HasSuffix(entry, "/") { + entry = strings.TrimSpace(entry[1 : len(entry)-1]) r.regexCacheFactory.AddEntry(entry) } else { r.stringCacheFactory.AddEntry(entry)