22
const transientSizeMax = 0
23
const transientValueHasStringSlice = true
25
func byteAt(b []byte, index uint) byte {
29
func setByteAt(b []byte, index uint, val byte) {
33
func byteSliceOf(b []byte, start, end uint) []byte {
41
func stringView(v []byte) string {
45
func bytesView(v string) []byte {
49
func byteSliceSameData(v1 []byte, v2 []byte) bool {
50
return cap(v1) != 0 && cap(v2) != 0 && &(v1[:1][0]) == &(v2[:1][0])
53
func okBytes2(b []byte) (v [2]byte) {
58
func okBytes3(b []byte) (v [3]byte) {
63
func okBytes4(b []byte) (v [4]byte) {
68
func okBytes8(b []byte) (v [8]byte) {
73
func isNil(v interface{}) (rv reflect.Value, isnil bool) {
74
rv = reflect.ValueOf(v)
75
if isnilBitset.isset(byte(rv.Kind())) {
81
func eq4i(i0, i1 interface{}) bool {
85
func rv4iptr(i interface{}) reflect.Value { return reflect.ValueOf(i) }
86
func rv4istr(i interface{}) reflect.Value { return reflect.ValueOf(i) }
91
func rv2i(rv reflect.Value) interface{} {
95
func rvAddr(rv reflect.Value, ptrType reflect.Type) reflect.Value {
99
func rvIsNil(rv reflect.Value) bool {
103
func rvSetSliceLen(rv reflect.Value, length int) {
107
func rvZeroAddrK(t reflect.Type, k reflect.Kind) reflect.Value {
108
return reflect.New(t).Elem()
111
func rvZeroK(t reflect.Type, k reflect.Kind) reflect.Value {
112
return reflect.Zero(t)
115
func rvConvert(v reflect.Value, t reflect.Type) (rv reflect.Value) {
119
return v.Addr().Convert(reflect.PtrTo(t)).Elem()
124
func rt2id(rt reflect.Type) uintptr {
125
return reflect.ValueOf(rt).Pointer()
128
func i2rtid(i interface{}) uintptr {
129
return reflect.ValueOf(reflect.TypeOf(i)).Pointer()
134
func isEmptyValue(v reflect.Value, tinfos *TypeInfos, recursive bool) bool {
136
case reflect.Invalid:
145
for i, vlen := 0, v.Len(); i < vlen; i++ {
146
if !isEmptyValue(v.Index(i), tinfos, false) {
151
case reflect.Map, reflect.Slice, reflect.Chan:
152
return v.IsNil() || v.Len() == 0
155
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
157
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
159
case reflect.Complex64, reflect.Complex128:
161
return math.Float64bits(real(c)) == 0 && math.Float64bits(imag(c)) == 0
162
case reflect.Float32, reflect.Float64:
163
return v.Float() == 0
164
case reflect.Func, reflect.UnsafePointer:
166
case reflect.Interface, reflect.Ptr:
168
if recursive && !isnil {
169
return isEmptyValue(v.Elem(), tinfos, recursive)
173
return isEmptyStruct(v, tinfos, recursive)
183
func isEmptyStruct(v reflect.Value, tinfos *TypeInfos, recursive bool) bool {
191
tinfos = defTypeInfos
193
ti := tinfos.get(rtid, vt)
194
if ti.rtid == timeTypId {
195
return rv2i(v).(time.Time).IsZero()
198
return rv2i(v).(isZeroer).IsZero()
200
if ti.flagIsZeroerPtr && v.CanAddr() {
201
return rv2i(v.Addr()).(isZeroer).IsZero()
203
if ti.flagIsCodecEmptyer {
204
return rv2i(v).(isCodecEmptyer).IsCodecEmpty()
206
if ti.flagIsCodecEmptyerPtr && v.CanAddr() {
207
return rv2i(v.Addr()).(isCodecEmptyer).IsCodecEmpty()
209
if ti.flagComparable {
210
return rv2i(v) == rv2i(rvZeroK(vt, reflect.Struct))
217
for _, si := range ti.sfi.source() {
218
sfv := si.path.field(v)
219
if sfv.IsValid() && !isEmptyValue(sfv, tinfos, recursive) {
228
type perTypeElem struct {
232
addr [2]reflect.Value
235
func (x *perTypeElem) get(index uint8) (v reflect.Value) {
240
v = reflect.New(x.t).Elem()
250
type decPerType struct {
254
type encPerType struct {
258
func (x *perType) elem(t reflect.Type) *perTypeElem {
261
var j = uint(len(x.v))
265
if x.v[h].rtid < rtid {
272
if i < uint(len(x.v)) {
273
if x.v[i].rtid != rtid {
274
x.v = append(x.v, perTypeElem{})
275
copy(x.v[i+1:], x.v[i:])
276
x.v[i] = perTypeElem{t: t, rtid: rtid, zero: reflect.Zero(t)}
279
x.v = append(x.v, perTypeElem{t: t, rtid: rtid, zero: reflect.Zero(t)})
284
func (x *perType) TransientAddrK(t reflect.Type, k reflect.Kind) (rv reflect.Value) {
285
return x.elem(t).get(0)
288
func (x *perType) TransientAddr2K(t reflect.Type, k reflect.Kind) (rv reflect.Value) {
289
return x.elem(t).get(1)
292
func (x *perType) AddressableRO(v reflect.Value) (rv reflect.Value) {
293
rv = x.elem(v.Type()).get(0)
299
type structFieldInfos struct {
304
func (x *structFieldInfos) load(source, sorted []*structFieldInfo) {
309
func (x *structFieldInfos) sorted() (v []*structFieldInfo) { return x.s }
310
func (x *structFieldInfos) source() (v []*structFieldInfo) { return x.c }
312
type atomicClsErr struct {
316
func (x *atomicClsErr) load() (e clsErr) {
317
if i := x.v.Load(); i != nil {
323
func (x *atomicClsErr) store(p clsErr) {
328
type atomicTypeInfoSlice struct {
332
func (x *atomicTypeInfoSlice) load() (e []rtid2ti) {
333
if i := x.v.Load(); i != nil {
339
func (x *atomicTypeInfoSlice) store(p []rtid2ti) {
344
type atomicRtidFnSlice struct {
348
func (x *atomicRtidFnSlice) load() (e []codecRtidFn) {
349
if i := x.v.Load(); i != nil {
350
e = i.([]codecRtidFn)
355
func (x *atomicRtidFnSlice) store(p []codecRtidFn) {
360
func (n *fauxUnion) ru() reflect.Value {
361
return reflect.ValueOf(&n.u).Elem()
363
func (n *fauxUnion) ri() reflect.Value {
364
return reflect.ValueOf(&n.i).Elem()
366
func (n *fauxUnion) rf() reflect.Value {
367
return reflect.ValueOf(&n.f).Elem()
369
func (n *fauxUnion) rl() reflect.Value {
370
return reflect.ValueOf(&n.l).Elem()
372
func (n *fauxUnion) rs() reflect.Value {
373
return reflect.ValueOf(&n.s).Elem()
375
func (n *fauxUnion) rt() reflect.Value {
376
return reflect.ValueOf(&n.t).Elem()
378
func (n *fauxUnion) rb() reflect.Value {
379
return reflect.ValueOf(&n.b).Elem()
383
func rvSetBytes(rv reflect.Value, v []byte) {
387
func rvSetString(rv reflect.Value, v string) {
391
func rvSetBool(rv reflect.Value, v bool) {
395
func rvSetTime(rv reflect.Value, v time.Time) {
396
rv.Set(reflect.ValueOf(v))
399
func rvSetFloat32(rv reflect.Value, v float32) {
400
rv.SetFloat(float64(v))
403
func rvSetFloat64(rv reflect.Value, v float64) {
407
func rvSetComplex64(rv reflect.Value, v complex64) {
408
rv.SetComplex(complex128(v))
411
func rvSetComplex128(rv reflect.Value, v complex128) {
415
func rvSetInt(rv reflect.Value, v int) {
419
func rvSetInt8(rv reflect.Value, v int8) {
423
func rvSetInt16(rv reflect.Value, v int16) {
427
func rvSetInt32(rv reflect.Value, v int32) {
431
func rvSetInt64(rv reflect.Value, v int64) {
435
func rvSetUint(rv reflect.Value, v uint) {
436
rv.SetUint(uint64(v))
439
func rvSetUintptr(rv reflect.Value, v uintptr) {
440
rv.SetUint(uint64(v))
443
func rvSetUint8(rv reflect.Value, v uint8) {
444
rv.SetUint(uint64(v))
447
func rvSetUint16(rv reflect.Value, v uint16) {
448
rv.SetUint(uint64(v))
451
func rvSetUint32(rv reflect.Value, v uint32) {
452
rv.SetUint(uint64(v))
455
func rvSetUint64(rv reflect.Value, v uint64) {
461
func rvSetDirect(rv reflect.Value, v reflect.Value) {
465
func rvSetDirectZero(rv reflect.Value) {
466
rv.Set(reflect.Zero(rv.Type()))
473
func rvSetIntf(rv reflect.Value, v reflect.Value) {
477
func rvSetZero(rv reflect.Value) {
478
rv.Set(reflect.Zero(rv.Type()))
481
func rvSlice(rv reflect.Value, length int) reflect.Value {
482
return rv.Slice(0, length)
485
func rvMakeSlice(rv reflect.Value, ti *typeInfo, xlen, xcap int) (v reflect.Value, set bool) {
486
v = reflect.MakeSlice(ti.rt, xlen, xcap)
493
func rvGrowSlice(rv reflect.Value, ti *typeInfo, cap, incr int) (v reflect.Value, newcap int, set bool) {
494
newcap = int(growCap(uint(cap), uint(ti.elemsize), uint(incr)))
495
v = reflect.MakeSlice(ti.rt, newcap, newcap)
504
func rvSliceIndex(rv reflect.Value, i int, ti *typeInfo) reflect.Value {
508
func rvArrayIndex(rv reflect.Value, i int, ti *typeInfo) reflect.Value {
512
func rvSliceZeroCap(t reflect.Type) (v reflect.Value) {
513
return reflect.MakeSlice(t, 0, 0)
516
func rvLenSlice(rv reflect.Value) int {
520
func rvCapSlice(rv reflect.Value) int {
524
func rvGetArrayBytes(rv reflect.Value, scratch []byte) (bs []byte) {
526
if scratch == nil || rv.CanAddr() {
527
return rv.Slice(0, l).Bytes()
530
if l <= cap(scratch) {
535
reflect.Copy(reflect.ValueOf(bs), rv)
539
func rvGetArray4Slice(rv reflect.Value) (v reflect.Value) {
540
v = rvZeroAddrK(reflectArrayOf(rvLenSlice(rv), rv.Type().Elem()), reflect.Array)
545
func rvGetSlice4Array(rv reflect.Value, v interface{}) {
552
rve := reflect.ValueOf(v).Elem()
555
rve.Set(rv.Slice(0, l))
557
rvs := reflect.MakeSlice(rve.Type(), l, l)
558
reflect.Copy(rvs, rv)
564
func rvCopySlice(dest, src reflect.Value, _ reflect.Type) {
565
reflect.Copy(dest, src)
570
func rvGetBool(rv reflect.Value) bool {
574
func rvGetBytes(rv reflect.Value) []byte {
578
func rvGetTime(rv reflect.Value) time.Time {
579
return rv2i(rv).(time.Time)
582
func rvGetString(rv reflect.Value) string {
586
func rvGetFloat64(rv reflect.Value) float64 {
590
func rvGetFloat32(rv reflect.Value) float32 {
591
return float32(rv.Float())
594
func rvGetComplex64(rv reflect.Value) complex64 {
595
return complex64(rv.Complex())
598
func rvGetComplex128(rv reflect.Value) complex128 {
602
func rvGetInt(rv reflect.Value) int {
606
func rvGetInt8(rv reflect.Value) int8 {
607
return int8(rv.Int())
610
func rvGetInt16(rv reflect.Value) int16 {
611
return int16(rv.Int())
614
func rvGetInt32(rv reflect.Value) int32 {
615
return int32(rv.Int())
618
func rvGetInt64(rv reflect.Value) int64 {
622
func rvGetUint(rv reflect.Value) uint {
623
return uint(rv.Uint())
626
func rvGetUint8(rv reflect.Value) uint8 {
627
return uint8(rv.Uint())
630
func rvGetUint16(rv reflect.Value) uint16 {
631
return uint16(rv.Uint())
634
func rvGetUint32(rv reflect.Value) uint32 {
635
return uint32(rv.Uint())
638
func rvGetUint64(rv reflect.Value) uint64 {
642
func rvGetUintptr(rv reflect.Value) uintptr {
643
return uintptr(rv.Uint())
646
func rvLenMap(rv reflect.Value) int {
662
func mapStoresElemIndirect(elemsize uintptr) bool { return false }
664
func mapSet(m, k, v reflect.Value, keyFastKind mapKeyFastKind, _, _ bool) {
668
func mapGet(m, k, v reflect.Value, keyFastKind mapKeyFastKind, _, _ bool) (vv reflect.Value) {
676
func mapAddrLoopvarRV(t reflect.Type, k reflect.Kind) (r reflect.Value) {
682
func (e *Encoder) jsondriver() *jsonEncDriver {
683
return e.e.(*jsonEncDriver)
688
func (d *Decoder) jsondriver() *jsonDecDriver {
689
return d.d.(*jsonDecDriver)
692
func (d *Decoder) stringZC(v []byte) (s string) {
696
func (d *Decoder) mapKeyString(callFnRvk *bool, kstrbs, kstr2bs *[]byte) string {
697
return d.string(*kstr2bs)
702
func (n *structFieldInfoPathNode) rvField(v reflect.Value) reflect.Value {
703
return v.Field(int(n.index))