mirror of
https://github.com/json-iterator/go.git
synced 2026-06-18 20:14:33 +02:00
get encoder without get type first
This commit is contained in:
1 parent
820ec30bd6
commit
d346ea6e55
1 file changed
+6
-2
+6
-2
@@ -75,8 +75,12 @@ func (stream *Stream) WriteVal(val interface{}) {
|
||||
stream.WriteNil()
|
||||
return
|
||||
}
|
||||
typ := reflect2.TypeOf(val)
|
||||
encoder := stream.cfg.EncoderOf(typ)
|
||||
cacheKey := reflect2.RTypeOf(val)
|
||||
encoder := stream.cfg.getEncoderFromCache(cacheKey)
|
||||
if encoder == nil {
|
||||
typ := reflect2.TypeOf(val)
|
||||
encoder = stream.cfg.EncoderOf(typ)
|
||||
}
|
||||
encoder.Encode(reflect2.PtrOf(val), stream)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user