From abca3e38b6aef91db1cd0b891c70cf91c80cb2fb Mon Sep 17 00:00:00 2001 From: xiaok29 <1526783667@qq.com> Date: Thu, 5 Sep 2024 16:49:09 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20perf:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace map[string]bool with map[string]struct{} to reduce memory footprint --- redirect.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/redirect.go b/redirect.go index ed39584..f1cc433 100644 --- a/redirect.go +++ b/redirect.go @@ -72,9 +72,9 @@ func AllowedHostRedirectPolicy(hosts ...string) RedirectPolicy { // AllowedDomainRedirectPolicy allows redirect only if the redirected domain // match one of the domain that specified. func AllowedDomainRedirectPolicy(hosts ...string) RedirectPolicy { - domains := make(map[string]bool) + domains := make(map[string]struct{}) for _, h := range hosts { - domains[strings.ToLower(getDomain(h))] = true + domains[strings.ToLower(getDomain(h))] = struct{}{} } return func(req *http.Request, via []*http.Request) error {