go-json/decode_compile_norace.go

23 lines
466 B
Go
Raw Normal View History

2021-02-04 12:00:08 +03:00
// +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
}