Source File
reflect.go
Belonging Package
github.com/goccy/go-json/internal/decoder
package decoderimport ()// The decoders allocate and assign values through the reflect package, never through the internal// functions of the runtime: the pointers to the type descriptors they need are computed once, when// a decoder is compiled.// valueAt returns the addressable reflect.Value of the value at p, whose pointer type is ptrType// ( the type descriptor of *T for a value of T ). It is reflect.NewAt(T, p).Elem() without the lookup// of the pointer type which reflect.NewAt does for every call.func valueAt(, unsafe.Pointer) reflect.Value {return reflect.ValueOf(*(*any)(unsafe.Pointer(&emptyInterface{typ: , ptr: }))).Elem()}// ptrTypeOf returns the type descriptor of *typ.func ptrTypeOf( reflect.Type) unsafe.Pointer {return runtime.TypePtr(reflect.PointerTo())}// newValue allocates a zero value of typ.func newValue( reflect.Type) unsafe.Pointer {return reflect.New().UnsafePointer()}// allocatorOf returns the function which allocates a zero value of typ, for a decoder which allocates one for// every value it decodes, as the one of a pointer does. For the kinds of the basic types it is new of the basic// type of the kind, whose layout, pointers included, is the one of typ whatever its name; for time.Time, it is// new of it. They cost less than reflect.New, which looks up the pointer type of typ at every call. It is nil// for any other type, whose pointer is decoded by ptrDecoder, which allocates by newValue ( see basicPtrDecoder ).func allocatorOf( reflect.Type) func() unsafe.Pointer {if == reflect.TypeOf(time.Time{}) {return func() unsafe.Pointer { return unsafe.Pointer(new(time.Time)) }}switch .Kind() {case reflect.Bool:return func() unsafe.Pointer { return unsafe.Pointer(new(bool)) }case reflect.Int:return func() unsafe.Pointer { return unsafe.Pointer(new(int)) }case reflect.Int8:return func() unsafe.Pointer { return unsafe.Pointer(new(int8)) }case reflect.Int16:return func() unsafe.Pointer { return unsafe.Pointer(new(int16)) }case reflect.Int32:return func() unsafe.Pointer { return unsafe.Pointer(new(int32)) }case reflect.Int64:return func() unsafe.Pointer { return unsafe.Pointer(new(int64)) }case reflect.Uint:return func() unsafe.Pointer { return unsafe.Pointer(new(uint)) }case reflect.Uint8:return func() unsafe.Pointer { return unsafe.Pointer(new(uint8)) }case reflect.Uint16:return func() unsafe.Pointer { return unsafe.Pointer(new(uint16)) }case reflect.Uint32:return func() unsafe.Pointer { return unsafe.Pointer(new(uint32)) }case reflect.Uint64:return func() unsafe.Pointer { return unsafe.Pointer(new(uint64)) }case reflect.Uintptr:return func() unsafe.Pointer { return unsafe.Pointer(new(uintptr)) }case reflect.Float32:return func() unsafe.Pointer { return unsafe.Pointer(new(float32)) }case reflect.Float64:return func() unsafe.Pointer { return unsafe.Pointer(new(float64)) }case reflect.Complex64:return func() unsafe.Pointer { return unsafe.Pointer(new(complex64)) }case reflect.Complex128:return func() unsafe.Pointer { return unsafe.Pointer(new(complex128)) }case reflect.String:return func() unsafe.Pointer { return unsafe.Pointer(new(string)) }}return nil}// zeroBase is the address of the data of an empty slice which is not nil.var zeroBase [0]byte
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |