From 33aa56097a34e1d92d84d0acb6b47adc9a10d301 Mon Sep 17 00:00:00 2001 From: Iceber Gu Date: Sun, 12 Nov 2023 00:08:01 +0800 Subject: [PATCH] Set the initial length of set[T] in sets.KeySet Signed-off-by: Iceber Gu --- staging/src/k8s.io/apimachinery/pkg/util/sets/set.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staging/src/k8s.io/apimachinery/pkg/util/sets/set.go b/staging/src/k8s.io/apimachinery/pkg/util/sets/set.go index d50526f4262..1e6d573d78b 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/sets/set.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/sets/set.go @@ -37,7 +37,7 @@ func New[T comparable](items ...T) Set[T] { // KeySet creates a Set from a keys of a map[comparable](? extends interface{}). // If the value passed in is not actually a map, this will panic. func KeySet[T comparable, V any](theMap map[T]V) Set[T] { - ret := Set[T]{} + ret := make(Set[T], len(theMap)) for keyValue := range theMap { ret.Insert(keyValue) }