Skip to content

Commit

Permalink
🎈 perf:
Browse files Browse the repository at this point in the history
Replace map[string]bool with map[string]struct{} to reduce memory footprint
  • Loading branch information
XiaoK29 committed Sep 5, 2024
1 parent 004636e commit abca3e3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions redirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit abca3e3

Please sign in to comment.