go-json/decode_compile_norace.go

23 lines
467 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) {
2021-02-09 15:37:18 +03:00
if typeptr > maxTypeAddr {
2021-02-04 12:00:08 +03:00
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
}