From 9727de2d9de9d7087d0f13a9f43fafa043b781fa Mon Sep 17 00:00:00 2001 From: alexmchughdev Date: Wed, 6 May 2026 20:04:58 +0100 Subject: [PATCH] kube-proxy/ipvs/ipset: preallocate ListEntries result with bound capacity ListEntries' result slice is bounded by the number of lines parsed from the ipset output (`len(strs)`). Pass that as the make() capacity so the slice doesn't need to be regrown as entries are appended. No behavior change. --- pkg/proxy/ipvs/ipset/ipset.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/proxy/ipvs/ipset/ipset.go b/pkg/proxy/ipvs/ipset/ipset.go index c2b5c74707e..a043a5f7f46 100644 --- a/pkg/proxy/ipvs/ipset/ipset.go +++ b/pkg/proxy/ipvs/ipset/ipset.go @@ -401,7 +401,7 @@ func (runner *runner) ListEntries(set string) ([]string, error) { memberMatcher := regexp.MustCompile(EntryMemberPattern) list := memberMatcher.ReplaceAllString(string(out[:]), "") strs := strings.Split(list, "\n") - results := make([]string, 0) + results := make([]string, 0, len(strs)) for i := range strs { if len(strs[i]) > 0 { results = append(results, strs[i])