Save 2-3 commits from unstructured object creation.

parent d0daa108
...@@ -746,7 +746,7 @@ func isZero(v reflect.Value) bool { ...@@ -746,7 +746,7 @@ func isZero(v reflect.Value) bool {
func structToUnstructured(sv, dv reflect.Value) error { func structToUnstructured(sv, dv reflect.Value) error {
st, dt := sv.Type(), dv.Type() st, dt := sv.Type(), dv.Type()
if dt.Kind() == reflect.Interface && dv.NumMethod() == 0 { if dt.Kind() == reflect.Interface && dv.NumMethod() == 0 {
dv.Set(reflect.MakeMap(mapStringInterfaceType)) dv.Set(reflect.MakeMapWithSize(mapStringInterfaceType, st.NumField()))
dv = dv.Elem() dv = dv.Elem()
dt = dv.Type() dt = dv.Type()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment