pkg/kubectl: preallocate slice

To avoid slice growth with append operations.
This commit is contained in:
Gyu-Ho Lee
2016-05-29 02:09:39 -07:00
parent 825cd920ff
commit a14a288c3f
5 changed files with 21 additions and 20 deletions

View File

@@ -28,7 +28,7 @@ import (
func AddJsonFilenameFlag(cmd *cobra.Command, value *[]string, usage string) {
cmd.Flags().StringSliceVarP(value, "filename", "f", *value, usage)
annotations := []string{}
annotations := make([]string, 0, len(resource.FileExtensions))
for _, ext := range resource.FileExtensions {
annotations = append(annotations, strings.TrimLeft(ext, "."))
}