Avoid reallocating map in MatchLabels (#10715)

We know the max size of our map so we can create it with that information and avoid extra allocations

Signed-off-by: Łukasz Mierzwa <l.mierzwa@gmail.com>
pull/10720/head
Łukasz Mierzwa 3 years ago committed by GitHub
parent 4ece54852c
commit 89de30a0b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -119,7 +119,7 @@ func (ls *Labels) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (ls Labels) MatchLabels(on bool, names ...string) Labels {
matchedLabels := Labels{}
nameSet := map[string]struct{}{}
nameSet := make(map[string]struct{}, len(names))
for _, n := range names {
nameSet[n] = struct{}{}
}

Loading…
Cancel
Save