From c3fc714ec21db38f1a43b8bd3089fa7bc31144a9 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Fri, 27 May 2016 14:54:25 -0700 Subject: [PATCH] pkg/runtime: preallocate slice in unstructured.go To avoid slice growth when appending. --- pkg/runtime/unstructured.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/runtime/unstructured.go b/pkg/runtime/unstructured.go index 11a1e936284..4f87b9aa29a 100644 --- a/pkg/runtime/unstructured.go +++ b/pkg/runtime/unstructured.go @@ -59,7 +59,7 @@ func (unstructuredJSONScheme) EncodeToStream(obj Object, w io.Writer, overrides case *Unstructured: return json.NewEncoder(w).Encode(t.Object) case *UnstructuredList: - var items []map[string]interface{} + items := make([]map[string]interface{}, 0, len(t.Items)) for _, i := range t.Items { items = append(items, i.Object) }