mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-08-08 00:30:34 +00:00
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.
This commit is contained in:
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user