pkg/runtime: preallocate slice in unstructured.go

To avoid slice growth when appending.
This commit is contained in:
Gyu-Ho Lee 2016-05-27 14:54:25 -07:00
parent 1cca499e92
commit c3fc714ec2

View File

@ -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)
}