增加反射结果的缓存

This commit is contained in:
白茶清欢 2023-02-01 20:37:02 +08:00
parent 8ead62c058
commit 10854957c0

View File

@ -51,7 +51,6 @@ func (rt *ReflectType) Do(dataFlag string, data interface{}) *StructInfo {
// 缓存存在, 直接是有缓存结果
return cacheResult
}
// 缓存不存在, 解析
res := &StructInfo{
Flag: dataFlag,
@ -64,6 +63,7 @@ func (rt *ReflectType) Do(dataFlag string, data interface{}) *StructInfo {
}
if reflectType.Kind() != reflect.Struct {
// 非结构体,无需反射
rt.cacheTable[dataFlag] = res
return res
}
res.IsStruct = true