...
1
2
3
4 package decoder
5
6 import (
7 "unsafe"
8
9 "github.com/goccy/go-json/internal/runtime"
10 )
11
12 func CompileToGetDecoder(typ *runtime.Type) (Decoder, error) {
13 typeptr := uintptr(unsafe.Pointer(typ))
14 if typeptr > typeAddr.MaxTypeAddr {
15 return compileToGetDecoderSlowPath(typeptr, typ)
16 }
17
18 index := (typeptr - typeAddr.BaseTypeAddr) >> typeAddr.AddrShift
19 if dec := cachedDecoder[index]; dec != nil {
20 return dec, nil
21 }
22
23 dec, err := compileHead(typ, map[uintptr]Decoder{})
24 if err != nil {
25 return nil, err
26 }
27 cachedDecoder[index] = dec
28 return dec, nil
29 }
30
View as plain text