mirror of https://github.com/goccy/go-json.git
23 lines
466 B
Go
23 lines
466 B
Go
|
// +build !race
|
||
|
|
||
|
package json
|
||
|
|
||
|
func (d *Decoder) compileToGetDecoder(typeptr uintptr, typ *rtype) (decoder, error) {
|
||
|
if !existsCachedDecoder {
|
||
|
return d.compileToGetDecoderSlowPath(typeptr, typ)
|
||
|
}
|
||
|
|
||
|
index := typeptr - baseTypeAddr
|
||
|
if dec := cachedDecoder[index]; dec != nil {
|
||
|
return dec, nil
|
||
|
}
|
||
|
|
||
|
d.structTypeToDecoder = map[uintptr]decoder{}
|
||
|
dec, err := d.compileHead(typ)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
cachedDecoder[index] = dec
|
||
|
return dec, nil
|
||
|
}
|