mirror of
https://gitee.com/johng/gf
synced 2026-07-04 13:02:36 +08:00
improve the performance when converting struct that implements UnmarshalValue
This commit is contained in:
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user