mirror of
https://github.com/json-iterator/go.git
synced 2025-02-13 19:41:56 +02:00
get encoder without get type first
This commit is contained in:
parent
820ec30bd6
commit
d346ea6e55
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user