From 89de30a0b754f4eb54fb543037683f3db6cda109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Fri, 20 May 2022 09:18:31 +0100 Subject: [PATCH] Avoid reallocating map in MatchLabels (#10715) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- model/labels/labels.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/labels/labels.go b/model/labels/labels.go index f1226c0b0..34bb878d1 100644 --- a/model/labels/labels.go +++ b/model/labels/labels.go @@ -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{}{} }