improve the performance when converting struct that implements UnmarshalValue
@@ -61,12 +61,6 @@ func doStruct(params interface{}, pointer interface{}, recursive bool, mapping .
}
}()
- // paramsMap is the map[string]interface{} type variable for params.
- paramsMap := MapDeep(params)
- if paramsMap == nil {
- return gerror.Newf("invalid params: %v", params)
- }
-
// UnmarshalValue.
// Assign value with interface UnmarshalValue.
// Note that only pointer can implement interface UnmarshalValue.
@@ -74,6 +68,12 @@ func doStruct(params interface{}, pointer interface{}, recursive bool, mapping .
return v.UnmarshalValue(params)
}
+ // paramsMap is the map[string]interface{} type variable for params.
+ paramsMap := MapDeep(params)
+ if paramsMap == nil {
+ return gerror.Newf("invalid params: %v", params)
+ }
+
// Using reflect to do the converting,
// it also supports type of reflect.Value for <pointer>(always in internal usage).
elem, ok := pointer.(reflect.Value)
