From b141df5413a60174a0dcfb1ca78c87e619552b95 Mon Sep 17 00:00:00 2001 From: Harald Albers Date: Tue, 29 Oct 2024 13:05:24 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Sebastiaan van Stijn --- cli/command/system/completion.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cli/command/system/completion.go b/cli/command/system/completion.go index cb7f36896228..ac7ee7ba8a92 100644 --- a/cli/command/system/completion.go +++ b/cli/command/system/completion.go @@ -154,7 +154,7 @@ func eventTypeNames() []string { // The list is derived from eventActions. // Actions that are not suitable for usage in completions are removed. func validEventNames() []string { - names := []string{} + names := make([]string, 0, len(eventActions)) for _, eventAction := range eventActions { if strings.Contains(string(eventAction), " ") { continue @@ -191,7 +191,7 @@ func imageNames(dockerCLI completion.APIClientProvider, cmd *cobra.Command) []st if err != nil { return []string{} } - names := []string{} + names := make([]string, 0, len(list)) for _, img := range list { names = append(names, img.RepoTags...) } @@ -205,7 +205,7 @@ func networkNames(dockerCLI completion.APIClientProvider, cmd *cobra.Command) [] if err != nil { return []string{} } - names := []string{} + names := make([]string, 0, len(list)) for _, nw := range list { names = append(names, nw.Name) } @@ -219,7 +219,7 @@ func nodeNames(dockerCLI completion.APIClientProvider, cmd *cobra.Command) []str if err != nil { return []string{} } - names := []string{} + names := make([]string, 0, len(list)) for _, node := range list { names = append(names, node.Description.Hostname) } @@ -233,7 +233,7 @@ func volumeNames(dockerCLI completion.APIClientProvider, cmd *cobra.Command) []s if err != nil { return []string{} } - names := []string{} + names := make([]string, 0, len(list.Volumes)) for _, v := range list.Volumes { names = append(names, v.Name) }