diff --git a/cluster/addons.go b/cluster/addons.go index 55d921149..5a1a3c03f 100644 --- a/cluster/addons.go +++ b/cluster/addons.go @@ -124,8 +124,8 @@ func (c *Cluster) ApplySystemAddonExcuteJob(addonJob string) error { } func (c *Cluster) deployIngress(ctx context.Context) error { - log.Infof(ctx, "[ingress] Setting up %s ingress controller", c.Ingress.Type) - if c.Ingress.Type == "none" { + log.Infof(ctx, "[ingress] Setting up %s ingress controller", c.Ingress.Provider) + if c.Ingress.Provider == "none" { log.Infof(ctx, "[ingress] ingress controller is not defined") return nil } @@ -142,6 +142,6 @@ func (c *Cluster) deployIngress(ctx context.Context) error { if err := c.doAddonDeploy(ctx, ingressYaml, IngressAddonResourceName); err != nil { return err } - log.Infof(ctx, "[ingress] ingress controller %s is successfully deployed", c.Ingress.Type) + log.Infof(ctx, "[ingress] ingress controller %s is successfully deployed", c.Ingress.Provider) return nil } diff --git a/cluster/defaults.go b/cluster/defaults.go index 4e67b39c8..4da1a56fc 100644 --- a/cluster/defaults.go +++ b/cluster/defaults.go @@ -91,8 +91,8 @@ func (c *Cluster) setClusterDefaults(ctx context.Context) { log.Warnf(ctx, "PodSecurityPolicy can't be enabled with RBAC support disabled") c.Services.KubeAPI.PodSecurityPolicy = false } - if len(c.Ingress.Type) == 0 { - c.Ingress.Type = DefaultIngressController + if len(c.Ingress.Provider) == 0 { + c.Ingress.Provider = DefaultIngressController } c.setClusterImageDefaults() diff --git a/cluster/validation.go b/cluster/validation.go index 4b01cdf2a..717b12c1a 100644 --- a/cluster/validation.go +++ b/cluster/validation.go @@ -99,8 +99,8 @@ func validateServicesOptions(c *Cluster) error { func validateIngressOptions(c *Cluster) error { // Should be changed when adding more ingress types - if c.Ingress.Type != DefaultIngressController && c.Ingress.Type != "none" { - return fmt.Errorf("Ingress controller %s is incorrect", c.Ingress.Type) + if c.Ingress.Provider != DefaultIngressController && c.Ingress.Provider != "none" { + return fmt.Errorf("Ingress controller %s is incorrect", c.Ingress.Provider) } return nil } diff --git a/vendor.conf b/vendor.conf index b7ba44625..4cce587e1 100644 --- a/vendor.conf +++ b/vendor.conf @@ -24,4 +24,4 @@ github.com/coreos/go-semver e214231b295a8ea9479f11b70b35d5acf3556d9 github.com/ugorji/go/codec ccfe18359b55b97855cee1d3f74e5efbda4869dc github.com/rancher/norman 151aa66e3e99de7e0d195e2d5ca96b1f95544555 -github.com/rancher/types af7045b760563e7d9609d72dd7db4545881ef9c4 +github.com/rancher/types e54bf40bd62aea0be72a11ecce8951ee5cf86df9 diff --git a/vendor/github.com/rancher/types/apis/management.cattle.io/v3/rke_types.go b/vendor/github.com/rancher/types/apis/management.cattle.io/v3/rke_types.go index 87ca48b9b..ed0874e71 100644 --- a/vendor/github.com/rancher/types/apis/management.cattle.io/v3/rke_types.go +++ b/vendor/github.com/rancher/types/apis/management.cattle.io/v3/rke_types.go @@ -197,7 +197,7 @@ type AuthzConfig struct { type IngressConfig struct { // Ingress controller type used by kubernetes - Type string `yaml:"type" json:"type,omitempty"` + Provider string `yaml:"provider" json:"provider,omitempty"` // Ingress controller options Options map[string]string `yaml:"options" json:"options,omitempty"` // NodeSelector key pair diff --git a/vendor/github.com/ugorji/go/LICENSE b/vendor/github.com/ugorji/go/LICENSE deleted file mode 100644 index 95a0f0541..000000000 --- a/vendor/github.com/ugorji/go/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2012-2015 Ugorji Nwoke. -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/ugorji/go/README.md b/vendor/github.com/ugorji/go/README.md deleted file mode 100644 index 6bb74742f..000000000 --- a/vendor/github.com/ugorji/go/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# go/codec - -This repository contains the `go-codec` library, -a High Performance and Feature-Rich Idiomatic encode/decode and rpc library for - - - msgpack: https://github.com/msgpack/msgpack - - binc: http://github.com/ugorji/binc - - cbor: http://cbor.io http://tools.ietf.org/html/rfc7049 - - json: http://json.org http://tools.ietf.org/html/rfc7159 - -For more information: - - - [see the codec/Readme for quick usage information](https://github.com/ugorji/go/tree/master/codec#readme) - - [view the API on godoc](http://godoc.org/github.com/ugorji/go/codec) - - [read the detailed usage/how-to primer](http://ugorji.net/blog/go-codec-primer) - -Install using: - - go get github.com/ugorji/go/codec - diff --git a/vendor/github.com/ugorji/go/codec/0doc.go b/vendor/github.com/ugorji/go/codec/0doc.go index cfb804ec1..6dfeee35c 100644 --- a/vendor/github.com/ugorji/go/codec/0doc.go +++ b/vendor/github.com/ugorji/go/codec/0doc.go @@ -1,9 +1,10 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. /* -High Performance, Feature-Rich Idiomatic Go 1.4+ codec/encoding library for -binc, msgpack, cbor, json +Package codec provides a +High Performance, Feature-Rich Idiomatic Go 1.4+ codec/encoding library +for binc, msgpack, cbor, json. Supported Serialization formats are: @@ -32,15 +33,14 @@ Rich Feature Set includes: - Simple but extremely powerful and feature-rich API - Support for go1.4 and above, while selectively using newer APIs for later releases - - Good code coverage ( > 70% ) + - Excellent code coverage ( > 90% ) - Very High Performance. Our extensive benchmarks show us outperforming Gob, Json, Bson, etc by 2-4X. - Careful selected use of 'unsafe' for targeted performance gains. 100% mode exists where 'unsafe' is not used at all. - Lock-free (sans mutex) concurrency for scaling to 100's of cores - - Multiple conversions: - Package coerces types where appropriate - e.g. decode an int in the stream into a float, etc. + - Coerce types where appropriate + e.g. decode an int in the stream into a float, decode numbers from formatted strings, etc - Corner Cases: Overflows, nil maps/slices, nil values in streams are handled correctly - Standard field renaming via tags @@ -49,10 +49,16 @@ Rich Feature Set includes: (struct, slice, map, primitives, pointers, interface{}, etc) - Extensions to support efficient encoding/decoding of any named types - Support encoding.(Binary|Text)(M|Unm)arshaler interfaces + - Support IsZero() bool to determine if a value is a zero value. + Analogous to time.Time.IsZero() bool. - Decoding without a schema (into a interface{}). Includes Options to configure what specific map or slice type to use when decoding an encoded list or map into a nil interface{} + - Mapping a non-interface type to an interface, so we can decode appropriately + into any interface type with a correctly configured non-interface value. - Encode a struct as an array, and decode struct from an array in the data stream + - Option to encode struct keys as numbers (instead of strings) + (to support structured streams with fields encoded as numeric codes) - Comprehensive support for anonymous fields - Fast (no-reflection) encoding/decoding of common maps and slices - Code-generation for faster performance. @@ -93,6 +99,27 @@ encoded as an empty map because it has no exported fields, while UUID would be encoded as a string. However, with extension support, you can encode any of these however you like. +Custom Encoding and Decoding + +This package maintains symmetry in the encoding and decoding halfs. +We determine how to encode or decode by walking this decision tree + + - is type a codec.Selfer? + - is there an extension registered for the type? + - is format binary, and is type a encoding.BinaryMarshaler and BinaryUnmarshaler? + - is format specifically json, and is type a encoding/json.Marshaler and Unmarshaler? + - is format text-based, and type an encoding.TextMarshaler? + - else we use a pair of functions based on the "kind" of the type e.g. map, slice, int64, etc + +This symmetry is important to reduce chances of issues happening because the +encoding and decoding sides are out of sync e.g. decoded via very specific +encoding.TextUnmarshaler but encoded via kind-specific generalized mode. + +Consequently, if a type only defines one-half of the symmetry +(e.g. it implements UnmarshalJSON() but not MarshalJSON() ), +then that type doesn't satisfy the check and we will continue walking down the +decision tree. + RPC RPC Client and Server Codecs are implemented, so the codecs can be used @@ -180,6 +207,63 @@ Running Benchmarks Please see http://github.com/ugorji/go-codec-bench . +Caveats + +Struct fields matching the following are ignored during encoding and decoding + - struct tag value set to - + - func, complex numbers, unsafe pointers + - unexported and not embedded + - unexported and embedded and not struct kind + - unexported and embedded pointers (from go1.10) + +Every other field in a struct will be encoded/decoded. + +Embedded fields are encoded as if they exist in the top-level struct, +with some caveats. See Encode documentation. + */ package codec +// TODO: +// - In Go 1.10, when mid-stack inlining is enabled, +// we should use committed functions for writeXXX and readXXX calls. +// This involves uncommenting the methods for decReaderSwitch and encWriterSwitch +// and using those (decReaderSwitch and encWriterSwitch) in all handles +// instead of encWriter and decReader. +// The benefit is that, for the (En|De)coder over []byte, the encWriter/decReader +// will be inlined, giving a performance bump for that typical case. +// However, it will only be inlined if mid-stack inlining is enabled, +// as we call panic to raise errors, and panic currently prevents inlining. +// +// - Unexport BasicHandle. +// If godoc can now show the embedded options, then unexport it. +// +// PUNTED: +// - To make Handle comparable, make extHandle in BasicHandle a non-embedded pointer, +// and use overlay methods on *BasicHandle to call through to extHandle after initializing +// the "xh *extHandle" to point to a real slice. +// +// - Allow mapping a concrete type to an interface, for use during decoding. +// +// BEFORE EACH RELEASE: +// - Look through and fix padding for each type, to eliminate false sharing +// - critical shared objects that are read many times +// TypeInfos +// - pooled objects: +// decNaked, decNakedContainers, codecFner, typeInfoLoadArray, +// - small objects allocated independently, that we read/use much across threads: +// codecFn, typeInfo +// - Objects allocated independently and used a lot +// Decoder, Encoder, +// xxxHandle, xxxEncDriver, xxxDecDriver (xxx = json, msgpack, cbor, binc, simple) +// - In all above, arrange values modified together to be close to each other. +// +// For all of these, either ensure that they occupy full cache lines, +// or ensure that the things just past the cache line boundary are hardly read/written +// e.g. JsonHandle.RawBytesExt - which is copied into json(En|De)cDriver at init +// +// Occupying full cache lines means they occupy 8*N words (where N is an integer). +// Check this out by running: ./run.sh -z +// - look at those tagged ****, meaning they are not occupying full cache lines +// - look at those tagged <<<<, meaning they are larger than 32 words (something to watch) +// - Run "golint -min_confidence 0.81" diff --git a/vendor/github.com/ugorji/go/codec/README.md b/vendor/github.com/ugorji/go/codec/README.md index cadc41b4c..50d65e550 100644 --- a/vendor/github.com/ugorji/go/codec/README.md +++ b/vendor/github.com/ugorji/go/codec/README.md @@ -31,15 +31,14 @@ Rich Feature Set includes: - Simple but extremely powerful and feature-rich API - Support for go1.4 and above, while selectively using newer APIs for later releases - - Good code coverage ( > 70% ) + - Excellent code coverage ( > 90% ) - Very High Performance. Our extensive benchmarks show us outperforming Gob, Json, Bson, etc by 2-4X. - Careful selected use of 'unsafe' for targeted performance gains. 100% mode exists where 'unsafe' is not used at all. - Lock-free (sans mutex) concurrency for scaling to 100's of cores - - Multiple conversions: - Package coerces types where appropriate - e.g. decode an int in the stream into a float, etc. + - Coerce types where appropriate + e.g. decode an int in the stream into a float, decode numbers from formatted strings, etc - Corner Cases: Overflows, nil maps/slices, nil values in streams are handled correctly - Standard field renaming via tags @@ -48,10 +47,16 @@ Rich Feature Set includes: (struct, slice, map, primitives, pointers, interface{}, etc) - Extensions to support efficient encoding/decoding of any named types - Support encoding.(Binary|Text)(M|Unm)arshaler interfaces + - Support IsZero() bool to determine if a value is a zero value. + Analogous to time.Time.IsZero() bool. - Decoding without a schema (into a interface{}). Includes Options to configure what specific map or slice type to use when decoding an encoded list or map into a nil interface{} + - Mapping a non-interface type to an interface, so we can decode appropriately + into any interface type with a correctly configured non-interface value. - Encode a struct as an array, and decode struct from an array in the data stream + - Option to encode struct keys as numbers (instead of strings) + (to support structured streams with fields encoded as numeric codes) - Comprehensive support for anonymous fields - Fast (no-reflection) encoding/decoding of common maps and slices - Code-generation for faster performance. @@ -91,6 +96,27 @@ encoded as an empty map because it has no exported fields, while UUID would be encoded as a string. However, with extension support, you can encode any of these however you like. +## Custom Encoding and Decoding + +This package maintains symmetry in the encoding and decoding halfs. +We determine how to encode or decode by walking this decision tree + + - is type a codec.Selfer? + - is there an extension registered for the type? + - is format binary, and is type a encoding.BinaryMarshaler and BinaryUnmarshaler? + - is format specifically json, and is type a encoding/json.Marshaler and Unmarshaler? + - is format text-based, and type an encoding.TextMarshaler? + - else we use a pair of functions based on the "kind" of the type e.g. map, slice, int64, etc + +This symmetry is important to reduce chances of issues happening because the +encoding and decoding sides are out of sync e.g. decoded via very specific +encoding.TextUnmarshaler but encoded via kind-specific generalized mode. + +Consequently, if a type only defines one-half of the symmetry +(e.g. it implements UnmarshalJSON() but not MarshalJSON() ), +then that type doesn't satisfy the check and we will continue walking down the +decision tree. + ## RPC RPC Client and Server Codecs are implemented, so the codecs can be used @@ -164,3 +190,17 @@ You can run the tag 'safe' to run tests or build in safe mode. e.g. Please see http://github.com/ugorji/go-codec-bench . +## Caveats + +Struct fields matching the following are ignored during encoding and decoding + + - struct tag value set to - + - func, complex numbers, unsafe pointers + - unexported and not embedded + - unexported and embedded and not struct kind + - unexported and embedded pointers (from go1.10) + +Every other field in a struct will be encoded/decoded. + +Embedded fields are encoded as if they exist in the top-level struct, +with some caveats. See Encode documentation. diff --git a/vendor/github.com/ugorji/go/codec/binc.go b/vendor/github.com/ugorji/go/codec/binc.go index be5b7d338..39fd7d4a0 100644 --- a/vendor/github.com/ugorji/go/codec/binc.go +++ b/vendor/github.com/ugorji/go/codec/binc.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. package codec @@ -57,38 +57,31 @@ const ( type bincEncDriver struct { e *Encoder + h *BincHandle w encWriter m map[string]uint16 // symbols - b [scratchByteArrayLen]byte - s uint16 // symbols sequencer + b [16]byte // scratch, used for encoding numbers - bigendian style + s uint16 // symbols sequencer + // c containerState + encDriverTrackContainerWriter + noBuiltInTypes // encNoSeparator - encDriverNoopContainerWriter } -func (e *bincEncDriver) IsBuiltinType(rt uintptr) bool { - return rt == timeTypId +func (e *bincEncDriver) EncodeNil() { + e.w.writen1(bincVdSpecial<<4 | bincSpNil) } -func (e *bincEncDriver) EncodeBuiltin(rt uintptr, v interface{}) { - if rt == timeTypId { - var bs []byte - switch x := v.(type) { - case time.Time: - bs = encodeTime(x) - case *time.Time: - bs = encodeTime(*x) - default: - e.e.errorf("binc error encoding builtin: expect time.Time, received %T", v) - } +func (e *bincEncDriver) EncodeTime(t time.Time) { + if t.IsZero() { + e.EncodeNil() + } else { + bs := bincEncodeTime(t) e.w.writen1(bincVdTimestamp<<4 | uint8(len(bs))) e.w.writeb(bs) } } -func (e *bincEncDriver) EncodeNil() { - e.w.writen1(bincVdSpecial<<4 | bincSpNil) -} - func (e *bincEncDriver) EncodeBool(b bool) { if b { e.w.writen1(bincVdSpecial<<4 | bincSpTrue) @@ -198,13 +191,19 @@ func (e *bincEncDriver) encodeExtPreamble(xtag byte, length int) { func (e *bincEncDriver) WriteArrayStart(length int) { e.encLen(bincVdArray<<4, uint64(length)) + e.c = containerArrayStart } func (e *bincEncDriver) WriteMapStart(length int) { e.encLen(bincVdMap<<4, uint64(length)) + e.c = containerMapStart } func (e *bincEncDriver) EncodeString(c charEncoding, v string) { + if e.c == containerMapKey && c == cUTF8 && (e.h.AsSymbols == 0 || e.h.AsSymbols == 1) { + e.EncodeSymbol(v) + return + } l := uint64(len(v)) e.encBytesLen(c, l) if l > 0 { @@ -214,7 +213,7 @@ func (e *bincEncDriver) EncodeString(c charEncoding, v string) { func (e *bincEncDriver) EncodeSymbol(v string) { // if WriteSymbolsNoRefs { - // e.encodeString(c_UTF8, v) + // e.encodeString(cUTF8, v) // return // } @@ -224,10 +223,10 @@ func (e *bincEncDriver) EncodeSymbol(v string) { l := len(v) if l == 0 { - e.encBytesLen(c_UTF8, 0) + e.encBytesLen(cUTF8, 0) return } else if l == 1 { - e.encBytesLen(c_UTF8, 1) + e.encBytesLen(cUTF8, 1) e.w.writen1(v[0]) return } @@ -277,6 +276,10 @@ func (e *bincEncDriver) EncodeSymbol(v string) { } func (e *bincEncDriver) EncodeStringBytes(c charEncoding, v []byte) { + if v == nil { + e.EncodeNil() + return + } l := uint64(len(v)) e.encBytesLen(c, l) if l > 0 { @@ -286,7 +289,7 @@ func (e *bincEncDriver) EncodeStringBytes(c charEncoding, v []byte) { func (e *bincEncDriver) encBytesLen(c charEncoding, length uint64) { //TODO: support bincUnicodeOther (for now, just use string or bytearray) - if c == c_RAW { + if c == cRAW { e.encLen(bincVdByteArray<<4, length) } else { e.encLen(bincVdString<<4, length) @@ -325,6 +328,9 @@ type bincDecSymbol struct { } type bincDecDriver struct { + decDriverNoopContainerReader + noBuiltInTypes + d *Decoder h *BincHandle r decReader @@ -333,14 +339,15 @@ type bincDecDriver struct { bd byte vd byte vs byte - // noStreamingCodec - // decNoSeparator - b [scratchByteArrayLen]byte - + _ [3]byte // padding // linear searching on this slice is ok, // because we typically expect < 32 symbols in each stream. s []bincDecSymbol - decDriverNoopContainerReader + + // noStreamingCodec + // decNoSeparator + + b [8 * 8]byte // scratch } func (d *bincDecDriver) readNextBd() { @@ -371,9 +378,10 @@ func (d *bincDecDriver) ContainerType() (vt valueType) { return valueTypeArray } else if d.vd == bincVdMap { return valueTypeMap - } else { - // d.d.errorf("isContainerType: unsupported parameter: %v", vt) } + // else { + // d.d.errorf("isContainerType: unsupported parameter: %v", vt) + // } return valueTypeUnset } @@ -388,27 +396,24 @@ func (d *bincDecDriver) TryDecodeAsNil() bool { return false } -func (d *bincDecDriver) IsBuiltinType(rt uintptr) bool { - return rt == timeTypId -} - -func (d *bincDecDriver) DecodeBuiltin(rt uintptr, v interface{}) { +func (d *bincDecDriver) DecodeTime() (t time.Time) { if !d.bdRead { d.readNextBd() } - if rt == timeTypId { - if d.vd != bincVdTimestamp { - d.d.errorf("Invalid d.vd. Expecting 0x%x. Received: 0x%x", bincVdTimestamp, d.vd) - return - } - tt, err := decodeTime(d.r.readx(int(d.vs))) - if err != nil { - panic(err) - } - var vt *time.Time = v.(*time.Time) - *vt = tt + if d.bd == bincVdSpecial<<4|bincSpNil { d.bdRead = false + return + } + if d.vd != bincVdTimestamp { + d.d.errorf("Invalid d.vd. Expecting 0x%x. Received: 0x%x", bincVdTimestamp, d.vd) + return + } + t, err := bincDecodeTime(d.r.readx(int(d.vs))) + if err != nil { + panic(err) } + d.bdRead = false + return } func (d *bincDecDriver) decFloatPre(vs, defaultLen byte) { @@ -497,45 +502,33 @@ func (d *bincDecDriver) decCheckInteger() (ui uint64, neg bool) { return } } else { - d.d.errorf("number can only be decoded from uint or int values. d.bd: 0x%x, d.vd: 0x%x", d.bd, d.vd) + d.d.errorf("integer can only be decoded from int/uint. d.bd: 0x%x, d.vd: 0x%x", d.bd, d.vd) return } return } -func (d *bincDecDriver) DecodeInt(bitsize uint8) (i int64) { +func (d *bincDecDriver) DecodeInt64() (i int64) { ui, neg := d.decCheckInteger() - i, overflow := chkOvf.SignedInt(ui) - if overflow { - d.d.errorf("simple: overflow converting %v to signed integer", ui) - return - } + i = chkOvf.SignedIntV(ui) if neg { i = -i } - if chkOvf.Int(i, bitsize) { - d.d.errorf("binc: overflow integer: %v for num bits: %v", i, bitsize) - return - } d.bdRead = false return } -func (d *bincDecDriver) DecodeUint(bitsize uint8) (ui uint64) { +func (d *bincDecDriver) DecodeUint64() (ui uint64) { ui, neg := d.decCheckInteger() if neg { d.d.errorf("Assigning negative signed value to unsigned type") return } - if chkOvf.Uint(ui, bitsize) { - d.d.errorf("binc: overflow integer: %v", ui) - return - } d.bdRead = false return } -func (d *bincDecDriver) DecodeFloat(chkOverflow32 bool) (f float64) { +func (d *bincDecDriver) DecodeFloat64() (f float64) { if !d.bdRead { d.readNextBd() } @@ -557,11 +550,7 @@ func (d *bincDecDriver) DecodeFloat(chkOverflow32 bool) (f float64) { } else if vd == bincVdFloat { f = d.decFloat() } else { - f = float64(d.DecodeInt(64)) - } - if chkOverflow32 && chkOvf.Float32(f) { - d.d.errorf("binc: float32 overflow: %v", f) - return + f = float64(d.DecodeInt64()) } d.bdRead = false return @@ -633,7 +622,8 @@ func (d *bincDecDriver) decLenNumber() (v uint64) { return } -func (d *bincDecDriver) decStringAndBytes(bs []byte, withString, zerocopy bool) (bs2 []byte, s string) { +func (d *bincDecDriver) decStringAndBytes(bs []byte, withString, zerocopy bool) ( + bs2 []byte, s string) { if !d.bdRead { d.readNextBd() } @@ -641,7 +631,7 @@ func (d *bincDecDriver) decStringAndBytes(bs []byte, withString, zerocopy bool) d.bdRead = false return } - var slen int = -1 + var slen = -1 // var ok bool switch d.vd { case bincVdString, bincVdByteArray: @@ -743,6 +733,11 @@ func (d *bincDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { d.bdRead = false return nil } + // check if an "array" of uint8's (see ContainerType for how to infer if an array) + if d.vd == bincVdArray { + bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d) + return + } var clen int if d.vd == bincVdString || d.vd == bincVdByteArray { clen = d.decLen() @@ -863,8 +858,8 @@ func (d *bincDecDriver) DecodeNaked() { n.v = valueTypeBytes n.l = d.DecodeBytes(nil, false) case bincVdTimestamp: - n.v = valueTypeTimestamp - tt, err := decodeTime(d.r.readx(int(d.vs))) + n.v = valueTypeTime + tt, err := bincDecodeTime(d.r.readx(int(d.vs))) if err != nil { panic(err) } @@ -912,27 +907,50 @@ type BincHandle struct { BasicHandle binaryEncodingType noElemSeparators + + // AsSymbols defines what should be encoded as symbols. + // + // Encoding as symbols can reduce the encoded size significantly. + // + // However, during decoding, each string to be encoded as a symbol must + // be checked to see if it has been seen before. Consequently, encoding time + // will increase if using symbols, because string comparisons has a clear cost. + // + // Values: + // - 0: default: library uses best judgement + // - 1: use symbols + // - 2: do not use symbols + AsSymbols uint8 + + // AsSymbols: may later on introduce more options ... + // - m: map keys + // - s: struct fields + // - n: none + // - a: all: same as m, s, ... + + _ [1]uint64 // padding } +// Name returns the name of the handle: binc +func (h *BincHandle) Name() string { return "binc" } + +// SetBytesExt sets an extension func (h *BincHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) { - return h.SetExt(rt, tag, &setExtWrapper{b: ext}) + return h.SetExt(rt, tag, &extWrapper{ext, interfaceExtFailer{}}) } func (h *BincHandle) newEncDriver(e *Encoder) encDriver { - return &bincEncDriver{e: e, w: e.w} + return &bincEncDriver{e: e, h: h, w: e.w} } func (h *BincHandle) newDecDriver(d *Decoder) decDriver { return &bincDecDriver{d: d, h: h, r: d.r, br: d.bytes} } -func (_ *BincHandle) IsBuiltinType(rt uintptr) bool { - return rt == timeTypId -} - func (e *bincEncDriver) reset() { e.w = e.e.w e.s = 0 + e.c = 0 e.m = nil } @@ -942,5 +960,165 @@ func (d *bincDecDriver) reset() { d.bd, d.bdRead, d.vd, d.vs = 0, false, 0, 0 } +// var timeDigits = [...]byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'} + +// EncodeTime encodes a time.Time as a []byte, including +// information on the instant in time and UTC offset. +// +// Format Description +// +// A timestamp is composed of 3 components: +// +// - secs: signed integer representing seconds since unix epoch +// - nsces: unsigned integer representing fractional seconds as a +// nanosecond offset within secs, in the range 0 <= nsecs < 1e9 +// - tz: signed integer representing timezone offset in minutes east of UTC, +// and a dst (daylight savings time) flag +// +// When encoding a timestamp, the first byte is the descriptor, which +// defines which components are encoded and how many bytes are used to +// encode secs and nsecs components. *If secs/nsecs is 0 or tz is UTC, it +// is not encoded in the byte array explicitly*. +// +// Descriptor 8 bits are of the form `A B C DDD EE`: +// A: Is secs component encoded? 1 = true +// B: Is nsecs component encoded? 1 = true +// C: Is tz component encoded? 1 = true +// DDD: Number of extra bytes for secs (range 0-7). +// If A = 1, secs encoded in DDD+1 bytes. +// If A = 0, secs is not encoded, and is assumed to be 0. +// If A = 1, then we need at least 1 byte to encode secs. +// DDD says the number of extra bytes beyond that 1. +// E.g. if DDD=0, then secs is represented in 1 byte. +// if DDD=2, then secs is represented in 3 bytes. +// EE: Number of extra bytes for nsecs (range 0-3). +// If B = 1, nsecs encoded in EE+1 bytes (similar to secs/DDD above) +// +// Following the descriptor bytes, subsequent bytes are: +// +// secs component encoded in `DDD + 1` bytes (if A == 1) +// nsecs component encoded in `EE + 1` bytes (if B == 1) +// tz component encoded in 2 bytes (if C == 1) +// +// secs and nsecs components are integers encoded in a BigEndian +// 2-complement encoding format. +// +// tz component is encoded as 2 bytes (16 bits). Most significant bit 15 to +// Least significant bit 0 are described below: +// +// Timezone offset has a range of -12:00 to +14:00 (ie -720 to +840 minutes). +// Bit 15 = have\_dst: set to 1 if we set the dst flag. +// Bit 14 = dst\_on: set to 1 if dst is in effect at the time, or 0 if not. +// Bits 13..0 = timezone offset in minutes. It is a signed integer in Big Endian format. +// +func bincEncodeTime(t time.Time) []byte { + //t := rv.Interface().(time.Time) + tsecs, tnsecs := t.Unix(), t.Nanosecond() + var ( + bd byte + btmp [8]byte + bs [16]byte + i int = 1 + ) + l := t.Location() + if l == time.UTC { + l = nil + } + if tsecs != 0 { + bd = bd | 0x80 + bigen.PutUint64(btmp[:], uint64(tsecs)) + f := pruneSignExt(btmp[:], tsecs >= 0) + bd = bd | (byte(7-f) << 2) + copy(bs[i:], btmp[f:]) + i = i + (8 - f) + } + if tnsecs != 0 { + bd = bd | 0x40 + bigen.PutUint32(btmp[:4], uint32(tnsecs)) + f := pruneSignExt(btmp[:4], true) + bd = bd | byte(3-f) + copy(bs[i:], btmp[f:4]) + i = i + (4 - f) + } + if l != nil { + bd = bd | 0x20 + // Note that Go Libs do not give access to dst flag. + _, zoneOffset := t.Zone() + //zoneName, zoneOffset := t.Zone() + zoneOffset /= 60 + z := uint16(zoneOffset) + bigen.PutUint16(btmp[:2], z) + // clear dst flags + bs[i] = btmp[0] & 0x3f + bs[i+1] = btmp[1] + i = i + 2 + } + bs[0] = bd + return bs[0:i] +} + +// bincDecodeTime decodes a []byte into a time.Time. +func bincDecodeTime(bs []byte) (tt time.Time, err error) { + bd := bs[0] + var ( + tsec int64 + tnsec uint32 + tz uint16 + i byte = 1 + i2 byte + n byte + ) + if bd&(1<<7) != 0 { + var btmp [8]byte + n = ((bd >> 2) & 0x7) + 1 + i2 = i + n + copy(btmp[8-n:], bs[i:i2]) + //if first bit of bs[i] is set, then fill btmp[0..8-n] with 0xff (ie sign extend it) + if bs[i]&(1<<7) != 0 { + copy(btmp[0:8-n], bsAll0xff) + //for j,k := byte(0), 8-n; j < k; j++ { btmp[j] = 0xff } + } + i = i2 + tsec = int64(bigen.Uint64(btmp[:])) + } + if bd&(1<<6) != 0 { + var btmp [4]byte + n = (bd & 0x3) + 1 + i2 = i + n + copy(btmp[4-n:], bs[i:i2]) + i = i2 + tnsec = bigen.Uint32(btmp[:]) + } + if bd&(1<<5) == 0 { + tt = time.Unix(tsec, int64(tnsec)).UTC() + return + } + // In stdlib time.Parse, when a date is parsed without a zone name, it uses "" as zone name. + // However, we need name here, so it can be shown when time is printed. + // Zone name is in form: UTC-08:00. + // Note that Go Libs do not give access to dst flag, so we ignore dst bits + + i2 = i + 2 + tz = bigen.Uint16(bs[i:i2]) + // i = i2 + // sign extend sign bit into top 2 MSB (which were dst bits): + if tz&(1<<13) == 0 { // positive + tz = tz & 0x3fff //clear 2 MSBs: dst bits + } else { // negative + tz = tz | 0xc000 //set 2 MSBs: dst bits + } + tzint := int16(tz) + if tzint == 0 { + tt = time.Unix(tsec, int64(tnsec)).UTC() + } else { + // For Go Time, do not use a descriptive timezone. + // It's unnecessary, and makes it harder to do a reflect.DeepEqual. + // The Offset already tells what the offset should be, if not on UTC and unknown zone name. + // var zoneName = timeLocUTCName(tzint) + tt = time.Unix(tsec, int64(tnsec)).In(time.FixedZone("", int(tzint)*60)) + } + return +} + var _ decDriver = (*bincDecDriver)(nil) var _ encDriver = (*bincEncDriver)(nil) diff --git a/vendor/github.com/ugorji/go/codec/cbor.go b/vendor/github.com/ugorji/go/codec/cbor.go index 592cee851..be01e19e7 100644 --- a/vendor/github.com/ugorji/go/codec/cbor.go +++ b/vendor/github.com/ugorji/go/codec/cbor.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. package codec @@ -6,6 +6,7 @@ package codec import ( "math" "reflect" + "time" ) const ( @@ -38,6 +39,8 @@ const ( cborBdBreak = 0xff ) +// These define some in-stream descriptors for +// manual encoding e.g. when doing explicit indefinite-length const ( CborStreamBytes byte = 0x5f CborStreamString = 0x7f @@ -67,6 +70,7 @@ type cborEncDriver struct { w encWriter h *CborHandle x [8]byte + _ [3]uint64 // padding } func (e *cborEncDriver) EncodeNil() { @@ -124,6 +128,24 @@ func (e *cborEncDriver) encLen(bd byte, length int) { e.encUint(uint64(length), bd) } +func (e *cborEncDriver) EncodeTime(t time.Time) { + if t.IsZero() { + e.EncodeNil() + } else if e.h.TimeRFC3339 { + e.encUint(0, cborBaseTag) + e.EncodeString(cUTF8, t.Format(time.RFC3339Nano)) + } else { + e.encUint(1, cborBaseTag) + t = t.UTC().Round(time.Microsecond) + sec, nsec := t.Unix(), uint64(t.Nanosecond()) + if nsec == 0 { + e.EncodeInt(sec) + } else { + e.EncodeFloat64(float64(sec) + float64(nsec)/1e9) + } + } +} + func (e *cborEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext, en *Encoder) { e.encUint(uint64(xtag), cborBaseTag) if v := ext.ConvertExt(rv); v == nil { @@ -173,36 +195,65 @@ func (e *cborEncDriver) WriteArrayEnd() { } func (e *cborEncDriver) EncodeString(c charEncoding, v string) { - e.encLen(cborBaseString, len(v)) - e.w.writestr(v) + e.encStringBytesS(cborBaseString, v) } -func (e *cborEncDriver) EncodeSymbol(v string) { - e.EncodeString(c_UTF8, v) +func (e *cborEncDriver) EncodeStringBytes(c charEncoding, v []byte) { + if v == nil { + e.EncodeNil() + } else if c == cRAW { + e.encStringBytesS(cborBaseBytes, stringView(v)) + } else { + e.encStringBytesS(cborBaseString, stringView(v)) + } } -func (e *cborEncDriver) EncodeStringBytes(c charEncoding, v []byte) { - if c == c_RAW { - e.encLen(cborBaseBytes, len(v)) +func (e *cborEncDriver) encStringBytesS(bb byte, v string) { + if e.h.IndefiniteLength { + if bb == cborBaseBytes { + e.w.writen1(cborBdIndefiniteBytes) + } else { + e.w.writen1(cborBdIndefiniteString) + } + blen := len(v) / 4 + if blen == 0 { + blen = 64 + } else if blen > 1024 { + blen = 1024 + } + for i := 0; i < len(v); { + var v2 string + i2 := i + blen + if i2 < len(v) { + v2 = v[i:i2] + } else { + v2 = v[i:] + } + e.encLen(bb, len(v2)) + e.w.writestr(v2) + i = i2 + } + e.w.writen1(cborBdBreak) } else { - e.encLen(cborBaseString, len(v)) + e.encLen(bb, len(v)) + e.w.writestr(v) } - e.w.writeb(v) } // ---------------------- type cborDecDriver struct { - d *Decoder - h *CborHandle - r decReader - b [scratchByteArrayLen]byte + d *Decoder + h *CborHandle + r decReader + // b [scratchByteArrayLen]byte br bool // bytes reader bdRead bool bd byte noBuiltInTypes // decNoSeparator decDriverNoopContainerReader + _ [3]uint64 // padding } func (d *cborDecDriver) readNextBd() { @@ -231,9 +282,10 @@ func (d *cborDecDriver) ContainerType() (vt valueType) { return valueTypeArray } else if d.bd == cborBdIndefiniteMap || (d.bd >= cborBaseMap && d.bd < cborBaseTag) { return valueTypeMap - } else { - // d.d.errorf("isContainerType: unsupported parameter: %v", vt) } + // else { + // d.d.errorf("isContainerType: unsupported parameter: %v", vt) + // } return valueTypeUnset } @@ -296,46 +348,30 @@ func (d *cborDecDriver) decCheckInteger() (neg bool) { return } -func (d *cborDecDriver) DecodeInt(bitsize uint8) (i int64) { +func (d *cborDecDriver) DecodeInt64() (i int64) { neg := d.decCheckInteger() ui := d.decUint() // check if this number can be converted to an int without overflow - var overflow bool if neg { - if i, overflow = chkOvf.SignedInt(ui + 1); overflow { - d.d.errorf("cbor: overflow converting %v to signed integer", ui+1) - return - } - i = -i + i = -(chkOvf.SignedIntV(ui + 1)) } else { - if i, overflow = chkOvf.SignedInt(ui); overflow { - d.d.errorf("cbor: overflow converting %v to signed integer", ui) - return - } - } - if chkOvf.Int(i, bitsize) { - d.d.errorf("cbor: overflow integer: %v", i) - return + i = chkOvf.SignedIntV(ui) } d.bdRead = false return } -func (d *cborDecDriver) DecodeUint(bitsize uint8) (ui uint64) { +func (d *cborDecDriver) DecodeUint64() (ui uint64) { if d.decCheckInteger() { d.d.errorf("Assigning negative signed value to unsigned type") return } ui = d.decUint() - if chkOvf.Uint(ui, bitsize) { - d.d.errorf("cbor: overflow integer: %v", ui) - return - } d.bdRead = false return } -func (d *cborDecDriver) DecodeFloat(chkOverflow32 bool) (f float64) { +func (d *cborDecDriver) DecodeFloat64() (f float64) { if !d.bdRead { d.readNextBd() } @@ -346,15 +382,11 @@ func (d *cborDecDriver) DecodeFloat(chkOverflow32 bool) (f float64) { } else if bd == cborBdFloat64 { f = math.Float64frombits(bigen.Uint64(d.r.readx(8))) } else if bd >= cborBaseUint && bd < cborBaseBytes { - f = float64(d.DecodeInt(64)) + f = float64(d.DecodeInt64()) } else { d.d.errorf("Float only valid from float16/32/64: Invalid descriptor: %v", bd) return } - if chkOverflow32 && chkOvf.Float32(f) { - d.d.errorf("cbor: float32 overflow: %v", f) - return - } d.bdRead = false return } @@ -408,7 +440,8 @@ func (d *cborDecDriver) decAppendIndefiniteBytes(bs []byte) []byte { break } if major := d.bd >> 5; major != cborMajorBytes && major != cborMajorText { - d.d.errorf("cbor: expect bytes or string major type in indefinite string/bytes; got: %v, byte: %v", major, d.bd) + d.d.errorf("expect bytes/string major type in indefinite string/bytes;"+ + " got: %v, byte: %v", major, d.bd) return nil } n := d.decLen() @@ -438,29 +471,84 @@ func (d *cborDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { return nil } if d.bd == cborBdIndefiniteBytes || d.bd == cborBdIndefiniteString { + d.bdRead = false if bs == nil { - return d.decAppendIndefiniteBytes(nil) + if zerocopy { + return d.decAppendIndefiniteBytes(d.d.b[:0]) + } + return d.decAppendIndefiniteBytes(zeroByteSlice) } return d.decAppendIndefiniteBytes(bs[:0]) } + // check if an "array" of uint8's (see ContainerType for how to infer if an array) + if d.bd == cborBdIndefiniteArray || (d.bd >= cborBaseArray && d.bd < cborBaseMap) { + bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d) + return + } clen := d.decLen() d.bdRead = false if zerocopy { if d.br { return d.r.readx(clen) } else if len(bs) == 0 { - bs = d.b[:] + bs = d.d.b[:] } } - return decByteSlice(d.r, clen, d.d.h.MaxInitLen, bs) + return decByteSlice(d.r, clen, d.h.MaxInitLen, bs) } func (d *cborDecDriver) DecodeString() (s string) { - return string(d.DecodeBytes(d.b[:], true)) + return string(d.DecodeBytes(d.d.b[:], true)) } func (d *cborDecDriver) DecodeStringAsBytes() (s []byte) { - return d.DecodeBytes(d.b[:], true) + return d.DecodeBytes(d.d.b[:], true) +} + +func (d *cborDecDriver) DecodeTime() (t time.Time) { + if !d.bdRead { + d.readNextBd() + } + if d.bd == cborBdNil || d.bd == cborBdUndefined { + d.bdRead = false + return + } + xtag := d.decUint() + d.bdRead = false + return d.decodeTime(xtag) +} + +func (d *cborDecDriver) decodeTime(xtag uint64) (t time.Time) { + if !d.bdRead { + d.readNextBd() + } + switch xtag { + case 0: + var err error + if t, err = time.Parse(time.RFC3339, stringView(d.DecodeStringAsBytes())); err != nil { + d.d.errorv(err) + } + case 1: + // decode an int64 or a float, and infer time.Time from there. + // for floats, round to microseconds, as that is what is guaranteed to fit well. + switch { + case d.bd == cborBdFloat16, d.bd == cborBdFloat32: + f1, f2 := math.Modf(d.DecodeFloat64()) + t = time.Unix(int64(f1), int64(f2*1e9)) + case d.bd == cborBdFloat64: + f1, f2 := math.Modf(d.DecodeFloat64()) + t = time.Unix(int64(f1), int64(f2*1e9)) + case d.bd >= cborBaseUint && d.bd < cborBaseNegInt, + d.bd >= cborBaseNegInt && d.bd < cborBaseBytes: + t = time.Unix(d.DecodeInt64(), 0) + default: + d.d.errorf("time.Time can only be decoded from a number (or RFC3339 string)") + } + default: + d.d.errorf("invalid tag for time.Time - expecting 0 or 1, got 0x%x", xtag) + } + t = t.UTC().Round(time.Microsecond) + return } func (d *cborDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxtag uint64) { @@ -503,12 +591,9 @@ func (d *cborDecDriver) DecodeNaked() { case cborBdTrue: n.v = valueTypeBool n.b = true - case cborBdFloat16, cborBdFloat32: + case cborBdFloat16, cborBdFloat32, cborBdFloat64: n.v = valueTypeFloat - n.f = d.DecodeFloat(true) - case cborBdFloat64: - n.v = valueTypeFloat - n.f = d.DecodeFloat(false) + n.f = d.DecodeFloat64() case cborBdIndefiniteBytes: n.v = valueTypeBytes n.l = d.DecodeBytes(nil, false) @@ -526,14 +611,14 @@ func (d *cborDecDriver) DecodeNaked() { case d.bd >= cborBaseUint && d.bd < cborBaseNegInt: if d.h.SignedInteger { n.v = valueTypeInt - n.i = d.DecodeInt(64) + n.i = d.DecodeInt64() } else { n.v = valueTypeUint - n.u = d.DecodeUint(64) + n.u = d.DecodeUint64() } case d.bd >= cborBaseNegInt && d.bd < cborBaseBytes: n.v = valueTypeInt - n.i = d.DecodeInt(64) + n.i = d.DecodeInt64() case d.bd >= cborBaseBytes && d.bd < cborBaseString: n.v = valueTypeBytes n.l = d.DecodeBytes(nil, false) @@ -550,6 +635,11 @@ func (d *cborDecDriver) DecodeNaked() { n.v = valueTypeExt n.u = d.decUint() n.l = nil + if n.u == 0 || n.u == 1 { + d.bdRead = false + n.v = valueTypeTime + n.t = d.decodeTime(n.u) + } // d.bdRead = false // d.d.decode(&re.Value) // handled by decode itself. // decodeFurther = true @@ -580,23 +670,8 @@ func (d *cborDecDriver) DecodeNaked() { // // None of the optional extensions (with tags) defined in the spec are supported out-of-the-box. // Users can implement them as needed (using SetExt), including spec-documented ones: -// - timestamp, BigNum, BigFloat, Decimals, Encoded Text (e.g. URL, regexp, base64, MIME Message), etc. -// -// To encode with indefinite lengths (streaming), users will use -// (Must)Encode methods of *Encoder, along with writing CborStreamXXX constants. -// -// For example, to encode "one-byte" as an indefinite length string: -// var buf bytes.Buffer -// e := NewEncoder(&buf, new(CborHandle)) -// buf.WriteByte(CborStreamString) -// e.MustEncode("one-") -// e.MustEncode("byte") -// buf.WriteByte(CborStreamBreak) -// encodedBytes := buf.Bytes() -// var vv interface{} -// NewDecoderBytes(buf.Bytes(), new(CborHandle)).MustDecode(&vv) -// // Now, vv contains the same string "one-byte" -// +// - timestamp, BigNum, BigFloat, Decimals, +// - Encoded Text (e.g. URL, regexp, base64, MIME Message), etc. type CborHandle struct { binaryEncodingType noElemSeparators @@ -604,10 +679,20 @@ type CborHandle struct { // IndefiniteLength=true, means that we encode using indefinitelength IndefiniteLength bool + + // TimeRFC3339 says to encode time.Time using RFC3339 format. + // If unset, we encode time.Time using seconds past epoch. + TimeRFC3339 bool + + _ [1]uint64 // padding } +// Name returns the name of the handle: cbor +func (h *CborHandle) Name() string { return "cbor" } + +// SetInterfaceExt sets an extension func (h *CborHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) { - return h.SetExt(rt, tag, &setExtWrapper{i: ext}) + return h.SetExt(rt, tag, &extWrapper{bytesExtFailer{}, ext}) } func (h *CborHandle) newEncDriver(e *Encoder) encDriver { diff --git a/vendor/github.com/ugorji/go/codec/decode.go b/vendor/github.com/ugorji/go/codec/decode.go index 246533f32..148c609c1 100644 --- a/vendor/github.com/ugorji/go/codec/decode.go +++ b/vendor/github.com/ugorji/go/codec/decode.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. package codec @@ -9,6 +9,7 @@ import ( "fmt" "io" "reflect" + "strconv" "sync" "time" ) @@ -20,12 +21,17 @@ const ( ) var ( - onlyMapOrArrayCanDecodeIntoStructErr = errors.New("only encoded map or array can be decoded into a struct") - cannotDecodeIntoNilErr = errors.New("cannot decode into nil") + errstrOnlyMapOrArrayCanDecodeIntoStruct = "only encoded map or array can be decoded into a struct" + errstrCannotDecodeIntoNil = "cannot decode into nil" - decUnreadByteNothingToReadErr = errors.New("cannot unread - nothing has been read") - decUnreadByteLastByteNotReadErr = errors.New("cannot unread - last byte has not been read") - decUnreadByteUnknownErr = errors.New("cannot unread - reason unknown") + errmsgExpandSliceOverflow = "expand slice: slice overflow" + errmsgExpandSliceCannotChange = "expand slice: cannot change" + + errDecoderNotInitialized = errors.New("Decoder not initialized") + + errDecUnreadByteNothingToRead = errors.New("cannot unread - nothing has been read") + errDecUnreadByteLastByteNotRead = errors.New("cannot unread - last byte has not been read") + errDecUnreadByteUnknown = errors.New("cannot unread - reason unknown") ) // decReader abstracts the reading source, allowing implementations that can @@ -39,9 +45,6 @@ type decReader interface { readx(n int) []byte readb([]byte) readn1() uint8 - readn3() (uint8, uint8, uint8) - readn4() (uint8, uint8, uint8, uint8) - // readn1eof() (v uint8, eof bool) numread() int // number of bytes read track() stopTrack() []byte @@ -54,11 +57,6 @@ type decReader interface { readUntil(in []byte, stop byte) (out []byte) } -// type decReaderByteScanner interface { -// io.Reader -// io.ByteScanner -// } - type decDriver interface { // this will check if the next token is a break. CheckBreak() bool @@ -70,7 +68,6 @@ type decDriver interface { // vt is one of: Bytes, String, Nil, Slice or Map. Return unSet if not known. ContainerType() (vt valueType) // IsBuiltinType(rt uintptr) bool - DecodeBuiltin(rt uintptr, v interface{}) // DecodeNaked will decode primitives (number, bool, string, []byte) and RawExt. // For maps and arrays, it will not do the decoding in-band, but will signal @@ -84,9 +81,15 @@ type decDriver interface { // extensions should also use readx to decode them, for efficiency. // kInterface will extract the detached byte slice if it has to pass it outside its realm. DecodeNaked() - DecodeInt(bitsize uint8) (i int64) - DecodeUint(bitsize uint8) (ui uint64) - DecodeFloat(chkOverflow32 bool) (f float64) + + // Deprecated: use DecodeInt64 and DecodeUint64 instead + // DecodeInt(bitsize uint8) (i int64) + // DecodeUint(bitsize uint8) (ui uint64) + + DecodeInt64() (i int64) + DecodeUint64() (ui uint64) + + DecodeFloat64() (f float64) DecodeBool() (b bool) // DecodeString can also decode symbols. // It looks redundant as DecodeBytes is available. @@ -104,6 +107,9 @@ type decDriver interface { // decodeExt will decode into a *RawExt or into an extension. DecodeExt(v interface{}, xtag uint64, ext Ext) (realxtag uint64) // decodeExt(verifyTag bool, tag byte) (xtag byte, xbs []byte) + + DecodeTime() (t time.Time) + ReadArrayStart() int ReadArrayElem() ReadArrayEnd() @@ -116,39 +122,44 @@ type decDriver interface { uncacheRead() } -// type decNoSeparator struct {} -// func (_ decNoSeparator) ReadEnd() {} - type decDriverNoopContainerReader struct{} -func (_ decDriverNoopContainerReader) ReadArrayStart() (v int) { return } -func (_ decDriverNoopContainerReader) ReadArrayElem() {} -func (_ decDriverNoopContainerReader) ReadArrayEnd() {} -func (_ decDriverNoopContainerReader) ReadMapStart() (v int) { return } -func (_ decDriverNoopContainerReader) ReadMapElemKey() {} -func (_ decDriverNoopContainerReader) ReadMapElemValue() {} -func (_ decDriverNoopContainerReader) ReadMapEnd() {} -func (_ decDriverNoopContainerReader) CheckBreak() (v bool) { return } +func (x decDriverNoopContainerReader) ReadArrayStart() (v int) { return } +func (x decDriverNoopContainerReader) ReadArrayElem() {} +func (x decDriverNoopContainerReader) ReadArrayEnd() {} +func (x decDriverNoopContainerReader) ReadMapStart() (v int) { return } +func (x decDriverNoopContainerReader) ReadMapElemKey() {} +func (x decDriverNoopContainerReader) ReadMapElemValue() {} +func (x decDriverNoopContainerReader) ReadMapEnd() {} +func (x decDriverNoopContainerReader) CheckBreak() (v bool) { return } -// func (_ decNoSeparator) uncacheRead() {} +// func (x decNoSeparator) uncacheRead() {} +// DecodeOptions captures configuration options during decode. type DecodeOptions struct { // MapType specifies type to use during schema-less decoding of a map in the stream. - // If nil, we use map[interface{}]interface{} + // If nil (unset), we default to map[string]interface{} iff json handle and MapStringAsKey=true, + // else map[interface{}]interface{}. MapType reflect.Type // SliceType specifies type to use during schema-less decoding of an array in the stream. - // If nil, we use []interface{} + // If nil (unset), we default to []interface{} for all formats. SliceType reflect.Type - // MaxInitLen defines the maxinum initial length that we "make" a collection (string, slice, map, chan). - // If 0 or negative, we default to a sensible value based on the size of an element in the collection. + // MaxInitLen defines the maxinum initial length that we "make" a collection + // (string, slice, map, chan). If 0 or negative, we default to a sensible value + // based on the size of an element in the collection. // // For example, when decoding, a stream may say that it has 2^64 elements. - // We should not auto-matically provision a slice of that length, to prevent Out-Of-Memory crash. + // We should not auto-matically provision a slice of that size, to prevent Out-Of-Memory crash. // Instead, we provision up to MaxInitLen, fill that up, and start appending after that. MaxInitLen int + // ReaderBufferSize is the size of the buffer used when reading. + // + // if > 0, we use a smart buffer internally for performance purposes. + ReaderBufferSize int + // If ErrorIfNoField, return an error when decoding a map // from a codec stream into a struct, and no matching struct field is found. ErrorIfNoField bool @@ -219,11 +230,6 @@ type DecodeOptions struct { // If true, we will delete the mapping of the key. // Else, just set the mapping to the zero value of the type. DeleteOnNilMapValue bool - - // ReaderBufferSize is the size of the buffer used when reading. - // - // if > 0, we use a smart buffer internally for performance purposes. - ReaderBufferSize int } // ------------------------------------ @@ -236,10 +242,9 @@ type bufioDecReader struct { n int // num read err error - trb bool tr []byte - - b [8]byte + trb bool + b [4]byte } func (z *bufioDecReader) reset(r io.Reader) { @@ -342,7 +347,7 @@ func (z *bufioDecReader) UnreadByte() (err error) { } return } - return decUnreadByteNothingToReadErr + return errDecUnreadByteNothingToRead } func (z *bufioDecReader) numread() int { @@ -397,16 +402,6 @@ func (z *bufioDecReader) readn1() (b uint8) { return } -func (z *bufioDecReader) readn3() (b1, b2, b3 uint8) { - z.readb(z.b[:3]) - return z.b[0], z.b[1], z.b[2] -} - -func (z *bufioDecReader) readn4() (b1, b2, b3, b4 uint8) { - z.readb(z.b[:4]) - return z.b[0], z.b[1], z.b[2], z.b[3] -} - func (z *bufioDecReader) search(in []byte, accept *bitset256, stop, flag uint8) (token byte, out []byte) { // flag: 1 (skip), 2 (readTo), 4 (readUntil) if flag == 4 { @@ -549,16 +544,15 @@ type ioDecReader struct { rr io.Reader br io.ByteScanner - l byte // last byte - ls byte // last byte status. 0: init-canDoNothing, 1: canRead, 2: canUnread + l byte // last byte + ls byte // last byte status. 0: init-canDoNothing, 1: canRead, 2: canUnread + trb bool // tracking bytes turned on + _ bool b [4]byte // tiny buffer for reading single bytes - trb bool // tracking bytes turned on - // temp byte array re-used internally for efficiency during read. - // shares buffer with Decoder, so we keep size of struct within 8 words. - x *[scratchByteArrayLen]byte - n int // num read - tr []byte // tracking bytes read + x [scratchByteArrayLen]byte // for: get struct field name, swallow valueTypeBytes, etc + n int // num read + tr []byte // tracking bytes read } func (z *ioDecReader) reset(r io.Reader) { @@ -620,11 +614,11 @@ func (z *ioDecReader) UnreadByte() (err error) { case 2: z.ls = 1 case 0: - err = decUnreadByteNothingToReadErr + err = errDecUnreadByteNothingToRead case 1: - err = decUnreadByteLastByteNotReadErr + err = errDecUnreadByteLastByteNotRead default: - err = decUnreadByteUnknownErr + err = errDecUnreadByteUnknown } return } @@ -692,16 +686,6 @@ func (z *ioDecReader) readn1() (b uint8) { panic(err) } -func (z *ioDecReader) readn3() (b1, b2, b3 uint8) { - z.readb(z.b[:3]) - return z.b[0], z.b[1], z.b[2] -} - -func (z *ioDecReader) readn4() (b1, b2, b3, b4 uint8) { - z.readb(z.b[:4]) - return z.b[0], z.b[1], z.b[2], z.b[3] -} - func (z *ioDecReader) skip(accept *bitset256) (token byte) { for { var eof bool @@ -773,7 +757,7 @@ func (z *ioDecReader) stopTrack() (bs []byte) { // ------------------------------------ -var bytesDecReaderCannotUnreadErr = errors.New("cannot unread last byte read") +var errBytesDecReaderCannotUnread = errors.New("cannot unread last byte read") // bytesDecReader is a decReader that reads off a byte slice with zero copying type bytesDecReader struct { @@ -796,7 +780,7 @@ func (z *bytesDecReader) numread() int { func (z *bytesDecReader) unreadn1() { if z.c == 0 || len(z.b) == 0 { - panic(bytesDecReaderCannotUnreadErr) + panic(errBytesDecReaderCannotUnread) } z.c-- z.a++ @@ -836,31 +820,6 @@ func (z *bytesDecReader) readn1() (v uint8) { return } -func (z *bytesDecReader) readn3() (b1, b2, b3 uint8) { - if 3 > z.a { - panic(io.ErrUnexpectedEOF) - } - b3 = z.b[z.c+2] - b2 = z.b[z.c+1] - b1 = z.b[z.c] - z.c += 3 - z.a -= 3 - return -} - -func (z *bytesDecReader) readn4() (b1, b2, b3, b4 uint8) { - if 4 > z.a { - panic(io.ErrUnexpectedEOF) - } - b4 = z.b[z.c+3] - b3 = z.b[z.c+2] - b2 = z.b[z.c+1] - b1 = z.b[z.c] - z.c += 4 - z.a -= 4 - return -} - // func (z *bytesDecReader) readn1eof() (v uint8, eof bool) { // if z.a == 0 { // eof = true @@ -936,9 +895,9 @@ func (z *bytesDecReader) stopTrack() (bs []byte) { // ---------------------------------------- -func (d *Decoder) builtin(f *codecFnInfo, rv reflect.Value) { - d.d.DecodeBuiltin(f.ti.rtid, rv2i(rv)) -} +// func (d *Decoder) builtin(f *codecFnInfo, rv reflect.Value) { +// d.d.DecodeBuiltin(f.ti.rtid, rv2i(rv)) +// } func (d *Decoder) rawExt(f *codecFnInfo, rv reflect.Value) { d.d.DecodeExt(rv2i(rv), 0, nil) @@ -948,29 +907,12 @@ func (d *Decoder) ext(f *codecFnInfo, rv reflect.Value) { d.d.DecodeExt(rv2i(rv), f.xfTag, f.xfFn) } -func (d *Decoder) getValueForUnmarshalInterface(rv reflect.Value, indir int8) (v interface{}) { - if indir == -1 { - v = rv2i(rv.Addr()) - } else if indir == 0 { - v = rv2i(rv) - } else { - for j := int8(0); j < indir; j++ { - if rv.IsNil() { - rv.Set(reflect.New(rv.Type().Elem())) - } - rv = rv.Elem() - } - v = rv2i(rv) - } - return -} - func (d *Decoder) selferUnmarshal(f *codecFnInfo, rv reflect.Value) { - d.getValueForUnmarshalInterface(rv, f.ti.csIndir).(Selfer).CodecDecodeSelf(d) + rv2i(rv).(Selfer).CodecDecodeSelf(d) } func (d *Decoder) binaryUnmarshal(f *codecFnInfo, rv reflect.Value) { - bm := d.getValueForUnmarshalInterface(rv, f.ti.bunmIndir).(encoding.BinaryUnmarshaler) + bm := rv2i(rv).(encoding.BinaryUnmarshaler) xbs := d.d.DecodeBytes(nil, true) if fnerr := bm.UnmarshalBinary(xbs); fnerr != nil { panic(fnerr) @@ -978,7 +920,7 @@ func (d *Decoder) binaryUnmarshal(f *codecFnInfo, rv reflect.Value) { } func (d *Decoder) textUnmarshal(f *codecFnInfo, rv reflect.Value) { - tm := d.getValueForUnmarshalInterface(rv, f.ti.tunmIndir).(encoding.TextUnmarshaler) + tm := rv2i(rv).(encoding.TextUnmarshaler) fnerr := tm.UnmarshalText(d.d.DecodeStringAsBytes()) if fnerr != nil { panic(fnerr) @@ -986,7 +928,7 @@ func (d *Decoder) textUnmarshal(f *codecFnInfo, rv reflect.Value) { } func (d *Decoder) jsonUnmarshal(f *codecFnInfo, rv reflect.Value) { - tm := d.getValueForUnmarshalInterface(rv, f.ti.junmIndir).(jsonUnmarshaler) + tm := rv2i(rv).(jsonUnmarshaler) // bs := d.d.DecodeBytes(d.b[:], true, true) // grab the bytes to be read, as UnmarshalJSON needs the full JSON so as to unmarshal it itself. fnerr := tm.UnmarshalJSON(d.nextValueBytes()) @@ -1011,7 +953,6 @@ func (d *Decoder) kInterfaceNaked(f *codecFnInfo) (rvn reflect.Value) { return } // We cannot decode non-nil stream value into nil interface with methods (e.g. io.Reader). - // if num := f.ti.rt.NumMethod(); num > 0 { if f.ti.numMeth > 0 { d.errorf("cannot decode non-nil codec value into nil %v (%v methods)", f.ti.rt, f.ti.numMeth) return @@ -1019,10 +960,20 @@ func (d *Decoder) kInterfaceNaked(f *codecFnInfo) (rvn reflect.Value) { // var useRvn bool switch n.v { case valueTypeMap: - if d.mtid == 0 || d.mtid == mapIntfIntfTypId { + // if json, default to a map type with string keys + mtid := d.mtid + if mtid == 0 { + if d.jsms { + mtid = mapStrIntfTypId + } else { + mtid = mapIntfIntfTypId + } + } + if mtid == mapIntfIntfTypId { + n.initContainers() if n.lm < arrayCacheLen { n.ma[n.lm] = nil - rvn = n.rr[decNakedMapIntfIntfIdx*arrayCacheLen+n.lm] + rvn = n.rma[n.lm] n.lm++ d.decode(&n.ma[n.lm-1]) n.lm-- @@ -1031,10 +982,11 @@ func (d *Decoder) kInterfaceNaked(f *codecFnInfo) (rvn reflect.Value) { d.decode(&v2) rvn = reflect.ValueOf(&v2).Elem() } - } else if d.mtid == mapStrIntfTypId { // for json performance + } else if mtid == mapStrIntfTypId { // for json performance + n.initContainers() if n.ln < arrayCacheLen { n.na[n.ln] = nil - rvn = n.rr[decNakedMapStrIntfIdx*arrayCacheLen+n.ln] + rvn = n.rna[n.ln] n.ln++ d.decode(&n.na[n.ln-1]) n.ln-- @@ -1044,20 +996,21 @@ func (d *Decoder) kInterfaceNaked(f *codecFnInfo) (rvn reflect.Value) { rvn = reflect.ValueOf(&v2).Elem() } } else { - rvn = reflect.New(d.h.MapType) - if useLookupRecognizedTypes && d.mtr { // isRecognizedRtid(d.mtid) { + if d.mtr { + rvn = reflect.New(d.h.MapType) d.decode(rv2i(rvn)) rvn = rvn.Elem() } else { - rvn = rvn.Elem() - d.decodeValue(rvn, nil, false, true) + rvn = reflect.New(d.h.MapType).Elem() + d.decodeValue(rvn, nil, true) } } case valueTypeArray: if d.stid == 0 || d.stid == intfSliceTypId { + n.initContainers() if n.ls < arrayCacheLen { n.sa[n.ls] = nil - rvn = n.rr[decNakedSliceIntfIdx*arrayCacheLen+n.ls] + rvn = n.rsa[n.ls] n.ls++ d.decode(&n.sa[n.ls-1]) n.ls-- @@ -1072,19 +1025,20 @@ func (d *Decoder) kInterfaceNaked(f *codecFnInfo) (rvn reflect.Value) { rvn = rvn2 } } else { - rvn = reflect.New(d.h.SliceType) - if useLookupRecognizedTypes && d.str { // isRecognizedRtid(d.stid) { + if d.str { + rvn = reflect.New(d.h.SliceType) d.decode(rv2i(rvn)) rvn = rvn.Elem() } else { - rvn = rvn.Elem() - d.decodeValue(rvn, nil, false, true) + rvn = reflect.New(d.h.SliceType).Elem() + d.decodeValue(rvn, nil, true) } } case valueTypeExt: var v interface{} tag, bytes := n.u, n.l // calling decode below might taint the values if bytes == nil { + n.initContainers() if n.li < arrayCacheLen { n.ia[n.li] = nil n.li++ @@ -1116,21 +1070,21 @@ func (d *Decoder) kInterfaceNaked(f *codecFnInfo) (rvn reflect.Value) { case valueTypeNil: // no-op case valueTypeInt: - rvn = n.rr[decNakedIntIdx] // d.np.get(&n.i) + rvn = n.ri case valueTypeUint: - rvn = n.rr[decNakedUintIdx] // d.np.get(&n.u) + rvn = n.ru case valueTypeFloat: - rvn = n.rr[decNakedFloatIdx] // d.np.get(&n.f) + rvn = n.rf case valueTypeBool: - rvn = n.rr[decNakedBoolIdx] // d.np.get(&n.b) + rvn = n.rb case valueTypeString, valueTypeSymbol: - rvn = n.rr[decNakedStringIdx] // d.np.get(&n.s) + rvn = n.rs case valueTypeBytes: - rvn = n.rr[decNakedBytesIdx] // d.np.get(&n.l) - case valueTypeTimestamp: - rvn = n.rr[decNakedTimeIdx] // d.np.get(&n.t) + rvn = n.rl + case valueTypeTime: + rvn = n.rt default: - panic(fmt.Errorf("kInterfaceNaked: unexpected valueType: %d", n.v)) + panicv.errorf("kInterfaceNaked: unexpected valueType: %d", n.v) } return } @@ -1144,24 +1098,25 @@ func (d *Decoder) kInterface(f *codecFnInfo, rv reflect.Value) { // every interface passed here MUST be settable. var rvn reflect.Value - if rv.IsNil() { - if rvn = d.kInterfaceNaked(f); rvn.IsValid() { - rv.Set(rvn) - } - return - } - if d.h.InterfaceReset { - if rvn = d.kInterfaceNaked(f); rvn.IsValid() { + if rv.IsNil() || d.h.InterfaceReset { + // check if mapping to a type: if so, initialize it and move on + rvn = d.h.intf2impl(f.ti.rtid) + if rvn.IsValid() { rv.Set(rvn) } else { - // reset to zero value based on current type in there. - rv.Set(reflect.Zero(rv.Elem().Type())) + rvn = d.kInterfaceNaked(f) + if rvn.IsValid() { + rv.Set(rvn) + } else if d.h.InterfaceReset { + // reset to zero value based on current type in there. + rv.Set(reflect.Zero(rv.Elem().Type())) + } + return } - return + } else { + // now we have a non-nil interface value, meaning it contains a type + rvn = rv.Elem() } - - // now we have a non-nil interface value, meaning it contains a type - rvn = rv.Elem() if d.d.TryDecodeAsNil() { rv.Set(reflect.Zero(rvn.Type())) return @@ -1174,28 +1129,38 @@ func (d *Decoder) kInterface(f *codecFnInfo, rv reflect.Value) { rvn2, canDecode := isDecodeable(rvn) if canDecode { - d.decodeValue(rvn2, nil, true, true) + d.decodeValue(rvn2, nil, true) return } rvn2 = reflect.New(rvn.Type()).Elem() rvn2.Set(rvn) - d.decodeValue(rvn2, nil, true, true) + d.decodeValue(rvn2, nil, true) rv.Set(rvn2) } -func (d *Decoder) kStruct(f *codecFnInfo, rv reflect.Value) { - // checking if recognized within kstruct is too expensive. - // only check where you can determine if valid outside the loop - // ie on homogenous collections: slices, arrays and maps. - // - // if true, we don't create too many decFn's. - // It's a delicate balance. - const checkRecognized bool = false // false: TODO +func decStructFieldKey(dd decDriver, keyType valueType, b *[decScratchByteArrayLen]byte) (rvkencname []byte) { + // use if-else-if, not switch (which compiles to binary-search) + // since keyType is typically valueTypeString, branch prediction is pretty good. + if keyType == valueTypeString { + rvkencname = dd.DecodeStringAsBytes() + } else if keyType == valueTypeInt { + rvkencname = strconv.AppendInt(b[:0], dd.DecodeInt64(), 10) + } else if keyType == valueTypeUint { + rvkencname = strconv.AppendUint(b[:0], dd.DecodeUint64(), 10) + } else if keyType == valueTypeFloat { + rvkencname = strconv.AppendFloat(b[:0], dd.DecodeFloat64(), 'f', -1, 64) + } else { + rvkencname = dd.DecodeStringAsBytes() + } + return rvkencname +} + +func (d *Decoder) kStruct(f *codecFnInfo, rv reflect.Value) { fti := f.ti dd := d.d - elemsep := d.hh.hasElemSeparators() + elemsep := d.esep sfn := structFieldNode{v: rv, update: true} ctyp := dd.ContainerType() if ctyp == valueTypeMap { @@ -1204,17 +1169,15 @@ func (d *Decoder) kStruct(f *codecFnInfo, rv reflect.Value) { dd.ReadMapEnd() return } - tisfi := fti.sfi + tisfi := fti.sfiSort hasLen := containerLen >= 0 + var rvkencname []byte for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { - // rvkencname := dd.DecodeString() if elemsep { dd.ReadMapElemKey() } - rvkencnameB := dd.DecodeStringAsBytes() - rvkencname := stringView(rvkencnameB) - // rvksi := ti.getForEncName(rvkencname) + rvkencname = decStructFieldKey(dd, fti.keyType, &d.b) if elemsep { dd.ReadMapElemValue() } @@ -1223,12 +1186,12 @@ func (d *Decoder) kStruct(f *codecFnInfo, rv reflect.Value) { if dd.TryDecodeAsNil() { si.setToZeroValue(rv) } else { - d.decodeValue(sfn.field(si), nil, checkRecognized, true) + d.decodeValue(sfn.field(si), nil, true) } } else { - d.structFieldNotFound(-1, rvkencname) + d.structFieldNotFound(-1, stringView(rvkencname)) } - // keepAlive4StringView(rvkencnameB) // maintain ref 4 stringView // not needed, as reference is outside loop + // keepAlive4StringView(rvkencnameB) // not needed, as reference is outside loop } dd.ReadMapEnd() } else if ctyp == valueTypeArray { @@ -1240,7 +1203,7 @@ func (d *Decoder) kStruct(f *codecFnInfo, rv reflect.Value) { // Not much gain from doing it two ways for array. // Arrays are not used as much for structs. hasLen := containerLen >= 0 - for j, si := range fti.sfip { + for j, si := range fti.sfiSrc { if (hasLen && j == containerLen) || (!hasLen && dd.CheckBreak()) { break } @@ -1250,12 +1213,12 @@ func (d *Decoder) kStruct(f *codecFnInfo, rv reflect.Value) { if dd.TryDecodeAsNil() { si.setToZeroValue(rv) } else { - d.decodeValue(sfn.field(si), nil, checkRecognized, true) + d.decodeValue(sfn.field(si), nil, true) } } - if containerLen > len(fti.sfip) { + if containerLen > len(fti.sfiSrc) { // read remaining values and throw away - for j := len(fti.sfip); j < containerLen; j++ { + for j := len(fti.sfiSrc); j < containerLen; j++ { if elemsep { dd.ReadArrayElem() } @@ -1264,7 +1227,7 @@ func (d *Decoder) kStruct(f *codecFnInfo, rv reflect.Value) { } dd.ReadArrayEnd() } else { - d.error(onlyMapOrArrayCanDecodeIntoStructErr) + d.errorstr(errstrOnlyMapOrArrayCanDecodeIntoStruct) return } } @@ -1273,27 +1236,35 @@ func (d *Decoder) kSlice(f *codecFnInfo, rv reflect.Value) { // A slice can be set from a map or array in stream. // This way, the order can be kept (as order is lost with map). ti := f.ti + if f.seq == seqTypeChan && ti.chandir&uint8(reflect.SendDir) == 0 { + d.errorf("receive-only channel cannot be used for sending byte(s)") + } dd := d.d - rtelem0 := ti.rt.Elem() + rtelem0 := ti.elem ctyp := dd.ContainerType() if ctyp == valueTypeBytes || ctyp == valueTypeString { // you can only decode bytes or string in the stream into a slice or array of bytes if !(ti.rtid == uint8SliceTypId || rtelem0.Kind() == reflect.Uint8) { - d.errorf("bytes or string in the stream must be decoded into a slice or array of bytes, not %v", ti.rt) + d.errorf("bytes/string in stream must decode into slice/array of bytes, not %v", ti.rt) } if f.seq == seqTypeChan { bs2 := dd.DecodeBytes(nil, true) - ch := rv2i(rv).(chan<- byte) + irv := rv2i(rv) + ch, ok := irv.(chan<- byte) + if !ok { + ch = irv.(chan byte) + } for _, b := range bs2 { ch <- b } } else { rvbs := rv.Bytes() bs2 := dd.DecodeBytes(rvbs, false) - if rvbs == nil && bs2 != nil || rvbs != nil && bs2 == nil || len(bs2) != len(rvbs) { + // if rvbs == nil && bs2 != nil || rvbs != nil && bs2 == nil || len(bs2) != len(rvbs) { + if !(len(bs2) > 0 && len(bs2) == len(rvbs) && &bs2[0] == &rvbs[0]) { if rv.CanSet() { rv.SetBytes(bs2) - } else { + } else if len(rvbs) > 0 && len(bs2) > 0 { copy(rvbs, bs2) } } @@ -1326,7 +1297,6 @@ func (d *Decoder) kSlice(f *codecFnInfo, rv reflect.Value) { rtelem0Size := int(rtelem0.Size()) rtElem0Kind := rtelem0.Kind() - rtElem0Id := rt2id(rtelem0) rtelem0Mut := !isImmutableKind(rtElem0Kind) rtelem := rtelem0 rtelemkind := rtelem.Kind() @@ -1337,9 +1307,10 @@ func (d *Decoder) kSlice(f *codecFnInfo, rv reflect.Value) { var fn *codecFn - var rv0, rv9 reflect.Value - rv0 = rv - rvChanged := false + var rvCanset = rv.CanSet() + var rvChanged bool + var rv0 = rv + var rv9 reflect.Value rvlen := rv.Len() rvcap := rv.Cap() @@ -1349,42 +1320,38 @@ func (d *Decoder) kSlice(f *codecFnInfo, rv reflect.Value) { oldRvlenGtZero := rvlen > 0 rvlen = decInferLen(containerLenS, d.h.MaxInitLen, int(rtelem0.Size())) if rvlen <= rvcap { - if rv.CanSet() { + if rvCanset { rv.SetLen(rvlen) - } else { - rv = rv.Slice(0, rvlen) - rvChanged = true } - } else { + } else if rvCanset { rv = reflect.MakeSlice(ti.rt, rvlen, rvlen) rvcap = rvlen rvChanged = true + } else { + d.errorf("cannot decode into non-settable slice") } if rvChanged && oldRvlenGtZero && !isImmutableKind(rtelem0.Kind()) { reflect.Copy(rv, rv0) // only copy up to length NOT cap i.e. rv0.Slice(0, rvcap) } } else if containerLenS != rvlen { rvlen = containerLenS - if rv.CanSet() { + if rvCanset { rv.SetLen(rvlen) - } else { - rv = rv.Slice(0, rvlen) - rvChanged = true } + // else { + // rv = rv.Slice(0, rvlen) + // rvChanged = true + // d.errorf("cannot decode into non-settable slice") + // } } } - var recognizedRtid, recognizedRtidPtr bool - if useLookupRecognizedTypes { - recognizedRtid = isRecognizedRtid(rtElem0Id) - recognizedRtidPtr = isRecognizedRtidPtr(rtElem0Id) - } - // consider creating new element once, and just decoding into it. var rtelem0Zero reflect.Value var rtelem0ZeroValid bool var decodeAsNil bool var j int + d.cfer() for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { if j == 0 && (f.seq == seqTypeSlice || f.seq == seqTypeChan) && rv.IsNil() { if hasLen { @@ -1392,11 +1359,16 @@ func (d *Decoder) kSlice(f *codecFnInfo, rv reflect.Value) { } else { rvlen = 8 } - if f.seq == seqTypeSlice { - rv = reflect.MakeSlice(ti.rt, rvlen, rvlen) - rvChanged = true - } else if f.seq == seqTypeChan { - rv.Set(reflect.MakeChan(ti.rt, rvlen)) + if rvCanset { + if f.seq == seqTypeSlice { + rv = reflect.MakeSlice(ti.rt, rvlen, rvlen) + rvChanged = true + } else { // chan + rv = reflect.MakeChan(ti.rt, rvlen) + rvChanged = true + } + } else { + d.errorf("cannot decode into non-settable slice") } } slh.ElemContainerState(j) @@ -1409,14 +1381,10 @@ func (d *Decoder) kSlice(f *codecFnInfo, rv reflect.Value) { if rtelem0Mut || !rv9.IsValid() { // || (rtElem0Kind == reflect.Ptr && rv9.IsNil()) { rv9 = reflect.New(rtelem0).Elem() } - if useLookupRecognizedTypes && (recognizedRtid || recognizedRtidPtr) { - d.decode(rv2i(rv9.Addr())) - } else { - if fn == nil { - fn = d.cf.get(rtelem, true, true) - } - d.decodeValue(rv9, fn, false, true) + if fn == nil { + fn = d.cf.get(rtelem, true, true) } + d.decodeValue(rv9, fn, true) rv.Send(rv9) } else { // if indefinite, etc, then expand the slice if necessary @@ -1426,9 +1394,14 @@ func (d *Decoder) kSlice(f *codecFnInfo, rv reflect.Value) { d.arrayCannotExpand(rvlen, j+1) decodeIntoBlank = true } else { // if f.seq == seqTypeSlice - // rv = reflect.Append(rv, reflect.Zero(rtelem0)) // uses append logic, plus varargs + // rv = reflect.Append(rv, reflect.Zero(rtelem0)) // append logic + varargs var rvcap2 int - rv9, rvcap2, rvChanged = decExpandSliceRV(rv, ti.rt, rtelem0Size, 1, rvlen, rvcap) + var rvErrmsg2 string + rv9, rvcap2, rvChanged, rvErrmsg2 = + expandSliceRV(rv, ti.rt, rvCanset, rtelem0Size, 1, rvlen, rvcap) + if rvErrmsg2 != "" { + d.errorf(rvErrmsg2) + } rvlen++ if rvChanged { rv = rv9 @@ -1453,19 +1426,10 @@ func (d *Decoder) kSlice(f *codecFnInfo, rv reflect.Value) { continue } - if useLookupRecognizedTypes && recognizedRtid { - d.decode(rv2i(rv9.Addr())) - } else if useLookupRecognizedTypes && recognizedRtidPtr { // && !rv9.IsNil() { - if rv9.IsNil() { - rv9.Set(reflect.New(rtelem)) - } - d.decode(rv2i(rv9)) - } else { - if fn == nil { - fn = d.cf.get(rtelem, true, true) - } - d.decodeValue(rv9, fn, false, true) + if fn == nil { + fn = d.cf.get(rtelem, true, true) } + d.decodeValue(rv9, fn, true) } } } @@ -1473,19 +1437,21 @@ func (d *Decoder) kSlice(f *codecFnInfo, rv reflect.Value) { if j < rvlen { if rv.CanSet() { rv.SetLen(j) - } else { + } else if rvCanset { rv = rv.Slice(0, j) rvChanged = true - } + } // else { d.errorf("kSlice: cannot change non-settable slice") } rvlen = j } else if j == 0 && rv.IsNil() { - rv = reflect.MakeSlice(ti.rt, 0, 0) - rvChanged = true + if rvCanset { + rv = reflect.MakeSlice(ti.rt, 0, 0) + rvChanged = true + } // else { d.errorf("kSlice: cannot change non-settable slice") } } } slh.End() - if rvChanged { + if rvChanged { // infers rvCanset=true, so it can be reset rv0.Set(rv) } } @@ -1498,7 +1464,7 @@ func (d *Decoder) kSlice(f *codecFnInfo, rv reflect.Value) { func (d *Decoder) kMap(f *codecFnInfo, rv reflect.Value) { dd := d.d containerLen := dd.ReadMapStart() - elemsep := d.hh.hasElemSeparators() + elemsep := d.esep ti := f.ti if rv.IsNil() { rv.Set(makeMapReflect(ti.rt, containerLen)) @@ -1509,20 +1475,13 @@ func (d *Decoder) kMap(f *codecFnInfo, rv reflect.Value) { return } - ktype, vtype := ti.rt.Key(), ti.rt.Elem() + ktype, vtype := ti.key, ti.elem ktypeId := rt2id(ktype) - vtypeId := rt2id(vtype) vtypeKind := vtype.Kind() - var recognizedKtyp, recognizedVtyp, recognizedPtrKtyp, recognizedPtrVtyp bool - if useLookupRecognizedTypes { - recognizedKtyp = isRecognizedRtid(ktypeId) - recognizedVtyp = isRecognizedRtid(vtypeId) - recognizedPtrKtyp = isRecognizedRtidPtr(ktypeId) - recognizedPtrVtyp = isRecognizedRtidPtr(vtypeId) - } var keyFn, valFn *codecFn var ktypeLo, vtypeLo reflect.Type + for ktypeLo = ktype; ktypeLo.Kind() == reflect.Ptr; ktypeLo = ktypeLo.Elem() { } @@ -1553,45 +1512,39 @@ func (d *Decoder) kMap(f *codecFnInfo, rv reflect.Value) { ktypeIsIntf := ktypeId == intfTypId hasLen := containerLen > 0 var kstrbs []byte + d.cfer() for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { - if elemsep { - dd.ReadMapElemKey() - } - // if a nil key, just ignore the mapped value and continue - if dd.TryDecodeAsNil() { - if elemsep { - dd.ReadMapElemValue() - } - d.swallow() - continue - } if rvkMut || !rvkp.IsValid() { rvkp = reflect.New(ktype) rvk = rvkp.Elem() } - if ktypeIsString { + if elemsep { + dd.ReadMapElemKey() + } + if false && dd.TryDecodeAsNil() { // nil cannot be a map key, so disregard this block + // Previously, if a nil key, we just ignored the mapped value and continued. + // However, that makes the result of encoding and then decoding map[intf]intf{nil:nil} + // to be an empty map. + // Instead, we treat a nil key as the zero value of the type. + rvk.Set(reflect.Zero(ktype)) + } else if ktypeIsString { kstrbs = dd.DecodeStringAsBytes() rvk.SetString(stringView(kstrbs)) // NOTE: if doing an insert, you MUST use a real string (not stringview) - } else if useLookupRecognizedTypes && recognizedKtyp { - d.decode(rv2i(rvkp)) - // rvk = rvkp.Elem() //TODO: remove, unnecessary - } else if useLookupRecognizedTypes && recognizedPtrKtyp { - if rvk.IsNil() { - rvk = reflect.New(ktypeLo) - } - d.decode(rv2i(rvk)) } else { if keyFn == nil { keyFn = d.cf.get(ktypeLo, true, true) } - d.decodeValue(rvk, keyFn, false, true) + d.decodeValue(rvk, keyFn, true) } // special case if a byte array. if ktypeIsIntf { - rvk = rvk.Elem() - if rvk.Type() == uint8SliceTyp { - rvk = reflect.ValueOf(d.string(rvk.Bytes())) + if rvk2 := rvk.Elem(); rvk2.IsValid() { + if rvk2.Type() == uint8SliceTyp { + rvk = reflect.ValueOf(d.string(rvk2.Bytes())) + } else { + rvk = rvk2 + } } } @@ -1649,21 +1602,11 @@ func (d *Decoder) kMap(f *codecFnInfo, rv reflect.Value) { if mapSet && ktypeIsString { rvk.SetString(d.string(kstrbs)) } - if useLookupRecognizedTypes && recognizedVtyp && rvv.CanAddr() { - d.decode(rv2i(rvv.Addr())) - } else if useLookupRecognizedTypes && recognizedPtrVtyp { - if rvv.IsNil() { - rvv = reflect.New(vtypeLo) - mapSet = true - } - d.decode(rv2i(rvv)) - } else { - if valFn == nil { - valFn = d.cf.get(vtypeLo, true, true) - } - d.decodeValue(rvv, valFn, false, true) - // d.decodeValueFn(rvv, valFn) + if valFn == nil { + valFn = d.cf.get(vtypeLo, true, true) } + d.decodeValue(rvv, valFn, true) + // d.decodeValueFn(rvv, valFn) if mapSet { rv.SetMapIndex(rvk, rvv) } @@ -1693,78 +1636,77 @@ func (d *Decoder) kMap(f *codecFnInfo, rv reflect.Value) { // // kInterfaceNaked will ensure that there is no allocation for the common // uses. + +type decNakedContainers struct { + // array/stacks for reducing allocation + // keep arrays at the bottom? Chance is that they are not used much. + ia [arrayCacheLen]interface{} + ma [arrayCacheLen]map[interface{}]interface{} + na [arrayCacheLen]map[string]interface{} + sa [arrayCacheLen][]interface{} + + // ria [arrayCacheLen]reflect.Value // not needed, as we decode directly into &ia[n] + rma, rna, rsa [arrayCacheLen]reflect.Value // reflect.Value mapping to above +} + +func (n *decNakedContainers) init() { + for i := 0; i < arrayCacheLen; i++ { + // n.ria[i] = reflect.ValueOf(&(n.ia[i])).Elem() + n.rma[i] = reflect.ValueOf(&(n.ma[i])).Elem() + n.rna[i] = reflect.ValueOf(&(n.na[i])).Elem() + n.rsa[i] = reflect.ValueOf(&(n.sa[i])).Elem() + } +} + type decNaked struct { // r RawExt // used for RawExt, uint, []byte. + + // primitives below u uint64 i int64 f float64 l []byte s string - t time.Time + // ---- cpu cache line boundary? + t time.Time b bool - inited bool - - v valueType - + // state + v valueType li, lm, ln, ls int8 + inited bool - // array/stacks for reducing allocation - // keep arrays at the bottom? Chance is that they are not used much. - ia [arrayCacheLen]interface{} - ma [arrayCacheLen]map[interface{}]interface{} - na [arrayCacheLen]map[string]interface{} - sa [arrayCacheLen][]interface{} - // ra [2]RawExt + *decNakedContainers - rr [5 * arrayCacheLen]reflect.Value -} + ru, ri, rf, rl, rs, rb, rt reflect.Value // mapping to the primitives above -const ( - decNakedUintIdx = iota - decNakedIntIdx - decNakedFloatIdx - decNakedBytesIdx - decNakedStringIdx - decNakedTimeIdx - decNakedBoolIdx -) -const ( - _ = iota // maps to the scalars above - decNakedIntfIdx - decNakedMapIntfIntfIdx - decNakedMapStrIntfIdx - decNakedSliceIntfIdx -) + // _ [6]uint64 // padding // no padding - rt goes into next cache line +} func (n *decNaked) init() { if n.inited { return } - // n.ms = n.ma[:0] - // n.is = n.ia[:0] - // n.ns = n.na[:0] - // n.ss = n.sa[:0] - - n.rr[decNakedUintIdx] = reflect.ValueOf(&n.u).Elem() - n.rr[decNakedIntIdx] = reflect.ValueOf(&n.i).Elem() - n.rr[decNakedFloatIdx] = reflect.ValueOf(&n.f).Elem() - n.rr[decNakedBytesIdx] = reflect.ValueOf(&n.l).Elem() - n.rr[decNakedStringIdx] = reflect.ValueOf(&n.s).Elem() - n.rr[decNakedTimeIdx] = reflect.ValueOf(&n.t).Elem() - n.rr[decNakedBoolIdx] = reflect.ValueOf(&n.b).Elem() - - for i := range [arrayCacheLen]struct{}{} { - n.rr[decNakedIntfIdx*arrayCacheLen+i] = reflect.ValueOf(&(n.ia[i])).Elem() - n.rr[decNakedMapIntfIntfIdx*arrayCacheLen+i] = reflect.ValueOf(&(n.ma[i])).Elem() - n.rr[decNakedMapStrIntfIdx*arrayCacheLen+i] = reflect.ValueOf(&(n.na[i])).Elem() - n.rr[decNakedSliceIntfIdx*arrayCacheLen+i] = reflect.ValueOf(&(n.sa[i])).Elem() - } + n.ru = reflect.ValueOf(&n.u).Elem() + n.ri = reflect.ValueOf(&n.i).Elem() + n.rf = reflect.ValueOf(&n.f).Elem() + n.rl = reflect.ValueOf(&n.l).Elem() + n.rs = reflect.ValueOf(&n.s).Elem() + n.rt = reflect.ValueOf(&n.t).Elem() + n.rb = reflect.ValueOf(&n.b).Elem() + n.inited = true // n.rr[] = reflect.ValueOf(&n.) } +func (n *decNaked) initContainers() { + if n.decNakedContainers == nil { + n.decNakedContainers = new(decNakedContainers) + n.decNakedContainers.init() + } +} + func (n *decNaked) reset() { if n == nil { return @@ -1777,8 +1719,92 @@ type rtid2rv struct { rv reflect.Value } +// -------------- + +type decReaderSwitch struct { + rb bytesDecReader + // ---- cpu cache line boundary? + ri *ioDecReader + mtr, str bool // whether maptype or slicetype are known types + + be bool // is binary encoding + bytes bool // is bytes reader + js bool // is json handle + jsms bool // is json handle, and MapKeyAsString + esep bool // has elem separators +} + +// TODO: Uncomment after mid-stack inlining enabled in go 1.10 +// +// func (z *decReaderSwitch) unreadn1() { +// if z.bytes { +// z.rb.unreadn1() +// } else { +// z.ri.unreadn1() +// } +// } +// func (z *decReaderSwitch) readx(n int) []byte { +// if z.bytes { +// return z.rb.readx(n) +// } +// return z.ri.readx(n) +// } +// func (z *decReaderSwitch) readb(s []byte) { +// if z.bytes { +// z.rb.readb(s) +// } else { +// z.ri.readb(s) +// } +// } +// func (z *decReaderSwitch) readn1() uint8 { +// if z.bytes { +// return z.rb.readn1() +// } +// return z.ri.readn1() +// } +// func (z *decReaderSwitch) numread() int { +// if z.bytes { +// return z.rb.numread() +// } +// return z.ri.numread() +// } +// func (z *decReaderSwitch) track() { +// if z.bytes { +// z.rb.track() +// } else { +// z.ri.track() +// } +// } +// func (z *decReaderSwitch) stopTrack() []byte { +// if z.bytes { +// return z.rb.stopTrack() +// } +// return z.ri.stopTrack() +// } +// func (z *decReaderSwitch) skip(accept *bitset256) (token byte) { +// if z.bytes { +// return z.rb.skip(accept) +// } +// return z.ri.skip(accept) +// } +// func (z *decReaderSwitch) readTo(in []byte, accept *bitset256) (out []byte) { +// if z.bytes { +// return z.rb.readTo(in, accept) +// } +// return z.ri.readTo(in, accept) +// } +// func (z *decReaderSwitch) readUntil(in []byte, stop byte) (out []byte) { +// if z.bytes { +// return z.rb.readUntil(in, stop) +// } +// return z.ri.readUntil(in, stop) +// } + +const decScratchByteArrayLen = cacheLineSize - 8 + // A Decoder reads and decodes an object from an input stream in the codec format. type Decoder struct { + panicHdl // hopefully, reduce derefencing cost by laying the decReader inside the Decoder. // Try to put things that go together to fit within a cache line (8 words). @@ -1786,42 +1812,28 @@ type Decoder struct { // NOTE: Decoder shouldn't call it's read methods, // as the handler MAY need to do some coordination. r decReader - hh Handle h *BasicHandle - - mtr, mtrp, str, strp bool // - - be bool // is binary encoding - bytes bool // is bytes reader - js bool // is json handle + bi *bufioDecReader + // cache the mapTypeId and sliceTypeId for faster comparisons + mtid uintptr + stid uintptr // ---- cpu cache line boundary? + decReaderSwitch - rb bytesDecReader - ri ioDecReader - bi bufioDecReader - + // ---- cpu cache line boundary? + codecFnPooler // cr containerStateRecv - n *decNaked nsp *sync.Pool - - // ---- cpu cache line boundary? - - is map[string]string // used for interning strings - - // cache the mapTypeId and sliceTypeId for faster comparisons - mtid uintptr - stid uintptr - - b [scratchByteArrayLen]byte - // _ uintptr // for alignment purposes, so next one starts from a cache line - err error + // ---- cpu cache line boundary? + b [decScratchByteArrayLen]byte // scratch buffer, used by Decoder and xxxEncDrivers + is map[string]string // used for interning strings - cf codecFner - // _ [64]byte // force alignment??? + // padding - false sharing help // modify 232 if Decoder struct changes. + // _ [cacheLineSize - 232%cacheLineSize]byte } // NewDecoder returns a Decoder for decoding a stream of bytes from an io.Reader. @@ -1845,11 +1857,16 @@ func NewDecoderBytes(in []byte, h Handle) *Decoder { var defaultDecNaked decNaked func newDecoder(h Handle) *Decoder { - d := &Decoder{hh: h, h: h.getBasicHandle(), be: h.isBinary()} - + d := &Decoder{h: h.getBasicHandle(), err: errDecoderNotInitialized} + d.hh = h + d.be = h.isBinary() // NOTE: do not initialize d.n here. It is lazily initialized in d.naked() - - _, d.js = h.(*JsonHandle) + var jh *JsonHandle + jh, d.js = h.(*JsonHandle) + if d.js { + d.jsms = jh.MapKeyAsString + } + d.esep = d.hh.hasElemSeparators() if d.h.InternString { d.is = make(map[string]string, 32) } @@ -1858,71 +1875,80 @@ func newDecoder(h Handle) *Decoder { return d } -// naked must be called before each call to .DecodeNaked, -// as they will use it. -func (d *Decoder) naked() *decNaked { - if d.n == nil { - // consider one of: - // - get from sync.Pool (if GC is frequent, there's no value here) - // - new alloc (safest. only init'ed if it a naked decode will be done) - // - field in Decoder (makes the Decoder struct very big) - // To support using a decoder where a DecodeNaked is not needed, - // we prefer #1 or #2. - // d.n = new(decNaked) // &d.nv // new(decNaked) // grab from a sync.Pool - // d.n.init() - var v interface{} - d.nsp, v = pool.decNaked() - d.n = v.(*decNaked) - } - return d.n -} - func (d *Decoder) resetCommon() { d.n.reset() d.d.reset() - d.cf.reset(d.hh) d.err = nil - // reset all things which were cached from the Handle, - // but could be changed. + // reset all things which were cached from the Handle, but could change d.mtid, d.stid = 0, 0 - d.mtr, d.mtrp, d.str, d.strp = false, false, false, false + d.mtr, d.str = false, false if d.h.MapType != nil { d.mtid = rt2id(d.h.MapType) - if useLookupRecognizedTypes { - d.mtr = isRecognizedRtid(d.mtid) - d.mtrp = isRecognizedRtidPtr(d.mtid) - } + d.mtr = fastpathAV.index(d.mtid) != -1 } if d.h.SliceType != nil { d.stid = rt2id(d.h.SliceType) - if useLookupRecognizedTypes { - d.str = isRecognizedRtid(d.stid) - d.strp = isRecognizedRtidPtr(d.stid) - } + d.str = fastpathAV.index(d.stid) != -1 } } +// Reset the Decoder with a new Reader to decode from, +// clearing all state from last run(s). func (d *Decoder) Reset(r io.Reader) { + if r == nil { + return + } + if d.bi == nil { + d.bi = new(bufioDecReader) + } + d.bytes = false if d.h.ReaderBufferSize > 0 { d.bi.buf = make([]byte, 0, d.h.ReaderBufferSize) d.bi.reset(r) - d.r = &d.bi + d.r = d.bi } else { - d.ri.x = &d.b + // d.ri.x = &d.b // d.s = d.sa[:0] + if d.ri == nil { + d.ri = new(ioDecReader) + } d.ri.reset(r) - d.r = &d.ri + d.r = d.ri } d.resetCommon() } +// ResetBytes resets the Decoder with a new []byte to decode from, +// clearing all state from last run(s). func (d *Decoder) ResetBytes(in []byte) { + if in == nil { + return + } d.bytes = true d.rb.reset(in) d.r = &d.rb d.resetCommon() } +// naked must be called before each call to .DecodeNaked, +// as they will use it. +func (d *Decoder) naked() *decNaked { + if d.n == nil { + // consider one of: + // - get from sync.Pool (if GC is frequent, there's no value here) + // - new alloc (safest. only init'ed if it a naked decode will be done) + // - field in Decoder (makes the Decoder struct very big) + // To support using a decoder where a DecodeNaked is not needed, + // we prefer #1 or #2. + // d.n = new(decNaked) // &d.nv // new(decNaked) // grab from a sync.Pool + // d.n.init() + var v interface{} + d.nsp, v = pool.decNaked() + d.n = v.(*decNaked) + } + return d.n +} + // Decode decodes the stream from reader and stores the result in the // value pointed to by v. v cannot be a nil pointer. v can also be // a reflect.Value of a pointer. @@ -1973,8 +1999,12 @@ func (d *Decoder) ResetBytes(in []byte) { // However, when decoding a stream nil, we reset the destination container // to its "zero" value (e.g. nil for slice/map, etc). // +// Note: we allow nil values in the stream anywhere except for map keys. +// A nil value in the encoded stream where a map key is expected is treated as an error. func (d *Decoder) Decode(v interface{}) (err error) { - defer panicToErrs2(&d.err, &err) + // need to call defer directly, else it seems the recover is not fully handled + defer panicToErrs2(d, &d.err, &err) + defer d.alwaysAtEnd() d.MustDecode(v) return } @@ -1987,18 +2017,11 @@ func (d *Decoder) MustDecode(v interface{}) { panic(d.err) } if d.d.TryDecodeAsNil() { - d.setZero(v) + setZero(v) } else { d.decode(v) } - if d.nsp != nil { - if d.n != nil { - d.nsp.Put(d.n) - d.n = nil - } - d.nsp = nil - } - d.n = nil + d.alwaysAtEnd() // xprintf(">>>>>>>> >>>>>>>> num decFns: %v\n", d.cf.sn) } @@ -2008,13 +2031,22 @@ func (d *Decoder) MustDecode(v interface{}) { // d.decodeValueNoFn(reflect.ValueOf(&blank).Elem()) // } +func (d *Decoder) alwaysAtEnd() { + if d.n != nil { + // if n != nil, then nsp != nil (they are always set together) + d.nsp.Put(d.n) + d.n, d.nsp = nil, nil + } + d.codecFnPooler.alwaysAtEnd() +} + func (d *Decoder) swallow() { // smarter decode that just swallows the content dd := d.d if dd.TryDecodeAsNil() { return } - elemsep := d.hh.hasElemSeparators() + elemsep := d.esep switch dd.ContainerType() { case valueTypeMap: containerLen := dd.ReadMapStart() @@ -2051,6 +2083,7 @@ func (d *Decoder) swallow() { n := d.naked() dd.DecodeNaked() if n.v == valueTypeExt && n.l == nil { + n.initContainers() if n.li < arrayCacheLen { n.ia[n.li] = nil n.li++ @@ -2065,10 +2098,11 @@ func (d *Decoder) swallow() { } } -func (d *Decoder) setZero(iv interface{}) { +func setZero(iv interface{}) { if iv == nil || definitelyNil(iv) { return } + var canDecode bool switch v := iv.(type) { case *string: *v = "" @@ -2102,16 +2136,16 @@ func (d *Decoder) setZero(iv interface{}) { *v = nil case *Raw: *v = nil + case *time.Time: + *v = time.Time{} case reflect.Value: - v = d.ensureDecodeable(v) - if v.CanSet() { + if v, canDecode = isDecodeable(v); canDecode && v.CanSet() { v.Set(reflect.Zero(v.Type())) } // TODO: else drain if chan, clear if map, set all to nil if slice??? default: - if !fastpathDecodeSetZeroTypeSwitch(iv, d) { + if !fastpathDecodeSetZeroTypeSwitch(iv) { v := reflect.ValueOf(iv) - v = d.ensureDecodeable(v) - if v.CanSet() { + if v, canDecode = isDecodeable(v); canDecode && v.CanSet() { v.Set(reflect.Zero(v.Type())) } // TODO: else drain if chan, clear if map, set all to nil if slice??? } @@ -2122,7 +2156,7 @@ func (d *Decoder) decode(iv interface{}) { // check nil and interfaces explicitly, // so that type switches just have a run of constant non-interface types. if iv == nil { - d.error(cannotDecodeIntoNilErr) + d.errorstr(errstrCannotDecodeIntoNil) return } if v, ok := iv.(Selfer); ok { @@ -2136,57 +2170,67 @@ func (d *Decoder) decode(iv interface{}) { case reflect.Value: v = d.ensureDecodeable(v) - d.decodeValue(v, nil, false, true) // TODO: maybe ask to recognize ... + d.decodeValue(v, nil, true) case *string: *v = d.d.DecodeString() case *bool: *v = d.d.DecodeBool() case *int: - *v = int(d.d.DecodeInt(intBitsize)) + *v = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) case *int8: - *v = int8(d.d.DecodeInt(8)) + *v = int8(chkOvf.IntV(d.d.DecodeInt64(), 8)) case *int16: - *v = int16(d.d.DecodeInt(16)) + *v = int16(chkOvf.IntV(d.d.DecodeInt64(), 16)) case *int32: - *v = int32(d.d.DecodeInt(32)) + *v = int32(chkOvf.IntV(d.d.DecodeInt64(), 32)) case *int64: - *v = d.d.DecodeInt(64) + *v = d.d.DecodeInt64() case *uint: - *v = uint(d.d.DecodeUint(uintBitsize)) + *v = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) case *uint8: - *v = uint8(d.d.DecodeUint(8)) + *v = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) case *uint16: - *v = uint16(d.d.DecodeUint(16)) + *v = uint16(chkOvf.UintV(d.d.DecodeUint64(), 16)) case *uint32: - *v = uint32(d.d.DecodeUint(32)) + *v = uint32(chkOvf.UintV(d.d.DecodeUint64(), 32)) case *uint64: - *v = d.d.DecodeUint(64) + *v = d.d.DecodeUint64() case *float32: - *v = float32(d.d.DecodeFloat(true)) + f64 := d.d.DecodeFloat64() + if chkOvf.Float32(f64) { + d.errorf("float32 overflow: %v", f64) + } + *v = float32(f64) case *float64: - *v = d.d.DecodeFloat(false) + *v = d.d.DecodeFloat64() case *[]uint8: *v = d.d.DecodeBytes(*v, false) - + case []uint8: + b := d.d.DecodeBytes(v, false) + if !(len(b) > 0 && len(b) == len(v) && &b[0] == &v[0]) { + copy(v, b) + } + case *time.Time: + *v = d.d.DecodeTime() case *Raw: *v = d.rawBytes() case *interface{}: - d.decodeValue(reflect.ValueOf(iv).Elem(), nil, false, true) // TODO: consider recognize here + d.decodeValue(reflect.ValueOf(iv).Elem(), nil, true) // d.decodeValueNotNil(reflect.ValueOf(iv).Elem()) default: if !fastpathDecodeTypeSwitch(iv, d) { v := reflect.ValueOf(iv) v = d.ensureDecodeable(v) - d.decodeValue(v, nil, false, false) + d.decodeValue(v, nil, false) // d.decodeValueFallback(v) } } } -func (d *Decoder) decodeValue(rv reflect.Value, fn *codecFn, tryRecognized, chkAll bool) { +func (d *Decoder) decodeValue(rv reflect.Value, fn *codecFn, chkAll bool) { // If stream is not containing a nil value, then we can deref to the base // non-pointer value, and decode into that. var rvp reflect.Value @@ -2205,27 +2249,19 @@ func (d *Decoder) decodeValue(rv reflect.Value, fn *codecFn, tryRecognized, chkA } } - if useLookupRecognizedTypes && tryRecognized && isRecognizedRtid(rv2rtid(rv)) { - if rvpValid { - d.decode(rv2i(rvp)) - return - } else if rv.CanAddr() { - d.decode(rv2i(rv.Addr())) - return - } - } - if fn == nil { // always pass checkCodecSelfer=true, in case T or ****T is passed, where *T is a Selfer - fn = d.cf.get(rv.Type(), chkAll, true) // chkAll, chkAll) + fn = d.cfer().get(rv.Type(), chkAll, true) // chkAll, chkAll) } - if fn.i.addr { + if fn.i.addrD { if rvpValid { fn.fd(d, &fn.i, rvp) } else if rv.CanAddr() { fn.fd(d, &fn.i, rv.Addr()) - } else { + } else if !fn.i.addrF { fn.fd(d, &fn.i, rv) + } else { + d.errorf("cannot decode into a non-pointer value") } } else { fn.fd(d, &fn.i, rv) @@ -2281,7 +2317,7 @@ func (d *Decoder) ensureDecodeable(rv reflect.Value) (rv2 reflect.Value) { return } if !rv.IsValid() { - d.error(cannotDecodeIntoNilErr) + d.errorstr(errstrCannotDecodeIntoNil) return } if !rv.CanInterface() { @@ -2289,43 +2325,11 @@ func (d *Decoder) ensureDecodeable(rv reflect.Value) (rv2 reflect.Value) { return } rvi := rv2i(rv) - d.errorf("cannot decode into value of kind: %v, type: %T, %v", rv.Kind(), rvi, rvi) + rvk := rv.Kind() + d.errorf("cannot decode into value of kind: %v, type: %T, %v", rvk, rvi, rvi) return } -// func (d *Decoder) chkPtrValue(rv reflect.Value) { -// // We can only decode into a non-nil pointer -// if rv.Kind() == reflect.Ptr && !rv.IsNil() { -// return -// } -// d.errNotValidPtrValue(rv) -// } - -// func (d *Decoder) errNotValidPtrValue(rv reflect.Value) { -// if !rv.IsValid() { -// d.error(cannotDecodeIntoNilErr) -// return -// } -// if !rv.CanInterface() { -// d.errorf("cannot decode into a value without an interface: %v", rv) -// return -// } -// rvi := rv2i(rv) -// d.errorf("cannot decode into non-pointer or nil pointer. Got: %v, %T, %v", rv.Kind(), rvi, rvi) -// } - -func (d *Decoder) error(err error) { - panic(err) -} - -func (d *Decoder) errorf(format string, params ...interface{}) { - params2 := make([]interface{}, len(params)+1) - params2[0] = d.r.numread() - copy(params2[1:], params) - err := fmt.Errorf("[pos %d]: "+format, params2...) - panic(err) -} - // Possibly get an interned version of a string // // This should mostly be used for map keys, where the key type is string. @@ -2360,6 +2364,10 @@ func (d *Decoder) rawBytes() []byte { return bs2 } +func (d *Decoder) wrapErrstr(v interface{}, err *error) { + *err = fmt.Errorf("%s decode error [pos %d]: %v", d.hh.Name(), d.r.numread(), v) +} + // -------------------------------------------------- // decSliceHelper assists when decoding into a slice, from a map or an array in the stream. @@ -2373,12 +2381,13 @@ type decSliceHelper struct { func (d *Decoder) decSliceHelperStart() (x decSliceHelper, clen int) { dd := d.d ctyp := dd.ContainerType() - if ctyp == valueTypeArray { + switch ctyp { + case valueTypeArray: x.array = true clen = dd.ReadArrayStart() - } else if ctyp == valueTypeMap { + case valueTypeMap: clen = dd.ReadMapStart() * 2 - } else { + default: d.errorf("only encoded map or array can be decoded into a slice (%d)", ctyp) } // x.ct = ctyp @@ -2397,12 +2406,10 @@ func (x decSliceHelper) End() { func (x decSliceHelper) ElemContainerState(index int) { if x.array { x.d.d.ReadArrayElem() + } else if index%2 == 0 { + x.d.d.ReadMapElemKey() } else { - if index%2 == 0 { - x.d.d.ReadMapElemKey() - } else { - x.d.d.ReadMapElemValue() - } + x.d.d.ReadMapElemValue() } } @@ -2458,6 +2465,9 @@ func decInferLen(clen, maxlen, unit int) (rvlen int) { if clen <= 0 { return } + if unit == 0 { + return clen + } if maxlen <= 0 { // no maxlen defined. Use maximum of 256K memory, with a floor of 4K items. // maxlen = 256 * 1024 / unit @@ -2478,22 +2488,30 @@ func decInferLen(clen, maxlen, unit int) (rvlen int) { return } -func decExpandSliceRV(s reflect.Value, st reflect.Type, stElemSize, num, slen, scap int) ( - s2 reflect.Value, scap2 int, changed bool) { +func expandSliceRV(s reflect.Value, st reflect.Type, canChange bool, stElemSize, num, slen, scap int) ( + s2 reflect.Value, scap2 int, changed bool, err string) { l1 := slen + num // new slice length if l1 < slen { - panic("expandSlice: slice overflow") + err = errmsgExpandSliceOverflow + return } if l1 <= scap { if s.CanSet() { s.SetLen(l1) - } else { + } else if canChange { s2 = s.Slice(0, l1) scap2 = scap changed = true + } else { + err = errmsgExpandSliceCannotChange + return } return } + if !canChange { + err = errmsgExpandSliceCannotChange + return + } scap2 = growCap(scap, stElemSize, num) s2 = reflect.MakeSlice(st, l1, scap2) changed = true diff --git a/vendor/github.com/ugorji/go/codec/encode.go b/vendor/github.com/ugorji/go/codec/encode.go index dd15a2f4f..48053d24c 100644 --- a/vendor/github.com/ugorji/go/codec/encode.go +++ b/vendor/github.com/ugorji/go/codec/encode.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. package codec @@ -6,36 +6,19 @@ package codec import ( "bufio" "encoding" + "errors" "fmt" "io" "reflect" "sort" + "strconv" "sync" + "time" ) const defEncByteBufSize = 1 << 6 // 4:16, 6:64, 8:256, 10:1024 -// AsSymbolFlag defines what should be encoded as symbols. -type AsSymbolFlag uint8 - -const ( - // AsSymbolDefault is default. - // Currently, this means only encode struct field names as symbols. - // The default is subject to change. - AsSymbolDefault AsSymbolFlag = iota - - // AsSymbolAll means encode anything which could be a symbol as a symbol. - AsSymbolAll = 0xfe - - // AsSymbolNone means do not encode anything as a symbol. - AsSymbolNone = 1 << iota - - // AsSymbolMapStringKeys means encode keys in map[string]XXX as symbols. - AsSymbolMapStringKeysFlag - - // AsSymbolStructFieldName means encode struct field names as symbols. - AsSymbolStructFieldNameFlag -) +var errEncoderNotInitialized = errors.New("Encoder not initialized") // encWriter abstracts writing to a byte array or to an io.Writer. type encWriter interface { @@ -43,15 +26,11 @@ type encWriter interface { writestr(string) writen1(byte) writen2(byte, byte) - writen4(byte, byte, byte, byte) - writen5(byte, byte, byte, byte, byte) atEndOfEncode() } // encDriver abstracts the actual codec (binc vs msgpack, etc) type encDriver interface { - // IsBuiltinType(rt uintptr) bool - EncodeBuiltin(rt uintptr, v interface{}) EncodeNil() EncodeInt(i int64) EncodeUint(i uint64) @@ -61,6 +40,12 @@ type encDriver interface { // encodeExtPreamble(xtag byte, length int) EncodeRawExt(re *RawExt, e *Encoder) EncodeExt(v interface{}, xtag uint64, ext Ext, e *Encoder) + EncodeString(c charEncoding, v string) + // EncodeSymbol(v string) + EncodeStringBytes(c charEncoding, v []byte) + EncodeTime(time.Time) + //encBignum(f *big.Int) + //encStringRunes(c charEncoding, v []rune) WriteArrayStart(length int) WriteArrayElem() WriteArrayEnd() @@ -68,12 +53,6 @@ type encDriver interface { WriteMapElemKey() WriteMapElemValue() WriteMapEnd() - EncodeString(c charEncoding, v string) - EncodeSymbol(v string) - EncodeStringBytes(c charEncoding, v []byte) - //TODO - //encBignum(f *big.Int) - //encStringRunes(c charEncoding, v []rune) reset() atEndOfEncode() @@ -83,27 +62,33 @@ type ioEncStringWriter interface { WriteString(s string) (n int, err error) } -type ioEncFlusher interface { - Flush() error -} - type encDriverAsis interface { EncodeAsis(v []byte) } -// type encNoSeparator struct{} -// func (_ encNoSeparator) EncodeEnd() {} - type encDriverNoopContainerWriter struct{} -func (_ encDriverNoopContainerWriter) WriteArrayStart(length int) {} -func (_ encDriverNoopContainerWriter) WriteArrayElem() {} -func (_ encDriverNoopContainerWriter) WriteArrayEnd() {} -func (_ encDriverNoopContainerWriter) WriteMapStart(length int) {} -func (_ encDriverNoopContainerWriter) WriteMapElemKey() {} -func (_ encDriverNoopContainerWriter) WriteMapElemValue() {} -func (_ encDriverNoopContainerWriter) WriteMapEnd() {} -func (_ encDriverNoopContainerWriter) atEndOfEncode() {} +func (encDriverNoopContainerWriter) WriteArrayStart(length int) {} +func (encDriverNoopContainerWriter) WriteArrayElem() {} +func (encDriverNoopContainerWriter) WriteArrayEnd() {} +func (encDriverNoopContainerWriter) WriteMapStart(length int) {} +func (encDriverNoopContainerWriter) WriteMapElemKey() {} +func (encDriverNoopContainerWriter) WriteMapElemValue() {} +func (encDriverNoopContainerWriter) WriteMapEnd() {} +func (encDriverNoopContainerWriter) atEndOfEncode() {} + +type encDriverTrackContainerWriter struct { + c containerState +} + +func (e *encDriverTrackContainerWriter) WriteArrayStart(length int) { e.c = containerArrayStart } +func (e *encDriverTrackContainerWriter) WriteArrayElem() { e.c = containerArrayElem } +func (e *encDriverTrackContainerWriter) WriteArrayEnd() { e.c = containerArrayEnd } +func (e *encDriverTrackContainerWriter) WriteMapStart(length int) { e.c = containerMapStart } +func (e *encDriverTrackContainerWriter) WriteMapElemKey() { e.c = containerMapKey } +func (e *encDriverTrackContainerWriter) WriteMapElemValue() { e.c = containerMapValue } +func (e *encDriverTrackContainerWriter) WriteMapEnd() { e.c = containerMapEnd } +func (e *encDriverTrackContainerWriter) atEndOfEncode() {} // type ioEncWriterWriter interface { // WriteByte(c byte) error @@ -111,7 +96,13 @@ func (_ encDriverNoopContainerWriter) atEndOfEncode() {} // Write(p []byte) (n int, err error) // } +// EncodeOptions captures configuration options during encode. type EncodeOptions struct { + // WriterBufferSize is the size of the buffer used when writing. + // + // if > 0, we use a smart buffer internally for performance purposes. + WriterBufferSize int + // Encode a struct as an array, and not as a map StructToArray bool @@ -153,70 +144,35 @@ type EncodeOptions struct { // If unset, we error out. Raw bool - // AsSymbols defines what should be encoded as symbols. - // - // Encoding as symbols can reduce the encoded size significantly. - // - // However, during decoding, each string to be encoded as a symbol must - // be checked to see if it has been seen before. Consequently, encoding time - // will increase if using symbols, because string comparisons has a clear cost. - // - // Sample values: - // AsSymbolNone - // AsSymbolAll - // AsSymbolMapStringKeys - // AsSymbolMapStringKeysFlag | AsSymbolStructFieldNameFlag - AsSymbols AsSymbolFlag - - // WriterBufferSize is the size of the buffer used when writing. - // - // if > 0, we use a smart buffer internally for performance purposes. - WriterBufferSize int + // // AsSymbols defines what should be encoded as symbols. + // // + // // Encoding as symbols can reduce the encoded size significantly. + // // + // // However, during decoding, each string to be encoded as a symbol must + // // be checked to see if it has been seen before. Consequently, encoding time + // // will increase if using symbols, because string comparisons has a clear cost. + // // + // // Sample values: + // // AsSymbolNone + // // AsSymbolAll + // // AsSymbolMapStringKeys + // // AsSymbolMapStringKeysFlag | AsSymbolStructFieldNameFlag + // AsSymbols AsSymbolFlag } // --------------------------------------------- -type simpleIoEncWriter struct { - io.Writer -} - -// type bufIoEncWriter struct { -// w io.Writer -// buf []byte -// err error -// } - -// func (x *bufIoEncWriter) Write(b []byte) (n int, err error) { -// if x.err != nil { -// return 0, x.err -// } -// if cap(x.buf)-len(x.buf) >= len(b) { -// x.buf = append(x.buf, b) -// return len(b), nil -// } -// n, err = x.w.Write(x.buf) -// if err != nil { -// x.err = err -// return 0, x.err -// } -// n, err = x.w.Write(b) -// x.err = err -// return -// } - // ioEncWriter implements encWriter and can write to an io.Writer implementation type ioEncWriter struct { w io.Writer ww io.Writer bw io.ByteWriter sw ioEncStringWriter - fw ioEncFlusher + fw ioFlusher b [8]byte } func (z *ioEncWriter) WriteByte(b byte) (err error) { - // x.bs[0] = b - // _, err = x.ww.Write(x.bs[:]) z.b[0] = b _, err = z.w.Write(z.b[:1]) return @@ -227,18 +183,12 @@ func (z *ioEncWriter) WriteString(s string) (n int, err error) { } func (z *ioEncWriter) writeb(bs []byte) { - // if len(bs) == 0 { - // return - // } if _, err := z.ww.Write(bs); err != nil { panic(err) } } func (z *ioEncWriter) writestr(s string) { - // if len(s) == 0 { - // return - // } if _, err := z.sw.WriteString(s); err != nil { panic(err) } @@ -260,19 +210,12 @@ func (z *ioEncWriter) writen2(b1, b2 byte) { panic(err) } -func (z *ioEncWriter) writen4(b1, b2, b3, b4 byte) { - z.b[0], z.b[1], z.b[2], z.b[3] = b1, b2, b3, b4 - if _, err := z.ww.Write(z.b[:4]); err != nil { - panic(err) - } -} - -func (z *ioEncWriter) writen5(b1, b2, b3, b4, b5 byte) { - z.b[0], z.b[1], z.b[2], z.b[3], z.b[4] = b1, b2, b3, b4, b5 - if _, err := z.ww.Write(z.b[:5]); err != nil { - panic(err) - } -} +// func (z *ioEncWriter) writen5(b1, b2, b3, b4, b5 byte) { +// z.b[0], z.b[1], z.b[2], z.b[3], z.b[4] = b1, b2, b3, b4, b5 +// if _, err := z.ww.Write(z.b[:5]); err != nil { +// panic(err) +// } +// } func (z *ioEncWriter) atEndOfEncode() { if z.fw != nil { @@ -280,207 +223,65 @@ func (z *ioEncWriter) atEndOfEncode() { } } -// ---------------------------------------- +// --------------------------------------------- -// bytesEncWriter implements encWriter and can write to an byte slice. -// It is used by Marshal function. -type bytesEncWriter struct { +// bytesEncAppender implements encWriter and can write to an byte slice. +type bytesEncAppender struct { b []byte - c int // cursor - out *[]byte // write out on atEndOfEncode -} - -func (z *bytesEncWriter) writeb(s []byte) { - oc, a := z.growNoAlloc(len(s)) - if a { - z.growAlloc(len(s), oc) - } - copy(z.b[oc:], s) -} - -func (z *bytesEncWriter) writestr(s string) { - oc, a := z.growNoAlloc(len(s)) - if a { - z.growAlloc(len(s), oc) - } - copy(z.b[oc:], s) + out *[]byte } -func (z *bytesEncWriter) writen1(b1 byte) { - oc, a := z.growNoAlloc(1) - if a { - z.growAlloc(1, oc) - } - z.b[oc] = b1 +func (z *bytesEncAppender) writeb(s []byte) { + z.b = append(z.b, s...) } - -func (z *bytesEncWriter) writen2(b1, b2 byte) { - oc, a := z.growNoAlloc(2) - if a { - z.growAlloc(2, oc) - } - z.b[oc+1] = b2 - z.b[oc] = b1 +func (z *bytesEncAppender) writestr(s string) { + z.b = append(z.b, s...) } - -func (z *bytesEncWriter) writen4(b1, b2, b3, b4 byte) { - oc, a := z.growNoAlloc(4) - if a { - z.growAlloc(4, oc) - } - z.b[oc+3] = b4 - z.b[oc+2] = b3 - z.b[oc+1] = b2 - z.b[oc] = b1 +func (z *bytesEncAppender) writen1(b1 byte) { + z.b = append(z.b, b1) } - -func (z *bytesEncWriter) writen5(b1, b2, b3, b4, b5 byte) { - oc, a := z.growNoAlloc(5) - if a { - z.growAlloc(5, oc) - } - z.b[oc+4] = b5 - z.b[oc+3] = b4 - z.b[oc+2] = b3 - z.b[oc+1] = b2 - z.b[oc] = b1 +func (z *bytesEncAppender) writen2(b1, b2 byte) { + z.b = append(z.b, b1, b2) } - -func (z *bytesEncWriter) atEndOfEncode() { - *(z.out) = z.b[:z.c] +func (z *bytesEncAppender) atEndOfEncode() { + *(z.out) = z.b } - -// have a growNoalloc(n int), which can be inlined. -// if allocation is needed, then call growAlloc(n int) - -func (z *bytesEncWriter) growNoAlloc(n int) (oldcursor int, allocNeeded bool) { - oldcursor = z.c - z.c = z.c + n - if z.c > len(z.b) { - if z.c > cap(z.b) { - allocNeeded = true - } else { - z.b = z.b[:cap(z.b)] - } - } - return -} - -func (z *bytesEncWriter) growAlloc(n int, oldcursor int) { - // appendslice logic (if cap < 1024, *2, else *1.25): more expensive. many copy calls. - // bytes.Buffer model (2*cap + n): much better - // bs := make([]byte, 2*cap(z.b)+n) - bs := make([]byte, growCap(cap(z.b), 1, n)) - copy(bs, z.b[:oldcursor]) - z.b = bs +func (z *bytesEncAppender) reset(in []byte, out *[]byte) { + z.b = in[:0] + z.out = out } // --------------------------------------------- -func (e *Encoder) builtin(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeBuiltin(f.ti.rtid, rv2i(rv)) -} - -func (e *Encoder) raw(f *codecFnInfo, rv reflect.Value) { - e.rawBytes(rv2i(rv).(Raw)) -} - func (e *Encoder) rawExt(f *codecFnInfo, rv reflect.Value) { - // rev := rv2i(rv).(RawExt) - // e.e.EncodeRawExt(&rev, e) - var re *RawExt - if rv.CanAddr() { - re = rv2i(rv.Addr()).(*RawExt) - } else { - rev := rv2i(rv).(RawExt) - re = &rev - } - e.e.EncodeRawExt(re, e) + e.e.EncodeRawExt(rv2i(rv).(*RawExt), e) } func (e *Encoder) ext(f *codecFnInfo, rv reflect.Value) { - // if this is a struct|array and it was addressable, then pass the address directly (not the value) - if k := rv.Kind(); (k == reflect.Struct || k == reflect.Array) && rv.CanAddr() { - rv = rv.Addr() - } e.e.EncodeExt(rv2i(rv), f.xfTag, f.xfFn, e) } -func (e *Encoder) getValueForMarshalInterface(rv reflect.Value, indir int8) (v interface{}, proceed bool) { - if indir == 0 { - v = rv2i(rv) - } else if indir == -1 { - // If a non-pointer was passed to Encode(), then that value is not addressable. - // Take addr if addressable, else copy value to an addressable value. - if rv.CanAddr() { - v = rv2i(rv.Addr()) - } else { - rv2 := reflect.New(rv.Type()) - rv2.Elem().Set(rv) - v = rv2i(rv2) - } - } else { - for j := int8(0); j < indir; j++ { - if rv.IsNil() { - e.e.EncodeNil() - return - } - rv = rv.Elem() - } - v = rv2i(rv) - } - return v, true -} - func (e *Encoder) selferMarshal(f *codecFnInfo, rv reflect.Value) { - if v, proceed := e.getValueForMarshalInterface(rv, f.ti.csIndir); proceed { - v.(Selfer).CodecEncodeSelf(e) - } + rv2i(rv).(Selfer).CodecEncodeSelf(e) } func (e *Encoder) binaryMarshal(f *codecFnInfo, rv reflect.Value) { - if v, proceed := e.getValueForMarshalInterface(rv, f.ti.bmIndir); proceed { - bs, fnerr := v.(encoding.BinaryMarshaler).MarshalBinary() - e.marshal(bs, fnerr, false, c_RAW) - } + bs, fnerr := rv2i(rv).(encoding.BinaryMarshaler).MarshalBinary() + e.marshal(bs, fnerr, false, cRAW) } func (e *Encoder) textMarshal(f *codecFnInfo, rv reflect.Value) { - if v, proceed := e.getValueForMarshalInterface(rv, f.ti.tmIndir); proceed { - bs, fnerr := v.(encoding.TextMarshaler).MarshalText() - e.marshal(bs, fnerr, false, c_UTF8) - } + bs, fnerr := rv2i(rv).(encoding.TextMarshaler).MarshalText() + e.marshal(bs, fnerr, false, cUTF8) } func (e *Encoder) jsonMarshal(f *codecFnInfo, rv reflect.Value) { - if v, proceed := e.getValueForMarshalInterface(rv, f.ti.jmIndir); proceed { - bs, fnerr := v.(jsonMarshaler).MarshalJSON() - e.marshal(bs, fnerr, true, c_UTF8) - } -} - -func (e *Encoder) kBool(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeBool(rv.Bool()) -} - -func (e *Encoder) kString(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeString(c_UTF8, rv.String()) + bs, fnerr := rv2i(rv).(jsonMarshaler).MarshalJSON() + e.marshal(bs, fnerr, true, cUTF8) } -func (e *Encoder) kFloat64(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeFloat64(rv.Float()) -} - -func (e *Encoder) kFloat32(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeFloat32(float32(rv.Float())) -} - -func (e *Encoder) kInt(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeInt(rv.Int()) -} - -func (e *Encoder) kUint(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeUint(rv.Uint()) +func (e *Encoder) raw(f *codecFnInfo, rv reflect.Value) { + e.rawBytes(rv2i(rv).(Raw)) } func (e *Encoder) kInvalid(f *codecFnInfo, rv reflect.Value) { @@ -506,18 +307,25 @@ func (e *Encoder) kSlice(f *codecFnInfo, rv reflect.Value) { // If in this method, then there was no extension function defined. // So it's okay to treat as []byte. if ti.rtid == uint8SliceTypId { - ee.EncodeStringBytes(c_RAW, rv.Bytes()) + ee.EncodeStringBytes(cRAW, rv.Bytes()) return } } - elemsep := e.hh.hasElemSeparators() - rtelem := ti.rt.Elem() + if f.seq == seqTypeChan && ti.chandir&uint8(reflect.RecvDir) == 0 { + e.errorf("send-only channel cannot be used for receiving byte(s)") + } + elemsep := e.esep l := rv.Len() - if ti.rtid == uint8SliceTypId || rtelem.Kind() == reflect.Uint8 { + rtelem := ti.elem + rtelemIsByte := uint8TypId == rt2id(rtelem) // NOT rtelem.Kind() == reflect.Uint8 + // if a slice, array or chan of bytes, treat specially + if rtelemIsByte { switch f.seq { + case seqTypeSlice: + ee.EncodeStringBytes(cRAW, rv.Bytes()) case seqTypeArray: if rv.CanAddr() { - ee.EncodeStringBytes(c_RAW, rv.Slice(0, l).Bytes()) + ee.EncodeStringBytes(cRAW, rv.Slice(0, l).Bytes()) } else { var bs []byte if l <= cap(e.b) { @@ -526,24 +334,24 @@ func (e *Encoder) kSlice(f *codecFnInfo, rv reflect.Value) { bs = make([]byte, l) } reflect.Copy(reflect.ValueOf(bs), rv) - ee.EncodeStringBytes(c_RAW, bs) + ee.EncodeStringBytes(cRAW, bs) } - return - case seqTypeSlice: - ee.EncodeStringBytes(c_RAW, rv.Bytes()) - return - } - } - if ti.rtid == uint8SliceTypId && f.seq == seqTypeChan { - bs := e.b[:0] - // do not use range, so that the number of elements encoded - // does not change, and encoding does not hang waiting on someone to close chan. - // for b := range rv2i(rv).(<-chan byte) { bs = append(bs, b) } - ch := rv2i(rv).(<-chan byte) - for i := 0; i < l; i++ { - bs = append(bs, <-ch) + case seqTypeChan: + bs := e.b[:0] + // do not use range, so that the number of elements encoded + // does not change, and encoding does not hang waiting on someone to close chan. + // for b := range rv2i(rv).(<-chan byte) { bs = append(bs, b) } + // ch := rv2i(rv).(<-chan byte) // fix error - that this is a chan byte, not a <-chan byte. + irv := rv2i(rv) + ch, ok := irv.(<-chan byte) + if !ok { + ch = irv.(chan byte) + } + for i := 0; i < l; i++ { + bs = append(bs, <-ch) + } + ee.EncodeStringBytes(cRAW, bs) } - ee.EncodeStringBytes(c_RAW, bs) return } @@ -559,19 +367,15 @@ func (e *Encoder) kSlice(f *codecFnInfo, rv reflect.Value) { if l > 0 { var fn *codecFn - var recognizedVtyp = useLookupRecognizedTypes && isRecognizedRtidOrPtr(rt2id(rtelem)) - if !recognizedVtyp { - for rtelem.Kind() == reflect.Ptr { - rtelem = rtelem.Elem() - } - // if kind is reflect.Interface, do not pre-determine the - // encoding type, because preEncodeValue may break it down to - // a concrete type and kInterface will bomb. - if rtelem.Kind() != reflect.Interface { - fn = e.cf.get(rtelem, true, true) - } + for rtelem.Kind() == reflect.Ptr { + rtelem = rtelem.Elem() + } + // if kind is reflect.Interface, do not pre-determine the + // encoding type, because preEncodeValue may break it down to + // a concrete type and kInterface will bomb. + if rtelem.Kind() != reflect.Interface { + fn = e.cfer().get(rtelem, true, true) } - // TODO: Consider perf implication of encoding odd index values as symbols if type is string for j := 0; j < l; j++ { if elemsep { if ti.mbs { @@ -586,20 +390,12 @@ func (e *Encoder) kSlice(f *codecFnInfo, rv reflect.Value) { } if f.seq == seqTypeChan { if rv2, ok2 := rv.Recv(); ok2 { - if useLookupRecognizedTypes && recognizedVtyp { - e.encode(rv2i(rv2)) - } else { - e.encodeValue(rv2, fn, true) - } + e.encodeValue(rv2, fn, true) } else { ee.EncodeNil() // WE HAVE TO DO SOMETHING, so nil if nothing received. } } else { - if useLookupRecognizedTypes && recognizedVtyp { - e.encode(rv2i(rv.Index(j))) - } else { - e.encodeValue(rv.Index(j), fn, true) - } + e.encodeValue(rv.Index(j), fn, true) } } } @@ -613,50 +409,42 @@ func (e *Encoder) kSlice(f *codecFnInfo, rv reflect.Value) { func (e *Encoder) kStructNoOmitempty(f *codecFnInfo, rv reflect.Value) { fti := f.ti - elemsep := e.hh.hasElemSeparators() - tisfi := fti.sfip + elemsep := e.esep + tisfi := fti.sfiSrc toMap := !(fti.toArray || e.h.StructToArray) if toMap { - tisfi = fti.sfi + tisfi = fti.sfiSort } ee := e.e sfn := structFieldNode{v: rv, update: false} if toMap { ee.WriteMapStart(len(tisfi)) - // asSymbols := e.h.AsSymbols&AsSymbolStructFieldNameFlag != 0 - asSymbols := e.h.AsSymbols == AsSymbolDefault || e.h.AsSymbols&AsSymbolStructFieldNameFlag != 0 - if !elemsep { + if elemsep { for _, si := range tisfi { - if asSymbols { - ee.EncodeSymbol(si.encName) - } else { - ee.EncodeString(c_UTF8, si.encName) - } + ee.WriteMapElemKey() + // ee.EncodeString(cUTF8, si.encName) + encStructFieldKey(ee, fti.keyType, si.encName) + ee.WriteMapElemValue() e.encodeValue(sfn.field(si), nil, true) } } else { for _, si := range tisfi { - ee.WriteMapElemKey() - if asSymbols { - ee.EncodeSymbol(si.encName) - } else { - ee.EncodeString(c_UTF8, si.encName) - } - ee.WriteMapElemValue() + // ee.EncodeString(cUTF8, si.encName) + encStructFieldKey(ee, fti.keyType, si.encName) e.encodeValue(sfn.field(si), nil, true) } } ee.WriteMapEnd() } else { ee.WriteArrayStart(len(tisfi)) - if !elemsep { + if elemsep { for _, si := range tisfi { + ee.WriteArrayElem() e.encodeValue(sfn.field(si), nil, true) } } else { for _, si := range tisfi { - ee.WriteArrayElem() e.encodeValue(sfn.field(si), nil, true) } } @@ -664,16 +452,35 @@ func (e *Encoder) kStructNoOmitempty(f *codecFnInfo, rv reflect.Value) { } } +func encStructFieldKey(ee encDriver, keyType valueType, s string) { + var m must + + // use if-else-if, not switch (which compiles to binary-search) + // since keyType is typically valueTypeString, branch prediction is pretty good. + + if keyType == valueTypeString { + ee.EncodeString(cUTF8, s) + } else if keyType == valueTypeInt { + ee.EncodeInt(m.Int(strconv.ParseInt(s, 10, 64))) + } else if keyType == valueTypeUint { + ee.EncodeUint(m.Uint(strconv.ParseUint(s, 10, 64))) + } else if keyType == valueTypeFloat { + ee.EncodeFloat64(m.Float(strconv.ParseFloat(s, 64))) + } else { + ee.EncodeString(cUTF8, s) + } +} + func (e *Encoder) kStruct(f *codecFnInfo, rv reflect.Value) { fti := f.ti - elemsep := e.hh.hasElemSeparators() - tisfi := fti.sfip + elemsep := e.esep + tisfi := fti.sfiSrc toMap := !(fti.toArray || e.h.StructToArray) // if toMap, use the sorted array. If toArray, use unsorted array (to match sequence in struct) if toMap { - tisfi = fti.sfi + tisfi = fti.sfiSort } - newlen := len(fti.sfi) + newlen := len(fti.sfiSort) ee := e.e // Use sync.Pool to reduce allocating slices unnecessarily. @@ -691,6 +498,7 @@ func (e *Encoder) kStruct(f *codecFnInfo, rv reflect.Value) { var spool *sync.Pool var poolv interface{} var fkvs []stringRv + // fmt.Printf(">>>>>>>>>>>>>> encode.kStruct: newlen: %d\n", newlen) if newlen <= 8 { spool, poolv = pool.stringRv8() fkvs = poolv.(*[8]stringRv)[:newlen] @@ -718,14 +526,14 @@ func (e *Encoder) kStruct(f *codecFnInfo, rv reflect.Value) { // kv.r = si.field(rv, false) kv.r = sfn.field(si) if toMap { - if si.omitEmpty && isEmptyValue(kv.r, recur, recur) { + if si.omitEmpty() && isEmptyValue(kv.r, e.h.TypeInfos, recur, recur) { continue } kv.v = si.encName } else { // use the zero value. // if a reference or struct, set to nil (so you do not output too much) - if si.omitEmpty && isEmptyValue(kv.r, recur, recur) { + if si.omitEmpty() && isEmptyValue(kv.r, e.h.TypeInfos, recur, recur) { switch kv.r.Kind() { case reflect.Struct, reflect.Interface, reflect.Ptr, reflect.Array, reflect.Map, reflect.Slice: kv.r = reflect.Value{} //encode as nil @@ -738,41 +546,33 @@ func (e *Encoder) kStruct(f *codecFnInfo, rv reflect.Value) { if toMap { ee.WriteMapStart(newlen) - // asSymbols := e.h.AsSymbols&AsSymbolStructFieldNameFlag != 0 - asSymbols := e.h.AsSymbols == AsSymbolDefault || e.h.AsSymbols&AsSymbolStructFieldNameFlag != 0 - if !elemsep { + if elemsep { for j := 0; j < newlen; j++ { kv = fkvs[j] - if asSymbols { - ee.EncodeSymbol(kv.v) - } else { - ee.EncodeString(c_UTF8, kv.v) - } + ee.WriteMapElemKey() + // ee.EncodeString(cUTF8, kv.v) + encStructFieldKey(ee, fti.keyType, kv.v) + ee.WriteMapElemValue() e.encodeValue(kv.r, nil, true) } } else { for j := 0; j < newlen; j++ { kv = fkvs[j] - ee.WriteMapElemKey() - if asSymbols { - ee.EncodeSymbol(kv.v) - } else { - ee.EncodeString(c_UTF8, kv.v) - } - ee.WriteMapElemValue() + // ee.EncodeString(cUTF8, kv.v) + encStructFieldKey(ee, fti.keyType, kv.v) e.encodeValue(kv.r, nil, true) } } ee.WriteMapEnd() } else { ee.WriteArrayStart(newlen) - if !elemsep { + if elemsep { for j := 0; j < newlen; j++ { + ee.WriteArrayElem() e.encodeValue(fkvs[j].r, nil, true) } } else { for j := 0; j < newlen; j++ { - ee.WriteArrayElem() e.encodeValue(fkvs[j].r, nil, true) } } @@ -796,12 +596,12 @@ func (e *Encoder) kMap(f *codecFnInfo, rv reflect.Value) { l := rv.Len() ee.WriteMapStart(l) - elemsep := e.hh.hasElemSeparators() + elemsep := e.esep if l == 0 { ee.WriteMapEnd() return } - var asSymbols bool + // var asSymbols bool // determine the underlying key and val encFn's for the map. // This eliminates some work which is done for each loop iteration i.e. // rv.Type(), ref.ValueOf(rt).Pointer(), then check map/list for fn. @@ -811,103 +611,61 @@ func (e *Encoder) kMap(f *codecFnInfo, rv reflect.Value) { // a concrete type and kInterface will bomb. var keyFn, valFn *codecFn ti := f.ti - rtkey0 := ti.rt.Key() + rtkey0 := ti.key rtkey := rtkey0 - rtval0 := ti.rt.Elem() + rtval0 := ti.elem rtval := rtval0 - rtkeyid := rt2id(rtkey0) - rtvalid := rt2id(rtval0) + // rtkeyid := rt2id(rtkey0) for rtval.Kind() == reflect.Ptr { rtval = rtval.Elem() } if rtval.Kind() != reflect.Interface { - valFn = e.cf.get(rtval, true, true) + valFn = e.cfer().get(rtval, true, true) } mks := rv.MapKeys() if e.h.Canonical { - e.kMapCanonical(rtkey, rv, mks, valFn, asSymbols) + e.kMapCanonical(rtkey, rv, mks, valFn) ee.WriteMapEnd() return } - var recognizedKtyp, recognizedVtyp bool - var keyTypeIsString = rtkeyid == stringTypId - if keyTypeIsString { - asSymbols = e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 - } else { - if useLookupRecognizedTypes { - if recognizedKtyp = isRecognizedRtidOrPtr(rtkeyid); recognizedKtyp { - goto LABEL1 - } - } + var keyTypeIsString = stringTypId == rt2id(rtkey0) // rtkeyid + if !keyTypeIsString { for rtkey.Kind() == reflect.Ptr { rtkey = rtkey.Elem() } if rtkey.Kind() != reflect.Interface { - rtkeyid = rt2id(rtkey) - keyFn = e.cf.get(rtkey, true, true) + // rtkeyid = rt2id(rtkey) + keyFn = e.cfer().get(rtkey, true, true) } } // for j, lmks := 0, len(mks); j < lmks; j++ { -LABEL1: - recognizedVtyp = useLookupRecognizedTypes && isRecognizedRtidOrPtr(rtvalid) for j := range mks { if elemsep { ee.WriteMapElemKey() } if keyTypeIsString { - if asSymbols { - ee.EncodeSymbol(mks[j].String()) - } else { - ee.EncodeString(c_UTF8, mks[j].String()) - } - } else if useLookupRecognizedTypes && recognizedKtyp { - e.encode(rv2i(mks[j])) + ee.EncodeString(cUTF8, mks[j].String()) } else { e.encodeValue(mks[j], keyFn, true) } if elemsep { ee.WriteMapElemValue() } - if useLookupRecognizedTypes && recognizedVtyp { - e.encode(rv2i(rv.MapIndex(mks[j]))) - } else { - e.encodeValue(rv.MapIndex(mks[j]), valFn, true) - } + e.encodeValue(rv.MapIndex(mks[j]), valFn, true) + } ee.WriteMapEnd() } -func (e *Encoder) kMapCanonical(rtkey reflect.Type, rv reflect.Value, mks []reflect.Value, valFn *codecFn, asSymbols bool) { +func (e *Encoder) kMapCanonical(rtkey reflect.Type, rv reflect.Value, mks []reflect.Value, valFn *codecFn) { ee := e.e - elemsep := e.hh.hasElemSeparators() + elemsep := e.esep // we previously did out-of-band if an extension was registered. // This is not necessary, as the natural kind is sufficient for ordering. - // WHAT IS THIS? rtkeyid can never be a []uint8, per spec - // if rtkeyid == uint8SliceTypId { - // mksv := make([]bytesRv, len(mks)) - // for i, k := range mks { - // v := &mksv[i] - // v.r = k - // v.v = k.Bytes() - // } - // sort.Sort(bytesRvSlice(mksv)) - // for i := range mksv { - // if elemsep { - // ee.WriteMapElemKey() - // } - // ee.EncodeStringBytes(c_RAW, mksv[i].v) - // if elemsep { - // ee.WriteMapElemValue() - // } - // e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true) - // } - // return - // } - switch rtkey.Kind() { case reflect.Bool: mksv := make([]boolRv, len(mks)) @@ -939,11 +697,7 @@ func (e *Encoder) kMapCanonical(rtkey reflect.Type, rv reflect.Value, mks []refl if elemsep { ee.WriteMapElemKey() } - if asSymbols { - ee.EncodeSymbol(mksv[i].v) - } else { - ee.EncodeString(c_UTF8, mksv[i].v) - } + ee.EncodeString(cUTF8, mksv[i].v) if elemsep { ee.WriteMapElemValue() } @@ -1021,6 +775,28 @@ func (e *Encoder) kMapCanonical(rtkey reflect.Type, rv reflect.Value, mks []refl } e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true) } + case reflect.Struct: + if rv.Type() == timeTyp { + mksv := make([]timeRv, len(mks)) + for i, k := range mks { + v := &mksv[i] + v.r = k + v.v = rv2i(k).(time.Time) + } + sort.Sort(timeRvSlice(mksv)) + for i := range mksv { + if elemsep { + ee.WriteMapElemKey() + } + ee.EncodeTime(mksv[i].v) + if elemsep { + ee.WriteMapElemValue() + } + e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true) + } + break + } + fallthrough default: // out-of-band // first encode each key to a []byte first, then sort them, then record @@ -1050,32 +826,78 @@ func (e *Encoder) kMapCanonical(rtkey reflect.Type, rv reflect.Value, mks []refl // // -------------------------------------------------- +type encWriterSwitch struct { + wi *ioEncWriter + // wb bytesEncWriter + wb bytesEncAppender + wx bool // if bytes, wx=true + esep bool // whether it has elem separators + isas bool // whether e.as != nil +} + +// // TODO: Uncomment after mid-stack inlining enabled in go 1.10 + +// func (z *encWriterSwitch) writeb(s []byte) { +// if z.wx { +// z.wb.writeb(s) +// } else { +// z.wi.writeb(s) +// } +// } +// func (z *encWriterSwitch) writestr(s string) { +// if z.wx { +// z.wb.writestr(s) +// } else { +// z.wi.writestr(s) +// } +// } +// func (z *encWriterSwitch) writen1(b1 byte) { +// if z.wx { +// z.wb.writen1(b1) +// } else { +// z.wi.writen1(b1) +// } +// } +// func (z *encWriterSwitch) writen2(b1, b2 byte) { +// if z.wx { +// z.wb.writen2(b1, b2) +// } else { +// z.wi.writen2(b1, b2) +// } +// } + // An Encoder writes an object to an output stream in the codec format. type Encoder struct { + panicHdl // hopefully, reduce derefencing cost by laying the encWriter inside the Encoder e encDriver // NOTE: Encoder shouldn't call it's write methods, // as the handler MAY need to do some coordination. w encWriter - hh Handle h *BasicHandle + bw *bufio.Writer + as encDriverAsis // ---- cpu cache line boundary? - wi ioEncWriter - wb bytesEncWriter - bw bufio.Writer + // ---- cpu cache line boundary? + encWriterSwitch + err error - // cr containerStateRecv - as encDriverAsis // ---- cpu cache line boundary? + codecFnPooler + ci set + js bool // here, so that no need to piggy back on *codecFner for this + be bool // here, so that no need to piggy back on *codecFner for this + _ [6]byte // padding - ci set - err error + // ---- writable fields during execution --- *try* to keep in sep cache line - b [scratchByteArrayLen]byte - cf codecFner + // ---- cpu cache line boundary? + // b [scratchByteArrayLen]byte + // _ [cacheLineSize - scratchByteArrayLen]byte // padding + b [cacheLineSize - 0]byte // used for encoding a chan or (non-addressable) array of bytes } // NewEncoder returns an Encoder for encoding into an io.Writer. @@ -1100,53 +922,74 @@ func NewEncoderBytes(out *[]byte, h Handle) *Encoder { } func newEncoder(h Handle) *Encoder { - e := &Encoder{hh: h, h: h.getBasicHandle()} - e.e = h.newEncDriver(e) - e.as, _ = e.e.(encDriverAsis) - // e.cr, _ = e.e.(containerStateRecv) + e := &Encoder{h: h.getBasicHandle(), err: errEncoderNotInitialized} + e.hh = h + e.esep = h.hasElemSeparators() return e } -// Reset the Encoder with a new output stream. +func (e *Encoder) resetCommon() { + if e.e == nil || e.hh.recreateEncDriver(e.e) { + e.e = e.hh.newEncDriver(e) + e.as, e.isas = e.e.(encDriverAsis) + // e.cr, _ = e.e.(containerStateRecv) + } + e.be = e.hh.isBinary() + _, e.js = e.hh.(*JsonHandle) + e.e.reset() + e.err = nil +} + +// Reset resets the Encoder with a new output stream. // // This accommodates using the state of the Encoder, // where it has "cached" information about sub-engines. func (e *Encoder) Reset(w io.Writer) { + if w == nil { + return + } + if e.wi == nil { + e.wi = new(ioEncWriter) + } var ok bool + e.wx = false e.wi.w = w if e.h.WriterBufferSize > 0 { - bw := bufio.NewWriterSize(w, e.h.WriterBufferSize) - e.bw = *bw - e.wi.bw = &e.bw - e.wi.sw = &e.bw - e.wi.fw = &e.bw - e.wi.ww = &e.bw + e.bw = bufio.NewWriterSize(w, e.h.WriterBufferSize) + e.wi.bw = e.bw + e.wi.sw = e.bw + e.wi.fw = e.bw + e.wi.ww = e.bw } else { if e.wi.bw, ok = w.(io.ByteWriter); !ok { - e.wi.bw = &e.wi + e.wi.bw = e.wi } if e.wi.sw, ok = w.(ioEncStringWriter); !ok { - e.wi.sw = &e.wi + e.wi.sw = e.wi } - e.wi.fw, _ = w.(ioEncFlusher) + e.wi.fw, _ = w.(ioFlusher) e.wi.ww = w } - e.w = &e.wi - e.e.reset() - e.cf.reset(e.hh) - e.err = nil + e.w = e.wi + e.resetCommon() } +// ResetBytes resets the Encoder with a new destination output []byte. func (e *Encoder) ResetBytes(out *[]byte) { - in := *out + if out == nil { + return + } + var in []byte + if out != nil { + in = *out + } if in == nil { in = make([]byte, defEncByteBufSize) } - e.wb.b, e.wb.out, e.wb.c = in, out, 0 + e.wx = true + e.wb.reset(in, out) e.w = &e.wb - e.e.reset() - e.cf.reset(e.hh) - e.err = nil + e.resetCommon() } // Encode writes an object into a stream. @@ -1157,7 +1000,14 @@ func (e *Encoder) ResetBytes(out *[]byte) { // Note that the "json" key is used in the absence of the "codec" key. // // To set an option on all fields (e.g. omitempty on all fields), you -// can create a field called _struct, and set flags on it. +// can create a field called _struct, and set flags on it. The options +// which can be set on _struct are: +// - omitempty: so all fields are omitted if empty +// - toarray: so struct is encoded as an array +// - int: so struct key names are encoded as signed integers (instead of strings) +// - uint: so struct key names are encoded as unsigned integers (instead of strings) +// - float: so struct key names are encoded as floats (instead of strings) +// More details on these below. // // Struct values "usually" encode as maps. Each exported struct field is encoded unless: // - the field's tag is "-", OR @@ -1165,6 +1015,13 @@ func (e *Encoder) ResetBytes(out *[]byte) { // // When encoding as a map, the first string in the tag (before the comma) // is the map key string to use when encoding. +// ... +// This key is typically encoded as a string. +// However, there are instances where the encoded stream has mapping keys encoded as numbers. +// For example, some cbor streams have keys as integer codes in the stream, but they should map +// to fields in a structured object. Consequently, a struct is the natural representation in code. +// For these, configure the struct to encode/decode the keys as numbers (instead of string). +// This is done with the int,uint or float option on the _struct field (see above). // // However, struct values may encode as arrays. This happens when: // - StructToArray Encode option is set, OR @@ -1197,20 +1054,27 @@ func (e *Encoder) ResetBytes(out *[]byte) { // } // // type MyStruct struct { -// _struct bool `codec:",toarray"` //encode struct as an array +// _struct bool `codec:",toarray"` //encode struct as an array +// } +// +// type MyStruct struct { +// _struct bool `codec:",uint"` //encode struct with "unsigned integer" keys +// Field1 string `codec:"1"` //encode Field1 key using: EncodeInt(1) +// Field2 string `codec:"2"` //encode Field2 key using: EncodeInt(2) // } // // The mode of encoding is based on the type of the value. When a value is seen: // - If a Selfer, call its CodecEncodeSelf method // - If an extension is registered for it, call that extension function -// - If it implements encoding.(Binary|Text|JSON)Marshaler, call its Marshal(Binary|Text|JSON) method +// - If implements encoding.(Binary|Text|JSON)Marshaler, call Marshal(Binary|Text|JSON) method // - Else encode it based on its reflect.Kind // // Note that struct field names and keys in map[string]XXX will be treated as symbols. // Some formats support symbols (e.g. binc) and will properly encode the string // only once in the stream, and use a tag to refer to it thereafter. func (e *Encoder) Encode(v interface{}) (err error) { - defer panicToErrs2(&e.err, &err) + defer panicToErrs2(e, &e.err, &err) + defer e.alwaysAtEnd() e.MustEncode(v) return } @@ -1224,8 +1088,13 @@ func (e *Encoder) MustEncode(v interface{}) { e.encode(v) e.e.atEndOfEncode() e.w.atEndOfEncode() + e.alwaysAtEnd() } +// func (e *Encoder) alwaysAtEnd() { +// e.codecFnPooler.alwaysAtEnd() +// } + func (e *Encoder) encode(iv interface{}) { if iv == nil || definitelyNil(iv) { e.e.EncodeNil() @@ -1236,18 +1105,17 @@ func (e *Encoder) encode(iv interface{}) { return } + // a switch with only concrete types can be optimized. + // consequently, we deal with nil and interfaces outside. + switch v := iv.(type) { - // case nil: - // e.e.EncodeNil() - // case Selfer: - // v.CodecEncodeSelf(e) case Raw: e.rawBytes(v) case reflect.Value: e.encodeValue(v, nil, true) case string: - e.e.EncodeString(c_UTF8, v) + e.e.EncodeString(cUTF8, v) case bool: e.e.EncodeBool(v) case int: @@ -1276,12 +1144,16 @@ func (e *Encoder) encode(iv interface{}) { e.e.EncodeFloat32(v) case float64: e.e.EncodeFloat64(v) - + case time.Time: + e.e.EncodeTime(v) case []uint8: - e.e.EncodeStringBytes(c_RAW, v) + e.e.EncodeStringBytes(cRAW, v) + + case *Raw: + e.rawBytes(*v) case *string: - e.e.EncodeString(c_UTF8, *v) + e.e.EncodeString(cUTF8, *v) case *bool: e.e.EncodeBool(*v) case *int: @@ -1310,13 +1182,16 @@ func (e *Encoder) encode(iv interface{}) { e.e.EncodeFloat32(*v) case *float64: e.e.EncodeFloat64(*v) + case *time.Time: + e.e.EncodeTime(*v) case *[]uint8: - e.e.EncodeStringBytes(c_RAW, *v) + e.e.EncodeStringBytes(cRAW, *v) default: if !fastpathEncodeTypeSwitch(iv, e) { - e.encodeValue(reflect.ValueOf(iv), nil, false) + // checkfastpath=true (not false), as underlying slice/map type may be fast-path + e.encodeValue(reflect.ValueOf(iv), nil, true) } } } @@ -1324,6 +1199,8 @@ func (e *Encoder) encode(iv interface{}) { func (e *Encoder) encodeValue(rv reflect.Value, fn *codecFn, checkFastpath bool) { // if a valid fn is passed, it MUST BE for the dereferenced type of rv var sptr uintptr + var rvp reflect.Value + var rvpValid bool TOP: switch rv.Kind() { case reflect.Ptr: @@ -1331,6 +1208,8 @@ TOP: e.e.EncodeNil() return } + rvpValid = true + rvp = rv rv = rv.Elem() if e.h.CheckCircularRef && rv.Kind() == reflect.Struct { // TODO: Movable pointers will be an issue here. Future problem. @@ -1361,15 +1240,22 @@ TOP: if fn == nil { rt := rv.Type() - // TODO: calling isRecognizedRtid here is a major slowdown - if false && useLookupRecognizedTypes && isRecognizedRtidOrPtr(rt2id(rt)) { - e.encode(rv2i(rv)) - return - } // always pass checkCodecSelfer=true, in case T or ****T is passed, where *T is a Selfer - fn = e.cf.get(rt, checkFastpath, true) + fn = e.cfer().get(rt, checkFastpath, true) + } + if fn.i.addrE { + if rvpValid { + fn.fe(e, &fn.i, rvp) + } else if rv.CanAddr() { + fn.fe(e, &fn.i, rv.Addr()) + } else { + rv2 := reflect.New(rv.Type()) + rv2.Elem().Set(rv) + fn.fe(e, &fn.i, rv2) + } + } else { + fn.fe(e, &fn.i, rv) } - fn.fe(e, &fn.i, rv) if sptr != 0 { (&e.ci).remove(sptr) } @@ -1389,10 +1275,10 @@ func (e *Encoder) marshal(bs []byte, fnerr error, asis bool, c charEncoding) { } func (e *Encoder) asis(v []byte) { - if e.as == nil { - e.w.writeb(v) - } else { + if e.isas { e.as.EncodeAsis(v) + } else { + e.w.writeb(v) } } @@ -1401,14 +1287,9 @@ func (e *Encoder) rawBytes(vv Raw) { if !e.h.Raw { e.errorf("Raw values cannot be encoded: %v", v) } - if e.as == nil { - e.w.writeb(v) - } else { - e.as.EncodeAsis(v) - } + e.asis(v) } -func (e *Encoder) errorf(format string, params ...interface{}) { - err := fmt.Errorf(format, params...) - panic(err) +func (e *Encoder) wrapErrstr(v interface{}, err *error) { + *err = fmt.Errorf("%s encode error: %v", e.hh.Name(), v) } diff --git a/vendor/github.com/ugorji/go/codec/fast-path.generated.go b/vendor/github.com/ugorji/go/codec/fast-path.generated.go index 69b11fcf6..87f2562f6 100644 --- a/vendor/github.com/ugorji/go/codec/fast-path.generated.go +++ b/vendor/github.com/ugorji/go/codec/fast-path.generated.go @@ -3,10 +3,7 @@ // Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. -// ************************************************************ -// DO NOT EDIT. -// THIS FILE IS AUTO-GENERATED from fast-path.go.tmpl -// ************************************************************ +// Code generated from fast-path.go.tmpl - DO NOT EDIT. package codec @@ -18,19 +15,19 @@ package codec // This file can be omitted without causing a build failure. // // The advantage of fast paths is: -// - Many calls bypass reflection altogether +// - Many calls bypass reflection altogether // // Currently support -// - slice of all builtin types, -// - map of all builtin types to string or interface value -// - symmetrical maps of all builtin types (e.g. str-str, uint8-uint8) +// - slice of all builtin types, +// - map of all builtin types to string or interface value +// - symmetrical maps of all builtin types (e.g. str-str, uint8-uint8) // This should provide adequate "typical" implementations. // // Note that fast track decode functions must handle values for which an address cannot be obtained. // For example: -// m2 := map[string]int{} -// p2 := []interface{}{m2} -// // decoding into p2 will bomb if fast track functions do not treat like unaddressable. +// m2 := map[string]int{} +// p2 := []interface{}{m2} +// // decoding into p2 will bomb if fast track functions do not treat like unaddressable. // import ( @@ -86,10 +83,6 @@ func init() { fd func(*Decoder, *codecFnInfo, reflect.Value)) (f fastpathE) { xrt := reflect.TypeOf(v) xptr := rt2id(xrt) - if useLookupRecognizedTypes { - recognizedRtids = append(recognizedRtids, xptr) - recognizedRtidPtrs = append(recognizedRtidPtrs, rt2id(reflect.PtrTo(xrt))) - } fastpathAV[i] = fastpathE{xptr, xrt, fe, fd} i++ return @@ -381,2734 +374,1090 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { fastpathTV.EncSliceIntfV(v, e) case *[]interface{}: fastpathTV.EncSliceIntfV(*v, e) + case []string: + fastpathTV.EncSliceStringV(v, e) + case *[]string: + fastpathTV.EncSliceStringV(*v, e) + case []float32: + fastpathTV.EncSliceFloat32V(v, e) + case *[]float32: + fastpathTV.EncSliceFloat32V(*v, e) + case []float64: + fastpathTV.EncSliceFloat64V(v, e) + case *[]float64: + fastpathTV.EncSliceFloat64V(*v, e) + case []uint: + fastpathTV.EncSliceUintV(v, e) + case *[]uint: + fastpathTV.EncSliceUintV(*v, e) + case []uint16: + fastpathTV.EncSliceUint16V(v, e) + case *[]uint16: + fastpathTV.EncSliceUint16V(*v, e) + case []uint32: + fastpathTV.EncSliceUint32V(v, e) + case *[]uint32: + fastpathTV.EncSliceUint32V(*v, e) + case []uint64: + fastpathTV.EncSliceUint64V(v, e) + case *[]uint64: + fastpathTV.EncSliceUint64V(*v, e) + case []uintptr: + fastpathTV.EncSliceUintptrV(v, e) + case *[]uintptr: + fastpathTV.EncSliceUintptrV(*v, e) + case []int: + fastpathTV.EncSliceIntV(v, e) + case *[]int: + fastpathTV.EncSliceIntV(*v, e) + case []int8: + fastpathTV.EncSliceInt8V(v, e) + case *[]int8: + fastpathTV.EncSliceInt8V(*v, e) + case []int16: + fastpathTV.EncSliceInt16V(v, e) + case *[]int16: + fastpathTV.EncSliceInt16V(*v, e) + case []int32: + fastpathTV.EncSliceInt32V(v, e) + case *[]int32: + fastpathTV.EncSliceInt32V(*v, e) + case []int64: + fastpathTV.EncSliceInt64V(v, e) + case *[]int64: + fastpathTV.EncSliceInt64V(*v, e) + case []bool: + fastpathTV.EncSliceBoolV(v, e) + case *[]bool: + fastpathTV.EncSliceBoolV(*v, e) case map[interface{}]interface{}: fastpathTV.EncMapIntfIntfV(v, e) case *map[interface{}]interface{}: fastpathTV.EncMapIntfIntfV(*v, e) - case map[interface{}]string: fastpathTV.EncMapIntfStringV(v, e) case *map[interface{}]string: fastpathTV.EncMapIntfStringV(*v, e) - case map[interface{}]uint: fastpathTV.EncMapIntfUintV(v, e) case *map[interface{}]uint: fastpathTV.EncMapIntfUintV(*v, e) - case map[interface{}]uint8: fastpathTV.EncMapIntfUint8V(v, e) case *map[interface{}]uint8: fastpathTV.EncMapIntfUint8V(*v, e) - case map[interface{}]uint16: fastpathTV.EncMapIntfUint16V(v, e) case *map[interface{}]uint16: fastpathTV.EncMapIntfUint16V(*v, e) - case map[interface{}]uint32: fastpathTV.EncMapIntfUint32V(v, e) case *map[interface{}]uint32: fastpathTV.EncMapIntfUint32V(*v, e) - case map[interface{}]uint64: fastpathTV.EncMapIntfUint64V(v, e) case *map[interface{}]uint64: fastpathTV.EncMapIntfUint64V(*v, e) - case map[interface{}]uintptr: fastpathTV.EncMapIntfUintptrV(v, e) case *map[interface{}]uintptr: fastpathTV.EncMapIntfUintptrV(*v, e) - case map[interface{}]int: fastpathTV.EncMapIntfIntV(v, e) case *map[interface{}]int: fastpathTV.EncMapIntfIntV(*v, e) - case map[interface{}]int8: fastpathTV.EncMapIntfInt8V(v, e) case *map[interface{}]int8: fastpathTV.EncMapIntfInt8V(*v, e) - case map[interface{}]int16: fastpathTV.EncMapIntfInt16V(v, e) case *map[interface{}]int16: fastpathTV.EncMapIntfInt16V(*v, e) - case map[interface{}]int32: fastpathTV.EncMapIntfInt32V(v, e) case *map[interface{}]int32: fastpathTV.EncMapIntfInt32V(*v, e) - case map[interface{}]int64: fastpathTV.EncMapIntfInt64V(v, e) case *map[interface{}]int64: fastpathTV.EncMapIntfInt64V(*v, e) - case map[interface{}]float32: fastpathTV.EncMapIntfFloat32V(v, e) case *map[interface{}]float32: fastpathTV.EncMapIntfFloat32V(*v, e) - case map[interface{}]float64: fastpathTV.EncMapIntfFloat64V(v, e) case *map[interface{}]float64: fastpathTV.EncMapIntfFloat64V(*v, e) - case map[interface{}]bool: fastpathTV.EncMapIntfBoolV(v, e) case *map[interface{}]bool: fastpathTV.EncMapIntfBoolV(*v, e) - - case []string: - fastpathTV.EncSliceStringV(v, e) - case *[]string: - fastpathTV.EncSliceStringV(*v, e) - case map[string]interface{}: fastpathTV.EncMapStringIntfV(v, e) case *map[string]interface{}: fastpathTV.EncMapStringIntfV(*v, e) - case map[string]string: fastpathTV.EncMapStringStringV(v, e) case *map[string]string: fastpathTV.EncMapStringStringV(*v, e) - case map[string]uint: fastpathTV.EncMapStringUintV(v, e) case *map[string]uint: fastpathTV.EncMapStringUintV(*v, e) - case map[string]uint8: fastpathTV.EncMapStringUint8V(v, e) case *map[string]uint8: fastpathTV.EncMapStringUint8V(*v, e) - case map[string]uint16: fastpathTV.EncMapStringUint16V(v, e) case *map[string]uint16: fastpathTV.EncMapStringUint16V(*v, e) - case map[string]uint32: fastpathTV.EncMapStringUint32V(v, e) case *map[string]uint32: fastpathTV.EncMapStringUint32V(*v, e) - case map[string]uint64: fastpathTV.EncMapStringUint64V(v, e) case *map[string]uint64: fastpathTV.EncMapStringUint64V(*v, e) - case map[string]uintptr: fastpathTV.EncMapStringUintptrV(v, e) case *map[string]uintptr: fastpathTV.EncMapStringUintptrV(*v, e) - case map[string]int: fastpathTV.EncMapStringIntV(v, e) case *map[string]int: fastpathTV.EncMapStringIntV(*v, e) - case map[string]int8: fastpathTV.EncMapStringInt8V(v, e) case *map[string]int8: fastpathTV.EncMapStringInt8V(*v, e) - case map[string]int16: fastpathTV.EncMapStringInt16V(v, e) case *map[string]int16: fastpathTV.EncMapStringInt16V(*v, e) - case map[string]int32: fastpathTV.EncMapStringInt32V(v, e) case *map[string]int32: fastpathTV.EncMapStringInt32V(*v, e) - case map[string]int64: fastpathTV.EncMapStringInt64V(v, e) case *map[string]int64: fastpathTV.EncMapStringInt64V(*v, e) - case map[string]float32: fastpathTV.EncMapStringFloat32V(v, e) case *map[string]float32: fastpathTV.EncMapStringFloat32V(*v, e) - case map[string]float64: fastpathTV.EncMapStringFloat64V(v, e) case *map[string]float64: fastpathTV.EncMapStringFloat64V(*v, e) - case map[string]bool: fastpathTV.EncMapStringBoolV(v, e) case *map[string]bool: fastpathTV.EncMapStringBoolV(*v, e) - - case []float32: - fastpathTV.EncSliceFloat32V(v, e) - case *[]float32: - fastpathTV.EncSliceFloat32V(*v, e) - case map[float32]interface{}: fastpathTV.EncMapFloat32IntfV(v, e) case *map[float32]interface{}: fastpathTV.EncMapFloat32IntfV(*v, e) - case map[float32]string: fastpathTV.EncMapFloat32StringV(v, e) case *map[float32]string: fastpathTV.EncMapFloat32StringV(*v, e) - case map[float32]uint: fastpathTV.EncMapFloat32UintV(v, e) case *map[float32]uint: fastpathTV.EncMapFloat32UintV(*v, e) - case map[float32]uint8: fastpathTV.EncMapFloat32Uint8V(v, e) case *map[float32]uint8: fastpathTV.EncMapFloat32Uint8V(*v, e) - case map[float32]uint16: fastpathTV.EncMapFloat32Uint16V(v, e) case *map[float32]uint16: fastpathTV.EncMapFloat32Uint16V(*v, e) - case map[float32]uint32: fastpathTV.EncMapFloat32Uint32V(v, e) case *map[float32]uint32: fastpathTV.EncMapFloat32Uint32V(*v, e) - case map[float32]uint64: fastpathTV.EncMapFloat32Uint64V(v, e) case *map[float32]uint64: fastpathTV.EncMapFloat32Uint64V(*v, e) - case map[float32]uintptr: fastpathTV.EncMapFloat32UintptrV(v, e) case *map[float32]uintptr: fastpathTV.EncMapFloat32UintptrV(*v, e) - case map[float32]int: fastpathTV.EncMapFloat32IntV(v, e) case *map[float32]int: fastpathTV.EncMapFloat32IntV(*v, e) - case map[float32]int8: fastpathTV.EncMapFloat32Int8V(v, e) case *map[float32]int8: fastpathTV.EncMapFloat32Int8V(*v, e) - case map[float32]int16: fastpathTV.EncMapFloat32Int16V(v, e) case *map[float32]int16: fastpathTV.EncMapFloat32Int16V(*v, e) - case map[float32]int32: fastpathTV.EncMapFloat32Int32V(v, e) case *map[float32]int32: fastpathTV.EncMapFloat32Int32V(*v, e) - case map[float32]int64: fastpathTV.EncMapFloat32Int64V(v, e) case *map[float32]int64: fastpathTV.EncMapFloat32Int64V(*v, e) - case map[float32]float32: fastpathTV.EncMapFloat32Float32V(v, e) case *map[float32]float32: fastpathTV.EncMapFloat32Float32V(*v, e) - case map[float32]float64: fastpathTV.EncMapFloat32Float64V(v, e) case *map[float32]float64: fastpathTV.EncMapFloat32Float64V(*v, e) - case map[float32]bool: fastpathTV.EncMapFloat32BoolV(v, e) case *map[float32]bool: fastpathTV.EncMapFloat32BoolV(*v, e) - - case []float64: - fastpathTV.EncSliceFloat64V(v, e) - case *[]float64: - fastpathTV.EncSliceFloat64V(*v, e) - case map[float64]interface{}: fastpathTV.EncMapFloat64IntfV(v, e) case *map[float64]interface{}: fastpathTV.EncMapFloat64IntfV(*v, e) - case map[float64]string: fastpathTV.EncMapFloat64StringV(v, e) case *map[float64]string: fastpathTV.EncMapFloat64StringV(*v, e) - case map[float64]uint: fastpathTV.EncMapFloat64UintV(v, e) case *map[float64]uint: fastpathTV.EncMapFloat64UintV(*v, e) - case map[float64]uint8: fastpathTV.EncMapFloat64Uint8V(v, e) case *map[float64]uint8: fastpathTV.EncMapFloat64Uint8V(*v, e) - case map[float64]uint16: fastpathTV.EncMapFloat64Uint16V(v, e) case *map[float64]uint16: fastpathTV.EncMapFloat64Uint16V(*v, e) - case map[float64]uint32: fastpathTV.EncMapFloat64Uint32V(v, e) case *map[float64]uint32: fastpathTV.EncMapFloat64Uint32V(*v, e) - case map[float64]uint64: fastpathTV.EncMapFloat64Uint64V(v, e) case *map[float64]uint64: fastpathTV.EncMapFloat64Uint64V(*v, e) - case map[float64]uintptr: fastpathTV.EncMapFloat64UintptrV(v, e) case *map[float64]uintptr: fastpathTV.EncMapFloat64UintptrV(*v, e) - case map[float64]int: fastpathTV.EncMapFloat64IntV(v, e) case *map[float64]int: fastpathTV.EncMapFloat64IntV(*v, e) - case map[float64]int8: fastpathTV.EncMapFloat64Int8V(v, e) case *map[float64]int8: fastpathTV.EncMapFloat64Int8V(*v, e) - case map[float64]int16: fastpathTV.EncMapFloat64Int16V(v, e) case *map[float64]int16: fastpathTV.EncMapFloat64Int16V(*v, e) - case map[float64]int32: fastpathTV.EncMapFloat64Int32V(v, e) case *map[float64]int32: fastpathTV.EncMapFloat64Int32V(*v, e) - case map[float64]int64: fastpathTV.EncMapFloat64Int64V(v, e) case *map[float64]int64: fastpathTV.EncMapFloat64Int64V(*v, e) - case map[float64]float32: fastpathTV.EncMapFloat64Float32V(v, e) case *map[float64]float32: fastpathTV.EncMapFloat64Float32V(*v, e) - case map[float64]float64: fastpathTV.EncMapFloat64Float64V(v, e) case *map[float64]float64: fastpathTV.EncMapFloat64Float64V(*v, e) - case map[float64]bool: fastpathTV.EncMapFloat64BoolV(v, e) case *map[float64]bool: fastpathTV.EncMapFloat64BoolV(*v, e) - - case []uint: - fastpathTV.EncSliceUintV(v, e) - case *[]uint: - fastpathTV.EncSliceUintV(*v, e) - case map[uint]interface{}: fastpathTV.EncMapUintIntfV(v, e) case *map[uint]interface{}: fastpathTV.EncMapUintIntfV(*v, e) - case map[uint]string: fastpathTV.EncMapUintStringV(v, e) case *map[uint]string: fastpathTV.EncMapUintStringV(*v, e) - case map[uint]uint: fastpathTV.EncMapUintUintV(v, e) case *map[uint]uint: fastpathTV.EncMapUintUintV(*v, e) - case map[uint]uint8: fastpathTV.EncMapUintUint8V(v, e) case *map[uint]uint8: fastpathTV.EncMapUintUint8V(*v, e) - case map[uint]uint16: fastpathTV.EncMapUintUint16V(v, e) case *map[uint]uint16: fastpathTV.EncMapUintUint16V(*v, e) - case map[uint]uint32: fastpathTV.EncMapUintUint32V(v, e) case *map[uint]uint32: fastpathTV.EncMapUintUint32V(*v, e) - case map[uint]uint64: fastpathTV.EncMapUintUint64V(v, e) case *map[uint]uint64: fastpathTV.EncMapUintUint64V(*v, e) - case map[uint]uintptr: fastpathTV.EncMapUintUintptrV(v, e) case *map[uint]uintptr: fastpathTV.EncMapUintUintptrV(*v, e) - case map[uint]int: fastpathTV.EncMapUintIntV(v, e) case *map[uint]int: fastpathTV.EncMapUintIntV(*v, e) - case map[uint]int8: fastpathTV.EncMapUintInt8V(v, e) case *map[uint]int8: fastpathTV.EncMapUintInt8V(*v, e) - case map[uint]int16: fastpathTV.EncMapUintInt16V(v, e) case *map[uint]int16: fastpathTV.EncMapUintInt16V(*v, e) - case map[uint]int32: fastpathTV.EncMapUintInt32V(v, e) case *map[uint]int32: fastpathTV.EncMapUintInt32V(*v, e) - case map[uint]int64: fastpathTV.EncMapUintInt64V(v, e) case *map[uint]int64: fastpathTV.EncMapUintInt64V(*v, e) - case map[uint]float32: fastpathTV.EncMapUintFloat32V(v, e) case *map[uint]float32: fastpathTV.EncMapUintFloat32V(*v, e) - case map[uint]float64: fastpathTV.EncMapUintFloat64V(v, e) case *map[uint]float64: fastpathTV.EncMapUintFloat64V(*v, e) - case map[uint]bool: fastpathTV.EncMapUintBoolV(v, e) case *map[uint]bool: fastpathTV.EncMapUintBoolV(*v, e) - case map[uint8]interface{}: fastpathTV.EncMapUint8IntfV(v, e) case *map[uint8]interface{}: fastpathTV.EncMapUint8IntfV(*v, e) - case map[uint8]string: fastpathTV.EncMapUint8StringV(v, e) case *map[uint8]string: fastpathTV.EncMapUint8StringV(*v, e) - case map[uint8]uint: fastpathTV.EncMapUint8UintV(v, e) case *map[uint8]uint: fastpathTV.EncMapUint8UintV(*v, e) - case map[uint8]uint8: fastpathTV.EncMapUint8Uint8V(v, e) case *map[uint8]uint8: fastpathTV.EncMapUint8Uint8V(*v, e) - case map[uint8]uint16: fastpathTV.EncMapUint8Uint16V(v, e) case *map[uint8]uint16: fastpathTV.EncMapUint8Uint16V(*v, e) - case map[uint8]uint32: fastpathTV.EncMapUint8Uint32V(v, e) case *map[uint8]uint32: fastpathTV.EncMapUint8Uint32V(*v, e) - case map[uint8]uint64: fastpathTV.EncMapUint8Uint64V(v, e) case *map[uint8]uint64: fastpathTV.EncMapUint8Uint64V(*v, e) - case map[uint8]uintptr: fastpathTV.EncMapUint8UintptrV(v, e) case *map[uint8]uintptr: fastpathTV.EncMapUint8UintptrV(*v, e) - case map[uint8]int: fastpathTV.EncMapUint8IntV(v, e) case *map[uint8]int: fastpathTV.EncMapUint8IntV(*v, e) - case map[uint8]int8: fastpathTV.EncMapUint8Int8V(v, e) case *map[uint8]int8: fastpathTV.EncMapUint8Int8V(*v, e) - case map[uint8]int16: fastpathTV.EncMapUint8Int16V(v, e) case *map[uint8]int16: fastpathTV.EncMapUint8Int16V(*v, e) - case map[uint8]int32: fastpathTV.EncMapUint8Int32V(v, e) case *map[uint8]int32: fastpathTV.EncMapUint8Int32V(*v, e) - case map[uint8]int64: fastpathTV.EncMapUint8Int64V(v, e) case *map[uint8]int64: fastpathTV.EncMapUint8Int64V(*v, e) - case map[uint8]float32: fastpathTV.EncMapUint8Float32V(v, e) case *map[uint8]float32: fastpathTV.EncMapUint8Float32V(*v, e) - case map[uint8]float64: fastpathTV.EncMapUint8Float64V(v, e) case *map[uint8]float64: fastpathTV.EncMapUint8Float64V(*v, e) - case map[uint8]bool: fastpathTV.EncMapUint8BoolV(v, e) case *map[uint8]bool: fastpathTV.EncMapUint8BoolV(*v, e) - - case []uint16: - fastpathTV.EncSliceUint16V(v, e) - case *[]uint16: - fastpathTV.EncSliceUint16V(*v, e) - case map[uint16]interface{}: fastpathTV.EncMapUint16IntfV(v, e) case *map[uint16]interface{}: fastpathTV.EncMapUint16IntfV(*v, e) - case map[uint16]string: fastpathTV.EncMapUint16StringV(v, e) case *map[uint16]string: fastpathTV.EncMapUint16StringV(*v, e) - case map[uint16]uint: fastpathTV.EncMapUint16UintV(v, e) case *map[uint16]uint: fastpathTV.EncMapUint16UintV(*v, e) - case map[uint16]uint8: fastpathTV.EncMapUint16Uint8V(v, e) case *map[uint16]uint8: fastpathTV.EncMapUint16Uint8V(*v, e) - case map[uint16]uint16: fastpathTV.EncMapUint16Uint16V(v, e) case *map[uint16]uint16: fastpathTV.EncMapUint16Uint16V(*v, e) - case map[uint16]uint32: fastpathTV.EncMapUint16Uint32V(v, e) case *map[uint16]uint32: fastpathTV.EncMapUint16Uint32V(*v, e) - case map[uint16]uint64: fastpathTV.EncMapUint16Uint64V(v, e) case *map[uint16]uint64: fastpathTV.EncMapUint16Uint64V(*v, e) - case map[uint16]uintptr: fastpathTV.EncMapUint16UintptrV(v, e) case *map[uint16]uintptr: fastpathTV.EncMapUint16UintptrV(*v, e) - case map[uint16]int: fastpathTV.EncMapUint16IntV(v, e) case *map[uint16]int: fastpathTV.EncMapUint16IntV(*v, e) - case map[uint16]int8: fastpathTV.EncMapUint16Int8V(v, e) case *map[uint16]int8: fastpathTV.EncMapUint16Int8V(*v, e) - case map[uint16]int16: fastpathTV.EncMapUint16Int16V(v, e) case *map[uint16]int16: fastpathTV.EncMapUint16Int16V(*v, e) - case map[uint16]int32: fastpathTV.EncMapUint16Int32V(v, e) case *map[uint16]int32: fastpathTV.EncMapUint16Int32V(*v, e) - case map[uint16]int64: fastpathTV.EncMapUint16Int64V(v, e) case *map[uint16]int64: fastpathTV.EncMapUint16Int64V(*v, e) - case map[uint16]float32: fastpathTV.EncMapUint16Float32V(v, e) case *map[uint16]float32: fastpathTV.EncMapUint16Float32V(*v, e) - case map[uint16]float64: fastpathTV.EncMapUint16Float64V(v, e) case *map[uint16]float64: fastpathTV.EncMapUint16Float64V(*v, e) - case map[uint16]bool: fastpathTV.EncMapUint16BoolV(v, e) case *map[uint16]bool: fastpathTV.EncMapUint16BoolV(*v, e) - - case []uint32: - fastpathTV.EncSliceUint32V(v, e) - case *[]uint32: - fastpathTV.EncSliceUint32V(*v, e) - case map[uint32]interface{}: fastpathTV.EncMapUint32IntfV(v, e) case *map[uint32]interface{}: fastpathTV.EncMapUint32IntfV(*v, e) - case map[uint32]string: fastpathTV.EncMapUint32StringV(v, e) case *map[uint32]string: fastpathTV.EncMapUint32StringV(*v, e) - case map[uint32]uint: fastpathTV.EncMapUint32UintV(v, e) case *map[uint32]uint: fastpathTV.EncMapUint32UintV(*v, e) - case map[uint32]uint8: fastpathTV.EncMapUint32Uint8V(v, e) case *map[uint32]uint8: fastpathTV.EncMapUint32Uint8V(*v, e) - case map[uint32]uint16: fastpathTV.EncMapUint32Uint16V(v, e) case *map[uint32]uint16: fastpathTV.EncMapUint32Uint16V(*v, e) - case map[uint32]uint32: fastpathTV.EncMapUint32Uint32V(v, e) case *map[uint32]uint32: fastpathTV.EncMapUint32Uint32V(*v, e) - case map[uint32]uint64: fastpathTV.EncMapUint32Uint64V(v, e) case *map[uint32]uint64: fastpathTV.EncMapUint32Uint64V(*v, e) - case map[uint32]uintptr: fastpathTV.EncMapUint32UintptrV(v, e) case *map[uint32]uintptr: fastpathTV.EncMapUint32UintptrV(*v, e) - case map[uint32]int: fastpathTV.EncMapUint32IntV(v, e) case *map[uint32]int: fastpathTV.EncMapUint32IntV(*v, e) - case map[uint32]int8: fastpathTV.EncMapUint32Int8V(v, e) case *map[uint32]int8: fastpathTV.EncMapUint32Int8V(*v, e) - case map[uint32]int16: fastpathTV.EncMapUint32Int16V(v, e) case *map[uint32]int16: fastpathTV.EncMapUint32Int16V(*v, e) - case map[uint32]int32: fastpathTV.EncMapUint32Int32V(v, e) case *map[uint32]int32: fastpathTV.EncMapUint32Int32V(*v, e) - case map[uint32]int64: fastpathTV.EncMapUint32Int64V(v, e) case *map[uint32]int64: fastpathTV.EncMapUint32Int64V(*v, e) - case map[uint32]float32: fastpathTV.EncMapUint32Float32V(v, e) case *map[uint32]float32: fastpathTV.EncMapUint32Float32V(*v, e) - case map[uint32]float64: fastpathTV.EncMapUint32Float64V(v, e) case *map[uint32]float64: fastpathTV.EncMapUint32Float64V(*v, e) - case map[uint32]bool: fastpathTV.EncMapUint32BoolV(v, e) case *map[uint32]bool: fastpathTV.EncMapUint32BoolV(*v, e) - - case []uint64: - fastpathTV.EncSliceUint64V(v, e) - case *[]uint64: - fastpathTV.EncSliceUint64V(*v, e) - case map[uint64]interface{}: fastpathTV.EncMapUint64IntfV(v, e) case *map[uint64]interface{}: fastpathTV.EncMapUint64IntfV(*v, e) - case map[uint64]string: fastpathTV.EncMapUint64StringV(v, e) case *map[uint64]string: fastpathTV.EncMapUint64StringV(*v, e) - case map[uint64]uint: fastpathTV.EncMapUint64UintV(v, e) case *map[uint64]uint: fastpathTV.EncMapUint64UintV(*v, e) - case map[uint64]uint8: fastpathTV.EncMapUint64Uint8V(v, e) case *map[uint64]uint8: fastpathTV.EncMapUint64Uint8V(*v, e) - case map[uint64]uint16: fastpathTV.EncMapUint64Uint16V(v, e) case *map[uint64]uint16: fastpathTV.EncMapUint64Uint16V(*v, e) - case map[uint64]uint32: fastpathTV.EncMapUint64Uint32V(v, e) case *map[uint64]uint32: fastpathTV.EncMapUint64Uint32V(*v, e) - case map[uint64]uint64: fastpathTV.EncMapUint64Uint64V(v, e) case *map[uint64]uint64: fastpathTV.EncMapUint64Uint64V(*v, e) - case map[uint64]uintptr: fastpathTV.EncMapUint64UintptrV(v, e) case *map[uint64]uintptr: fastpathTV.EncMapUint64UintptrV(*v, e) - case map[uint64]int: fastpathTV.EncMapUint64IntV(v, e) case *map[uint64]int: fastpathTV.EncMapUint64IntV(*v, e) - case map[uint64]int8: fastpathTV.EncMapUint64Int8V(v, e) case *map[uint64]int8: fastpathTV.EncMapUint64Int8V(*v, e) - case map[uint64]int16: fastpathTV.EncMapUint64Int16V(v, e) case *map[uint64]int16: fastpathTV.EncMapUint64Int16V(*v, e) - case map[uint64]int32: fastpathTV.EncMapUint64Int32V(v, e) case *map[uint64]int32: fastpathTV.EncMapUint64Int32V(*v, e) - case map[uint64]int64: fastpathTV.EncMapUint64Int64V(v, e) case *map[uint64]int64: fastpathTV.EncMapUint64Int64V(*v, e) - case map[uint64]float32: fastpathTV.EncMapUint64Float32V(v, e) case *map[uint64]float32: fastpathTV.EncMapUint64Float32V(*v, e) - case map[uint64]float64: fastpathTV.EncMapUint64Float64V(v, e) case *map[uint64]float64: fastpathTV.EncMapUint64Float64V(*v, e) - case map[uint64]bool: fastpathTV.EncMapUint64BoolV(v, e) case *map[uint64]bool: fastpathTV.EncMapUint64BoolV(*v, e) - - case []uintptr: - fastpathTV.EncSliceUintptrV(v, e) - case *[]uintptr: - fastpathTV.EncSliceUintptrV(*v, e) - case map[uintptr]interface{}: fastpathTV.EncMapUintptrIntfV(v, e) case *map[uintptr]interface{}: fastpathTV.EncMapUintptrIntfV(*v, e) - case map[uintptr]string: fastpathTV.EncMapUintptrStringV(v, e) case *map[uintptr]string: fastpathTV.EncMapUintptrStringV(*v, e) - case map[uintptr]uint: fastpathTV.EncMapUintptrUintV(v, e) case *map[uintptr]uint: fastpathTV.EncMapUintptrUintV(*v, e) - case map[uintptr]uint8: fastpathTV.EncMapUintptrUint8V(v, e) case *map[uintptr]uint8: fastpathTV.EncMapUintptrUint8V(*v, e) - case map[uintptr]uint16: fastpathTV.EncMapUintptrUint16V(v, e) case *map[uintptr]uint16: fastpathTV.EncMapUintptrUint16V(*v, e) - case map[uintptr]uint32: fastpathTV.EncMapUintptrUint32V(v, e) case *map[uintptr]uint32: fastpathTV.EncMapUintptrUint32V(*v, e) - case map[uintptr]uint64: fastpathTV.EncMapUintptrUint64V(v, e) case *map[uintptr]uint64: fastpathTV.EncMapUintptrUint64V(*v, e) - case map[uintptr]uintptr: fastpathTV.EncMapUintptrUintptrV(v, e) case *map[uintptr]uintptr: fastpathTV.EncMapUintptrUintptrV(*v, e) - case map[uintptr]int: fastpathTV.EncMapUintptrIntV(v, e) case *map[uintptr]int: fastpathTV.EncMapUintptrIntV(*v, e) - case map[uintptr]int8: fastpathTV.EncMapUintptrInt8V(v, e) case *map[uintptr]int8: fastpathTV.EncMapUintptrInt8V(*v, e) - case map[uintptr]int16: fastpathTV.EncMapUintptrInt16V(v, e) case *map[uintptr]int16: fastpathTV.EncMapUintptrInt16V(*v, e) - case map[uintptr]int32: fastpathTV.EncMapUintptrInt32V(v, e) case *map[uintptr]int32: fastpathTV.EncMapUintptrInt32V(*v, e) - case map[uintptr]int64: fastpathTV.EncMapUintptrInt64V(v, e) case *map[uintptr]int64: fastpathTV.EncMapUintptrInt64V(*v, e) - case map[uintptr]float32: fastpathTV.EncMapUintptrFloat32V(v, e) case *map[uintptr]float32: fastpathTV.EncMapUintptrFloat32V(*v, e) - case map[uintptr]float64: fastpathTV.EncMapUintptrFloat64V(v, e) case *map[uintptr]float64: fastpathTV.EncMapUintptrFloat64V(*v, e) - case map[uintptr]bool: fastpathTV.EncMapUintptrBoolV(v, e) case *map[uintptr]bool: fastpathTV.EncMapUintptrBoolV(*v, e) - - case []int: - fastpathTV.EncSliceIntV(v, e) - case *[]int: - fastpathTV.EncSliceIntV(*v, e) - - case map[int]interface{}: - fastpathTV.EncMapIntIntfV(v, e) - case *map[int]interface{}: - fastpathTV.EncMapIntIntfV(*v, e) - - case map[int]string: - fastpathTV.EncMapIntStringV(v, e) - case *map[int]string: - fastpathTV.EncMapIntStringV(*v, e) - - case map[int]uint: - fastpathTV.EncMapIntUintV(v, e) - case *map[int]uint: - fastpathTV.EncMapIntUintV(*v, e) - - case map[int]uint8: - fastpathTV.EncMapIntUint8V(v, e) - case *map[int]uint8: - fastpathTV.EncMapIntUint8V(*v, e) - - case map[int]uint16: - fastpathTV.EncMapIntUint16V(v, e) - case *map[int]uint16: - fastpathTV.EncMapIntUint16V(*v, e) - - case map[int]uint32: - fastpathTV.EncMapIntUint32V(v, e) - case *map[int]uint32: - fastpathTV.EncMapIntUint32V(*v, e) - - case map[int]uint64: - fastpathTV.EncMapIntUint64V(v, e) - case *map[int]uint64: - fastpathTV.EncMapIntUint64V(*v, e) - - case map[int]uintptr: - fastpathTV.EncMapIntUintptrV(v, e) - case *map[int]uintptr: - fastpathTV.EncMapIntUintptrV(*v, e) - - case map[int]int: - fastpathTV.EncMapIntIntV(v, e) - case *map[int]int: - fastpathTV.EncMapIntIntV(*v, e) - - case map[int]int8: - fastpathTV.EncMapIntInt8V(v, e) - case *map[int]int8: - fastpathTV.EncMapIntInt8V(*v, e) - - case map[int]int16: - fastpathTV.EncMapIntInt16V(v, e) - case *map[int]int16: - fastpathTV.EncMapIntInt16V(*v, e) - - case map[int]int32: - fastpathTV.EncMapIntInt32V(v, e) - case *map[int]int32: - fastpathTV.EncMapIntInt32V(*v, e) - - case map[int]int64: - fastpathTV.EncMapIntInt64V(v, e) - case *map[int]int64: - fastpathTV.EncMapIntInt64V(*v, e) - - case map[int]float32: - fastpathTV.EncMapIntFloat32V(v, e) - case *map[int]float32: - fastpathTV.EncMapIntFloat32V(*v, e) - - case map[int]float64: - fastpathTV.EncMapIntFloat64V(v, e) - case *map[int]float64: - fastpathTV.EncMapIntFloat64V(*v, e) - - case map[int]bool: - fastpathTV.EncMapIntBoolV(v, e) - case *map[int]bool: - fastpathTV.EncMapIntBoolV(*v, e) - - case []int8: - fastpathTV.EncSliceInt8V(v, e) - case *[]int8: - fastpathTV.EncSliceInt8V(*v, e) - - case map[int8]interface{}: - fastpathTV.EncMapInt8IntfV(v, e) - case *map[int8]interface{}: - fastpathTV.EncMapInt8IntfV(*v, e) - - case map[int8]string: - fastpathTV.EncMapInt8StringV(v, e) - case *map[int8]string: - fastpathTV.EncMapInt8StringV(*v, e) - - case map[int8]uint: - fastpathTV.EncMapInt8UintV(v, e) - case *map[int8]uint: - fastpathTV.EncMapInt8UintV(*v, e) - - case map[int8]uint8: - fastpathTV.EncMapInt8Uint8V(v, e) - case *map[int8]uint8: - fastpathTV.EncMapInt8Uint8V(*v, e) - - case map[int8]uint16: - fastpathTV.EncMapInt8Uint16V(v, e) - case *map[int8]uint16: - fastpathTV.EncMapInt8Uint16V(*v, e) - - case map[int8]uint32: - fastpathTV.EncMapInt8Uint32V(v, e) - case *map[int8]uint32: - fastpathTV.EncMapInt8Uint32V(*v, e) - - case map[int8]uint64: - fastpathTV.EncMapInt8Uint64V(v, e) - case *map[int8]uint64: - fastpathTV.EncMapInt8Uint64V(*v, e) - - case map[int8]uintptr: - fastpathTV.EncMapInt8UintptrV(v, e) - case *map[int8]uintptr: - fastpathTV.EncMapInt8UintptrV(*v, e) - - case map[int8]int: - fastpathTV.EncMapInt8IntV(v, e) - case *map[int8]int: - fastpathTV.EncMapInt8IntV(*v, e) - - case map[int8]int8: - fastpathTV.EncMapInt8Int8V(v, e) - case *map[int8]int8: - fastpathTV.EncMapInt8Int8V(*v, e) - - case map[int8]int16: - fastpathTV.EncMapInt8Int16V(v, e) - case *map[int8]int16: - fastpathTV.EncMapInt8Int16V(*v, e) - - case map[int8]int32: - fastpathTV.EncMapInt8Int32V(v, e) - case *map[int8]int32: - fastpathTV.EncMapInt8Int32V(*v, e) - - case map[int8]int64: - fastpathTV.EncMapInt8Int64V(v, e) - case *map[int8]int64: - fastpathTV.EncMapInt8Int64V(*v, e) - - case map[int8]float32: - fastpathTV.EncMapInt8Float32V(v, e) - case *map[int8]float32: - fastpathTV.EncMapInt8Float32V(*v, e) - - case map[int8]float64: - fastpathTV.EncMapInt8Float64V(v, e) - case *map[int8]float64: - fastpathTV.EncMapInt8Float64V(*v, e) - - case map[int8]bool: - fastpathTV.EncMapInt8BoolV(v, e) - case *map[int8]bool: - fastpathTV.EncMapInt8BoolV(*v, e) - - case []int16: - fastpathTV.EncSliceInt16V(v, e) - case *[]int16: - fastpathTV.EncSliceInt16V(*v, e) - - case map[int16]interface{}: - fastpathTV.EncMapInt16IntfV(v, e) - case *map[int16]interface{}: - fastpathTV.EncMapInt16IntfV(*v, e) - - case map[int16]string: - fastpathTV.EncMapInt16StringV(v, e) - case *map[int16]string: - fastpathTV.EncMapInt16StringV(*v, e) - - case map[int16]uint: - fastpathTV.EncMapInt16UintV(v, e) - case *map[int16]uint: - fastpathTV.EncMapInt16UintV(*v, e) - - case map[int16]uint8: - fastpathTV.EncMapInt16Uint8V(v, e) - case *map[int16]uint8: - fastpathTV.EncMapInt16Uint8V(*v, e) - - case map[int16]uint16: - fastpathTV.EncMapInt16Uint16V(v, e) - case *map[int16]uint16: - fastpathTV.EncMapInt16Uint16V(*v, e) - - case map[int16]uint32: - fastpathTV.EncMapInt16Uint32V(v, e) - case *map[int16]uint32: - fastpathTV.EncMapInt16Uint32V(*v, e) - - case map[int16]uint64: - fastpathTV.EncMapInt16Uint64V(v, e) - case *map[int16]uint64: - fastpathTV.EncMapInt16Uint64V(*v, e) - - case map[int16]uintptr: - fastpathTV.EncMapInt16UintptrV(v, e) - case *map[int16]uintptr: - fastpathTV.EncMapInt16UintptrV(*v, e) - - case map[int16]int: - fastpathTV.EncMapInt16IntV(v, e) - case *map[int16]int: - fastpathTV.EncMapInt16IntV(*v, e) - - case map[int16]int8: - fastpathTV.EncMapInt16Int8V(v, e) - case *map[int16]int8: - fastpathTV.EncMapInt16Int8V(*v, e) - - case map[int16]int16: - fastpathTV.EncMapInt16Int16V(v, e) - case *map[int16]int16: - fastpathTV.EncMapInt16Int16V(*v, e) - - case map[int16]int32: - fastpathTV.EncMapInt16Int32V(v, e) - case *map[int16]int32: - fastpathTV.EncMapInt16Int32V(*v, e) - - case map[int16]int64: - fastpathTV.EncMapInt16Int64V(v, e) - case *map[int16]int64: - fastpathTV.EncMapInt16Int64V(*v, e) - - case map[int16]float32: - fastpathTV.EncMapInt16Float32V(v, e) - case *map[int16]float32: - fastpathTV.EncMapInt16Float32V(*v, e) - - case map[int16]float64: - fastpathTV.EncMapInt16Float64V(v, e) - case *map[int16]float64: - fastpathTV.EncMapInt16Float64V(*v, e) - - case map[int16]bool: - fastpathTV.EncMapInt16BoolV(v, e) - case *map[int16]bool: - fastpathTV.EncMapInt16BoolV(*v, e) - - case []int32: - fastpathTV.EncSliceInt32V(v, e) - case *[]int32: - fastpathTV.EncSliceInt32V(*v, e) - - case map[int32]interface{}: - fastpathTV.EncMapInt32IntfV(v, e) - case *map[int32]interface{}: - fastpathTV.EncMapInt32IntfV(*v, e) - - case map[int32]string: - fastpathTV.EncMapInt32StringV(v, e) - case *map[int32]string: - fastpathTV.EncMapInt32StringV(*v, e) - - case map[int32]uint: - fastpathTV.EncMapInt32UintV(v, e) - case *map[int32]uint: - fastpathTV.EncMapInt32UintV(*v, e) - - case map[int32]uint8: - fastpathTV.EncMapInt32Uint8V(v, e) - case *map[int32]uint8: - fastpathTV.EncMapInt32Uint8V(*v, e) - - case map[int32]uint16: - fastpathTV.EncMapInt32Uint16V(v, e) - case *map[int32]uint16: - fastpathTV.EncMapInt32Uint16V(*v, e) - - case map[int32]uint32: - fastpathTV.EncMapInt32Uint32V(v, e) - case *map[int32]uint32: - fastpathTV.EncMapInt32Uint32V(*v, e) - - case map[int32]uint64: - fastpathTV.EncMapInt32Uint64V(v, e) - case *map[int32]uint64: - fastpathTV.EncMapInt32Uint64V(*v, e) - - case map[int32]uintptr: - fastpathTV.EncMapInt32UintptrV(v, e) - case *map[int32]uintptr: - fastpathTV.EncMapInt32UintptrV(*v, e) - - case map[int32]int: - fastpathTV.EncMapInt32IntV(v, e) - case *map[int32]int: - fastpathTV.EncMapInt32IntV(*v, e) - - case map[int32]int8: - fastpathTV.EncMapInt32Int8V(v, e) - case *map[int32]int8: - fastpathTV.EncMapInt32Int8V(*v, e) - - case map[int32]int16: - fastpathTV.EncMapInt32Int16V(v, e) - case *map[int32]int16: - fastpathTV.EncMapInt32Int16V(*v, e) - - case map[int32]int32: - fastpathTV.EncMapInt32Int32V(v, e) - case *map[int32]int32: - fastpathTV.EncMapInt32Int32V(*v, e) - - case map[int32]int64: - fastpathTV.EncMapInt32Int64V(v, e) - case *map[int32]int64: - fastpathTV.EncMapInt32Int64V(*v, e) - - case map[int32]float32: - fastpathTV.EncMapInt32Float32V(v, e) - case *map[int32]float32: - fastpathTV.EncMapInt32Float32V(*v, e) - - case map[int32]float64: - fastpathTV.EncMapInt32Float64V(v, e) - case *map[int32]float64: - fastpathTV.EncMapInt32Float64V(*v, e) - - case map[int32]bool: - fastpathTV.EncMapInt32BoolV(v, e) - case *map[int32]bool: - fastpathTV.EncMapInt32BoolV(*v, e) - - case []int64: - fastpathTV.EncSliceInt64V(v, e) - case *[]int64: - fastpathTV.EncSliceInt64V(*v, e) - - case map[int64]interface{}: - fastpathTV.EncMapInt64IntfV(v, e) - case *map[int64]interface{}: - fastpathTV.EncMapInt64IntfV(*v, e) - - case map[int64]string: - fastpathTV.EncMapInt64StringV(v, e) - case *map[int64]string: - fastpathTV.EncMapInt64StringV(*v, e) - - case map[int64]uint: - fastpathTV.EncMapInt64UintV(v, e) - case *map[int64]uint: - fastpathTV.EncMapInt64UintV(*v, e) - - case map[int64]uint8: - fastpathTV.EncMapInt64Uint8V(v, e) - case *map[int64]uint8: - fastpathTV.EncMapInt64Uint8V(*v, e) - - case map[int64]uint16: - fastpathTV.EncMapInt64Uint16V(v, e) - case *map[int64]uint16: - fastpathTV.EncMapInt64Uint16V(*v, e) - - case map[int64]uint32: - fastpathTV.EncMapInt64Uint32V(v, e) - case *map[int64]uint32: - fastpathTV.EncMapInt64Uint32V(*v, e) - - case map[int64]uint64: - fastpathTV.EncMapInt64Uint64V(v, e) - case *map[int64]uint64: - fastpathTV.EncMapInt64Uint64V(*v, e) - - case map[int64]uintptr: - fastpathTV.EncMapInt64UintptrV(v, e) - case *map[int64]uintptr: - fastpathTV.EncMapInt64UintptrV(*v, e) - - case map[int64]int: - fastpathTV.EncMapInt64IntV(v, e) - case *map[int64]int: - fastpathTV.EncMapInt64IntV(*v, e) - - case map[int64]int8: - fastpathTV.EncMapInt64Int8V(v, e) - case *map[int64]int8: - fastpathTV.EncMapInt64Int8V(*v, e) - - case map[int64]int16: - fastpathTV.EncMapInt64Int16V(v, e) - case *map[int64]int16: - fastpathTV.EncMapInt64Int16V(*v, e) - - case map[int64]int32: - fastpathTV.EncMapInt64Int32V(v, e) - case *map[int64]int32: - fastpathTV.EncMapInt64Int32V(*v, e) - - case map[int64]int64: - fastpathTV.EncMapInt64Int64V(v, e) - case *map[int64]int64: - fastpathTV.EncMapInt64Int64V(*v, e) - - case map[int64]float32: - fastpathTV.EncMapInt64Float32V(v, e) - case *map[int64]float32: - fastpathTV.EncMapInt64Float32V(*v, e) - - case map[int64]float64: - fastpathTV.EncMapInt64Float64V(v, e) - case *map[int64]float64: - fastpathTV.EncMapInt64Float64V(*v, e) - - case map[int64]bool: - fastpathTV.EncMapInt64BoolV(v, e) - case *map[int64]bool: - fastpathTV.EncMapInt64BoolV(*v, e) - - case []bool: - fastpathTV.EncSliceBoolV(v, e) - case *[]bool: - fastpathTV.EncSliceBoolV(*v, e) - - case map[bool]interface{}: - fastpathTV.EncMapBoolIntfV(v, e) - case *map[bool]interface{}: - fastpathTV.EncMapBoolIntfV(*v, e) - - case map[bool]string: - fastpathTV.EncMapBoolStringV(v, e) - case *map[bool]string: - fastpathTV.EncMapBoolStringV(*v, e) - - case map[bool]uint: - fastpathTV.EncMapBoolUintV(v, e) - case *map[bool]uint: - fastpathTV.EncMapBoolUintV(*v, e) - - case map[bool]uint8: - fastpathTV.EncMapBoolUint8V(v, e) - case *map[bool]uint8: - fastpathTV.EncMapBoolUint8V(*v, e) - - case map[bool]uint16: - fastpathTV.EncMapBoolUint16V(v, e) - case *map[bool]uint16: - fastpathTV.EncMapBoolUint16V(*v, e) - - case map[bool]uint32: - fastpathTV.EncMapBoolUint32V(v, e) - case *map[bool]uint32: - fastpathTV.EncMapBoolUint32V(*v, e) - - case map[bool]uint64: - fastpathTV.EncMapBoolUint64V(v, e) - case *map[bool]uint64: - fastpathTV.EncMapBoolUint64V(*v, e) - - case map[bool]uintptr: - fastpathTV.EncMapBoolUintptrV(v, e) - case *map[bool]uintptr: - fastpathTV.EncMapBoolUintptrV(*v, e) - - case map[bool]int: - fastpathTV.EncMapBoolIntV(v, e) - case *map[bool]int: - fastpathTV.EncMapBoolIntV(*v, e) - - case map[bool]int8: - fastpathTV.EncMapBoolInt8V(v, e) - case *map[bool]int8: - fastpathTV.EncMapBoolInt8V(*v, e) - - case map[bool]int16: - fastpathTV.EncMapBoolInt16V(v, e) - case *map[bool]int16: - fastpathTV.EncMapBoolInt16V(*v, e) - - case map[bool]int32: - fastpathTV.EncMapBoolInt32V(v, e) - case *map[bool]int32: - fastpathTV.EncMapBoolInt32V(*v, e) - - case map[bool]int64: - fastpathTV.EncMapBoolInt64V(v, e) - case *map[bool]int64: - fastpathTV.EncMapBoolInt64V(*v, e) - - case map[bool]float32: - fastpathTV.EncMapBoolFloat32V(v, e) - case *map[bool]float32: - fastpathTV.EncMapBoolFloat32V(*v, e) - - case map[bool]float64: - fastpathTV.EncMapBoolFloat64V(v, e) - case *map[bool]float64: - fastpathTV.EncMapBoolFloat64V(*v, e) - - case map[bool]bool: - fastpathTV.EncMapBoolBoolV(v, e) - case *map[bool]bool: - fastpathTV.EncMapBoolBoolV(*v, e) - - default: - _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) - return false - } - return true -} - -func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { - switch v := iv.(type) { - - case []interface{}: - fastpathTV.EncSliceIntfV(v, e) - case *[]interface{}: - fastpathTV.EncSliceIntfV(*v, e) - - case []string: - fastpathTV.EncSliceStringV(v, e) - case *[]string: - fastpathTV.EncSliceStringV(*v, e) - - case []float32: - fastpathTV.EncSliceFloat32V(v, e) - case *[]float32: - fastpathTV.EncSliceFloat32V(*v, e) - - case []float64: - fastpathTV.EncSliceFloat64V(v, e) - case *[]float64: - fastpathTV.EncSliceFloat64V(*v, e) - - case []uint: - fastpathTV.EncSliceUintV(v, e) - case *[]uint: - fastpathTV.EncSliceUintV(*v, e) - - case []uint16: - fastpathTV.EncSliceUint16V(v, e) - case *[]uint16: - fastpathTV.EncSliceUint16V(*v, e) - - case []uint32: - fastpathTV.EncSliceUint32V(v, e) - case *[]uint32: - fastpathTV.EncSliceUint32V(*v, e) - - case []uint64: - fastpathTV.EncSliceUint64V(v, e) - case *[]uint64: - fastpathTV.EncSliceUint64V(*v, e) - - case []uintptr: - fastpathTV.EncSliceUintptrV(v, e) - case *[]uintptr: - fastpathTV.EncSliceUintptrV(*v, e) - - case []int: - fastpathTV.EncSliceIntV(v, e) - case *[]int: - fastpathTV.EncSliceIntV(*v, e) - - case []int8: - fastpathTV.EncSliceInt8V(v, e) - case *[]int8: - fastpathTV.EncSliceInt8V(*v, e) - - case []int16: - fastpathTV.EncSliceInt16V(v, e) - case *[]int16: - fastpathTV.EncSliceInt16V(*v, e) - - case []int32: - fastpathTV.EncSliceInt32V(v, e) - case *[]int32: - fastpathTV.EncSliceInt32V(*v, e) - - case []int64: - fastpathTV.EncSliceInt64V(v, e) - case *[]int64: - fastpathTV.EncSliceInt64V(*v, e) - - case []bool: - fastpathTV.EncSliceBoolV(v, e) - case *[]bool: - fastpathTV.EncSliceBoolV(*v, e) - - default: - _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) - return false - } - return true -} - -func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { - switch v := iv.(type) { - - case map[interface{}]interface{}: - fastpathTV.EncMapIntfIntfV(v, e) - case *map[interface{}]interface{}: - fastpathTV.EncMapIntfIntfV(*v, e) - - case map[interface{}]string: - fastpathTV.EncMapIntfStringV(v, e) - case *map[interface{}]string: - fastpathTV.EncMapIntfStringV(*v, e) - - case map[interface{}]uint: - fastpathTV.EncMapIntfUintV(v, e) - case *map[interface{}]uint: - fastpathTV.EncMapIntfUintV(*v, e) - - case map[interface{}]uint8: - fastpathTV.EncMapIntfUint8V(v, e) - case *map[interface{}]uint8: - fastpathTV.EncMapIntfUint8V(*v, e) - - case map[interface{}]uint16: - fastpathTV.EncMapIntfUint16V(v, e) - case *map[interface{}]uint16: - fastpathTV.EncMapIntfUint16V(*v, e) - - case map[interface{}]uint32: - fastpathTV.EncMapIntfUint32V(v, e) - case *map[interface{}]uint32: - fastpathTV.EncMapIntfUint32V(*v, e) - - case map[interface{}]uint64: - fastpathTV.EncMapIntfUint64V(v, e) - case *map[interface{}]uint64: - fastpathTV.EncMapIntfUint64V(*v, e) - - case map[interface{}]uintptr: - fastpathTV.EncMapIntfUintptrV(v, e) - case *map[interface{}]uintptr: - fastpathTV.EncMapIntfUintptrV(*v, e) - - case map[interface{}]int: - fastpathTV.EncMapIntfIntV(v, e) - case *map[interface{}]int: - fastpathTV.EncMapIntfIntV(*v, e) - - case map[interface{}]int8: - fastpathTV.EncMapIntfInt8V(v, e) - case *map[interface{}]int8: - fastpathTV.EncMapIntfInt8V(*v, e) - - case map[interface{}]int16: - fastpathTV.EncMapIntfInt16V(v, e) - case *map[interface{}]int16: - fastpathTV.EncMapIntfInt16V(*v, e) - - case map[interface{}]int32: - fastpathTV.EncMapIntfInt32V(v, e) - case *map[interface{}]int32: - fastpathTV.EncMapIntfInt32V(*v, e) - - case map[interface{}]int64: - fastpathTV.EncMapIntfInt64V(v, e) - case *map[interface{}]int64: - fastpathTV.EncMapIntfInt64V(*v, e) - - case map[interface{}]float32: - fastpathTV.EncMapIntfFloat32V(v, e) - case *map[interface{}]float32: - fastpathTV.EncMapIntfFloat32V(*v, e) - - case map[interface{}]float64: - fastpathTV.EncMapIntfFloat64V(v, e) - case *map[interface{}]float64: - fastpathTV.EncMapIntfFloat64V(*v, e) - - case map[interface{}]bool: - fastpathTV.EncMapIntfBoolV(v, e) - case *map[interface{}]bool: - fastpathTV.EncMapIntfBoolV(*v, e) - - case map[string]interface{}: - fastpathTV.EncMapStringIntfV(v, e) - case *map[string]interface{}: - fastpathTV.EncMapStringIntfV(*v, e) - - case map[string]string: - fastpathTV.EncMapStringStringV(v, e) - case *map[string]string: - fastpathTV.EncMapStringStringV(*v, e) - - case map[string]uint: - fastpathTV.EncMapStringUintV(v, e) - case *map[string]uint: - fastpathTV.EncMapStringUintV(*v, e) - - case map[string]uint8: - fastpathTV.EncMapStringUint8V(v, e) - case *map[string]uint8: - fastpathTV.EncMapStringUint8V(*v, e) - - case map[string]uint16: - fastpathTV.EncMapStringUint16V(v, e) - case *map[string]uint16: - fastpathTV.EncMapStringUint16V(*v, e) - - case map[string]uint32: - fastpathTV.EncMapStringUint32V(v, e) - case *map[string]uint32: - fastpathTV.EncMapStringUint32V(*v, e) - - case map[string]uint64: - fastpathTV.EncMapStringUint64V(v, e) - case *map[string]uint64: - fastpathTV.EncMapStringUint64V(*v, e) - - case map[string]uintptr: - fastpathTV.EncMapStringUintptrV(v, e) - case *map[string]uintptr: - fastpathTV.EncMapStringUintptrV(*v, e) - - case map[string]int: - fastpathTV.EncMapStringIntV(v, e) - case *map[string]int: - fastpathTV.EncMapStringIntV(*v, e) - - case map[string]int8: - fastpathTV.EncMapStringInt8V(v, e) - case *map[string]int8: - fastpathTV.EncMapStringInt8V(*v, e) - - case map[string]int16: - fastpathTV.EncMapStringInt16V(v, e) - case *map[string]int16: - fastpathTV.EncMapStringInt16V(*v, e) - - case map[string]int32: - fastpathTV.EncMapStringInt32V(v, e) - case *map[string]int32: - fastpathTV.EncMapStringInt32V(*v, e) - - case map[string]int64: - fastpathTV.EncMapStringInt64V(v, e) - case *map[string]int64: - fastpathTV.EncMapStringInt64V(*v, e) - - case map[string]float32: - fastpathTV.EncMapStringFloat32V(v, e) - case *map[string]float32: - fastpathTV.EncMapStringFloat32V(*v, e) - - case map[string]float64: - fastpathTV.EncMapStringFloat64V(v, e) - case *map[string]float64: - fastpathTV.EncMapStringFloat64V(*v, e) - - case map[string]bool: - fastpathTV.EncMapStringBoolV(v, e) - case *map[string]bool: - fastpathTV.EncMapStringBoolV(*v, e) - - case map[float32]interface{}: - fastpathTV.EncMapFloat32IntfV(v, e) - case *map[float32]interface{}: - fastpathTV.EncMapFloat32IntfV(*v, e) - - case map[float32]string: - fastpathTV.EncMapFloat32StringV(v, e) - case *map[float32]string: - fastpathTV.EncMapFloat32StringV(*v, e) - - case map[float32]uint: - fastpathTV.EncMapFloat32UintV(v, e) - case *map[float32]uint: - fastpathTV.EncMapFloat32UintV(*v, e) - - case map[float32]uint8: - fastpathTV.EncMapFloat32Uint8V(v, e) - case *map[float32]uint8: - fastpathTV.EncMapFloat32Uint8V(*v, e) - - case map[float32]uint16: - fastpathTV.EncMapFloat32Uint16V(v, e) - case *map[float32]uint16: - fastpathTV.EncMapFloat32Uint16V(*v, e) - - case map[float32]uint32: - fastpathTV.EncMapFloat32Uint32V(v, e) - case *map[float32]uint32: - fastpathTV.EncMapFloat32Uint32V(*v, e) - - case map[float32]uint64: - fastpathTV.EncMapFloat32Uint64V(v, e) - case *map[float32]uint64: - fastpathTV.EncMapFloat32Uint64V(*v, e) - - case map[float32]uintptr: - fastpathTV.EncMapFloat32UintptrV(v, e) - case *map[float32]uintptr: - fastpathTV.EncMapFloat32UintptrV(*v, e) - - case map[float32]int: - fastpathTV.EncMapFloat32IntV(v, e) - case *map[float32]int: - fastpathTV.EncMapFloat32IntV(*v, e) - - case map[float32]int8: - fastpathTV.EncMapFloat32Int8V(v, e) - case *map[float32]int8: - fastpathTV.EncMapFloat32Int8V(*v, e) - - case map[float32]int16: - fastpathTV.EncMapFloat32Int16V(v, e) - case *map[float32]int16: - fastpathTV.EncMapFloat32Int16V(*v, e) - - case map[float32]int32: - fastpathTV.EncMapFloat32Int32V(v, e) - case *map[float32]int32: - fastpathTV.EncMapFloat32Int32V(*v, e) - - case map[float32]int64: - fastpathTV.EncMapFloat32Int64V(v, e) - case *map[float32]int64: - fastpathTV.EncMapFloat32Int64V(*v, e) - - case map[float32]float32: - fastpathTV.EncMapFloat32Float32V(v, e) - case *map[float32]float32: - fastpathTV.EncMapFloat32Float32V(*v, e) - - case map[float32]float64: - fastpathTV.EncMapFloat32Float64V(v, e) - case *map[float32]float64: - fastpathTV.EncMapFloat32Float64V(*v, e) - - case map[float32]bool: - fastpathTV.EncMapFloat32BoolV(v, e) - case *map[float32]bool: - fastpathTV.EncMapFloat32BoolV(*v, e) - - case map[float64]interface{}: - fastpathTV.EncMapFloat64IntfV(v, e) - case *map[float64]interface{}: - fastpathTV.EncMapFloat64IntfV(*v, e) - - case map[float64]string: - fastpathTV.EncMapFloat64StringV(v, e) - case *map[float64]string: - fastpathTV.EncMapFloat64StringV(*v, e) - - case map[float64]uint: - fastpathTV.EncMapFloat64UintV(v, e) - case *map[float64]uint: - fastpathTV.EncMapFloat64UintV(*v, e) - - case map[float64]uint8: - fastpathTV.EncMapFloat64Uint8V(v, e) - case *map[float64]uint8: - fastpathTV.EncMapFloat64Uint8V(*v, e) - - case map[float64]uint16: - fastpathTV.EncMapFloat64Uint16V(v, e) - case *map[float64]uint16: - fastpathTV.EncMapFloat64Uint16V(*v, e) - - case map[float64]uint32: - fastpathTV.EncMapFloat64Uint32V(v, e) - case *map[float64]uint32: - fastpathTV.EncMapFloat64Uint32V(*v, e) - - case map[float64]uint64: - fastpathTV.EncMapFloat64Uint64V(v, e) - case *map[float64]uint64: - fastpathTV.EncMapFloat64Uint64V(*v, e) - - case map[float64]uintptr: - fastpathTV.EncMapFloat64UintptrV(v, e) - case *map[float64]uintptr: - fastpathTV.EncMapFloat64UintptrV(*v, e) - - case map[float64]int: - fastpathTV.EncMapFloat64IntV(v, e) - case *map[float64]int: - fastpathTV.EncMapFloat64IntV(*v, e) - - case map[float64]int8: - fastpathTV.EncMapFloat64Int8V(v, e) - case *map[float64]int8: - fastpathTV.EncMapFloat64Int8V(*v, e) - - case map[float64]int16: - fastpathTV.EncMapFloat64Int16V(v, e) - case *map[float64]int16: - fastpathTV.EncMapFloat64Int16V(*v, e) - - case map[float64]int32: - fastpathTV.EncMapFloat64Int32V(v, e) - case *map[float64]int32: - fastpathTV.EncMapFloat64Int32V(*v, e) - - case map[float64]int64: - fastpathTV.EncMapFloat64Int64V(v, e) - case *map[float64]int64: - fastpathTV.EncMapFloat64Int64V(*v, e) - - case map[float64]float32: - fastpathTV.EncMapFloat64Float32V(v, e) - case *map[float64]float32: - fastpathTV.EncMapFloat64Float32V(*v, e) - - case map[float64]float64: - fastpathTV.EncMapFloat64Float64V(v, e) - case *map[float64]float64: - fastpathTV.EncMapFloat64Float64V(*v, e) - - case map[float64]bool: - fastpathTV.EncMapFloat64BoolV(v, e) - case *map[float64]bool: - fastpathTV.EncMapFloat64BoolV(*v, e) - - case map[uint]interface{}: - fastpathTV.EncMapUintIntfV(v, e) - case *map[uint]interface{}: - fastpathTV.EncMapUintIntfV(*v, e) - - case map[uint]string: - fastpathTV.EncMapUintStringV(v, e) - case *map[uint]string: - fastpathTV.EncMapUintStringV(*v, e) - - case map[uint]uint: - fastpathTV.EncMapUintUintV(v, e) - case *map[uint]uint: - fastpathTV.EncMapUintUintV(*v, e) - - case map[uint]uint8: - fastpathTV.EncMapUintUint8V(v, e) - case *map[uint]uint8: - fastpathTV.EncMapUintUint8V(*v, e) - - case map[uint]uint16: - fastpathTV.EncMapUintUint16V(v, e) - case *map[uint]uint16: - fastpathTV.EncMapUintUint16V(*v, e) - - case map[uint]uint32: - fastpathTV.EncMapUintUint32V(v, e) - case *map[uint]uint32: - fastpathTV.EncMapUintUint32V(*v, e) - - case map[uint]uint64: - fastpathTV.EncMapUintUint64V(v, e) - case *map[uint]uint64: - fastpathTV.EncMapUintUint64V(*v, e) - - case map[uint]uintptr: - fastpathTV.EncMapUintUintptrV(v, e) - case *map[uint]uintptr: - fastpathTV.EncMapUintUintptrV(*v, e) - - case map[uint]int: - fastpathTV.EncMapUintIntV(v, e) - case *map[uint]int: - fastpathTV.EncMapUintIntV(*v, e) - - case map[uint]int8: - fastpathTV.EncMapUintInt8V(v, e) - case *map[uint]int8: - fastpathTV.EncMapUintInt8V(*v, e) - - case map[uint]int16: - fastpathTV.EncMapUintInt16V(v, e) - case *map[uint]int16: - fastpathTV.EncMapUintInt16V(*v, e) - - case map[uint]int32: - fastpathTV.EncMapUintInt32V(v, e) - case *map[uint]int32: - fastpathTV.EncMapUintInt32V(*v, e) - - case map[uint]int64: - fastpathTV.EncMapUintInt64V(v, e) - case *map[uint]int64: - fastpathTV.EncMapUintInt64V(*v, e) - - case map[uint]float32: - fastpathTV.EncMapUintFloat32V(v, e) - case *map[uint]float32: - fastpathTV.EncMapUintFloat32V(*v, e) - - case map[uint]float64: - fastpathTV.EncMapUintFloat64V(v, e) - case *map[uint]float64: - fastpathTV.EncMapUintFloat64V(*v, e) - - case map[uint]bool: - fastpathTV.EncMapUintBoolV(v, e) - case *map[uint]bool: - fastpathTV.EncMapUintBoolV(*v, e) - - case map[uint8]interface{}: - fastpathTV.EncMapUint8IntfV(v, e) - case *map[uint8]interface{}: - fastpathTV.EncMapUint8IntfV(*v, e) - - case map[uint8]string: - fastpathTV.EncMapUint8StringV(v, e) - case *map[uint8]string: - fastpathTV.EncMapUint8StringV(*v, e) - - case map[uint8]uint: - fastpathTV.EncMapUint8UintV(v, e) - case *map[uint8]uint: - fastpathTV.EncMapUint8UintV(*v, e) - - case map[uint8]uint8: - fastpathTV.EncMapUint8Uint8V(v, e) - case *map[uint8]uint8: - fastpathTV.EncMapUint8Uint8V(*v, e) - - case map[uint8]uint16: - fastpathTV.EncMapUint8Uint16V(v, e) - case *map[uint8]uint16: - fastpathTV.EncMapUint8Uint16V(*v, e) - - case map[uint8]uint32: - fastpathTV.EncMapUint8Uint32V(v, e) - case *map[uint8]uint32: - fastpathTV.EncMapUint8Uint32V(*v, e) - - case map[uint8]uint64: - fastpathTV.EncMapUint8Uint64V(v, e) - case *map[uint8]uint64: - fastpathTV.EncMapUint8Uint64V(*v, e) - - case map[uint8]uintptr: - fastpathTV.EncMapUint8UintptrV(v, e) - case *map[uint8]uintptr: - fastpathTV.EncMapUint8UintptrV(*v, e) - - case map[uint8]int: - fastpathTV.EncMapUint8IntV(v, e) - case *map[uint8]int: - fastpathTV.EncMapUint8IntV(*v, e) - - case map[uint8]int8: - fastpathTV.EncMapUint8Int8V(v, e) - case *map[uint8]int8: - fastpathTV.EncMapUint8Int8V(*v, e) - - case map[uint8]int16: - fastpathTV.EncMapUint8Int16V(v, e) - case *map[uint8]int16: - fastpathTV.EncMapUint8Int16V(*v, e) - - case map[uint8]int32: - fastpathTV.EncMapUint8Int32V(v, e) - case *map[uint8]int32: - fastpathTV.EncMapUint8Int32V(*v, e) - - case map[uint8]int64: - fastpathTV.EncMapUint8Int64V(v, e) - case *map[uint8]int64: - fastpathTV.EncMapUint8Int64V(*v, e) - - case map[uint8]float32: - fastpathTV.EncMapUint8Float32V(v, e) - case *map[uint8]float32: - fastpathTV.EncMapUint8Float32V(*v, e) - - case map[uint8]float64: - fastpathTV.EncMapUint8Float64V(v, e) - case *map[uint8]float64: - fastpathTV.EncMapUint8Float64V(*v, e) - - case map[uint8]bool: - fastpathTV.EncMapUint8BoolV(v, e) - case *map[uint8]bool: - fastpathTV.EncMapUint8BoolV(*v, e) - - case map[uint16]interface{}: - fastpathTV.EncMapUint16IntfV(v, e) - case *map[uint16]interface{}: - fastpathTV.EncMapUint16IntfV(*v, e) - - case map[uint16]string: - fastpathTV.EncMapUint16StringV(v, e) - case *map[uint16]string: - fastpathTV.EncMapUint16StringV(*v, e) - - case map[uint16]uint: - fastpathTV.EncMapUint16UintV(v, e) - case *map[uint16]uint: - fastpathTV.EncMapUint16UintV(*v, e) - - case map[uint16]uint8: - fastpathTV.EncMapUint16Uint8V(v, e) - case *map[uint16]uint8: - fastpathTV.EncMapUint16Uint8V(*v, e) - - case map[uint16]uint16: - fastpathTV.EncMapUint16Uint16V(v, e) - case *map[uint16]uint16: - fastpathTV.EncMapUint16Uint16V(*v, e) - - case map[uint16]uint32: - fastpathTV.EncMapUint16Uint32V(v, e) - case *map[uint16]uint32: - fastpathTV.EncMapUint16Uint32V(*v, e) - - case map[uint16]uint64: - fastpathTV.EncMapUint16Uint64V(v, e) - case *map[uint16]uint64: - fastpathTV.EncMapUint16Uint64V(*v, e) - - case map[uint16]uintptr: - fastpathTV.EncMapUint16UintptrV(v, e) - case *map[uint16]uintptr: - fastpathTV.EncMapUint16UintptrV(*v, e) - - case map[uint16]int: - fastpathTV.EncMapUint16IntV(v, e) - case *map[uint16]int: - fastpathTV.EncMapUint16IntV(*v, e) - - case map[uint16]int8: - fastpathTV.EncMapUint16Int8V(v, e) - case *map[uint16]int8: - fastpathTV.EncMapUint16Int8V(*v, e) - - case map[uint16]int16: - fastpathTV.EncMapUint16Int16V(v, e) - case *map[uint16]int16: - fastpathTV.EncMapUint16Int16V(*v, e) - - case map[uint16]int32: - fastpathTV.EncMapUint16Int32V(v, e) - case *map[uint16]int32: - fastpathTV.EncMapUint16Int32V(*v, e) - - case map[uint16]int64: - fastpathTV.EncMapUint16Int64V(v, e) - case *map[uint16]int64: - fastpathTV.EncMapUint16Int64V(*v, e) - - case map[uint16]float32: - fastpathTV.EncMapUint16Float32V(v, e) - case *map[uint16]float32: - fastpathTV.EncMapUint16Float32V(*v, e) - - case map[uint16]float64: - fastpathTV.EncMapUint16Float64V(v, e) - case *map[uint16]float64: - fastpathTV.EncMapUint16Float64V(*v, e) - - case map[uint16]bool: - fastpathTV.EncMapUint16BoolV(v, e) - case *map[uint16]bool: - fastpathTV.EncMapUint16BoolV(*v, e) - - case map[uint32]interface{}: - fastpathTV.EncMapUint32IntfV(v, e) - case *map[uint32]interface{}: - fastpathTV.EncMapUint32IntfV(*v, e) - - case map[uint32]string: - fastpathTV.EncMapUint32StringV(v, e) - case *map[uint32]string: - fastpathTV.EncMapUint32StringV(*v, e) - - case map[uint32]uint: - fastpathTV.EncMapUint32UintV(v, e) - case *map[uint32]uint: - fastpathTV.EncMapUint32UintV(*v, e) - - case map[uint32]uint8: - fastpathTV.EncMapUint32Uint8V(v, e) - case *map[uint32]uint8: - fastpathTV.EncMapUint32Uint8V(*v, e) - - case map[uint32]uint16: - fastpathTV.EncMapUint32Uint16V(v, e) - case *map[uint32]uint16: - fastpathTV.EncMapUint32Uint16V(*v, e) - - case map[uint32]uint32: - fastpathTV.EncMapUint32Uint32V(v, e) - case *map[uint32]uint32: - fastpathTV.EncMapUint32Uint32V(*v, e) - - case map[uint32]uint64: - fastpathTV.EncMapUint32Uint64V(v, e) - case *map[uint32]uint64: - fastpathTV.EncMapUint32Uint64V(*v, e) - - case map[uint32]uintptr: - fastpathTV.EncMapUint32UintptrV(v, e) - case *map[uint32]uintptr: - fastpathTV.EncMapUint32UintptrV(*v, e) - - case map[uint32]int: - fastpathTV.EncMapUint32IntV(v, e) - case *map[uint32]int: - fastpathTV.EncMapUint32IntV(*v, e) - - case map[uint32]int8: - fastpathTV.EncMapUint32Int8V(v, e) - case *map[uint32]int8: - fastpathTV.EncMapUint32Int8V(*v, e) - - case map[uint32]int16: - fastpathTV.EncMapUint32Int16V(v, e) - case *map[uint32]int16: - fastpathTV.EncMapUint32Int16V(*v, e) - - case map[uint32]int32: - fastpathTV.EncMapUint32Int32V(v, e) - case *map[uint32]int32: - fastpathTV.EncMapUint32Int32V(*v, e) - - case map[uint32]int64: - fastpathTV.EncMapUint32Int64V(v, e) - case *map[uint32]int64: - fastpathTV.EncMapUint32Int64V(*v, e) - - case map[uint32]float32: - fastpathTV.EncMapUint32Float32V(v, e) - case *map[uint32]float32: - fastpathTV.EncMapUint32Float32V(*v, e) - - case map[uint32]float64: - fastpathTV.EncMapUint32Float64V(v, e) - case *map[uint32]float64: - fastpathTV.EncMapUint32Float64V(*v, e) - - case map[uint32]bool: - fastpathTV.EncMapUint32BoolV(v, e) - case *map[uint32]bool: - fastpathTV.EncMapUint32BoolV(*v, e) - - case map[uint64]interface{}: - fastpathTV.EncMapUint64IntfV(v, e) - case *map[uint64]interface{}: - fastpathTV.EncMapUint64IntfV(*v, e) - - case map[uint64]string: - fastpathTV.EncMapUint64StringV(v, e) - case *map[uint64]string: - fastpathTV.EncMapUint64StringV(*v, e) - - case map[uint64]uint: - fastpathTV.EncMapUint64UintV(v, e) - case *map[uint64]uint: - fastpathTV.EncMapUint64UintV(*v, e) - - case map[uint64]uint8: - fastpathTV.EncMapUint64Uint8V(v, e) - case *map[uint64]uint8: - fastpathTV.EncMapUint64Uint8V(*v, e) - - case map[uint64]uint16: - fastpathTV.EncMapUint64Uint16V(v, e) - case *map[uint64]uint16: - fastpathTV.EncMapUint64Uint16V(*v, e) - - case map[uint64]uint32: - fastpathTV.EncMapUint64Uint32V(v, e) - case *map[uint64]uint32: - fastpathTV.EncMapUint64Uint32V(*v, e) - - case map[uint64]uint64: - fastpathTV.EncMapUint64Uint64V(v, e) - case *map[uint64]uint64: - fastpathTV.EncMapUint64Uint64V(*v, e) - - case map[uint64]uintptr: - fastpathTV.EncMapUint64UintptrV(v, e) - case *map[uint64]uintptr: - fastpathTV.EncMapUint64UintptrV(*v, e) - - case map[uint64]int: - fastpathTV.EncMapUint64IntV(v, e) - case *map[uint64]int: - fastpathTV.EncMapUint64IntV(*v, e) - - case map[uint64]int8: - fastpathTV.EncMapUint64Int8V(v, e) - case *map[uint64]int8: - fastpathTV.EncMapUint64Int8V(*v, e) - - case map[uint64]int16: - fastpathTV.EncMapUint64Int16V(v, e) - case *map[uint64]int16: - fastpathTV.EncMapUint64Int16V(*v, e) - - case map[uint64]int32: - fastpathTV.EncMapUint64Int32V(v, e) - case *map[uint64]int32: - fastpathTV.EncMapUint64Int32V(*v, e) - - case map[uint64]int64: - fastpathTV.EncMapUint64Int64V(v, e) - case *map[uint64]int64: - fastpathTV.EncMapUint64Int64V(*v, e) - - case map[uint64]float32: - fastpathTV.EncMapUint64Float32V(v, e) - case *map[uint64]float32: - fastpathTV.EncMapUint64Float32V(*v, e) - - case map[uint64]float64: - fastpathTV.EncMapUint64Float64V(v, e) - case *map[uint64]float64: - fastpathTV.EncMapUint64Float64V(*v, e) - - case map[uint64]bool: - fastpathTV.EncMapUint64BoolV(v, e) - case *map[uint64]bool: - fastpathTV.EncMapUint64BoolV(*v, e) - - case map[uintptr]interface{}: - fastpathTV.EncMapUintptrIntfV(v, e) - case *map[uintptr]interface{}: - fastpathTV.EncMapUintptrIntfV(*v, e) - - case map[uintptr]string: - fastpathTV.EncMapUintptrStringV(v, e) - case *map[uintptr]string: - fastpathTV.EncMapUintptrStringV(*v, e) - - case map[uintptr]uint: - fastpathTV.EncMapUintptrUintV(v, e) - case *map[uintptr]uint: - fastpathTV.EncMapUintptrUintV(*v, e) - - case map[uintptr]uint8: - fastpathTV.EncMapUintptrUint8V(v, e) - case *map[uintptr]uint8: - fastpathTV.EncMapUintptrUint8V(*v, e) - - case map[uintptr]uint16: - fastpathTV.EncMapUintptrUint16V(v, e) - case *map[uintptr]uint16: - fastpathTV.EncMapUintptrUint16V(*v, e) - - case map[uintptr]uint32: - fastpathTV.EncMapUintptrUint32V(v, e) - case *map[uintptr]uint32: - fastpathTV.EncMapUintptrUint32V(*v, e) - - case map[uintptr]uint64: - fastpathTV.EncMapUintptrUint64V(v, e) - case *map[uintptr]uint64: - fastpathTV.EncMapUintptrUint64V(*v, e) - - case map[uintptr]uintptr: - fastpathTV.EncMapUintptrUintptrV(v, e) - case *map[uintptr]uintptr: - fastpathTV.EncMapUintptrUintptrV(*v, e) - - case map[uintptr]int: - fastpathTV.EncMapUintptrIntV(v, e) - case *map[uintptr]int: - fastpathTV.EncMapUintptrIntV(*v, e) - - case map[uintptr]int8: - fastpathTV.EncMapUintptrInt8V(v, e) - case *map[uintptr]int8: - fastpathTV.EncMapUintptrInt8V(*v, e) - - case map[uintptr]int16: - fastpathTV.EncMapUintptrInt16V(v, e) - case *map[uintptr]int16: - fastpathTV.EncMapUintptrInt16V(*v, e) - - case map[uintptr]int32: - fastpathTV.EncMapUintptrInt32V(v, e) - case *map[uintptr]int32: - fastpathTV.EncMapUintptrInt32V(*v, e) - - case map[uintptr]int64: - fastpathTV.EncMapUintptrInt64V(v, e) - case *map[uintptr]int64: - fastpathTV.EncMapUintptrInt64V(*v, e) - - case map[uintptr]float32: - fastpathTV.EncMapUintptrFloat32V(v, e) - case *map[uintptr]float32: - fastpathTV.EncMapUintptrFloat32V(*v, e) - - case map[uintptr]float64: - fastpathTV.EncMapUintptrFloat64V(v, e) - case *map[uintptr]float64: - fastpathTV.EncMapUintptrFloat64V(*v, e) - - case map[uintptr]bool: - fastpathTV.EncMapUintptrBoolV(v, e) - case *map[uintptr]bool: - fastpathTV.EncMapUintptrBoolV(*v, e) - case map[int]interface{}: fastpathTV.EncMapIntIntfV(v, e) case *map[int]interface{}: fastpathTV.EncMapIntIntfV(*v, e) - case map[int]string: fastpathTV.EncMapIntStringV(v, e) case *map[int]string: fastpathTV.EncMapIntStringV(*v, e) - case map[int]uint: fastpathTV.EncMapIntUintV(v, e) case *map[int]uint: fastpathTV.EncMapIntUintV(*v, e) - case map[int]uint8: fastpathTV.EncMapIntUint8V(v, e) case *map[int]uint8: fastpathTV.EncMapIntUint8V(*v, e) - case map[int]uint16: fastpathTV.EncMapIntUint16V(v, e) case *map[int]uint16: fastpathTV.EncMapIntUint16V(*v, e) - case map[int]uint32: fastpathTV.EncMapIntUint32V(v, e) case *map[int]uint32: fastpathTV.EncMapIntUint32V(*v, e) - case map[int]uint64: fastpathTV.EncMapIntUint64V(v, e) case *map[int]uint64: fastpathTV.EncMapIntUint64V(*v, e) - case map[int]uintptr: fastpathTV.EncMapIntUintptrV(v, e) case *map[int]uintptr: fastpathTV.EncMapIntUintptrV(*v, e) - case map[int]int: fastpathTV.EncMapIntIntV(v, e) case *map[int]int: fastpathTV.EncMapIntIntV(*v, e) - case map[int]int8: fastpathTV.EncMapIntInt8V(v, e) case *map[int]int8: fastpathTV.EncMapIntInt8V(*v, e) - case map[int]int16: fastpathTV.EncMapIntInt16V(v, e) case *map[int]int16: fastpathTV.EncMapIntInt16V(*v, e) - case map[int]int32: fastpathTV.EncMapIntInt32V(v, e) case *map[int]int32: fastpathTV.EncMapIntInt32V(*v, e) - case map[int]int64: fastpathTV.EncMapIntInt64V(v, e) case *map[int]int64: fastpathTV.EncMapIntInt64V(*v, e) - case map[int]float32: fastpathTV.EncMapIntFloat32V(v, e) case *map[int]float32: fastpathTV.EncMapIntFloat32V(*v, e) - case map[int]float64: fastpathTV.EncMapIntFloat64V(v, e) case *map[int]float64: fastpathTV.EncMapIntFloat64V(*v, e) - case map[int]bool: fastpathTV.EncMapIntBoolV(v, e) case *map[int]bool: fastpathTV.EncMapIntBoolV(*v, e) - case map[int8]interface{}: fastpathTV.EncMapInt8IntfV(v, e) case *map[int8]interface{}: fastpathTV.EncMapInt8IntfV(*v, e) - case map[int8]string: fastpathTV.EncMapInt8StringV(v, e) case *map[int8]string: fastpathTV.EncMapInt8StringV(*v, e) - case map[int8]uint: fastpathTV.EncMapInt8UintV(v, e) case *map[int8]uint: fastpathTV.EncMapInt8UintV(*v, e) - case map[int8]uint8: fastpathTV.EncMapInt8Uint8V(v, e) case *map[int8]uint8: fastpathTV.EncMapInt8Uint8V(*v, e) - case map[int8]uint16: fastpathTV.EncMapInt8Uint16V(v, e) case *map[int8]uint16: fastpathTV.EncMapInt8Uint16V(*v, e) - case map[int8]uint32: fastpathTV.EncMapInt8Uint32V(v, e) case *map[int8]uint32: fastpathTV.EncMapInt8Uint32V(*v, e) - case map[int8]uint64: fastpathTV.EncMapInt8Uint64V(v, e) case *map[int8]uint64: fastpathTV.EncMapInt8Uint64V(*v, e) - case map[int8]uintptr: fastpathTV.EncMapInt8UintptrV(v, e) case *map[int8]uintptr: fastpathTV.EncMapInt8UintptrV(*v, e) - case map[int8]int: fastpathTV.EncMapInt8IntV(v, e) case *map[int8]int: fastpathTV.EncMapInt8IntV(*v, e) - case map[int8]int8: fastpathTV.EncMapInt8Int8V(v, e) case *map[int8]int8: fastpathTV.EncMapInt8Int8V(*v, e) - case map[int8]int16: fastpathTV.EncMapInt8Int16V(v, e) case *map[int8]int16: fastpathTV.EncMapInt8Int16V(*v, e) - case map[int8]int32: fastpathTV.EncMapInt8Int32V(v, e) case *map[int8]int32: fastpathTV.EncMapInt8Int32V(*v, e) - case map[int8]int64: fastpathTV.EncMapInt8Int64V(v, e) case *map[int8]int64: fastpathTV.EncMapInt8Int64V(*v, e) - case map[int8]float32: fastpathTV.EncMapInt8Float32V(v, e) case *map[int8]float32: fastpathTV.EncMapInt8Float32V(*v, e) - case map[int8]float64: fastpathTV.EncMapInt8Float64V(v, e) case *map[int8]float64: fastpathTV.EncMapInt8Float64V(*v, e) - case map[int8]bool: fastpathTV.EncMapInt8BoolV(v, e) case *map[int8]bool: fastpathTV.EncMapInt8BoolV(*v, e) - case map[int16]interface{}: fastpathTV.EncMapInt16IntfV(v, e) case *map[int16]interface{}: fastpathTV.EncMapInt16IntfV(*v, e) - case map[int16]string: fastpathTV.EncMapInt16StringV(v, e) case *map[int16]string: fastpathTV.EncMapInt16StringV(*v, e) - case map[int16]uint: fastpathTV.EncMapInt16UintV(v, e) case *map[int16]uint: fastpathTV.EncMapInt16UintV(*v, e) - case map[int16]uint8: fastpathTV.EncMapInt16Uint8V(v, e) case *map[int16]uint8: fastpathTV.EncMapInt16Uint8V(*v, e) - case map[int16]uint16: fastpathTV.EncMapInt16Uint16V(v, e) case *map[int16]uint16: fastpathTV.EncMapInt16Uint16V(*v, e) - case map[int16]uint32: fastpathTV.EncMapInt16Uint32V(v, e) case *map[int16]uint32: fastpathTV.EncMapInt16Uint32V(*v, e) - case map[int16]uint64: fastpathTV.EncMapInt16Uint64V(v, e) case *map[int16]uint64: fastpathTV.EncMapInt16Uint64V(*v, e) - case map[int16]uintptr: fastpathTV.EncMapInt16UintptrV(v, e) case *map[int16]uintptr: fastpathTV.EncMapInt16UintptrV(*v, e) - case map[int16]int: fastpathTV.EncMapInt16IntV(v, e) case *map[int16]int: fastpathTV.EncMapInt16IntV(*v, e) - case map[int16]int8: fastpathTV.EncMapInt16Int8V(v, e) case *map[int16]int8: fastpathTV.EncMapInt16Int8V(*v, e) - case map[int16]int16: fastpathTV.EncMapInt16Int16V(v, e) case *map[int16]int16: fastpathTV.EncMapInt16Int16V(*v, e) - case map[int16]int32: fastpathTV.EncMapInt16Int32V(v, e) case *map[int16]int32: fastpathTV.EncMapInt16Int32V(*v, e) - case map[int16]int64: fastpathTV.EncMapInt16Int64V(v, e) case *map[int16]int64: fastpathTV.EncMapInt16Int64V(*v, e) - case map[int16]float32: fastpathTV.EncMapInt16Float32V(v, e) case *map[int16]float32: fastpathTV.EncMapInt16Float32V(*v, e) - case map[int16]float64: fastpathTV.EncMapInt16Float64V(v, e) case *map[int16]float64: fastpathTV.EncMapInt16Float64V(*v, e) - case map[int16]bool: fastpathTV.EncMapInt16BoolV(v, e) case *map[int16]bool: fastpathTV.EncMapInt16BoolV(*v, e) - case map[int32]interface{}: fastpathTV.EncMapInt32IntfV(v, e) case *map[int32]interface{}: fastpathTV.EncMapInt32IntfV(*v, e) - case map[int32]string: fastpathTV.EncMapInt32StringV(v, e) case *map[int32]string: fastpathTV.EncMapInt32StringV(*v, e) - case map[int32]uint: fastpathTV.EncMapInt32UintV(v, e) case *map[int32]uint: fastpathTV.EncMapInt32UintV(*v, e) - case map[int32]uint8: fastpathTV.EncMapInt32Uint8V(v, e) case *map[int32]uint8: fastpathTV.EncMapInt32Uint8V(*v, e) - case map[int32]uint16: fastpathTV.EncMapInt32Uint16V(v, e) case *map[int32]uint16: fastpathTV.EncMapInt32Uint16V(*v, e) - case map[int32]uint32: fastpathTV.EncMapInt32Uint32V(v, e) case *map[int32]uint32: fastpathTV.EncMapInt32Uint32V(*v, e) - case map[int32]uint64: fastpathTV.EncMapInt32Uint64V(v, e) case *map[int32]uint64: fastpathTV.EncMapInt32Uint64V(*v, e) - case map[int32]uintptr: fastpathTV.EncMapInt32UintptrV(v, e) case *map[int32]uintptr: fastpathTV.EncMapInt32UintptrV(*v, e) - case map[int32]int: fastpathTV.EncMapInt32IntV(v, e) case *map[int32]int: fastpathTV.EncMapInt32IntV(*v, e) - case map[int32]int8: fastpathTV.EncMapInt32Int8V(v, e) case *map[int32]int8: fastpathTV.EncMapInt32Int8V(*v, e) - case map[int32]int16: fastpathTV.EncMapInt32Int16V(v, e) case *map[int32]int16: fastpathTV.EncMapInt32Int16V(*v, e) - case map[int32]int32: fastpathTV.EncMapInt32Int32V(v, e) case *map[int32]int32: fastpathTV.EncMapInt32Int32V(*v, e) - case map[int32]int64: fastpathTV.EncMapInt32Int64V(v, e) case *map[int32]int64: fastpathTV.EncMapInt32Int64V(*v, e) - case map[int32]float32: fastpathTV.EncMapInt32Float32V(v, e) case *map[int32]float32: fastpathTV.EncMapInt32Float32V(*v, e) - case map[int32]float64: fastpathTV.EncMapInt32Float64V(v, e) case *map[int32]float64: fastpathTV.EncMapInt32Float64V(*v, e) - case map[int32]bool: fastpathTV.EncMapInt32BoolV(v, e) case *map[int32]bool: fastpathTV.EncMapInt32BoolV(*v, e) - case map[int64]interface{}: fastpathTV.EncMapInt64IntfV(v, e) case *map[int64]interface{}: fastpathTV.EncMapInt64IntfV(*v, e) - case map[int64]string: fastpathTV.EncMapInt64StringV(v, e) case *map[int64]string: fastpathTV.EncMapInt64StringV(*v, e) - case map[int64]uint: fastpathTV.EncMapInt64UintV(v, e) case *map[int64]uint: fastpathTV.EncMapInt64UintV(*v, e) - case map[int64]uint8: fastpathTV.EncMapInt64Uint8V(v, e) case *map[int64]uint8: fastpathTV.EncMapInt64Uint8V(*v, e) - case map[int64]uint16: fastpathTV.EncMapInt64Uint16V(v, e) case *map[int64]uint16: fastpathTV.EncMapInt64Uint16V(*v, e) - case map[int64]uint32: fastpathTV.EncMapInt64Uint32V(v, e) case *map[int64]uint32: fastpathTV.EncMapInt64Uint32V(*v, e) - case map[int64]uint64: fastpathTV.EncMapInt64Uint64V(v, e) case *map[int64]uint64: fastpathTV.EncMapInt64Uint64V(*v, e) - case map[int64]uintptr: fastpathTV.EncMapInt64UintptrV(v, e) case *map[int64]uintptr: fastpathTV.EncMapInt64UintptrV(*v, e) - case map[int64]int: fastpathTV.EncMapInt64IntV(v, e) case *map[int64]int: fastpathTV.EncMapInt64IntV(*v, e) - case map[int64]int8: fastpathTV.EncMapInt64Int8V(v, e) case *map[int64]int8: fastpathTV.EncMapInt64Int8V(*v, e) - case map[int64]int16: fastpathTV.EncMapInt64Int16V(v, e) case *map[int64]int16: fastpathTV.EncMapInt64Int16V(*v, e) - case map[int64]int32: fastpathTV.EncMapInt64Int32V(v, e) case *map[int64]int32: fastpathTV.EncMapInt64Int32V(*v, e) - case map[int64]int64: fastpathTV.EncMapInt64Int64V(v, e) case *map[int64]int64: fastpathTV.EncMapInt64Int64V(*v, e) - case map[int64]float32: fastpathTV.EncMapInt64Float32V(v, e) case *map[int64]float32: fastpathTV.EncMapInt64Float32V(*v, e) - case map[int64]float64: fastpathTV.EncMapInt64Float64V(v, e) case *map[int64]float64: fastpathTV.EncMapInt64Float64V(*v, e) - case map[int64]bool: fastpathTV.EncMapInt64BoolV(v, e) case *map[int64]bool: fastpathTV.EncMapInt64BoolV(*v, e) - case map[bool]interface{}: fastpathTV.EncMapBoolIntfV(v, e) case *map[bool]interface{}: fastpathTV.EncMapBoolIntfV(*v, e) - case map[bool]string: fastpathTV.EncMapBoolStringV(v, e) case *map[bool]string: fastpathTV.EncMapBoolStringV(*v, e) - case map[bool]uint: fastpathTV.EncMapBoolUintV(v, e) case *map[bool]uint: fastpathTV.EncMapBoolUintV(*v, e) - case map[bool]uint8: fastpathTV.EncMapBoolUint8V(v, e) case *map[bool]uint8: fastpathTV.EncMapBoolUint8V(*v, e) - case map[bool]uint16: fastpathTV.EncMapBoolUint16V(v, e) case *map[bool]uint16: fastpathTV.EncMapBoolUint16V(*v, e) - case map[bool]uint32: fastpathTV.EncMapBoolUint32V(v, e) case *map[bool]uint32: fastpathTV.EncMapBoolUint32V(*v, e) - case map[bool]uint64: fastpathTV.EncMapBoolUint64V(v, e) case *map[bool]uint64: fastpathTV.EncMapBoolUint64V(*v, e) - case map[bool]uintptr: fastpathTV.EncMapBoolUintptrV(v, e) case *map[bool]uintptr: fastpathTV.EncMapBoolUintptrV(*v, e) - case map[bool]int: fastpathTV.EncMapBoolIntV(v, e) case *map[bool]int: fastpathTV.EncMapBoolIntV(*v, e) - case map[bool]int8: fastpathTV.EncMapBoolInt8V(v, e) case *map[bool]int8: fastpathTV.EncMapBoolInt8V(*v, e) - case map[bool]int16: fastpathTV.EncMapBoolInt16V(v, e) case *map[bool]int16: fastpathTV.EncMapBoolInt16V(*v, e) - case map[bool]int32: fastpathTV.EncMapBoolInt32V(v, e) case *map[bool]int32: fastpathTV.EncMapBoolInt32V(*v, e) - case map[bool]int64: fastpathTV.EncMapBoolInt64V(v, e) case *map[bool]int64: fastpathTV.EncMapBoolInt64V(*v, e) - case map[bool]float32: fastpathTV.EncMapBoolFloat32V(v, e) case *map[bool]float32: fastpathTV.EncMapBoolFloat32V(*v, e) - case map[bool]float64: fastpathTV.EncMapBoolFloat64V(v, e) case *map[bool]float64: fastpathTV.EncMapBoolFloat64V(*v, e) - case map[bool]bool: fastpathTV.EncMapBoolBoolV(v, e) case *map[bool]bool: fastpathTV.EncMapBoolBoolV(*v, e) default: - _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) + _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 return false } return true @@ -3124,17 +1473,24 @@ func (e *Encoder) fastpathEncSliceIntfR(f *codecFnInfo, rv reflect.Value) { } } func (_ fastpathT) EncSliceIntfV(v []interface{}, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteArrayStart(len(v)) - for _, v2 := range v { - if esep { + if esep { + for _, v2 := range v { ee.WriteArrayElem() + e.encode(v2) + } + } else { + for _, v2 := range v { + e.encode(v2) } - e.encode(v2) } ee.WriteArrayEnd() } - func (_ fastpathT) EncAsMapSliceIntfV(v []interface{}, e *Encoder) { ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { @@ -3142,15 +1498,19 @@ func (_ fastpathT) EncAsMapSliceIntfV(v []interface{}, e *Encoder) { return } ee.WriteMapStart(len(v) / 2) - for j, v2 := range v { - if esep { + if esep { + for j, v2 := range v { if j%2 == 0 { ee.WriteMapElemKey() } else { ee.WriteMapElemValue() } + e.encode(v2) + } + } else { + for _, v2 := range v { + e.encode(v2) } - e.encode(v2) } ee.WriteMapEnd() } @@ -3163,17 +1523,24 @@ func (e *Encoder) fastpathEncSliceStringR(f *codecFnInfo, rv reflect.Value) { } } func (_ fastpathT) EncSliceStringV(v []string, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteArrayStart(len(v)) - for _, v2 := range v { - if esep { + if esep { + for _, v2 := range v { ee.WriteArrayElem() + ee.EncodeString(cUTF8, v2) + } + } else { + for _, v2 := range v { + ee.EncodeString(cUTF8, v2) } - ee.EncodeString(c_UTF8, v2) } ee.WriteArrayEnd() } - func (_ fastpathT) EncAsMapSliceStringV(v []string, e *Encoder) { ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { @@ -3181,15 +1548,19 @@ func (_ fastpathT) EncAsMapSliceStringV(v []string, e *Encoder) { return } ee.WriteMapStart(len(v) / 2) - for j, v2 := range v { - if esep { + if esep { + for j, v2 := range v { if j%2 == 0 { ee.WriteMapElemKey() } else { ee.WriteMapElemValue() } + ee.EncodeString(cUTF8, v2) + } + } else { + for _, v2 := range v { + ee.EncodeString(cUTF8, v2) } - ee.EncodeString(c_UTF8, v2) } ee.WriteMapEnd() } @@ -3202,17 +1573,24 @@ func (e *Encoder) fastpathEncSliceFloat32R(f *codecFnInfo, rv reflect.Value) { } } func (_ fastpathT) EncSliceFloat32V(v []float32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteArrayStart(len(v)) - for _, v2 := range v { - if esep { + if esep { + for _, v2 := range v { ee.WriteArrayElem() + ee.EncodeFloat32(v2) + } + } else { + for _, v2 := range v { + ee.EncodeFloat32(v2) } - ee.EncodeFloat32(v2) } ee.WriteArrayEnd() } - func (_ fastpathT) EncAsMapSliceFloat32V(v []float32, e *Encoder) { ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { @@ -3220,15 +1598,19 @@ func (_ fastpathT) EncAsMapSliceFloat32V(v []float32, e *Encoder) { return } ee.WriteMapStart(len(v) / 2) - for j, v2 := range v { - if esep { + if esep { + for j, v2 := range v { if j%2 == 0 { ee.WriteMapElemKey() } else { ee.WriteMapElemValue() } + ee.EncodeFloat32(v2) + } + } else { + for _, v2 := range v { + ee.EncodeFloat32(v2) } - ee.EncodeFloat32(v2) } ee.WriteMapEnd() } @@ -3241,17 +1623,24 @@ func (e *Encoder) fastpathEncSliceFloat64R(f *codecFnInfo, rv reflect.Value) { } } func (_ fastpathT) EncSliceFloat64V(v []float64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteArrayStart(len(v)) - for _, v2 := range v { - if esep { + if esep { + for _, v2 := range v { ee.WriteArrayElem() + ee.EncodeFloat64(v2) + } + } else { + for _, v2 := range v { + ee.EncodeFloat64(v2) } - ee.EncodeFloat64(v2) } ee.WriteArrayEnd() } - func (_ fastpathT) EncAsMapSliceFloat64V(v []float64, e *Encoder) { ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { @@ -3259,15 +1648,19 @@ func (_ fastpathT) EncAsMapSliceFloat64V(v []float64, e *Encoder) { return } ee.WriteMapStart(len(v) / 2) - for j, v2 := range v { - if esep { + if esep { + for j, v2 := range v { if j%2 == 0 { ee.WriteMapElemKey() } else { ee.WriteMapElemValue() } + ee.EncodeFloat64(v2) + } + } else { + for _, v2 := range v { + ee.EncodeFloat64(v2) } - ee.EncodeFloat64(v2) } ee.WriteMapEnd() } @@ -3280,17 +1673,24 @@ func (e *Encoder) fastpathEncSliceUintR(f *codecFnInfo, rv reflect.Value) { } } func (_ fastpathT) EncSliceUintV(v []uint, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteArrayStart(len(v)) - for _, v2 := range v { - if esep { + if esep { + for _, v2 := range v { ee.WriteArrayElem() + ee.EncodeUint(uint64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } ee.WriteArrayEnd() } - func (_ fastpathT) EncAsMapSliceUintV(v []uint, e *Encoder) { ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { @@ -3298,15 +1698,69 @@ func (_ fastpathT) EncAsMapSliceUintV(v []uint, e *Encoder) { return } ee.WriteMapStart(len(v) / 2) - for j, v2 := range v { - if esep { + if esep { + for j, v2 := range v { + if j%2 == 0 { + ee.WriteMapElemKey() + } else { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +func (e *Encoder) fastpathEncSliceUint8R(f *codecFnInfo, rv reflect.Value) { + if f.ti.mbs { + fastpathTV.EncAsMapSliceUint8V(rv2i(rv).([]uint8), e) + } else { + fastpathTV.EncSliceUint8V(rv2i(rv).([]uint8), e) + } +} +func (_ fastpathT) EncSliceUint8V(v []uint8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } + ee, esep := e.e, e.hh.hasElemSeparators() + ee.WriteArrayStart(len(v)) + if esep { + for _, v2 := range v { + ee.WriteArrayElem() + ee.EncodeUint(uint64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteArrayEnd() +} +func (_ fastpathT) EncAsMapSliceUint8V(v []uint8, e *Encoder) { + ee, esep := e.e, e.hh.hasElemSeparators() + if len(v)%2 == 1 { + e.errorf("mapBySlice requires even slice length, but got %v", len(v)) + return + } + ee.WriteMapStart(len(v) / 2) + if esep { + for j, v2 := range v { if j%2 == 0 { ee.WriteMapElemKey() } else { ee.WriteMapElemValue() } + ee.EncodeUint(uint64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } ee.WriteMapEnd() } @@ -3319,17 +1773,24 @@ func (e *Encoder) fastpathEncSliceUint16R(f *codecFnInfo, rv reflect.Value) { } } func (_ fastpathT) EncSliceUint16V(v []uint16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteArrayStart(len(v)) - for _, v2 := range v { - if esep { + if esep { + for _, v2 := range v { ee.WriteArrayElem() + ee.EncodeUint(uint64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } ee.WriteArrayEnd() } - func (_ fastpathT) EncAsMapSliceUint16V(v []uint16, e *Encoder) { ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { @@ -3337,15 +1798,19 @@ func (_ fastpathT) EncAsMapSliceUint16V(v []uint16, e *Encoder) { return } ee.WriteMapStart(len(v) / 2) - for j, v2 := range v { - if esep { + if esep { + for j, v2 := range v { if j%2 == 0 { ee.WriteMapElemKey() } else { ee.WriteMapElemValue() } + ee.EncodeUint(uint64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } ee.WriteMapEnd() } @@ -3358,17 +1823,24 @@ func (e *Encoder) fastpathEncSliceUint32R(f *codecFnInfo, rv reflect.Value) { } } func (_ fastpathT) EncSliceUint32V(v []uint32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteArrayStart(len(v)) - for _, v2 := range v { - if esep { + if esep { + for _, v2 := range v { ee.WriteArrayElem() + ee.EncodeUint(uint64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } ee.WriteArrayEnd() } - func (_ fastpathT) EncAsMapSliceUint32V(v []uint32, e *Encoder) { ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { @@ -3376,15 +1848,19 @@ func (_ fastpathT) EncAsMapSliceUint32V(v []uint32, e *Encoder) { return } ee.WriteMapStart(len(v) / 2) - for j, v2 := range v { - if esep { + if esep { + for j, v2 := range v { if j%2 == 0 { ee.WriteMapElemKey() } else { ee.WriteMapElemValue() } + ee.EncodeUint(uint64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } ee.WriteMapEnd() } @@ -3397,17 +1873,24 @@ func (e *Encoder) fastpathEncSliceUint64R(f *codecFnInfo, rv reflect.Value) { } } func (_ fastpathT) EncSliceUint64V(v []uint64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteArrayStart(len(v)) - for _, v2 := range v { - if esep { + if esep { + for _, v2 := range v { ee.WriteArrayElem() + ee.EncodeUint(uint64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } ee.WriteArrayEnd() } - func (_ fastpathT) EncAsMapSliceUint64V(v []uint64, e *Encoder) { ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { @@ -3415,15 +1898,19 @@ func (_ fastpathT) EncAsMapSliceUint64V(v []uint64, e *Encoder) { return } ee.WriteMapStart(len(v) / 2) - for j, v2 := range v { - if esep { + if esep { + for j, v2 := range v { if j%2 == 0 { ee.WriteMapElemKey() } else { ee.WriteMapElemValue() } + ee.EncodeUint(uint64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } ee.WriteMapEnd() } @@ -3436,17 +1923,24 @@ func (e *Encoder) fastpathEncSliceUintptrR(f *codecFnInfo, rv reflect.Value) { } } func (_ fastpathT) EncSliceUintptrV(v []uintptr, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteArrayStart(len(v)) - for _, v2 := range v { - if esep { + if esep { + for _, v2 := range v { ee.WriteArrayElem() + e.encode(v2) + } + } else { + for _, v2 := range v { + e.encode(v2) } - e.encode(v2) } ee.WriteArrayEnd() } - func (_ fastpathT) EncAsMapSliceUintptrV(v []uintptr, e *Encoder) { ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { @@ -3454,15 +1948,19 @@ func (_ fastpathT) EncAsMapSliceUintptrV(v []uintptr, e *Encoder) { return } ee.WriteMapStart(len(v) / 2) - for j, v2 := range v { - if esep { + if esep { + for j, v2 := range v { if j%2 == 0 { ee.WriteMapElemKey() } else { ee.WriteMapElemValue() } + e.encode(v2) + } + } else { + for _, v2 := range v { + e.encode(v2) } - e.encode(v2) } ee.WriteMapEnd() } @@ -3475,17 +1973,24 @@ func (e *Encoder) fastpathEncSliceIntR(f *codecFnInfo, rv reflect.Value) { } } func (_ fastpathT) EncSliceIntV(v []int, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteArrayStart(len(v)) - for _, v2 := range v { - if esep { + if esep { + for _, v2 := range v { ee.WriteArrayElem() + ee.EncodeInt(int64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } ee.WriteArrayEnd() } - func (_ fastpathT) EncAsMapSliceIntV(v []int, e *Encoder) { ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { @@ -3493,15 +1998,19 @@ func (_ fastpathT) EncAsMapSliceIntV(v []int, e *Encoder) { return } ee.WriteMapStart(len(v) / 2) - for j, v2 := range v { - if esep { + if esep { + for j, v2 := range v { if j%2 == 0 { ee.WriteMapElemKey() } else { ee.WriteMapElemValue() } + ee.EncodeInt(int64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } ee.WriteMapEnd() } @@ -3514,17 +2023,24 @@ func (e *Encoder) fastpathEncSliceInt8R(f *codecFnInfo, rv reflect.Value) { } } func (_ fastpathT) EncSliceInt8V(v []int8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteArrayStart(len(v)) - for _, v2 := range v { - if esep { + if esep { + for _, v2 := range v { ee.WriteArrayElem() + ee.EncodeInt(int64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } ee.WriteArrayEnd() } - func (_ fastpathT) EncAsMapSliceInt8V(v []int8, e *Encoder) { ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { @@ -3532,15 +2048,19 @@ func (_ fastpathT) EncAsMapSliceInt8V(v []int8, e *Encoder) { return } ee.WriteMapStart(len(v) / 2) - for j, v2 := range v { - if esep { + if esep { + for j, v2 := range v { if j%2 == 0 { ee.WriteMapElemKey() } else { ee.WriteMapElemValue() } + ee.EncodeInt(int64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } ee.WriteMapEnd() } @@ -3553,17 +2073,24 @@ func (e *Encoder) fastpathEncSliceInt16R(f *codecFnInfo, rv reflect.Value) { } } func (_ fastpathT) EncSliceInt16V(v []int16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteArrayStart(len(v)) - for _, v2 := range v { - if esep { + if esep { + for _, v2 := range v { ee.WriteArrayElem() + ee.EncodeInt(int64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } ee.WriteArrayEnd() } - func (_ fastpathT) EncAsMapSliceInt16V(v []int16, e *Encoder) { ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { @@ -3571,15 +2098,19 @@ func (_ fastpathT) EncAsMapSliceInt16V(v []int16, e *Encoder) { return } ee.WriteMapStart(len(v) / 2) - for j, v2 := range v { - if esep { + if esep { + for j, v2 := range v { if j%2 == 0 { ee.WriteMapElemKey() } else { ee.WriteMapElemValue() } + ee.EncodeInt(int64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } ee.WriteMapEnd() } @@ -3592,17 +2123,24 @@ func (e *Encoder) fastpathEncSliceInt32R(f *codecFnInfo, rv reflect.Value) { } } func (_ fastpathT) EncSliceInt32V(v []int32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteArrayStart(len(v)) - for _, v2 := range v { - if esep { + if esep { + for _, v2 := range v { ee.WriteArrayElem() + ee.EncodeInt(int64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } ee.WriteArrayEnd() } - func (_ fastpathT) EncAsMapSliceInt32V(v []int32, e *Encoder) { ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { @@ -3610,15 +2148,19 @@ func (_ fastpathT) EncAsMapSliceInt32V(v []int32, e *Encoder) { return } ee.WriteMapStart(len(v) / 2) - for j, v2 := range v { - if esep { + if esep { + for j, v2 := range v { if j%2 == 0 { ee.WriteMapElemKey() } else { ee.WriteMapElemValue() } + ee.EncodeInt(int64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } ee.WriteMapEnd() } @@ -3631,17 +2173,24 @@ func (e *Encoder) fastpathEncSliceInt64R(f *codecFnInfo, rv reflect.Value) { } } func (_ fastpathT) EncSliceInt64V(v []int64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteArrayStart(len(v)) - for _, v2 := range v { - if esep { + if esep { + for _, v2 := range v { ee.WriteArrayElem() + ee.EncodeInt(int64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } ee.WriteArrayEnd() } - func (_ fastpathT) EncAsMapSliceInt64V(v []int64, e *Encoder) { ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { @@ -3649,15 +2198,19 @@ func (_ fastpathT) EncAsMapSliceInt64V(v []int64, e *Encoder) { return } ee.WriteMapStart(len(v) / 2) - for j, v2 := range v { - if esep { + if esep { + for j, v2 := range v { if j%2 == 0 { ee.WriteMapElemKey() } else { ee.WriteMapElemValue() } + ee.EncodeInt(int64(v2)) + } + } else { + for _, v2 := range v { + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } ee.WriteMapEnd() } @@ -3670,17 +2223,24 @@ func (e *Encoder) fastpathEncSliceBoolR(f *codecFnInfo, rv reflect.Value) { } } func (_ fastpathT) EncSliceBoolV(v []bool, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteArrayStart(len(v)) - for _, v2 := range v { - if esep { + if esep { + for _, v2 := range v { ee.WriteArrayElem() + ee.EncodeBool(v2) + } + } else { + for _, v2 := range v { + ee.EncodeBool(v2) } - ee.EncodeBool(v2) } ee.WriteArrayEnd() } - func (_ fastpathT) EncAsMapSliceBoolV(v []bool, e *Encoder) { ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { @@ -3688,15 +2248,19 @@ func (_ fastpathT) EncAsMapSliceBoolV(v []bool, e *Encoder) { return } ee.WriteMapStart(len(v) / 2) - for j, v2 := range v { - if esep { + if esep { + for j, v2 := range v { if j%2 == 0 { ee.WriteMapElemKey() } else { ee.WriteMapElemValue() } + ee.EncodeBool(v2) + } + } else { + for _, v2 := range v { + ee.EncodeBool(v2) } - ee.EncodeBool(v2) } ee.WriteMapEnd() } @@ -3705,6 +2269,10 @@ func (e *Encoder) fastpathEncMapIntfIntfR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntfIntfV(rv2i(rv).(map[interface{}]interface{}), e) } func (_ fastpathT) EncMapIntfIntfV(v map[interface{}]interface{}, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -3722,26 +2290,32 @@ func (_ fastpathT) EncMapIntfIntfV(v map[interface{}]interface{}, e *Encoder) { i++ } sort.Sort(bytesISlice(v2)) - for j := range v2 { - if esep { + if esep { + for j := range v2 { ee.WriteMapElemKey() - } - e.asis(v2[j].v) - if esep { + e.asis(v2[j].v) ee.WriteMapElemValue() + e.encode(v[v2[j].i]) + } + } else { + for j := range v2 { + e.asis(v2[j].v) + e.encode(v[v2[j].i]) } - e.encode(v[v2[j].i]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + e.encode(k2) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -3751,6 +2325,10 @@ func (e *Encoder) fastpathEncMapIntfStringR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntfStringV(rv2i(rv).(map[interface{}]string), e) } func (_ fastpathT) EncMapIntfStringV(v map[interface{}]string, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -3768,26 +2346,32 @@ func (_ fastpathT) EncMapIntfStringV(v map[interface{}]string, e *Encoder) { i++ } sort.Sort(bytesISlice(v2)) - for j := range v2 { - if esep { + if esep { + for j := range v2 { ee.WriteMapElemKey() - } - e.asis(v2[j].v) - if esep { + e.asis(v2[j].v) ee.WriteMapElemValue() + e.encode(v[v2[j].i]) + } + } else { + for j := range v2 { + e.asis(v2[j].v) + e.encode(v[v2[j].i]) } - e.encode(v[v2[j].i]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v2) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeString(cUTF8, v2) } - ee.EncodeString(c_UTF8, v2) } } ee.WriteMapEnd() @@ -3797,6 +2381,10 @@ func (e *Encoder) fastpathEncMapIntfUintR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntfUintV(rv2i(rv).(map[interface{}]uint), e) } func (_ fastpathT) EncMapIntfUintV(v map[interface{}]uint, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -3814,26 +2402,32 @@ func (_ fastpathT) EncMapIntfUintV(v map[interface{}]uint, e *Encoder) { i++ } sort.Sort(bytesISlice(v2)) - for j := range v2 { - if esep { + if esep { + for j := range v2 { ee.WriteMapElemKey() - } - e.asis(v2[j].v) - if esep { + e.asis(v2[j].v) ee.WriteMapElemValue() + e.encode(v[v2[j].i]) + } + } else { + for j := range v2 { + e.asis(v2[j].v) + e.encode(v[v2[j].i]) } - e.encode(v[v2[j].i]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -3843,6 +2437,10 @@ func (e *Encoder) fastpathEncMapIntfUint8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntfUint8V(rv2i(rv).(map[interface{}]uint8), e) } func (_ fastpathT) EncMapIntfUint8V(v map[interface{}]uint8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -3860,26 +2458,32 @@ func (_ fastpathT) EncMapIntfUint8V(v map[interface{}]uint8, e *Encoder) { i++ } sort.Sort(bytesISlice(v2)) - for j := range v2 { - if esep { + if esep { + for j := range v2 { ee.WriteMapElemKey() - } - e.asis(v2[j].v) - if esep { + e.asis(v2[j].v) ee.WriteMapElemValue() + e.encode(v[v2[j].i]) + } + } else { + for j := range v2 { + e.asis(v2[j].v) + e.encode(v[v2[j].i]) } - e.encode(v[v2[j].i]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -3889,6 +2493,10 @@ func (e *Encoder) fastpathEncMapIntfUint16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntfUint16V(rv2i(rv).(map[interface{}]uint16), e) } func (_ fastpathT) EncMapIntfUint16V(v map[interface{}]uint16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -3906,26 +2514,32 @@ func (_ fastpathT) EncMapIntfUint16V(v map[interface{}]uint16, e *Encoder) { i++ } sort.Sort(bytesISlice(v2)) - for j := range v2 { - if esep { + if esep { + for j := range v2 { ee.WriteMapElemKey() - } - e.asis(v2[j].v) - if esep { + e.asis(v2[j].v) ee.WriteMapElemValue() + e.encode(v[v2[j].i]) + } + } else { + for j := range v2 { + e.asis(v2[j].v) + e.encode(v[v2[j].i]) } - e.encode(v[v2[j].i]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -3935,6 +2549,10 @@ func (e *Encoder) fastpathEncMapIntfUint32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntfUint32V(rv2i(rv).(map[interface{}]uint32), e) } func (_ fastpathT) EncMapIntfUint32V(v map[interface{}]uint32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -3952,26 +2570,32 @@ func (_ fastpathT) EncMapIntfUint32V(v map[interface{}]uint32, e *Encoder) { i++ } sort.Sort(bytesISlice(v2)) - for j := range v2 { - if esep { + if esep { + for j := range v2 { ee.WriteMapElemKey() - } - e.asis(v2[j].v) - if esep { + e.asis(v2[j].v) ee.WriteMapElemValue() + e.encode(v[v2[j].i]) + } + } else { + for j := range v2 { + e.asis(v2[j].v) + e.encode(v[v2[j].i]) } - e.encode(v[v2[j].i]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -3981,6 +2605,10 @@ func (e *Encoder) fastpathEncMapIntfUint64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntfUint64V(rv2i(rv).(map[interface{}]uint64), e) } func (_ fastpathT) EncMapIntfUint64V(v map[interface{}]uint64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -3998,26 +2626,32 @@ func (_ fastpathT) EncMapIntfUint64V(v map[interface{}]uint64, e *Encoder) { i++ } sort.Sort(bytesISlice(v2)) - for j := range v2 { - if esep { + if esep { + for j := range v2 { ee.WriteMapElemKey() - } - e.asis(v2[j].v) - if esep { + e.asis(v2[j].v) ee.WriteMapElemValue() + e.encode(v[v2[j].i]) + } + } else { + for j := range v2 { + e.asis(v2[j].v) + e.encode(v[v2[j].i]) } - e.encode(v[v2[j].i]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -4027,6 +2661,10 @@ func (e *Encoder) fastpathEncMapIntfUintptrR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntfUintptrV(rv2i(rv).(map[interface{}]uintptr), e) } func (_ fastpathT) EncMapIntfUintptrV(v map[interface{}]uintptr, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -4044,26 +2682,32 @@ func (_ fastpathT) EncMapIntfUintptrV(v map[interface{}]uintptr, e *Encoder) { i++ } sort.Sort(bytesISlice(v2)) - for j := range v2 { - if esep { + if esep { + for j := range v2 { ee.WriteMapElemKey() - } - e.asis(v2[j].v) - if esep { + e.asis(v2[j].v) ee.WriteMapElemValue() + e.encode(v[v2[j].i]) + } + } else { + for j := range v2 { + e.asis(v2[j].v) + e.encode(v[v2[j].i]) } - e.encode(v[v2[j].i]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + e.encode(k2) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -4073,6 +2717,10 @@ func (e *Encoder) fastpathEncMapIntfIntR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntfIntV(rv2i(rv).(map[interface{}]int), e) } func (_ fastpathT) EncMapIntfIntV(v map[interface{}]int, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -4090,26 +2738,32 @@ func (_ fastpathT) EncMapIntfIntV(v map[interface{}]int, e *Encoder) { i++ } sort.Sort(bytesISlice(v2)) - for j := range v2 { - if esep { + if esep { + for j := range v2 { ee.WriteMapElemKey() - } - e.asis(v2[j].v) - if esep { + e.asis(v2[j].v) ee.WriteMapElemValue() + e.encode(v[v2[j].i]) + } + } else { + for j := range v2 { + e.asis(v2[j].v) + e.encode(v[v2[j].i]) } - e.encode(v[v2[j].i]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -4119,6 +2773,10 @@ func (e *Encoder) fastpathEncMapIntfInt8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntfInt8V(rv2i(rv).(map[interface{}]int8), e) } func (_ fastpathT) EncMapIntfInt8V(v map[interface{}]int8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -4136,26 +2794,32 @@ func (_ fastpathT) EncMapIntfInt8V(v map[interface{}]int8, e *Encoder) { i++ } sort.Sort(bytesISlice(v2)) - for j := range v2 { - if esep { + if esep { + for j := range v2 { ee.WriteMapElemKey() - } - e.asis(v2[j].v) - if esep { + e.asis(v2[j].v) ee.WriteMapElemValue() + e.encode(v[v2[j].i]) + } + } else { + for j := range v2 { + e.asis(v2[j].v) + e.encode(v[v2[j].i]) } - e.encode(v[v2[j].i]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -4165,6 +2829,10 @@ func (e *Encoder) fastpathEncMapIntfInt16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntfInt16V(rv2i(rv).(map[interface{}]int16), e) } func (_ fastpathT) EncMapIntfInt16V(v map[interface{}]int16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -4182,26 +2850,32 @@ func (_ fastpathT) EncMapIntfInt16V(v map[interface{}]int16, e *Encoder) { i++ } sort.Sort(bytesISlice(v2)) - for j := range v2 { - if esep { + if esep { + for j := range v2 { ee.WriteMapElemKey() - } - e.asis(v2[j].v) - if esep { + e.asis(v2[j].v) ee.WriteMapElemValue() + e.encode(v[v2[j].i]) + } + } else { + for j := range v2 { + e.asis(v2[j].v) + e.encode(v[v2[j].i]) } - e.encode(v[v2[j].i]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -4211,6 +2885,10 @@ func (e *Encoder) fastpathEncMapIntfInt32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntfInt32V(rv2i(rv).(map[interface{}]int32), e) } func (_ fastpathT) EncMapIntfInt32V(v map[interface{}]int32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -4228,26 +2906,32 @@ func (_ fastpathT) EncMapIntfInt32V(v map[interface{}]int32, e *Encoder) { i++ } sort.Sort(bytesISlice(v2)) - for j := range v2 { - if esep { + if esep { + for j := range v2 { ee.WriteMapElemKey() - } - e.asis(v2[j].v) - if esep { + e.asis(v2[j].v) ee.WriteMapElemValue() + e.encode(v[v2[j].i]) + } + } else { + for j := range v2 { + e.asis(v2[j].v) + e.encode(v[v2[j].i]) } - e.encode(v[v2[j].i]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -4257,6 +2941,10 @@ func (e *Encoder) fastpathEncMapIntfInt64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntfInt64V(rv2i(rv).(map[interface{}]int64), e) } func (_ fastpathT) EncMapIntfInt64V(v map[interface{}]int64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -4274,26 +2962,32 @@ func (_ fastpathT) EncMapIntfInt64V(v map[interface{}]int64, e *Encoder) { i++ } sort.Sort(bytesISlice(v2)) - for j := range v2 { - if esep { + if esep { + for j := range v2 { ee.WriteMapElemKey() - } - e.asis(v2[j].v) - if esep { + e.asis(v2[j].v) ee.WriteMapElemValue() + e.encode(v[v2[j].i]) + } + } else { + for j := range v2 { + e.asis(v2[j].v) + e.encode(v[v2[j].i]) } - e.encode(v[v2[j].i]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -4303,6 +2997,10 @@ func (e *Encoder) fastpathEncMapIntfFloat32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntfFloat32V(rv2i(rv).(map[interface{}]float32), e) } func (_ fastpathT) EncMapIntfFloat32V(v map[interface{}]float32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -4320,26 +3018,32 @@ func (_ fastpathT) EncMapIntfFloat32V(v map[interface{}]float32, e *Encoder) { i++ } sort.Sort(bytesISlice(v2)) - for j := range v2 { - if esep { + if esep { + for j := range v2 { ee.WriteMapElemKey() - } - e.asis(v2[j].v) - if esep { + e.asis(v2[j].v) ee.WriteMapElemValue() + e.encode(v[v2[j].i]) + } + } else { + for j := range v2 { + e.asis(v2[j].v) + e.encode(v[v2[j].i]) } - e.encode(v[v2[j].i]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeFloat32(v2) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeFloat32(v2) } - ee.EncodeFloat32(v2) } } ee.WriteMapEnd() @@ -4349,6 +3053,10 @@ func (e *Encoder) fastpathEncMapIntfFloat64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntfFloat64V(rv2i(rv).(map[interface{}]float64), e) } func (_ fastpathT) EncMapIntfFloat64V(v map[interface{}]float64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -4366,26 +3074,32 @@ func (_ fastpathT) EncMapIntfFloat64V(v map[interface{}]float64, e *Encoder) { i++ } sort.Sort(bytesISlice(v2)) - for j := range v2 { - if esep { + if esep { + for j := range v2 { ee.WriteMapElemKey() - } - e.asis(v2[j].v) - if esep { + e.asis(v2[j].v) ee.WriteMapElemValue() + e.encode(v[v2[j].i]) + } + } else { + for j := range v2 { + e.asis(v2[j].v) + e.encode(v[v2[j].i]) } - e.encode(v[v2[j].i]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeFloat64(v2) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeFloat64(v2) } - ee.EncodeFloat64(v2) } } ee.WriteMapEnd() @@ -4395,6 +3109,10 @@ func (e *Encoder) fastpathEncMapIntfBoolR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntfBoolV(rv2i(rv).(map[interface{}]bool), e) } func (_ fastpathT) EncMapIntfBoolV(v map[interface{}]bool, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -4412,26 +3130,32 @@ func (_ fastpathT) EncMapIntfBoolV(v map[interface{}]bool, e *Encoder) { i++ } sort.Sort(bytesISlice(v2)) - for j := range v2 { - if esep { + if esep { + for j := range v2 { ee.WriteMapElemKey() - } - e.asis(v2[j].v) - if esep { + e.asis(v2[j].v) ee.WriteMapElemValue() + e.encode(v[v2[j].i]) + } + } else { + for j := range v2 { + e.asis(v2[j].v) + e.encode(v[v2[j].i]) } - e.encode(v[v2[j].i]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeBool(v2) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeBool(v2) } - ee.EncodeBool(v2) } } ee.WriteMapEnd() @@ -4441,9 +3165,12 @@ func (e *Encoder) fastpathEncMapStringIntfR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapStringIntfV(rv2i(rv).(map[string]interface{}), e) } func (_ fastpathT) EncMapStringIntfV(v map[string]interface{}, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) - asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 if e.h.Canonical { v2 := make([]string, len(v)) var i int @@ -4452,34 +3179,32 @@ func (_ fastpathT) EncMapStringIntfV(v map[string]interface{}, e *Encoder) { i++ } sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + e.encode(v[string(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeString(cUTF8, k2) + e.encode(v[string(k2)]) } - e.encode(v[string(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeString(cUTF8, k2) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -4489,9 +3214,12 @@ func (e *Encoder) fastpathEncMapStringStringR(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapStringStringV(rv2i(rv).(map[string]string), e) } func (_ fastpathT) EncMapStringStringV(v map[string]string, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) - asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 if e.h.Canonical { v2 := make([]string, len(v)) var i int @@ -4500,34 +3228,32 @@ func (_ fastpathT) EncMapStringStringV(v map[string]string, e *Encoder) { i++ } sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v[string(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeString(cUTF8, k2) + ee.EncodeString(cUTF8, v[string(k2)]) } - ee.EncodeString(c_UTF8, v[string(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v2) + } + } else { + for k2, v2 := range v { + ee.EncodeString(cUTF8, k2) + ee.EncodeString(cUTF8, v2) } - ee.EncodeString(c_UTF8, v2) } } ee.WriteMapEnd() @@ -4537,9 +3263,12 @@ func (e *Encoder) fastpathEncMapStringUintR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapStringUintV(rv2i(rv).(map[string]uint), e) } func (_ fastpathT) EncMapStringUintV(v map[string]uint, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) - asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 if e.h.Canonical { v2 := make([]string, len(v)) var i int @@ -4548,34 +3277,32 @@ func (_ fastpathT) EncMapStringUintV(v map[string]uint, e *Encoder) { i++ } sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[string(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeString(cUTF8, k2) + ee.EncodeUint(uint64(v[string(k2)])) } - ee.EncodeUint(uint64(v[string(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeString(cUTF8, k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -4585,9 +3312,12 @@ func (e *Encoder) fastpathEncMapStringUint8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapStringUint8V(rv2i(rv).(map[string]uint8), e) } func (_ fastpathT) EncMapStringUint8V(v map[string]uint8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) - asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 if e.h.Canonical { v2 := make([]string, len(v)) var i int @@ -4596,34 +3326,32 @@ func (_ fastpathT) EncMapStringUint8V(v map[string]uint8, e *Encoder) { i++ } sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[string(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeString(cUTF8, k2) + ee.EncodeUint(uint64(v[string(k2)])) } - ee.EncodeUint(uint64(v[string(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeString(cUTF8, k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -4633,9 +3361,12 @@ func (e *Encoder) fastpathEncMapStringUint16R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapStringUint16V(rv2i(rv).(map[string]uint16), e) } func (_ fastpathT) EncMapStringUint16V(v map[string]uint16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) - asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 if e.h.Canonical { v2 := make([]string, len(v)) var i int @@ -4644,34 +3375,32 @@ func (_ fastpathT) EncMapStringUint16V(v map[string]uint16, e *Encoder) { i++ } sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[string(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeString(cUTF8, k2) + ee.EncodeUint(uint64(v[string(k2)])) } - ee.EncodeUint(uint64(v[string(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeString(cUTF8, k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -4681,9 +3410,12 @@ func (e *Encoder) fastpathEncMapStringUint32R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapStringUint32V(rv2i(rv).(map[string]uint32), e) } func (_ fastpathT) EncMapStringUint32V(v map[string]uint32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) - asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 if e.h.Canonical { v2 := make([]string, len(v)) var i int @@ -4692,34 +3424,32 @@ func (_ fastpathT) EncMapStringUint32V(v map[string]uint32, e *Encoder) { i++ } sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[string(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeString(cUTF8, k2) + ee.EncodeUint(uint64(v[string(k2)])) } - ee.EncodeUint(uint64(v[string(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeString(cUTF8, k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -4729,9 +3459,12 @@ func (e *Encoder) fastpathEncMapStringUint64R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapStringUint64V(rv2i(rv).(map[string]uint64), e) } func (_ fastpathT) EncMapStringUint64V(v map[string]uint64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) - asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 if e.h.Canonical { v2 := make([]string, len(v)) var i int @@ -4740,34 +3473,32 @@ func (_ fastpathT) EncMapStringUint64V(v map[string]uint64, e *Encoder) { i++ } sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[string(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeString(cUTF8, k2) + ee.EncodeUint(uint64(v[string(k2)])) } - ee.EncodeUint(uint64(v[string(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeString(cUTF8, k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -4777,9 +3508,12 @@ func (e *Encoder) fastpathEncMapStringUintptrR(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapStringUintptrV(rv2i(rv).(map[string]uintptr), e) } func (_ fastpathT) EncMapStringUintptrV(v map[string]uintptr, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) - asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 if e.h.Canonical { v2 := make([]string, len(v)) var i int @@ -4788,34 +3522,32 @@ func (_ fastpathT) EncMapStringUintptrV(v map[string]uintptr, e *Encoder) { i++ } sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + e.encode(v[string(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeString(cUTF8, k2) + e.encode(v[string(k2)]) } - e.encode(v[string(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeString(cUTF8, k2) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -4825,9 +3557,12 @@ func (e *Encoder) fastpathEncMapStringIntR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapStringIntV(rv2i(rv).(map[string]int), e) } func (_ fastpathT) EncMapStringIntV(v map[string]int, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) - asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 if e.h.Canonical { v2 := make([]string, len(v)) var i int @@ -4836,34 +3571,32 @@ func (_ fastpathT) EncMapStringIntV(v map[string]int, e *Encoder) { i++ } sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[string(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeString(cUTF8, k2) + ee.EncodeInt(int64(v[string(k2)])) } - ee.EncodeInt(int64(v[string(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeString(cUTF8, k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -4873,9 +3606,12 @@ func (e *Encoder) fastpathEncMapStringInt8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapStringInt8V(rv2i(rv).(map[string]int8), e) } func (_ fastpathT) EncMapStringInt8V(v map[string]int8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) - asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 if e.h.Canonical { v2 := make([]string, len(v)) var i int @@ -4884,34 +3620,32 @@ func (_ fastpathT) EncMapStringInt8V(v map[string]int8, e *Encoder) { i++ } sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[string(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeString(cUTF8, k2) + ee.EncodeInt(int64(v[string(k2)])) } - ee.EncodeInt(int64(v[string(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeString(cUTF8, k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -4921,9 +3655,12 @@ func (e *Encoder) fastpathEncMapStringInt16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapStringInt16V(rv2i(rv).(map[string]int16), e) } func (_ fastpathT) EncMapStringInt16V(v map[string]int16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) - asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 if e.h.Canonical { v2 := make([]string, len(v)) var i int @@ -4932,34 +3669,32 @@ func (_ fastpathT) EncMapStringInt16V(v map[string]int16, e *Encoder) { i++ } sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[string(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeString(cUTF8, k2) + ee.EncodeInt(int64(v[string(k2)])) } - ee.EncodeInt(int64(v[string(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeString(cUTF8, k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -4969,9 +3704,12 @@ func (e *Encoder) fastpathEncMapStringInt32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapStringInt32V(rv2i(rv).(map[string]int32), e) } func (_ fastpathT) EncMapStringInt32V(v map[string]int32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) - asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 if e.h.Canonical { v2 := make([]string, len(v)) var i int @@ -4980,34 +3718,32 @@ func (_ fastpathT) EncMapStringInt32V(v map[string]int32, e *Encoder) { i++ } sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[string(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeString(cUTF8, k2) + ee.EncodeInt(int64(v[string(k2)])) } - ee.EncodeInt(int64(v[string(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeString(cUTF8, k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -5017,9 +3753,12 @@ func (e *Encoder) fastpathEncMapStringInt64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapStringInt64V(rv2i(rv).(map[string]int64), e) } func (_ fastpathT) EncMapStringInt64V(v map[string]int64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) - asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 if e.h.Canonical { v2 := make([]string, len(v)) var i int @@ -5028,34 +3767,32 @@ func (_ fastpathT) EncMapStringInt64V(v map[string]int64, e *Encoder) { i++ } sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[string(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeString(cUTF8, k2) + ee.EncodeInt(int64(v[string(k2)])) } - ee.EncodeInt(int64(v[string(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeString(cUTF8, k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -5065,9 +3802,12 @@ func (e *Encoder) fastpathEncMapStringFloat32R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapStringFloat32V(rv2i(rv).(map[string]float32), e) } func (_ fastpathT) EncMapStringFloat32V(v map[string]float32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) - asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 if e.h.Canonical { v2 := make([]string, len(v)) var i int @@ -5076,34 +3816,32 @@ func (_ fastpathT) EncMapStringFloat32V(v map[string]float32, e *Encoder) { i++ } sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeFloat32(v[string(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeString(cUTF8, k2) + ee.EncodeFloat32(v[string(k2)]) } - ee.EncodeFloat32(v[string(k2)]) } } else { - for k2, v2 := range v { - if esep { - ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + if esep { + for k2, v2 := range v { + ee.WriteMapElemKey() + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeFloat32(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeString(cUTF8, k2) + ee.EncodeFloat32(v2) } - ee.EncodeFloat32(v2) } } ee.WriteMapEnd() @@ -5113,9 +3851,12 @@ func (e *Encoder) fastpathEncMapStringFloat64R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapStringFloat64V(rv2i(rv).(map[string]float64), e) } func (_ fastpathT) EncMapStringFloat64V(v map[string]float64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) - asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 if e.h.Canonical { v2 := make([]string, len(v)) var i int @@ -5124,34 +3865,32 @@ func (_ fastpathT) EncMapStringFloat64V(v map[string]float64, e *Encoder) { i++ } sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeFloat64(v[string(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeString(cUTF8, k2) + ee.EncodeFloat64(v[string(k2)]) } - ee.EncodeFloat64(v[string(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeFloat64(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeString(cUTF8, k2) + ee.EncodeFloat64(v2) } - ee.EncodeFloat64(v2) } } ee.WriteMapEnd() @@ -5161,9 +3900,12 @@ func (e *Encoder) fastpathEncMapStringBoolR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapStringBoolV(rv2i(rv).(map[string]bool), e) } func (_ fastpathT) EncMapStringBoolV(v map[string]bool, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) - asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 if e.h.Canonical { v2 := make([]string, len(v)) var i int @@ -5172,34 +3914,32 @@ func (_ fastpathT) EncMapStringBoolV(v map[string]bool, e *Encoder) { i++ } sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeBool(v[string(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeString(cUTF8, k2) + ee.EncodeBool(v[string(k2)]) } - ee.EncodeBool(v[string(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - } - if esep { + ee.EncodeString(cUTF8, k2) ee.WriteMapElemValue() + ee.EncodeBool(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeString(cUTF8, k2) + ee.EncodeBool(v2) } - ee.EncodeBool(v2) } } ee.WriteMapEnd() @@ -5209,6 +3949,10 @@ func (e *Encoder) fastpathEncMapFloat32IntfR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapFloat32IntfV(rv2i(rv).(map[float32]interface{}), e) } func (_ fastpathT) EncMapFloat32IntfV(v map[float32]interface{}, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5219,26 +3963,32 @@ func (_ fastpathT) EncMapFloat32IntfV(v map[float32]interface{}, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat32(float32(k2)) - if esep { + ee.EncodeFloat32(float32(k2)) ee.WriteMapElemValue() + e.encode(v[float32(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat32(float32(k2)) + e.encode(v[float32(k2)]) } - e.encode(v[float32(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat32(k2) - if esep { + ee.EncodeFloat32(k2) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat32(k2) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -5248,6 +3998,10 @@ func (e *Encoder) fastpathEncMapFloat32StringR(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapFloat32StringV(rv2i(rv).(map[float32]string), e) } func (_ fastpathT) EncMapFloat32StringV(v map[float32]string, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5258,26 +4012,32 @@ func (_ fastpathT) EncMapFloat32StringV(v map[float32]string, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat32(float32(k2)) - if esep { + ee.EncodeFloat32(float32(k2)) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v[float32(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat32(float32(k2)) + ee.EncodeString(cUTF8, v[float32(k2)]) } - ee.EncodeString(c_UTF8, v[float32(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat32(k2) - if esep { + ee.EncodeFloat32(k2) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v2) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat32(k2) + ee.EncodeString(cUTF8, v2) } - ee.EncodeString(c_UTF8, v2) } } ee.WriteMapEnd() @@ -5287,6 +4047,10 @@ func (e *Encoder) fastpathEncMapFloat32UintR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapFloat32UintV(rv2i(rv).(map[float32]uint), e) } func (_ fastpathT) EncMapFloat32UintV(v map[float32]uint, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5297,26 +4061,32 @@ func (_ fastpathT) EncMapFloat32UintV(v map[float32]uint, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat32(float32(k2)) - if esep { + ee.EncodeFloat32(float32(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[float32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat32(float32(k2)) + ee.EncodeUint(uint64(v[float32(k2)])) } - ee.EncodeUint(uint64(v[float32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat32(k2) - if esep { + ee.EncodeFloat32(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat32(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -5326,6 +4096,10 @@ func (e *Encoder) fastpathEncMapFloat32Uint8R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapFloat32Uint8V(rv2i(rv).(map[float32]uint8), e) } func (_ fastpathT) EncMapFloat32Uint8V(v map[float32]uint8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5336,26 +4110,32 @@ func (_ fastpathT) EncMapFloat32Uint8V(v map[float32]uint8, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat32(float32(k2)) - if esep { + ee.EncodeFloat32(float32(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[float32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat32(float32(k2)) + ee.EncodeUint(uint64(v[float32(k2)])) } - ee.EncodeUint(uint64(v[float32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat32(k2) - if esep { + ee.EncodeFloat32(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat32(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -5365,6 +4145,10 @@ func (e *Encoder) fastpathEncMapFloat32Uint16R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapFloat32Uint16V(rv2i(rv).(map[float32]uint16), e) } func (_ fastpathT) EncMapFloat32Uint16V(v map[float32]uint16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5375,26 +4159,32 @@ func (_ fastpathT) EncMapFloat32Uint16V(v map[float32]uint16, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat32(float32(k2)) - if esep { + ee.EncodeFloat32(float32(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[float32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat32(float32(k2)) + ee.EncodeUint(uint64(v[float32(k2)])) } - ee.EncodeUint(uint64(v[float32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat32(k2) - if esep { + ee.EncodeFloat32(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat32(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -5404,6 +4194,10 @@ func (e *Encoder) fastpathEncMapFloat32Uint32R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapFloat32Uint32V(rv2i(rv).(map[float32]uint32), e) } func (_ fastpathT) EncMapFloat32Uint32V(v map[float32]uint32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5414,26 +4208,32 @@ func (_ fastpathT) EncMapFloat32Uint32V(v map[float32]uint32, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat32(float32(k2)) - if esep { + ee.EncodeFloat32(float32(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[float32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat32(float32(k2)) + ee.EncodeUint(uint64(v[float32(k2)])) } - ee.EncodeUint(uint64(v[float32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat32(k2) - if esep { + ee.EncodeFloat32(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat32(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -5443,6 +4243,10 @@ func (e *Encoder) fastpathEncMapFloat32Uint64R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapFloat32Uint64V(rv2i(rv).(map[float32]uint64), e) } func (_ fastpathT) EncMapFloat32Uint64V(v map[float32]uint64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5453,26 +4257,32 @@ func (_ fastpathT) EncMapFloat32Uint64V(v map[float32]uint64, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat32(float32(k2)) - if esep { + ee.EncodeFloat32(float32(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[float32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat32(float32(k2)) + ee.EncodeUint(uint64(v[float32(k2)])) } - ee.EncodeUint(uint64(v[float32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat32(k2) - if esep { + ee.EncodeFloat32(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat32(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -5482,6 +4292,10 @@ func (e *Encoder) fastpathEncMapFloat32UintptrR(f *codecFnInfo, rv reflect.Value fastpathTV.EncMapFloat32UintptrV(rv2i(rv).(map[float32]uintptr), e) } func (_ fastpathT) EncMapFloat32UintptrV(v map[float32]uintptr, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5492,26 +4306,32 @@ func (_ fastpathT) EncMapFloat32UintptrV(v map[float32]uintptr, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat32(float32(k2)) - if esep { + ee.EncodeFloat32(float32(k2)) ee.WriteMapElemValue() + e.encode(v[float32(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat32(float32(k2)) + e.encode(v[float32(k2)]) } - e.encode(v[float32(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat32(k2) - if esep { + ee.EncodeFloat32(k2) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat32(k2) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -5521,6 +4341,10 @@ func (e *Encoder) fastpathEncMapFloat32IntR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapFloat32IntV(rv2i(rv).(map[float32]int), e) } func (_ fastpathT) EncMapFloat32IntV(v map[float32]int, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5531,26 +4355,32 @@ func (_ fastpathT) EncMapFloat32IntV(v map[float32]int, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat32(float32(k2)) - if esep { + ee.EncodeFloat32(float32(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[float32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat32(float32(k2)) + ee.EncodeInt(int64(v[float32(k2)])) } - ee.EncodeInt(int64(v[float32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat32(k2) - if esep { + ee.EncodeFloat32(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat32(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -5560,6 +4390,10 @@ func (e *Encoder) fastpathEncMapFloat32Int8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapFloat32Int8V(rv2i(rv).(map[float32]int8), e) } func (_ fastpathT) EncMapFloat32Int8V(v map[float32]int8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5570,26 +4404,32 @@ func (_ fastpathT) EncMapFloat32Int8V(v map[float32]int8, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat32(float32(k2)) - if esep { + ee.EncodeFloat32(float32(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[float32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat32(float32(k2)) + ee.EncodeInt(int64(v[float32(k2)])) } - ee.EncodeInt(int64(v[float32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat32(k2) - if esep { + ee.EncodeFloat32(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat32(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -5599,6 +4439,10 @@ func (e *Encoder) fastpathEncMapFloat32Int16R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapFloat32Int16V(rv2i(rv).(map[float32]int16), e) } func (_ fastpathT) EncMapFloat32Int16V(v map[float32]int16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5609,26 +4453,32 @@ func (_ fastpathT) EncMapFloat32Int16V(v map[float32]int16, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat32(float32(k2)) - if esep { + ee.EncodeFloat32(float32(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[float32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat32(float32(k2)) + ee.EncodeInt(int64(v[float32(k2)])) } - ee.EncodeInt(int64(v[float32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat32(k2) - if esep { + ee.EncodeFloat32(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat32(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -5638,6 +4488,10 @@ func (e *Encoder) fastpathEncMapFloat32Int32R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapFloat32Int32V(rv2i(rv).(map[float32]int32), e) } func (_ fastpathT) EncMapFloat32Int32V(v map[float32]int32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5648,26 +4502,32 @@ func (_ fastpathT) EncMapFloat32Int32V(v map[float32]int32, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat32(float32(k2)) - if esep { + ee.EncodeFloat32(float32(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[float32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat32(float32(k2)) + ee.EncodeInt(int64(v[float32(k2)])) } - ee.EncodeInt(int64(v[float32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat32(k2) - if esep { + ee.EncodeFloat32(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat32(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -5677,6 +4537,10 @@ func (e *Encoder) fastpathEncMapFloat32Int64R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapFloat32Int64V(rv2i(rv).(map[float32]int64), e) } func (_ fastpathT) EncMapFloat32Int64V(v map[float32]int64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5687,26 +4551,32 @@ func (_ fastpathT) EncMapFloat32Int64V(v map[float32]int64, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat32(float32(k2)) - if esep { + ee.EncodeFloat32(float32(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[float32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat32(float32(k2)) + ee.EncodeInt(int64(v[float32(k2)])) } - ee.EncodeInt(int64(v[float32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat32(k2) - if esep { + ee.EncodeFloat32(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat32(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -5716,6 +4586,10 @@ func (e *Encoder) fastpathEncMapFloat32Float32R(f *codecFnInfo, rv reflect.Value fastpathTV.EncMapFloat32Float32V(rv2i(rv).(map[float32]float32), e) } func (_ fastpathT) EncMapFloat32Float32V(v map[float32]float32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5726,26 +4600,32 @@ func (_ fastpathT) EncMapFloat32Float32V(v map[float32]float32, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat32(float32(k2)) - if esep { + ee.EncodeFloat32(float32(k2)) ee.WriteMapElemValue() + ee.EncodeFloat32(v[float32(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat32(float32(k2)) + ee.EncodeFloat32(v[float32(k2)]) } - ee.EncodeFloat32(v[float32(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat32(k2) - if esep { + ee.EncodeFloat32(k2) ee.WriteMapElemValue() + ee.EncodeFloat32(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat32(k2) + ee.EncodeFloat32(v2) } - ee.EncodeFloat32(v2) } } ee.WriteMapEnd() @@ -5755,6 +4635,10 @@ func (e *Encoder) fastpathEncMapFloat32Float64R(f *codecFnInfo, rv reflect.Value fastpathTV.EncMapFloat32Float64V(rv2i(rv).(map[float32]float64), e) } func (_ fastpathT) EncMapFloat32Float64V(v map[float32]float64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5765,26 +4649,32 @@ func (_ fastpathT) EncMapFloat32Float64V(v map[float32]float64, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat32(float32(k2)) - if esep { + ee.EncodeFloat32(float32(k2)) ee.WriteMapElemValue() + ee.EncodeFloat64(v[float32(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat32(float32(k2)) + ee.EncodeFloat64(v[float32(k2)]) } - ee.EncodeFloat64(v[float32(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat32(k2) - if esep { + ee.EncodeFloat32(k2) ee.WriteMapElemValue() + ee.EncodeFloat64(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat32(k2) + ee.EncodeFloat64(v2) } - ee.EncodeFloat64(v2) } } ee.WriteMapEnd() @@ -5794,6 +4684,10 @@ func (e *Encoder) fastpathEncMapFloat32BoolR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapFloat32BoolV(rv2i(rv).(map[float32]bool), e) } func (_ fastpathT) EncMapFloat32BoolV(v map[float32]bool, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5804,26 +4698,32 @@ func (_ fastpathT) EncMapFloat32BoolV(v map[float32]bool, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat32(float32(k2)) - if esep { + ee.EncodeFloat32(float32(k2)) ee.WriteMapElemValue() + ee.EncodeBool(v[float32(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat32(float32(k2)) + ee.EncodeBool(v[float32(k2)]) } - ee.EncodeBool(v[float32(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat32(k2) - if esep { + ee.EncodeFloat32(k2) ee.WriteMapElemValue() + ee.EncodeBool(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat32(k2) + ee.EncodeBool(v2) } - ee.EncodeBool(v2) } } ee.WriteMapEnd() @@ -5833,6 +4733,10 @@ func (e *Encoder) fastpathEncMapFloat64IntfR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapFloat64IntfV(rv2i(rv).(map[float64]interface{}), e) } func (_ fastpathT) EncMapFloat64IntfV(v map[float64]interface{}, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5843,26 +4747,32 @@ func (_ fastpathT) EncMapFloat64IntfV(v map[float64]interface{}, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat64(float64(k2)) - if esep { + ee.EncodeFloat64(float64(k2)) ee.WriteMapElemValue() + e.encode(v[float64(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat64(float64(k2)) + e.encode(v[float64(k2)]) } - e.encode(v[float64(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat64(k2) - if esep { + ee.EncodeFloat64(k2) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat64(k2) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -5872,6 +4782,10 @@ func (e *Encoder) fastpathEncMapFloat64StringR(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapFloat64StringV(rv2i(rv).(map[float64]string), e) } func (_ fastpathT) EncMapFloat64StringV(v map[float64]string, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5882,26 +4796,32 @@ func (_ fastpathT) EncMapFloat64StringV(v map[float64]string, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat64(float64(k2)) - if esep { + ee.EncodeFloat64(float64(k2)) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v[float64(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat64(float64(k2)) + ee.EncodeString(cUTF8, v[float64(k2)]) } - ee.EncodeString(c_UTF8, v[float64(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat64(k2) - if esep { + ee.EncodeFloat64(k2) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v2) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat64(k2) + ee.EncodeString(cUTF8, v2) } - ee.EncodeString(c_UTF8, v2) } } ee.WriteMapEnd() @@ -5911,6 +4831,10 @@ func (e *Encoder) fastpathEncMapFloat64UintR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapFloat64UintV(rv2i(rv).(map[float64]uint), e) } func (_ fastpathT) EncMapFloat64UintV(v map[float64]uint, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5921,26 +4845,32 @@ func (_ fastpathT) EncMapFloat64UintV(v map[float64]uint, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat64(float64(k2)) - if esep { + ee.EncodeFloat64(float64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[float64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat64(float64(k2)) + ee.EncodeUint(uint64(v[float64(k2)])) } - ee.EncodeUint(uint64(v[float64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat64(k2) - if esep { + ee.EncodeFloat64(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat64(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -5950,6 +4880,10 @@ func (e *Encoder) fastpathEncMapFloat64Uint8R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapFloat64Uint8V(rv2i(rv).(map[float64]uint8), e) } func (_ fastpathT) EncMapFloat64Uint8V(v map[float64]uint8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5960,26 +4894,32 @@ func (_ fastpathT) EncMapFloat64Uint8V(v map[float64]uint8, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat64(float64(k2)) - if esep { + ee.EncodeFloat64(float64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[float64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat64(float64(k2)) + ee.EncodeUint(uint64(v[float64(k2)])) } - ee.EncodeUint(uint64(v[float64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat64(k2) - if esep { + ee.EncodeFloat64(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat64(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -5989,6 +4929,10 @@ func (e *Encoder) fastpathEncMapFloat64Uint16R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapFloat64Uint16V(rv2i(rv).(map[float64]uint16), e) } func (_ fastpathT) EncMapFloat64Uint16V(v map[float64]uint16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -5999,26 +4943,32 @@ func (_ fastpathT) EncMapFloat64Uint16V(v map[float64]uint16, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat64(float64(k2)) - if esep { + ee.EncodeFloat64(float64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[float64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat64(float64(k2)) + ee.EncodeUint(uint64(v[float64(k2)])) } - ee.EncodeUint(uint64(v[float64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat64(k2) - if esep { + ee.EncodeFloat64(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat64(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -6028,6 +4978,10 @@ func (e *Encoder) fastpathEncMapFloat64Uint32R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapFloat64Uint32V(rv2i(rv).(map[float64]uint32), e) } func (_ fastpathT) EncMapFloat64Uint32V(v map[float64]uint32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6038,26 +4992,32 @@ func (_ fastpathT) EncMapFloat64Uint32V(v map[float64]uint32, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat64(float64(k2)) - if esep { + ee.EncodeFloat64(float64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[float64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat64(float64(k2)) + ee.EncodeUint(uint64(v[float64(k2)])) } - ee.EncodeUint(uint64(v[float64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat64(k2) - if esep { + ee.EncodeFloat64(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat64(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -6067,6 +5027,10 @@ func (e *Encoder) fastpathEncMapFloat64Uint64R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapFloat64Uint64V(rv2i(rv).(map[float64]uint64), e) } func (_ fastpathT) EncMapFloat64Uint64V(v map[float64]uint64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6077,26 +5041,32 @@ func (_ fastpathT) EncMapFloat64Uint64V(v map[float64]uint64, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat64(float64(k2)) - if esep { + ee.EncodeFloat64(float64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[float64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat64(float64(k2)) + ee.EncodeUint(uint64(v[float64(k2)])) } - ee.EncodeUint(uint64(v[float64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat64(k2) - if esep { + ee.EncodeFloat64(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat64(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -6106,6 +5076,10 @@ func (e *Encoder) fastpathEncMapFloat64UintptrR(f *codecFnInfo, rv reflect.Value fastpathTV.EncMapFloat64UintptrV(rv2i(rv).(map[float64]uintptr), e) } func (_ fastpathT) EncMapFloat64UintptrV(v map[float64]uintptr, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6116,26 +5090,32 @@ func (_ fastpathT) EncMapFloat64UintptrV(v map[float64]uintptr, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat64(float64(k2)) - if esep { + ee.EncodeFloat64(float64(k2)) ee.WriteMapElemValue() + e.encode(v[float64(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat64(float64(k2)) + e.encode(v[float64(k2)]) } - e.encode(v[float64(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat64(k2) - if esep { + ee.EncodeFloat64(k2) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat64(k2) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -6145,6 +5125,10 @@ func (e *Encoder) fastpathEncMapFloat64IntR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapFloat64IntV(rv2i(rv).(map[float64]int), e) } func (_ fastpathT) EncMapFloat64IntV(v map[float64]int, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6155,26 +5139,32 @@ func (_ fastpathT) EncMapFloat64IntV(v map[float64]int, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat64(float64(k2)) - if esep { + ee.EncodeFloat64(float64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[float64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat64(float64(k2)) + ee.EncodeInt(int64(v[float64(k2)])) } - ee.EncodeInt(int64(v[float64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat64(k2) - if esep { + ee.EncodeFloat64(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat64(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -6184,6 +5174,10 @@ func (e *Encoder) fastpathEncMapFloat64Int8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapFloat64Int8V(rv2i(rv).(map[float64]int8), e) } func (_ fastpathT) EncMapFloat64Int8V(v map[float64]int8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6194,26 +5188,32 @@ func (_ fastpathT) EncMapFloat64Int8V(v map[float64]int8, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat64(float64(k2)) - if esep { + ee.EncodeFloat64(float64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[float64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat64(float64(k2)) + ee.EncodeInt(int64(v[float64(k2)])) } - ee.EncodeInt(int64(v[float64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat64(k2) - if esep { + ee.EncodeFloat64(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat64(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -6223,6 +5223,10 @@ func (e *Encoder) fastpathEncMapFloat64Int16R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapFloat64Int16V(rv2i(rv).(map[float64]int16), e) } func (_ fastpathT) EncMapFloat64Int16V(v map[float64]int16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6233,26 +5237,32 @@ func (_ fastpathT) EncMapFloat64Int16V(v map[float64]int16, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat64(float64(k2)) - if esep { + ee.EncodeFloat64(float64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[float64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat64(float64(k2)) + ee.EncodeInt(int64(v[float64(k2)])) } - ee.EncodeInt(int64(v[float64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat64(k2) - if esep { + ee.EncodeFloat64(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat64(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -6262,6 +5272,10 @@ func (e *Encoder) fastpathEncMapFloat64Int32R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapFloat64Int32V(rv2i(rv).(map[float64]int32), e) } func (_ fastpathT) EncMapFloat64Int32V(v map[float64]int32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6272,26 +5286,32 @@ func (_ fastpathT) EncMapFloat64Int32V(v map[float64]int32, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat64(float64(k2)) - if esep { + ee.EncodeFloat64(float64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[float64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat64(float64(k2)) + ee.EncodeInt(int64(v[float64(k2)])) } - ee.EncodeInt(int64(v[float64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat64(k2) - if esep { + ee.EncodeFloat64(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat64(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -6301,6 +5321,10 @@ func (e *Encoder) fastpathEncMapFloat64Int64R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapFloat64Int64V(rv2i(rv).(map[float64]int64), e) } func (_ fastpathT) EncMapFloat64Int64V(v map[float64]int64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6311,26 +5335,32 @@ func (_ fastpathT) EncMapFloat64Int64V(v map[float64]int64, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat64(float64(k2)) - if esep { + ee.EncodeFloat64(float64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[float64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat64(float64(k2)) + ee.EncodeInt(int64(v[float64(k2)])) } - ee.EncodeInt(int64(v[float64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat64(k2) - if esep { + ee.EncodeFloat64(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat64(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -6340,6 +5370,10 @@ func (e *Encoder) fastpathEncMapFloat64Float32R(f *codecFnInfo, rv reflect.Value fastpathTV.EncMapFloat64Float32V(rv2i(rv).(map[float64]float32), e) } func (_ fastpathT) EncMapFloat64Float32V(v map[float64]float32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6350,26 +5384,32 @@ func (_ fastpathT) EncMapFloat64Float32V(v map[float64]float32, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat64(float64(k2)) - if esep { + ee.EncodeFloat64(float64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat32(v[float64(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat64(float64(k2)) + ee.EncodeFloat32(v[float64(k2)]) } - ee.EncodeFloat32(v[float64(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat64(k2) - if esep { + ee.EncodeFloat64(k2) ee.WriteMapElemValue() + ee.EncodeFloat32(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat64(k2) + ee.EncodeFloat32(v2) } - ee.EncodeFloat32(v2) } } ee.WriteMapEnd() @@ -6379,6 +5419,10 @@ func (e *Encoder) fastpathEncMapFloat64Float64R(f *codecFnInfo, rv reflect.Value fastpathTV.EncMapFloat64Float64V(rv2i(rv).(map[float64]float64), e) } func (_ fastpathT) EncMapFloat64Float64V(v map[float64]float64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6389,26 +5433,32 @@ func (_ fastpathT) EncMapFloat64Float64V(v map[float64]float64, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat64(float64(k2)) - if esep { + ee.EncodeFloat64(float64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat64(v[float64(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat64(float64(k2)) + ee.EncodeFloat64(v[float64(k2)]) } - ee.EncodeFloat64(v[float64(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat64(k2) - if esep { + ee.EncodeFloat64(k2) ee.WriteMapElemValue() + ee.EncodeFloat64(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat64(k2) + ee.EncodeFloat64(v2) } - ee.EncodeFloat64(v2) } } ee.WriteMapEnd() @@ -6418,6 +5468,10 @@ func (e *Encoder) fastpathEncMapFloat64BoolR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapFloat64BoolV(rv2i(rv).(map[float64]bool), e) } func (_ fastpathT) EncMapFloat64BoolV(v map[float64]bool, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6428,26 +5482,32 @@ func (_ fastpathT) EncMapFloat64BoolV(v map[float64]bool, e *Encoder) { i++ } sort.Sort(floatSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeFloat64(float64(k2)) - if esep { + ee.EncodeFloat64(float64(k2)) ee.WriteMapElemValue() + ee.EncodeBool(v[float64(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeFloat64(float64(k2)) + ee.EncodeBool(v[float64(k2)]) } - ee.EncodeBool(v[float64(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeFloat64(k2) - if esep { + ee.EncodeFloat64(k2) ee.WriteMapElemValue() + ee.EncodeBool(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeFloat64(k2) + ee.EncodeBool(v2) } - ee.EncodeBool(v2) } } ee.WriteMapEnd() @@ -6457,6 +5517,10 @@ func (e *Encoder) fastpathEncMapUintIntfR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintIntfV(rv2i(rv).(map[uint]interface{}), e) } func (_ fastpathT) EncMapUintIntfV(v map[uint]interface{}, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6467,26 +5531,32 @@ func (_ fastpathT) EncMapUintIntfV(v map[uint]interface{}, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint(k2))) - if esep { + ee.EncodeUint(uint64(uint(k2))) ee.WriteMapElemValue() + e.encode(v[uint(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint(k2))) + e.encode(v[uint(k2)]) } - e.encode(v[uint(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -6496,6 +5566,10 @@ func (e *Encoder) fastpathEncMapUintStringR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintStringV(rv2i(rv).(map[uint]string), e) } func (_ fastpathT) EncMapUintStringV(v map[uint]string, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6506,26 +5580,32 @@ func (_ fastpathT) EncMapUintStringV(v map[uint]string, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint(k2))) - if esep { + ee.EncodeUint(uint64(uint(k2))) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v[uint(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint(k2))) + ee.EncodeString(cUTF8, v[uint(k2)]) } - ee.EncodeString(c_UTF8, v[uint(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeString(cUTF8, v2) } - ee.EncodeString(c_UTF8, v2) } } ee.WriteMapEnd() @@ -6535,6 +5615,10 @@ func (e *Encoder) fastpathEncMapUintUintR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintUintV(rv2i(rv).(map[uint]uint), e) } func (_ fastpathT) EncMapUintUintV(v map[uint]uint, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6545,26 +5629,32 @@ func (_ fastpathT) EncMapUintUintV(v map[uint]uint, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint(k2))) - if esep { + ee.EncodeUint(uint64(uint(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint(k2))) + ee.EncodeUint(uint64(v[uint(k2)])) } - ee.EncodeUint(uint64(v[uint(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -6574,6 +5664,10 @@ func (e *Encoder) fastpathEncMapUintUint8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintUint8V(rv2i(rv).(map[uint]uint8), e) } func (_ fastpathT) EncMapUintUint8V(v map[uint]uint8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6584,26 +5678,32 @@ func (_ fastpathT) EncMapUintUint8V(v map[uint]uint8, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint(k2))) - if esep { + ee.EncodeUint(uint64(uint(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint(k2))) + ee.EncodeUint(uint64(v[uint(k2)])) } - ee.EncodeUint(uint64(v[uint(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -6613,6 +5713,10 @@ func (e *Encoder) fastpathEncMapUintUint16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintUint16V(rv2i(rv).(map[uint]uint16), e) } func (_ fastpathT) EncMapUintUint16V(v map[uint]uint16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6623,26 +5727,32 @@ func (_ fastpathT) EncMapUintUint16V(v map[uint]uint16, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint(k2))) - if esep { + ee.EncodeUint(uint64(uint(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint(k2))) + ee.EncodeUint(uint64(v[uint(k2)])) } - ee.EncodeUint(uint64(v[uint(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -6652,6 +5762,10 @@ func (e *Encoder) fastpathEncMapUintUint32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintUint32V(rv2i(rv).(map[uint]uint32), e) } func (_ fastpathT) EncMapUintUint32V(v map[uint]uint32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6662,26 +5776,32 @@ func (_ fastpathT) EncMapUintUint32V(v map[uint]uint32, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint(k2))) - if esep { + ee.EncodeUint(uint64(uint(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint(k2))) + ee.EncodeUint(uint64(v[uint(k2)])) } - ee.EncodeUint(uint64(v[uint(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -6691,6 +5811,10 @@ func (e *Encoder) fastpathEncMapUintUint64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintUint64V(rv2i(rv).(map[uint]uint64), e) } func (_ fastpathT) EncMapUintUint64V(v map[uint]uint64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6701,26 +5825,32 @@ func (_ fastpathT) EncMapUintUint64V(v map[uint]uint64, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint(k2))) - if esep { + ee.EncodeUint(uint64(uint(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint(k2))) + ee.EncodeUint(uint64(v[uint(k2)])) } - ee.EncodeUint(uint64(v[uint(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -6730,6 +5860,10 @@ func (e *Encoder) fastpathEncMapUintUintptrR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintUintptrV(rv2i(rv).(map[uint]uintptr), e) } func (_ fastpathT) EncMapUintUintptrV(v map[uint]uintptr, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6740,26 +5874,32 @@ func (_ fastpathT) EncMapUintUintptrV(v map[uint]uintptr, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint(k2))) - if esep { + ee.EncodeUint(uint64(uint(k2))) ee.WriteMapElemValue() + e.encode(v[uint(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint(k2))) + e.encode(v[uint(k2)]) } - e.encode(v[uint(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -6769,6 +5909,10 @@ func (e *Encoder) fastpathEncMapUintIntR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintIntV(rv2i(rv).(map[uint]int), e) } func (_ fastpathT) EncMapUintIntV(v map[uint]int, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6779,26 +5923,32 @@ func (_ fastpathT) EncMapUintIntV(v map[uint]int, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint(k2))) - if esep { + ee.EncodeUint(uint64(uint(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint(k2))) + ee.EncodeInt(int64(v[uint(k2)])) } - ee.EncodeInt(int64(v[uint(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -6808,6 +5958,10 @@ func (e *Encoder) fastpathEncMapUintInt8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintInt8V(rv2i(rv).(map[uint]int8), e) } func (_ fastpathT) EncMapUintInt8V(v map[uint]int8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6818,26 +5972,32 @@ func (_ fastpathT) EncMapUintInt8V(v map[uint]int8, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint(k2))) - if esep { + ee.EncodeUint(uint64(uint(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint(k2))) + ee.EncodeInt(int64(v[uint(k2)])) } - ee.EncodeInt(int64(v[uint(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -6847,6 +6007,10 @@ func (e *Encoder) fastpathEncMapUintInt16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintInt16V(rv2i(rv).(map[uint]int16), e) } func (_ fastpathT) EncMapUintInt16V(v map[uint]int16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6857,26 +6021,32 @@ func (_ fastpathT) EncMapUintInt16V(v map[uint]int16, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint(k2))) - if esep { + ee.EncodeUint(uint64(uint(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint(k2))) + ee.EncodeInt(int64(v[uint(k2)])) } - ee.EncodeInt(int64(v[uint(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -6886,6 +6056,10 @@ func (e *Encoder) fastpathEncMapUintInt32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintInt32V(rv2i(rv).(map[uint]int32), e) } func (_ fastpathT) EncMapUintInt32V(v map[uint]int32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6896,26 +6070,32 @@ func (_ fastpathT) EncMapUintInt32V(v map[uint]int32, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint(k2))) - if esep { + ee.EncodeUint(uint64(uint(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint(k2))) + ee.EncodeInt(int64(v[uint(k2)])) } - ee.EncodeInt(int64(v[uint(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -6925,6 +6105,10 @@ func (e *Encoder) fastpathEncMapUintInt64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintInt64V(rv2i(rv).(map[uint]int64), e) } func (_ fastpathT) EncMapUintInt64V(v map[uint]int64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6935,26 +6119,32 @@ func (_ fastpathT) EncMapUintInt64V(v map[uint]int64, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint(k2))) - if esep { + ee.EncodeUint(uint64(uint(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint(k2))) + ee.EncodeInt(int64(v[uint(k2)])) } - ee.EncodeInt(int64(v[uint(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -6964,6 +6154,10 @@ func (e *Encoder) fastpathEncMapUintFloat32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintFloat32V(rv2i(rv).(map[uint]float32), e) } func (_ fastpathT) EncMapUintFloat32V(v map[uint]float32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -6974,26 +6168,32 @@ func (_ fastpathT) EncMapUintFloat32V(v map[uint]float32, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint(k2))) - if esep { + ee.EncodeUint(uint64(uint(k2))) ee.WriteMapElemValue() + ee.EncodeFloat32(v[uint(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint(k2))) + ee.EncodeFloat32(v[uint(k2)]) } - ee.EncodeFloat32(v[uint(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat32(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeFloat32(v2) } - ee.EncodeFloat32(v2) } } ee.WriteMapEnd() @@ -7003,6 +6203,10 @@ func (e *Encoder) fastpathEncMapUintFloat64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintFloat64V(rv2i(rv).(map[uint]float64), e) } func (_ fastpathT) EncMapUintFloat64V(v map[uint]float64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7013,26 +6217,32 @@ func (_ fastpathT) EncMapUintFloat64V(v map[uint]float64, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint(k2))) - if esep { + ee.EncodeUint(uint64(uint(k2))) ee.WriteMapElemValue() + ee.EncodeFloat64(v[uint(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint(k2))) + ee.EncodeFloat64(v[uint(k2)]) } - ee.EncodeFloat64(v[uint(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat64(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeFloat64(v2) } - ee.EncodeFloat64(v2) } } ee.WriteMapEnd() @@ -7042,6 +6252,10 @@ func (e *Encoder) fastpathEncMapUintBoolR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintBoolV(rv2i(rv).(map[uint]bool), e) } func (_ fastpathT) EncMapUintBoolV(v map[uint]bool, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7052,26 +6266,32 @@ func (_ fastpathT) EncMapUintBoolV(v map[uint]bool, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint(k2))) - if esep { + ee.EncodeUint(uint64(uint(k2))) ee.WriteMapElemValue() + ee.EncodeBool(v[uint(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint(k2))) + ee.EncodeBool(v[uint(k2)]) } - ee.EncodeBool(v[uint(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeBool(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeBool(v2) } - ee.EncodeBool(v2) } } ee.WriteMapEnd() @@ -7081,6 +6301,10 @@ func (e *Encoder) fastpathEncMapUint8IntfR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint8IntfV(rv2i(rv).(map[uint8]interface{}), e) } func (_ fastpathT) EncMapUint8IntfV(v map[uint8]interface{}, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7091,26 +6315,32 @@ func (_ fastpathT) EncMapUint8IntfV(v map[uint8]interface{}, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint8(k2))) - if esep { + ee.EncodeUint(uint64(uint8(k2))) ee.WriteMapElemValue() + e.encode(v[uint8(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint8(k2))) + e.encode(v[uint8(k2)]) } - e.encode(v[uint8(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -7120,6 +6350,10 @@ func (e *Encoder) fastpathEncMapUint8StringR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint8StringV(rv2i(rv).(map[uint8]string), e) } func (_ fastpathT) EncMapUint8StringV(v map[uint8]string, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7130,26 +6364,32 @@ func (_ fastpathT) EncMapUint8StringV(v map[uint8]string, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint8(k2))) - if esep { + ee.EncodeUint(uint64(uint8(k2))) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v[uint8(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint8(k2))) + ee.EncodeString(cUTF8, v[uint8(k2)]) } - ee.EncodeString(c_UTF8, v[uint8(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeString(cUTF8, v2) } - ee.EncodeString(c_UTF8, v2) } } ee.WriteMapEnd() @@ -7159,6 +6399,10 @@ func (e *Encoder) fastpathEncMapUint8UintR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint8UintV(rv2i(rv).(map[uint8]uint), e) } func (_ fastpathT) EncMapUint8UintV(v map[uint8]uint, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7169,26 +6413,32 @@ func (_ fastpathT) EncMapUint8UintV(v map[uint8]uint, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint8(k2))) - if esep { + ee.EncodeUint(uint64(uint8(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint8(k2))) + ee.EncodeUint(uint64(v[uint8(k2)])) } - ee.EncodeUint(uint64(v[uint8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -7198,6 +6448,10 @@ func (e *Encoder) fastpathEncMapUint8Uint8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint8Uint8V(rv2i(rv).(map[uint8]uint8), e) } func (_ fastpathT) EncMapUint8Uint8V(v map[uint8]uint8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7208,26 +6462,32 @@ func (_ fastpathT) EncMapUint8Uint8V(v map[uint8]uint8, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint8(k2))) - if esep { + ee.EncodeUint(uint64(uint8(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint8(k2))) + ee.EncodeUint(uint64(v[uint8(k2)])) } - ee.EncodeUint(uint64(v[uint8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -7237,6 +6497,10 @@ func (e *Encoder) fastpathEncMapUint8Uint16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint8Uint16V(rv2i(rv).(map[uint8]uint16), e) } func (_ fastpathT) EncMapUint8Uint16V(v map[uint8]uint16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7247,26 +6511,32 @@ func (_ fastpathT) EncMapUint8Uint16V(v map[uint8]uint16, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint8(k2))) - if esep { + ee.EncodeUint(uint64(uint8(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint8(k2))) + ee.EncodeUint(uint64(v[uint8(k2)])) } - ee.EncodeUint(uint64(v[uint8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -7276,6 +6546,10 @@ func (e *Encoder) fastpathEncMapUint8Uint32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint8Uint32V(rv2i(rv).(map[uint8]uint32), e) } func (_ fastpathT) EncMapUint8Uint32V(v map[uint8]uint32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7286,26 +6560,32 @@ func (_ fastpathT) EncMapUint8Uint32V(v map[uint8]uint32, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint8(k2))) - if esep { + ee.EncodeUint(uint64(uint8(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint8(k2))) + ee.EncodeUint(uint64(v[uint8(k2)])) } - ee.EncodeUint(uint64(v[uint8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -7315,6 +6595,10 @@ func (e *Encoder) fastpathEncMapUint8Uint64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint8Uint64V(rv2i(rv).(map[uint8]uint64), e) } func (_ fastpathT) EncMapUint8Uint64V(v map[uint8]uint64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7325,26 +6609,32 @@ func (_ fastpathT) EncMapUint8Uint64V(v map[uint8]uint64, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint8(k2))) - if esep { + ee.EncodeUint(uint64(uint8(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint8(k2))) + ee.EncodeUint(uint64(v[uint8(k2)])) } - ee.EncodeUint(uint64(v[uint8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -7354,6 +6644,10 @@ func (e *Encoder) fastpathEncMapUint8UintptrR(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint8UintptrV(rv2i(rv).(map[uint8]uintptr), e) } func (_ fastpathT) EncMapUint8UintptrV(v map[uint8]uintptr, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7364,26 +6658,32 @@ func (_ fastpathT) EncMapUint8UintptrV(v map[uint8]uintptr, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint8(k2))) - if esep { + ee.EncodeUint(uint64(uint8(k2))) ee.WriteMapElemValue() + e.encode(v[uint8(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint8(k2))) + e.encode(v[uint8(k2)]) } - e.encode(v[uint8(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -7393,6 +6693,10 @@ func (e *Encoder) fastpathEncMapUint8IntR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint8IntV(rv2i(rv).(map[uint8]int), e) } func (_ fastpathT) EncMapUint8IntV(v map[uint8]int, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7403,26 +6707,32 @@ func (_ fastpathT) EncMapUint8IntV(v map[uint8]int, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint8(k2))) - if esep { + ee.EncodeUint(uint64(uint8(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint8(k2))) + ee.EncodeInt(int64(v[uint8(k2)])) } - ee.EncodeInt(int64(v[uint8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -7432,6 +6742,10 @@ func (e *Encoder) fastpathEncMapUint8Int8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint8Int8V(rv2i(rv).(map[uint8]int8), e) } func (_ fastpathT) EncMapUint8Int8V(v map[uint8]int8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7442,26 +6756,32 @@ func (_ fastpathT) EncMapUint8Int8V(v map[uint8]int8, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint8(k2))) - if esep { + ee.EncodeUint(uint64(uint8(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint8(k2))) + ee.EncodeInt(int64(v[uint8(k2)])) } - ee.EncodeInt(int64(v[uint8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -7471,6 +6791,10 @@ func (e *Encoder) fastpathEncMapUint8Int16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint8Int16V(rv2i(rv).(map[uint8]int16), e) } func (_ fastpathT) EncMapUint8Int16V(v map[uint8]int16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7481,26 +6805,32 @@ func (_ fastpathT) EncMapUint8Int16V(v map[uint8]int16, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint8(k2))) - if esep { + ee.EncodeUint(uint64(uint8(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint8(k2))) + ee.EncodeInt(int64(v[uint8(k2)])) } - ee.EncodeInt(int64(v[uint8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -7510,6 +6840,10 @@ func (e *Encoder) fastpathEncMapUint8Int32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint8Int32V(rv2i(rv).(map[uint8]int32), e) } func (_ fastpathT) EncMapUint8Int32V(v map[uint8]int32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7520,26 +6854,32 @@ func (_ fastpathT) EncMapUint8Int32V(v map[uint8]int32, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint8(k2))) - if esep { + ee.EncodeUint(uint64(uint8(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint8(k2))) + ee.EncodeInt(int64(v[uint8(k2)])) } - ee.EncodeInt(int64(v[uint8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -7549,6 +6889,10 @@ func (e *Encoder) fastpathEncMapUint8Int64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint8Int64V(rv2i(rv).(map[uint8]int64), e) } func (_ fastpathT) EncMapUint8Int64V(v map[uint8]int64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7559,26 +6903,32 @@ func (_ fastpathT) EncMapUint8Int64V(v map[uint8]int64, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint8(k2))) - if esep { + ee.EncodeUint(uint64(uint8(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint8(k2))) + ee.EncodeInt(int64(v[uint8(k2)])) } - ee.EncodeInt(int64(v[uint8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -7588,6 +6938,10 @@ func (e *Encoder) fastpathEncMapUint8Float32R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint8Float32V(rv2i(rv).(map[uint8]float32), e) } func (_ fastpathT) EncMapUint8Float32V(v map[uint8]float32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7598,26 +6952,32 @@ func (_ fastpathT) EncMapUint8Float32V(v map[uint8]float32, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint8(k2))) - if esep { + ee.EncodeUint(uint64(uint8(k2))) ee.WriteMapElemValue() + ee.EncodeFloat32(v[uint8(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint8(k2))) + ee.EncodeFloat32(v[uint8(k2)]) } - ee.EncodeFloat32(v[uint8(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat32(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeFloat32(v2) } - ee.EncodeFloat32(v2) } } ee.WriteMapEnd() @@ -7627,6 +6987,10 @@ func (e *Encoder) fastpathEncMapUint8Float64R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint8Float64V(rv2i(rv).(map[uint8]float64), e) } func (_ fastpathT) EncMapUint8Float64V(v map[uint8]float64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7637,26 +7001,32 @@ func (_ fastpathT) EncMapUint8Float64V(v map[uint8]float64, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint8(k2))) - if esep { + ee.EncodeUint(uint64(uint8(k2))) ee.WriteMapElemValue() + ee.EncodeFloat64(v[uint8(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint8(k2))) + ee.EncodeFloat64(v[uint8(k2)]) } - ee.EncodeFloat64(v[uint8(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat64(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeFloat64(v2) } - ee.EncodeFloat64(v2) } } ee.WriteMapEnd() @@ -7666,6 +7036,10 @@ func (e *Encoder) fastpathEncMapUint8BoolR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint8BoolV(rv2i(rv).(map[uint8]bool), e) } func (_ fastpathT) EncMapUint8BoolV(v map[uint8]bool, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7676,26 +7050,32 @@ func (_ fastpathT) EncMapUint8BoolV(v map[uint8]bool, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint8(k2))) - if esep { + ee.EncodeUint(uint64(uint8(k2))) ee.WriteMapElemValue() + ee.EncodeBool(v[uint8(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint8(k2))) + ee.EncodeBool(v[uint8(k2)]) } - ee.EncodeBool(v[uint8(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeBool(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeBool(v2) } - ee.EncodeBool(v2) } } ee.WriteMapEnd() @@ -7705,6 +7085,10 @@ func (e *Encoder) fastpathEncMapUint16IntfR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint16IntfV(rv2i(rv).(map[uint16]interface{}), e) } func (_ fastpathT) EncMapUint16IntfV(v map[uint16]interface{}, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7715,26 +7099,32 @@ func (_ fastpathT) EncMapUint16IntfV(v map[uint16]interface{}, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint16(k2))) - if esep { + ee.EncodeUint(uint64(uint16(k2))) ee.WriteMapElemValue() + e.encode(v[uint16(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint16(k2))) + e.encode(v[uint16(k2)]) } - e.encode(v[uint16(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -7744,6 +7134,10 @@ func (e *Encoder) fastpathEncMapUint16StringR(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint16StringV(rv2i(rv).(map[uint16]string), e) } func (_ fastpathT) EncMapUint16StringV(v map[uint16]string, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7754,26 +7148,32 @@ func (_ fastpathT) EncMapUint16StringV(v map[uint16]string, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint16(k2))) - if esep { + ee.EncodeUint(uint64(uint16(k2))) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v[uint16(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint16(k2))) + ee.EncodeString(cUTF8, v[uint16(k2)]) } - ee.EncodeString(c_UTF8, v[uint16(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeString(cUTF8, v2) } - ee.EncodeString(c_UTF8, v2) } } ee.WriteMapEnd() @@ -7783,6 +7183,10 @@ func (e *Encoder) fastpathEncMapUint16UintR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint16UintV(rv2i(rv).(map[uint16]uint), e) } func (_ fastpathT) EncMapUint16UintV(v map[uint16]uint, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7793,26 +7197,32 @@ func (_ fastpathT) EncMapUint16UintV(v map[uint16]uint, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint16(k2))) - if esep { + ee.EncodeUint(uint64(uint16(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint16(k2))) + ee.EncodeUint(uint64(v[uint16(k2)])) } - ee.EncodeUint(uint64(v[uint16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -7822,6 +7232,10 @@ func (e *Encoder) fastpathEncMapUint16Uint8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint16Uint8V(rv2i(rv).(map[uint16]uint8), e) } func (_ fastpathT) EncMapUint16Uint8V(v map[uint16]uint8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7832,26 +7246,32 @@ func (_ fastpathT) EncMapUint16Uint8V(v map[uint16]uint8, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint16(k2))) - if esep { + ee.EncodeUint(uint64(uint16(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint16(k2))) + ee.EncodeUint(uint64(v[uint16(k2)])) } - ee.EncodeUint(uint64(v[uint16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -7861,6 +7281,10 @@ func (e *Encoder) fastpathEncMapUint16Uint16R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint16Uint16V(rv2i(rv).(map[uint16]uint16), e) } func (_ fastpathT) EncMapUint16Uint16V(v map[uint16]uint16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7871,26 +7295,32 @@ func (_ fastpathT) EncMapUint16Uint16V(v map[uint16]uint16, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint16(k2))) - if esep { + ee.EncodeUint(uint64(uint16(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint16(k2))) + ee.EncodeUint(uint64(v[uint16(k2)])) } - ee.EncodeUint(uint64(v[uint16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -7900,6 +7330,10 @@ func (e *Encoder) fastpathEncMapUint16Uint32R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint16Uint32V(rv2i(rv).(map[uint16]uint32), e) } func (_ fastpathT) EncMapUint16Uint32V(v map[uint16]uint32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7910,26 +7344,32 @@ func (_ fastpathT) EncMapUint16Uint32V(v map[uint16]uint32, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint16(k2))) - if esep { + ee.EncodeUint(uint64(uint16(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint16(k2))) + ee.EncodeUint(uint64(v[uint16(k2)])) } - ee.EncodeUint(uint64(v[uint16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -7939,6 +7379,10 @@ func (e *Encoder) fastpathEncMapUint16Uint64R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint16Uint64V(rv2i(rv).(map[uint16]uint64), e) } func (_ fastpathT) EncMapUint16Uint64V(v map[uint16]uint64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7949,26 +7393,32 @@ func (_ fastpathT) EncMapUint16Uint64V(v map[uint16]uint64, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint16(k2))) - if esep { + ee.EncodeUint(uint64(uint16(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint16(k2))) + ee.EncodeUint(uint64(v[uint16(k2)])) } - ee.EncodeUint(uint64(v[uint16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -7978,6 +7428,10 @@ func (e *Encoder) fastpathEncMapUint16UintptrR(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint16UintptrV(rv2i(rv).(map[uint16]uintptr), e) } func (_ fastpathT) EncMapUint16UintptrV(v map[uint16]uintptr, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -7988,26 +7442,32 @@ func (_ fastpathT) EncMapUint16UintptrV(v map[uint16]uintptr, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint16(k2))) - if esep { + ee.EncodeUint(uint64(uint16(k2))) ee.WriteMapElemValue() + e.encode(v[uint16(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint16(k2))) + e.encode(v[uint16(k2)]) } - e.encode(v[uint16(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -8017,6 +7477,10 @@ func (e *Encoder) fastpathEncMapUint16IntR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint16IntV(rv2i(rv).(map[uint16]int), e) } func (_ fastpathT) EncMapUint16IntV(v map[uint16]int, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8027,26 +7491,32 @@ func (_ fastpathT) EncMapUint16IntV(v map[uint16]int, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint16(k2))) - if esep { + ee.EncodeUint(uint64(uint16(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint16(k2))) + ee.EncodeInt(int64(v[uint16(k2)])) } - ee.EncodeInt(int64(v[uint16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -8056,6 +7526,10 @@ func (e *Encoder) fastpathEncMapUint16Int8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint16Int8V(rv2i(rv).(map[uint16]int8), e) } func (_ fastpathT) EncMapUint16Int8V(v map[uint16]int8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8066,26 +7540,32 @@ func (_ fastpathT) EncMapUint16Int8V(v map[uint16]int8, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint16(k2))) - if esep { + ee.EncodeUint(uint64(uint16(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint16(k2))) + ee.EncodeInt(int64(v[uint16(k2)])) } - ee.EncodeInt(int64(v[uint16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -8095,6 +7575,10 @@ func (e *Encoder) fastpathEncMapUint16Int16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint16Int16V(rv2i(rv).(map[uint16]int16), e) } func (_ fastpathT) EncMapUint16Int16V(v map[uint16]int16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8105,26 +7589,32 @@ func (_ fastpathT) EncMapUint16Int16V(v map[uint16]int16, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint16(k2))) - if esep { + ee.EncodeUint(uint64(uint16(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint16(k2))) + ee.EncodeInt(int64(v[uint16(k2)])) } - ee.EncodeInt(int64(v[uint16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -8134,6 +7624,10 @@ func (e *Encoder) fastpathEncMapUint16Int32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint16Int32V(rv2i(rv).(map[uint16]int32), e) } func (_ fastpathT) EncMapUint16Int32V(v map[uint16]int32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8144,26 +7638,32 @@ func (_ fastpathT) EncMapUint16Int32V(v map[uint16]int32, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint16(k2))) - if esep { + ee.EncodeUint(uint64(uint16(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint16(k2))) + ee.EncodeInt(int64(v[uint16(k2)])) } - ee.EncodeInt(int64(v[uint16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -8173,6 +7673,10 @@ func (e *Encoder) fastpathEncMapUint16Int64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint16Int64V(rv2i(rv).(map[uint16]int64), e) } func (_ fastpathT) EncMapUint16Int64V(v map[uint16]int64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8183,26 +7687,32 @@ func (_ fastpathT) EncMapUint16Int64V(v map[uint16]int64, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint16(k2))) - if esep { + ee.EncodeUint(uint64(uint16(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint16(k2))) + ee.EncodeInt(int64(v[uint16(k2)])) } - ee.EncodeInt(int64(v[uint16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -8212,6 +7722,10 @@ func (e *Encoder) fastpathEncMapUint16Float32R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint16Float32V(rv2i(rv).(map[uint16]float32), e) } func (_ fastpathT) EncMapUint16Float32V(v map[uint16]float32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8222,26 +7736,32 @@ func (_ fastpathT) EncMapUint16Float32V(v map[uint16]float32, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint16(k2))) - if esep { + ee.EncodeUint(uint64(uint16(k2))) ee.WriteMapElemValue() + ee.EncodeFloat32(v[uint16(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint16(k2))) + ee.EncodeFloat32(v[uint16(k2)]) } - ee.EncodeFloat32(v[uint16(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat32(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeFloat32(v2) } - ee.EncodeFloat32(v2) } } ee.WriteMapEnd() @@ -8251,6 +7771,10 @@ func (e *Encoder) fastpathEncMapUint16Float64R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint16Float64V(rv2i(rv).(map[uint16]float64), e) } func (_ fastpathT) EncMapUint16Float64V(v map[uint16]float64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8261,26 +7785,32 @@ func (_ fastpathT) EncMapUint16Float64V(v map[uint16]float64, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint16(k2))) - if esep { + ee.EncodeUint(uint64(uint16(k2))) ee.WriteMapElemValue() + ee.EncodeFloat64(v[uint16(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint16(k2))) + ee.EncodeFloat64(v[uint16(k2)]) } - ee.EncodeFloat64(v[uint16(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat64(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeFloat64(v2) } - ee.EncodeFloat64(v2) } } ee.WriteMapEnd() @@ -8290,6 +7820,10 @@ func (e *Encoder) fastpathEncMapUint16BoolR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint16BoolV(rv2i(rv).(map[uint16]bool), e) } func (_ fastpathT) EncMapUint16BoolV(v map[uint16]bool, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8300,26 +7834,32 @@ func (_ fastpathT) EncMapUint16BoolV(v map[uint16]bool, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint16(k2))) - if esep { + ee.EncodeUint(uint64(uint16(k2))) ee.WriteMapElemValue() + ee.EncodeBool(v[uint16(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint16(k2))) + ee.EncodeBool(v[uint16(k2)]) } - ee.EncodeBool(v[uint16(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeBool(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeBool(v2) } - ee.EncodeBool(v2) } } ee.WriteMapEnd() @@ -8329,6 +7869,10 @@ func (e *Encoder) fastpathEncMapUint32IntfR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint32IntfV(rv2i(rv).(map[uint32]interface{}), e) } func (_ fastpathT) EncMapUint32IntfV(v map[uint32]interface{}, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8339,26 +7883,32 @@ func (_ fastpathT) EncMapUint32IntfV(v map[uint32]interface{}, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint32(k2))) - if esep { + ee.EncodeUint(uint64(uint32(k2))) ee.WriteMapElemValue() + e.encode(v[uint32(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint32(k2))) + e.encode(v[uint32(k2)]) } - e.encode(v[uint32(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -8368,6 +7918,10 @@ func (e *Encoder) fastpathEncMapUint32StringR(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint32StringV(rv2i(rv).(map[uint32]string), e) } func (_ fastpathT) EncMapUint32StringV(v map[uint32]string, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8378,26 +7932,32 @@ func (_ fastpathT) EncMapUint32StringV(v map[uint32]string, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint32(k2))) - if esep { + ee.EncodeUint(uint64(uint32(k2))) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v[uint32(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint32(k2))) + ee.EncodeString(cUTF8, v[uint32(k2)]) } - ee.EncodeString(c_UTF8, v[uint32(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeString(cUTF8, v2) } - ee.EncodeString(c_UTF8, v2) } } ee.WriteMapEnd() @@ -8407,6 +7967,10 @@ func (e *Encoder) fastpathEncMapUint32UintR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint32UintV(rv2i(rv).(map[uint32]uint), e) } func (_ fastpathT) EncMapUint32UintV(v map[uint32]uint, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8417,26 +7981,32 @@ func (_ fastpathT) EncMapUint32UintV(v map[uint32]uint, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint32(k2))) - if esep { + ee.EncodeUint(uint64(uint32(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint32(k2))) + ee.EncodeUint(uint64(v[uint32(k2)])) } - ee.EncodeUint(uint64(v[uint32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -8446,6 +8016,10 @@ func (e *Encoder) fastpathEncMapUint32Uint8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint32Uint8V(rv2i(rv).(map[uint32]uint8), e) } func (_ fastpathT) EncMapUint32Uint8V(v map[uint32]uint8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8456,26 +8030,32 @@ func (_ fastpathT) EncMapUint32Uint8V(v map[uint32]uint8, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint32(k2))) - if esep { + ee.EncodeUint(uint64(uint32(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint32(k2))) + ee.EncodeUint(uint64(v[uint32(k2)])) } - ee.EncodeUint(uint64(v[uint32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -8485,6 +8065,10 @@ func (e *Encoder) fastpathEncMapUint32Uint16R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint32Uint16V(rv2i(rv).(map[uint32]uint16), e) } func (_ fastpathT) EncMapUint32Uint16V(v map[uint32]uint16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8495,26 +8079,32 @@ func (_ fastpathT) EncMapUint32Uint16V(v map[uint32]uint16, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint32(k2))) - if esep { + ee.EncodeUint(uint64(uint32(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint32(k2))) + ee.EncodeUint(uint64(v[uint32(k2)])) } - ee.EncodeUint(uint64(v[uint32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -8524,6 +8114,10 @@ func (e *Encoder) fastpathEncMapUint32Uint32R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint32Uint32V(rv2i(rv).(map[uint32]uint32), e) } func (_ fastpathT) EncMapUint32Uint32V(v map[uint32]uint32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8534,26 +8128,32 @@ func (_ fastpathT) EncMapUint32Uint32V(v map[uint32]uint32, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint32(k2))) - if esep { + ee.EncodeUint(uint64(uint32(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint32(k2))) + ee.EncodeUint(uint64(v[uint32(k2)])) } - ee.EncodeUint(uint64(v[uint32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -8563,6 +8163,10 @@ func (e *Encoder) fastpathEncMapUint32Uint64R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint32Uint64V(rv2i(rv).(map[uint32]uint64), e) } func (_ fastpathT) EncMapUint32Uint64V(v map[uint32]uint64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8573,26 +8177,32 @@ func (_ fastpathT) EncMapUint32Uint64V(v map[uint32]uint64, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint32(k2))) - if esep { + ee.EncodeUint(uint64(uint32(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint32(k2))) + ee.EncodeUint(uint64(v[uint32(k2)])) } - ee.EncodeUint(uint64(v[uint32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -8602,6 +8212,10 @@ func (e *Encoder) fastpathEncMapUint32UintptrR(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint32UintptrV(rv2i(rv).(map[uint32]uintptr), e) } func (_ fastpathT) EncMapUint32UintptrV(v map[uint32]uintptr, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8612,26 +8226,32 @@ func (_ fastpathT) EncMapUint32UintptrV(v map[uint32]uintptr, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint32(k2))) - if esep { + ee.EncodeUint(uint64(uint32(k2))) ee.WriteMapElemValue() + e.encode(v[uint32(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint32(k2))) + e.encode(v[uint32(k2)]) } - e.encode(v[uint32(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -8641,6 +8261,10 @@ func (e *Encoder) fastpathEncMapUint32IntR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint32IntV(rv2i(rv).(map[uint32]int), e) } func (_ fastpathT) EncMapUint32IntV(v map[uint32]int, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8651,26 +8275,32 @@ func (_ fastpathT) EncMapUint32IntV(v map[uint32]int, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint32(k2))) - if esep { + ee.EncodeUint(uint64(uint32(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint32(k2))) + ee.EncodeInt(int64(v[uint32(k2)])) } - ee.EncodeInt(int64(v[uint32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -8680,6 +8310,10 @@ func (e *Encoder) fastpathEncMapUint32Int8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint32Int8V(rv2i(rv).(map[uint32]int8), e) } func (_ fastpathT) EncMapUint32Int8V(v map[uint32]int8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8690,26 +8324,32 @@ func (_ fastpathT) EncMapUint32Int8V(v map[uint32]int8, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint32(k2))) - if esep { + ee.EncodeUint(uint64(uint32(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint32(k2))) + ee.EncodeInt(int64(v[uint32(k2)])) } - ee.EncodeInt(int64(v[uint32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -8719,6 +8359,10 @@ func (e *Encoder) fastpathEncMapUint32Int16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint32Int16V(rv2i(rv).(map[uint32]int16), e) } func (_ fastpathT) EncMapUint32Int16V(v map[uint32]int16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8729,26 +8373,32 @@ func (_ fastpathT) EncMapUint32Int16V(v map[uint32]int16, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint32(k2))) - if esep { + ee.EncodeUint(uint64(uint32(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint32(k2))) + ee.EncodeInt(int64(v[uint32(k2)])) } - ee.EncodeInt(int64(v[uint32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -8758,6 +8408,10 @@ func (e *Encoder) fastpathEncMapUint32Int32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint32Int32V(rv2i(rv).(map[uint32]int32), e) } func (_ fastpathT) EncMapUint32Int32V(v map[uint32]int32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8768,26 +8422,32 @@ func (_ fastpathT) EncMapUint32Int32V(v map[uint32]int32, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint32(k2))) - if esep { + ee.EncodeUint(uint64(uint32(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint32(k2))) + ee.EncodeInt(int64(v[uint32(k2)])) } - ee.EncodeInt(int64(v[uint32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -8797,6 +8457,10 @@ func (e *Encoder) fastpathEncMapUint32Int64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint32Int64V(rv2i(rv).(map[uint32]int64), e) } func (_ fastpathT) EncMapUint32Int64V(v map[uint32]int64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8807,26 +8471,32 @@ func (_ fastpathT) EncMapUint32Int64V(v map[uint32]int64, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint32(k2))) - if esep { + ee.EncodeUint(uint64(uint32(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint32(k2))) + ee.EncodeInt(int64(v[uint32(k2)])) } - ee.EncodeInt(int64(v[uint32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -8836,6 +8506,10 @@ func (e *Encoder) fastpathEncMapUint32Float32R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint32Float32V(rv2i(rv).(map[uint32]float32), e) } func (_ fastpathT) EncMapUint32Float32V(v map[uint32]float32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8846,26 +8520,32 @@ func (_ fastpathT) EncMapUint32Float32V(v map[uint32]float32, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint32(k2))) - if esep { + ee.EncodeUint(uint64(uint32(k2))) ee.WriteMapElemValue() + ee.EncodeFloat32(v[uint32(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint32(k2))) + ee.EncodeFloat32(v[uint32(k2)]) } - ee.EncodeFloat32(v[uint32(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat32(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeFloat32(v2) } - ee.EncodeFloat32(v2) } } ee.WriteMapEnd() @@ -8875,6 +8555,10 @@ func (e *Encoder) fastpathEncMapUint32Float64R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint32Float64V(rv2i(rv).(map[uint32]float64), e) } func (_ fastpathT) EncMapUint32Float64V(v map[uint32]float64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8885,26 +8569,32 @@ func (_ fastpathT) EncMapUint32Float64V(v map[uint32]float64, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint32(k2))) - if esep { + ee.EncodeUint(uint64(uint32(k2))) ee.WriteMapElemValue() + ee.EncodeFloat64(v[uint32(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint32(k2))) + ee.EncodeFloat64(v[uint32(k2)]) } - ee.EncodeFloat64(v[uint32(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat64(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeFloat64(v2) } - ee.EncodeFloat64(v2) } } ee.WriteMapEnd() @@ -8914,6 +8604,10 @@ func (e *Encoder) fastpathEncMapUint32BoolR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint32BoolV(rv2i(rv).(map[uint32]bool), e) } func (_ fastpathT) EncMapUint32BoolV(v map[uint32]bool, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8924,26 +8618,32 @@ func (_ fastpathT) EncMapUint32BoolV(v map[uint32]bool, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint32(k2))) - if esep { + ee.EncodeUint(uint64(uint32(k2))) ee.WriteMapElemValue() + ee.EncodeBool(v[uint32(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint32(k2))) + ee.EncodeBool(v[uint32(k2)]) } - ee.EncodeBool(v[uint32(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeBool(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeBool(v2) } - ee.EncodeBool(v2) } } ee.WriteMapEnd() @@ -8953,6 +8653,10 @@ func (e *Encoder) fastpathEncMapUint64IntfR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint64IntfV(rv2i(rv).(map[uint64]interface{}), e) } func (_ fastpathT) EncMapUint64IntfV(v map[uint64]interface{}, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -8963,26 +8667,32 @@ func (_ fastpathT) EncMapUint64IntfV(v map[uint64]interface{}, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint64(k2))) - if esep { + ee.EncodeUint(uint64(uint64(k2))) ee.WriteMapElemValue() + e.encode(v[uint64(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint64(k2))) + e.encode(v[uint64(k2)]) } - e.encode(v[uint64(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -8992,6 +8702,10 @@ func (e *Encoder) fastpathEncMapUint64StringR(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint64StringV(rv2i(rv).(map[uint64]string), e) } func (_ fastpathT) EncMapUint64StringV(v map[uint64]string, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9002,26 +8716,32 @@ func (_ fastpathT) EncMapUint64StringV(v map[uint64]string, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint64(k2))) - if esep { + ee.EncodeUint(uint64(uint64(k2))) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v[uint64(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint64(k2))) + ee.EncodeString(cUTF8, v[uint64(k2)]) } - ee.EncodeString(c_UTF8, v[uint64(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeString(cUTF8, v2) } - ee.EncodeString(c_UTF8, v2) } } ee.WriteMapEnd() @@ -9031,6 +8751,10 @@ func (e *Encoder) fastpathEncMapUint64UintR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint64UintV(rv2i(rv).(map[uint64]uint), e) } func (_ fastpathT) EncMapUint64UintV(v map[uint64]uint, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9041,26 +8765,32 @@ func (_ fastpathT) EncMapUint64UintV(v map[uint64]uint, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint64(k2))) - if esep { + ee.EncodeUint(uint64(uint64(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint64(k2))) + ee.EncodeUint(uint64(v[uint64(k2)])) } - ee.EncodeUint(uint64(v[uint64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -9070,6 +8800,10 @@ func (e *Encoder) fastpathEncMapUint64Uint8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint64Uint8V(rv2i(rv).(map[uint64]uint8), e) } func (_ fastpathT) EncMapUint64Uint8V(v map[uint64]uint8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9080,26 +8814,32 @@ func (_ fastpathT) EncMapUint64Uint8V(v map[uint64]uint8, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint64(k2))) - if esep { + ee.EncodeUint(uint64(uint64(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint64(k2))) + ee.EncodeUint(uint64(v[uint64(k2)])) } - ee.EncodeUint(uint64(v[uint64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -9109,6 +8849,10 @@ func (e *Encoder) fastpathEncMapUint64Uint16R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint64Uint16V(rv2i(rv).(map[uint64]uint16), e) } func (_ fastpathT) EncMapUint64Uint16V(v map[uint64]uint16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9119,26 +8863,32 @@ func (_ fastpathT) EncMapUint64Uint16V(v map[uint64]uint16, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint64(k2))) - if esep { + ee.EncodeUint(uint64(uint64(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint64(k2))) + ee.EncodeUint(uint64(v[uint64(k2)])) } - ee.EncodeUint(uint64(v[uint64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -9148,6 +8898,10 @@ func (e *Encoder) fastpathEncMapUint64Uint32R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint64Uint32V(rv2i(rv).(map[uint64]uint32), e) } func (_ fastpathT) EncMapUint64Uint32V(v map[uint64]uint32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9158,26 +8912,32 @@ func (_ fastpathT) EncMapUint64Uint32V(v map[uint64]uint32, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint64(k2))) - if esep { + ee.EncodeUint(uint64(uint64(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint64(k2))) + ee.EncodeUint(uint64(v[uint64(k2)])) } - ee.EncodeUint(uint64(v[uint64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -9187,6 +8947,10 @@ func (e *Encoder) fastpathEncMapUint64Uint64R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint64Uint64V(rv2i(rv).(map[uint64]uint64), e) } func (_ fastpathT) EncMapUint64Uint64V(v map[uint64]uint64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9197,26 +8961,32 @@ func (_ fastpathT) EncMapUint64Uint64V(v map[uint64]uint64, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint64(k2))) - if esep { + ee.EncodeUint(uint64(uint64(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uint64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint64(k2))) + ee.EncodeUint(uint64(v[uint64(k2)])) } - ee.EncodeUint(uint64(v[uint64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -9226,6 +8996,10 @@ func (e *Encoder) fastpathEncMapUint64UintptrR(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint64UintptrV(rv2i(rv).(map[uint64]uintptr), e) } func (_ fastpathT) EncMapUint64UintptrV(v map[uint64]uintptr, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9236,26 +9010,32 @@ func (_ fastpathT) EncMapUint64UintptrV(v map[uint64]uintptr, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint64(k2))) - if esep { + ee.EncodeUint(uint64(uint64(k2))) ee.WriteMapElemValue() + e.encode(v[uint64(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint64(k2))) + e.encode(v[uint64(k2)]) } - e.encode(v[uint64(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -9265,6 +9045,10 @@ func (e *Encoder) fastpathEncMapUint64IntR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint64IntV(rv2i(rv).(map[uint64]int), e) } func (_ fastpathT) EncMapUint64IntV(v map[uint64]int, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9275,26 +9059,32 @@ func (_ fastpathT) EncMapUint64IntV(v map[uint64]int, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint64(k2))) - if esep { + ee.EncodeUint(uint64(uint64(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint64(k2))) + ee.EncodeInt(int64(v[uint64(k2)])) } - ee.EncodeInt(int64(v[uint64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -9304,6 +9094,10 @@ func (e *Encoder) fastpathEncMapUint64Int8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint64Int8V(rv2i(rv).(map[uint64]int8), e) } func (_ fastpathT) EncMapUint64Int8V(v map[uint64]int8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9314,26 +9108,32 @@ func (_ fastpathT) EncMapUint64Int8V(v map[uint64]int8, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint64(k2))) - if esep { + ee.EncodeUint(uint64(uint64(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint64(k2))) + ee.EncodeInt(int64(v[uint64(k2)])) } - ee.EncodeInt(int64(v[uint64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -9343,6 +9143,10 @@ func (e *Encoder) fastpathEncMapUint64Int16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint64Int16V(rv2i(rv).(map[uint64]int16), e) } func (_ fastpathT) EncMapUint64Int16V(v map[uint64]int16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9353,26 +9157,32 @@ func (_ fastpathT) EncMapUint64Int16V(v map[uint64]int16, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint64(k2))) - if esep { + ee.EncodeUint(uint64(uint64(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint64(k2))) + ee.EncodeInt(int64(v[uint64(k2)])) } - ee.EncodeInt(int64(v[uint64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -9382,6 +9192,10 @@ func (e *Encoder) fastpathEncMapUint64Int32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint64Int32V(rv2i(rv).(map[uint64]int32), e) } func (_ fastpathT) EncMapUint64Int32V(v map[uint64]int32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9392,26 +9206,32 @@ func (_ fastpathT) EncMapUint64Int32V(v map[uint64]int32, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint64(k2))) - if esep { + ee.EncodeUint(uint64(uint64(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint64(k2))) + ee.EncodeInt(int64(v[uint64(k2)])) } - ee.EncodeInt(int64(v[uint64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -9421,6 +9241,10 @@ func (e *Encoder) fastpathEncMapUint64Int64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint64Int64V(rv2i(rv).(map[uint64]int64), e) } func (_ fastpathT) EncMapUint64Int64V(v map[uint64]int64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9431,26 +9255,32 @@ func (_ fastpathT) EncMapUint64Int64V(v map[uint64]int64, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint64(k2))) - if esep { + ee.EncodeUint(uint64(uint64(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uint64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint64(k2))) + ee.EncodeInt(int64(v[uint64(k2)])) } - ee.EncodeInt(int64(v[uint64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -9460,6 +9290,10 @@ func (e *Encoder) fastpathEncMapUint64Float32R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint64Float32V(rv2i(rv).(map[uint64]float32), e) } func (_ fastpathT) EncMapUint64Float32V(v map[uint64]float32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9470,26 +9304,32 @@ func (_ fastpathT) EncMapUint64Float32V(v map[uint64]float32, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint64(k2))) - if esep { + ee.EncodeUint(uint64(uint64(k2))) ee.WriteMapElemValue() + ee.EncodeFloat32(v[uint64(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint64(k2))) + ee.EncodeFloat32(v[uint64(k2)]) } - ee.EncodeFloat32(v[uint64(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat32(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeFloat32(v2) } - ee.EncodeFloat32(v2) } } ee.WriteMapEnd() @@ -9499,6 +9339,10 @@ func (e *Encoder) fastpathEncMapUint64Float64R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUint64Float64V(rv2i(rv).(map[uint64]float64), e) } func (_ fastpathT) EncMapUint64Float64V(v map[uint64]float64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9509,26 +9353,32 @@ func (_ fastpathT) EncMapUint64Float64V(v map[uint64]float64, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint64(k2))) - if esep { + ee.EncodeUint(uint64(uint64(k2))) ee.WriteMapElemValue() + ee.EncodeFloat64(v[uint64(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint64(k2))) + ee.EncodeFloat64(v[uint64(k2)]) } - ee.EncodeFloat64(v[uint64(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat64(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeFloat64(v2) } - ee.EncodeFloat64(v2) } } ee.WriteMapEnd() @@ -9538,6 +9388,10 @@ func (e *Encoder) fastpathEncMapUint64BoolR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUint64BoolV(rv2i(rv).(map[uint64]bool), e) } func (_ fastpathT) EncMapUint64BoolV(v map[uint64]bool, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9548,26 +9402,32 @@ func (_ fastpathT) EncMapUint64BoolV(v map[uint64]bool, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(uint64(k2))) - if esep { + ee.EncodeUint(uint64(uint64(k2))) ee.WriteMapElemValue() + ee.EncodeBool(v[uint64(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeUint(uint64(uint64(k2))) + ee.EncodeBool(v[uint64(k2)]) } - ee.EncodeBool(v[uint64(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeUint(uint64(k2)) - if esep { + ee.EncodeUint(uint64(k2)) ee.WriteMapElemValue() + ee.EncodeBool(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeUint(uint64(k2)) + ee.EncodeBool(v2) } - ee.EncodeBool(v2) } } ee.WriteMapEnd() @@ -9577,6 +9437,10 @@ func (e *Encoder) fastpathEncMapUintptrIntfR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintptrIntfV(rv2i(rv).(map[uintptr]interface{}), e) } func (_ fastpathT) EncMapUintptrIntfV(v map[uintptr]interface{}, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9587,26 +9451,32 @@ func (_ fastpathT) EncMapUintptrIntfV(v map[uintptr]interface{}, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - e.encode(uintptr(k2)) - if esep { + e.encode(uintptr(k2)) ee.WriteMapElemValue() + e.encode(v[uintptr(k2)]) + } + } else { + for _, k2 := range v2 { + e.encode(uintptr(k2)) + e.encode(v[uintptr(k2)]) } - e.encode(v[uintptr(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + e.encode(k2) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -9616,6 +9486,10 @@ func (e *Encoder) fastpathEncMapUintptrStringR(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUintptrStringV(rv2i(rv).(map[uintptr]string), e) } func (_ fastpathT) EncMapUintptrStringV(v map[uintptr]string, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9626,26 +9500,32 @@ func (_ fastpathT) EncMapUintptrStringV(v map[uintptr]string, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - e.encode(uintptr(k2)) - if esep { + e.encode(uintptr(k2)) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v[uintptr(k2)]) + } + } else { + for _, k2 := range v2 { + e.encode(uintptr(k2)) + ee.EncodeString(cUTF8, v[uintptr(k2)]) } - ee.EncodeString(c_UTF8, v[uintptr(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v2) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeString(cUTF8, v2) } - ee.EncodeString(c_UTF8, v2) } } ee.WriteMapEnd() @@ -9655,6 +9535,10 @@ func (e *Encoder) fastpathEncMapUintptrUintR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintptrUintV(rv2i(rv).(map[uintptr]uint), e) } func (_ fastpathT) EncMapUintptrUintV(v map[uintptr]uint, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9665,26 +9549,32 @@ func (_ fastpathT) EncMapUintptrUintV(v map[uintptr]uint, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - e.encode(uintptr(k2)) - if esep { + e.encode(uintptr(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uintptr(k2)])) + } + } else { + for _, k2 := range v2 { + e.encode(uintptr(k2)) + ee.EncodeUint(uint64(v[uintptr(k2)])) } - ee.EncodeUint(uint64(v[uintptr(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -9694,6 +9584,10 @@ func (e *Encoder) fastpathEncMapUintptrUint8R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUintptrUint8V(rv2i(rv).(map[uintptr]uint8), e) } func (_ fastpathT) EncMapUintptrUint8V(v map[uintptr]uint8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9704,26 +9598,32 @@ func (_ fastpathT) EncMapUintptrUint8V(v map[uintptr]uint8, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - e.encode(uintptr(k2)) - if esep { + e.encode(uintptr(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uintptr(k2)])) + } + } else { + for _, k2 := range v2 { + e.encode(uintptr(k2)) + ee.EncodeUint(uint64(v[uintptr(k2)])) } - ee.EncodeUint(uint64(v[uintptr(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -9733,6 +9633,10 @@ func (e *Encoder) fastpathEncMapUintptrUint16R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUintptrUint16V(rv2i(rv).(map[uintptr]uint16), e) } func (_ fastpathT) EncMapUintptrUint16V(v map[uintptr]uint16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9743,26 +9647,32 @@ func (_ fastpathT) EncMapUintptrUint16V(v map[uintptr]uint16, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - e.encode(uintptr(k2)) - if esep { + e.encode(uintptr(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uintptr(k2)])) + } + } else { + for _, k2 := range v2 { + e.encode(uintptr(k2)) + ee.EncodeUint(uint64(v[uintptr(k2)])) } - ee.EncodeUint(uint64(v[uintptr(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -9772,6 +9682,10 @@ func (e *Encoder) fastpathEncMapUintptrUint32R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUintptrUint32V(rv2i(rv).(map[uintptr]uint32), e) } func (_ fastpathT) EncMapUintptrUint32V(v map[uintptr]uint32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9782,26 +9696,32 @@ func (_ fastpathT) EncMapUintptrUint32V(v map[uintptr]uint32, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - e.encode(uintptr(k2)) - if esep { + e.encode(uintptr(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uintptr(k2)])) + } + } else { + for _, k2 := range v2 { + e.encode(uintptr(k2)) + ee.EncodeUint(uint64(v[uintptr(k2)])) } - ee.EncodeUint(uint64(v[uintptr(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -9811,6 +9731,10 @@ func (e *Encoder) fastpathEncMapUintptrUint64R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUintptrUint64V(rv2i(rv).(map[uintptr]uint64), e) } func (_ fastpathT) EncMapUintptrUint64V(v map[uintptr]uint64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9821,26 +9745,32 @@ func (_ fastpathT) EncMapUintptrUint64V(v map[uintptr]uint64, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - e.encode(uintptr(k2)) - if esep { + e.encode(uintptr(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[uintptr(k2)])) + } + } else { + for _, k2 := range v2 { + e.encode(uintptr(k2)) + ee.EncodeUint(uint64(v[uintptr(k2)])) } - ee.EncodeUint(uint64(v[uintptr(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -9850,6 +9780,10 @@ func (e *Encoder) fastpathEncMapUintptrUintptrR(f *codecFnInfo, rv reflect.Value fastpathTV.EncMapUintptrUintptrV(rv2i(rv).(map[uintptr]uintptr), e) } func (_ fastpathT) EncMapUintptrUintptrV(v map[uintptr]uintptr, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9860,26 +9794,32 @@ func (_ fastpathT) EncMapUintptrUintptrV(v map[uintptr]uintptr, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - e.encode(uintptr(k2)) - if esep { + e.encode(uintptr(k2)) ee.WriteMapElemValue() + e.encode(v[uintptr(k2)]) + } + } else { + for _, k2 := range v2 { + e.encode(uintptr(k2)) + e.encode(v[uintptr(k2)]) } - e.encode(v[uintptr(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + e.encode(k2) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -9889,6 +9829,10 @@ func (e *Encoder) fastpathEncMapUintptrIntR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintptrIntV(rv2i(rv).(map[uintptr]int), e) } func (_ fastpathT) EncMapUintptrIntV(v map[uintptr]int, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9899,26 +9843,32 @@ func (_ fastpathT) EncMapUintptrIntV(v map[uintptr]int, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - e.encode(uintptr(k2)) - if esep { + e.encode(uintptr(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uintptr(k2)])) + } + } else { + for _, k2 := range v2 { + e.encode(uintptr(k2)) + ee.EncodeInt(int64(v[uintptr(k2)])) } - ee.EncodeInt(int64(v[uintptr(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -9928,6 +9878,10 @@ func (e *Encoder) fastpathEncMapUintptrInt8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintptrInt8V(rv2i(rv).(map[uintptr]int8), e) } func (_ fastpathT) EncMapUintptrInt8V(v map[uintptr]int8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9938,26 +9892,32 @@ func (_ fastpathT) EncMapUintptrInt8V(v map[uintptr]int8, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - e.encode(uintptr(k2)) - if esep { + e.encode(uintptr(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uintptr(k2)])) + } + } else { + for _, k2 := range v2 { + e.encode(uintptr(k2)) + ee.EncodeInt(int64(v[uintptr(k2)])) } - ee.EncodeInt(int64(v[uintptr(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -9967,6 +9927,10 @@ func (e *Encoder) fastpathEncMapUintptrInt16R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUintptrInt16V(rv2i(rv).(map[uintptr]int16), e) } func (_ fastpathT) EncMapUintptrInt16V(v map[uintptr]int16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -9977,26 +9941,32 @@ func (_ fastpathT) EncMapUintptrInt16V(v map[uintptr]int16, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - e.encode(uintptr(k2)) - if esep { + e.encode(uintptr(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uintptr(k2)])) + } + } else { + for _, k2 := range v2 { + e.encode(uintptr(k2)) + ee.EncodeInt(int64(v[uintptr(k2)])) } - ee.EncodeInt(int64(v[uintptr(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -10006,6 +9976,10 @@ func (e *Encoder) fastpathEncMapUintptrInt32R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUintptrInt32V(rv2i(rv).(map[uintptr]int32), e) } func (_ fastpathT) EncMapUintptrInt32V(v map[uintptr]int32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10016,26 +9990,32 @@ func (_ fastpathT) EncMapUintptrInt32V(v map[uintptr]int32, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - e.encode(uintptr(k2)) - if esep { + e.encode(uintptr(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uintptr(k2)])) + } + } else { + for _, k2 := range v2 { + e.encode(uintptr(k2)) + ee.EncodeInt(int64(v[uintptr(k2)])) } - ee.EncodeInt(int64(v[uintptr(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -10045,6 +10025,10 @@ func (e *Encoder) fastpathEncMapUintptrInt64R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapUintptrInt64V(rv2i(rv).(map[uintptr]int64), e) } func (_ fastpathT) EncMapUintptrInt64V(v map[uintptr]int64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10055,26 +10039,32 @@ func (_ fastpathT) EncMapUintptrInt64V(v map[uintptr]int64, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - e.encode(uintptr(k2)) - if esep { + e.encode(uintptr(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[uintptr(k2)])) + } + } else { + for _, k2 := range v2 { + e.encode(uintptr(k2)) + ee.EncodeInt(int64(v[uintptr(k2)])) } - ee.EncodeInt(int64(v[uintptr(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -10084,6 +10074,10 @@ func (e *Encoder) fastpathEncMapUintptrFloat32R(f *codecFnInfo, rv reflect.Value fastpathTV.EncMapUintptrFloat32V(rv2i(rv).(map[uintptr]float32), e) } func (_ fastpathT) EncMapUintptrFloat32V(v map[uintptr]float32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10094,26 +10088,32 @@ func (_ fastpathT) EncMapUintptrFloat32V(v map[uintptr]float32, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - e.encode(uintptr(k2)) - if esep { + e.encode(uintptr(k2)) ee.WriteMapElemValue() + ee.EncodeFloat32(v[uintptr(k2)]) + } + } else { + for _, k2 := range v2 { + e.encode(uintptr(k2)) + ee.EncodeFloat32(v[uintptr(k2)]) } - ee.EncodeFloat32(v[uintptr(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeFloat32(v2) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeFloat32(v2) } - ee.EncodeFloat32(v2) } } ee.WriteMapEnd() @@ -10123,6 +10123,10 @@ func (e *Encoder) fastpathEncMapUintptrFloat64R(f *codecFnInfo, rv reflect.Value fastpathTV.EncMapUintptrFloat64V(rv2i(rv).(map[uintptr]float64), e) } func (_ fastpathT) EncMapUintptrFloat64V(v map[uintptr]float64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10133,26 +10137,32 @@ func (_ fastpathT) EncMapUintptrFloat64V(v map[uintptr]float64, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - e.encode(uintptr(k2)) - if esep { + e.encode(uintptr(k2)) ee.WriteMapElemValue() + ee.EncodeFloat64(v[uintptr(k2)]) + } + } else { + for _, k2 := range v2 { + e.encode(uintptr(k2)) + ee.EncodeFloat64(v[uintptr(k2)]) } - ee.EncodeFloat64(v[uintptr(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeFloat64(v2) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeFloat64(v2) } - ee.EncodeFloat64(v2) } } ee.WriteMapEnd() @@ -10162,6 +10172,10 @@ func (e *Encoder) fastpathEncMapUintptrBoolR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapUintptrBoolV(rv2i(rv).(map[uintptr]bool), e) } func (_ fastpathT) EncMapUintptrBoolV(v map[uintptr]bool, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10172,26 +10186,32 @@ func (_ fastpathT) EncMapUintptrBoolV(v map[uintptr]bool, e *Encoder) { i++ } sort.Sort(uintSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - e.encode(uintptr(k2)) - if esep { + e.encode(uintptr(k2)) ee.WriteMapElemValue() + ee.EncodeBool(v[uintptr(k2)]) + } + } else { + for _, k2 := range v2 { + e.encode(uintptr(k2)) + ee.EncodeBool(v[uintptr(k2)]) } - ee.EncodeBool(v[uintptr(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - e.encode(k2) - if esep { + e.encode(k2) ee.WriteMapElemValue() + ee.EncodeBool(v2) + } + } else { + for k2, v2 := range v { + e.encode(k2) + ee.EncodeBool(v2) } - ee.EncodeBool(v2) } } ee.WriteMapEnd() @@ -10201,6 +10221,10 @@ func (e *Encoder) fastpathEncMapIntIntfR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntIntfV(rv2i(rv).(map[int]interface{}), e) } func (_ fastpathT) EncMapIntIntfV(v map[int]interface{}, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10211,26 +10235,32 @@ func (_ fastpathT) EncMapIntIntfV(v map[int]interface{}, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int(k2))) - if esep { + ee.EncodeInt(int64(int(k2))) ee.WriteMapElemValue() + e.encode(v[int(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int(k2))) + e.encode(v[int(k2)]) } - e.encode(v[int(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -10240,6 +10270,10 @@ func (e *Encoder) fastpathEncMapIntStringR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntStringV(rv2i(rv).(map[int]string), e) } func (_ fastpathT) EncMapIntStringV(v map[int]string, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10250,26 +10284,32 @@ func (_ fastpathT) EncMapIntStringV(v map[int]string, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int(k2))) - if esep { + ee.EncodeInt(int64(int(k2))) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v[int(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int(k2))) + ee.EncodeString(cUTF8, v[int(k2)]) } - ee.EncodeString(c_UTF8, v[int(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeString(cUTF8, v2) } - ee.EncodeString(c_UTF8, v2) } } ee.WriteMapEnd() @@ -10279,6 +10319,10 @@ func (e *Encoder) fastpathEncMapIntUintR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntUintV(rv2i(rv).(map[int]uint), e) } func (_ fastpathT) EncMapIntUintV(v map[int]uint, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10289,26 +10333,32 @@ func (_ fastpathT) EncMapIntUintV(v map[int]uint, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int(k2))) - if esep { + ee.EncodeInt(int64(int(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int(k2))) + ee.EncodeUint(uint64(v[int(k2)])) } - ee.EncodeUint(uint64(v[int(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -10318,6 +10368,10 @@ func (e *Encoder) fastpathEncMapIntUint8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntUint8V(rv2i(rv).(map[int]uint8), e) } func (_ fastpathT) EncMapIntUint8V(v map[int]uint8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10328,26 +10382,32 @@ func (_ fastpathT) EncMapIntUint8V(v map[int]uint8, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int(k2))) - if esep { + ee.EncodeInt(int64(int(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int(k2))) + ee.EncodeUint(uint64(v[int(k2)])) } - ee.EncodeUint(uint64(v[int(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -10357,6 +10417,10 @@ func (e *Encoder) fastpathEncMapIntUint16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntUint16V(rv2i(rv).(map[int]uint16), e) } func (_ fastpathT) EncMapIntUint16V(v map[int]uint16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10367,26 +10431,32 @@ func (_ fastpathT) EncMapIntUint16V(v map[int]uint16, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int(k2))) - if esep { + ee.EncodeInt(int64(int(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int(k2))) + ee.EncodeUint(uint64(v[int(k2)])) } - ee.EncodeUint(uint64(v[int(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -10396,6 +10466,10 @@ func (e *Encoder) fastpathEncMapIntUint32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntUint32V(rv2i(rv).(map[int]uint32), e) } func (_ fastpathT) EncMapIntUint32V(v map[int]uint32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10406,26 +10480,32 @@ func (_ fastpathT) EncMapIntUint32V(v map[int]uint32, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int(k2))) - if esep { + ee.EncodeInt(int64(int(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int(k2))) + ee.EncodeUint(uint64(v[int(k2)])) } - ee.EncodeUint(uint64(v[int(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -10435,6 +10515,10 @@ func (e *Encoder) fastpathEncMapIntUint64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntUint64V(rv2i(rv).(map[int]uint64), e) } func (_ fastpathT) EncMapIntUint64V(v map[int]uint64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10445,26 +10529,32 @@ func (_ fastpathT) EncMapIntUint64V(v map[int]uint64, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int(k2))) - if esep { + ee.EncodeInt(int64(int(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int(k2))) + ee.EncodeUint(uint64(v[int(k2)])) } - ee.EncodeUint(uint64(v[int(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -10474,6 +10564,10 @@ func (e *Encoder) fastpathEncMapIntUintptrR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntUintptrV(rv2i(rv).(map[int]uintptr), e) } func (_ fastpathT) EncMapIntUintptrV(v map[int]uintptr, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10484,26 +10578,32 @@ func (_ fastpathT) EncMapIntUintptrV(v map[int]uintptr, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int(k2))) - if esep { + ee.EncodeInt(int64(int(k2))) ee.WriteMapElemValue() + e.encode(v[int(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int(k2))) + e.encode(v[int(k2)]) } - e.encode(v[int(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -10513,6 +10613,10 @@ func (e *Encoder) fastpathEncMapIntIntR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntIntV(rv2i(rv).(map[int]int), e) } func (_ fastpathT) EncMapIntIntV(v map[int]int, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10523,26 +10627,32 @@ func (_ fastpathT) EncMapIntIntV(v map[int]int, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int(k2))) - if esep { + ee.EncodeInt(int64(int(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int(k2))) + ee.EncodeInt(int64(v[int(k2)])) } - ee.EncodeInt(int64(v[int(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -10552,6 +10662,10 @@ func (e *Encoder) fastpathEncMapIntInt8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntInt8V(rv2i(rv).(map[int]int8), e) } func (_ fastpathT) EncMapIntInt8V(v map[int]int8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10562,26 +10676,32 @@ func (_ fastpathT) EncMapIntInt8V(v map[int]int8, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int(k2))) - if esep { + ee.EncodeInt(int64(int(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int(k2))) + ee.EncodeInt(int64(v[int(k2)])) } - ee.EncodeInt(int64(v[int(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -10591,6 +10711,10 @@ func (e *Encoder) fastpathEncMapIntInt16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntInt16V(rv2i(rv).(map[int]int16), e) } func (_ fastpathT) EncMapIntInt16V(v map[int]int16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10601,26 +10725,32 @@ func (_ fastpathT) EncMapIntInt16V(v map[int]int16, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int(k2))) - if esep { + ee.EncodeInt(int64(int(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int(k2))) + ee.EncodeInt(int64(v[int(k2)])) } - ee.EncodeInt(int64(v[int(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -10630,6 +10760,10 @@ func (e *Encoder) fastpathEncMapIntInt32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntInt32V(rv2i(rv).(map[int]int32), e) } func (_ fastpathT) EncMapIntInt32V(v map[int]int32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10640,26 +10774,32 @@ func (_ fastpathT) EncMapIntInt32V(v map[int]int32, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int(k2))) - if esep { + ee.EncodeInt(int64(int(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int(k2))) + ee.EncodeInt(int64(v[int(k2)])) } - ee.EncodeInt(int64(v[int(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -10669,6 +10809,10 @@ func (e *Encoder) fastpathEncMapIntInt64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntInt64V(rv2i(rv).(map[int]int64), e) } func (_ fastpathT) EncMapIntInt64V(v map[int]int64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10679,26 +10823,32 @@ func (_ fastpathT) EncMapIntInt64V(v map[int]int64, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int(k2))) - if esep { + ee.EncodeInt(int64(int(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int(k2))) + ee.EncodeInt(int64(v[int(k2)])) } - ee.EncodeInt(int64(v[int(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -10708,6 +10858,10 @@ func (e *Encoder) fastpathEncMapIntFloat32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntFloat32V(rv2i(rv).(map[int]float32), e) } func (_ fastpathT) EncMapIntFloat32V(v map[int]float32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10718,26 +10872,32 @@ func (_ fastpathT) EncMapIntFloat32V(v map[int]float32, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int(k2))) - if esep { + ee.EncodeInt(int64(int(k2))) ee.WriteMapElemValue() + ee.EncodeFloat32(v[int(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int(k2))) + ee.EncodeFloat32(v[int(k2)]) } - ee.EncodeFloat32(v[int(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat32(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeFloat32(v2) } - ee.EncodeFloat32(v2) } } ee.WriteMapEnd() @@ -10747,6 +10907,10 @@ func (e *Encoder) fastpathEncMapIntFloat64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntFloat64V(rv2i(rv).(map[int]float64), e) } func (_ fastpathT) EncMapIntFloat64V(v map[int]float64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10757,26 +10921,32 @@ func (_ fastpathT) EncMapIntFloat64V(v map[int]float64, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int(k2))) - if esep { + ee.EncodeInt(int64(int(k2))) ee.WriteMapElemValue() + ee.EncodeFloat64(v[int(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int(k2))) + ee.EncodeFloat64(v[int(k2)]) } - ee.EncodeFloat64(v[int(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat64(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeFloat64(v2) } - ee.EncodeFloat64(v2) } } ee.WriteMapEnd() @@ -10786,6 +10956,10 @@ func (e *Encoder) fastpathEncMapIntBoolR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapIntBoolV(rv2i(rv).(map[int]bool), e) } func (_ fastpathT) EncMapIntBoolV(v map[int]bool, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10796,26 +10970,32 @@ func (_ fastpathT) EncMapIntBoolV(v map[int]bool, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int(k2))) - if esep { + ee.EncodeInt(int64(int(k2))) ee.WriteMapElemValue() + ee.EncodeBool(v[int(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int(k2))) + ee.EncodeBool(v[int(k2)]) } - ee.EncodeBool(v[int(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeBool(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeBool(v2) } - ee.EncodeBool(v2) } } ee.WriteMapEnd() @@ -10825,6 +11005,10 @@ func (e *Encoder) fastpathEncMapInt8IntfR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt8IntfV(rv2i(rv).(map[int8]interface{}), e) } func (_ fastpathT) EncMapInt8IntfV(v map[int8]interface{}, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10835,26 +11019,32 @@ func (_ fastpathT) EncMapInt8IntfV(v map[int8]interface{}, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int8(k2))) - if esep { + ee.EncodeInt(int64(int8(k2))) ee.WriteMapElemValue() + e.encode(v[int8(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int8(k2))) + e.encode(v[int8(k2)]) } - e.encode(v[int8(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -10864,6 +11054,10 @@ func (e *Encoder) fastpathEncMapInt8StringR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt8StringV(rv2i(rv).(map[int8]string), e) } func (_ fastpathT) EncMapInt8StringV(v map[int8]string, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10874,26 +11068,32 @@ func (_ fastpathT) EncMapInt8StringV(v map[int8]string, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int8(k2))) - if esep { + ee.EncodeInt(int64(int8(k2))) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v[int8(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int8(k2))) + ee.EncodeString(cUTF8, v[int8(k2)]) } - ee.EncodeString(c_UTF8, v[int8(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeString(cUTF8, v2) } - ee.EncodeString(c_UTF8, v2) } } ee.WriteMapEnd() @@ -10903,6 +11103,10 @@ func (e *Encoder) fastpathEncMapInt8UintR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt8UintV(rv2i(rv).(map[int8]uint), e) } func (_ fastpathT) EncMapInt8UintV(v map[int8]uint, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10913,26 +11117,32 @@ func (_ fastpathT) EncMapInt8UintV(v map[int8]uint, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int8(k2))) - if esep { + ee.EncodeInt(int64(int8(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int8(k2))) + ee.EncodeUint(uint64(v[int8(k2)])) } - ee.EncodeUint(uint64(v[int8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -10942,6 +11152,10 @@ func (e *Encoder) fastpathEncMapInt8Uint8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt8Uint8V(rv2i(rv).(map[int8]uint8), e) } func (_ fastpathT) EncMapInt8Uint8V(v map[int8]uint8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10952,26 +11166,32 @@ func (_ fastpathT) EncMapInt8Uint8V(v map[int8]uint8, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int8(k2))) - if esep { + ee.EncodeInt(int64(int8(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int8(k2))) + ee.EncodeUint(uint64(v[int8(k2)])) } - ee.EncodeUint(uint64(v[int8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -10981,6 +11201,10 @@ func (e *Encoder) fastpathEncMapInt8Uint16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt8Uint16V(rv2i(rv).(map[int8]uint16), e) } func (_ fastpathT) EncMapInt8Uint16V(v map[int8]uint16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -10991,26 +11215,32 @@ func (_ fastpathT) EncMapInt8Uint16V(v map[int8]uint16, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int8(k2))) - if esep { + ee.EncodeInt(int64(int8(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int8(k2))) + ee.EncodeUint(uint64(v[int8(k2)])) } - ee.EncodeUint(uint64(v[int8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -11020,6 +11250,10 @@ func (e *Encoder) fastpathEncMapInt8Uint32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt8Uint32V(rv2i(rv).(map[int8]uint32), e) } func (_ fastpathT) EncMapInt8Uint32V(v map[int8]uint32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11030,26 +11264,32 @@ func (_ fastpathT) EncMapInt8Uint32V(v map[int8]uint32, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int8(k2))) - if esep { + ee.EncodeInt(int64(int8(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int8(k2))) + ee.EncodeUint(uint64(v[int8(k2)])) } - ee.EncodeUint(uint64(v[int8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -11059,6 +11299,10 @@ func (e *Encoder) fastpathEncMapInt8Uint64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt8Uint64V(rv2i(rv).(map[int8]uint64), e) } func (_ fastpathT) EncMapInt8Uint64V(v map[int8]uint64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11069,26 +11313,32 @@ func (_ fastpathT) EncMapInt8Uint64V(v map[int8]uint64, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int8(k2))) - if esep { + ee.EncodeInt(int64(int8(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int8(k2))) + ee.EncodeUint(uint64(v[int8(k2)])) } - ee.EncodeUint(uint64(v[int8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -11098,6 +11348,10 @@ func (e *Encoder) fastpathEncMapInt8UintptrR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt8UintptrV(rv2i(rv).(map[int8]uintptr), e) } func (_ fastpathT) EncMapInt8UintptrV(v map[int8]uintptr, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11108,26 +11362,32 @@ func (_ fastpathT) EncMapInt8UintptrV(v map[int8]uintptr, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int8(k2))) - if esep { + ee.EncodeInt(int64(int8(k2))) ee.WriteMapElemValue() + e.encode(v[int8(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int8(k2))) + e.encode(v[int8(k2)]) } - e.encode(v[int8(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -11137,6 +11397,10 @@ func (e *Encoder) fastpathEncMapInt8IntR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt8IntV(rv2i(rv).(map[int8]int), e) } func (_ fastpathT) EncMapInt8IntV(v map[int8]int, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11147,26 +11411,32 @@ func (_ fastpathT) EncMapInt8IntV(v map[int8]int, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int8(k2))) - if esep { + ee.EncodeInt(int64(int8(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int8(k2))) + ee.EncodeInt(int64(v[int8(k2)])) } - ee.EncodeInt(int64(v[int8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -11176,6 +11446,10 @@ func (e *Encoder) fastpathEncMapInt8Int8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt8Int8V(rv2i(rv).(map[int8]int8), e) } func (_ fastpathT) EncMapInt8Int8V(v map[int8]int8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11186,26 +11460,32 @@ func (_ fastpathT) EncMapInt8Int8V(v map[int8]int8, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int8(k2))) - if esep { + ee.EncodeInt(int64(int8(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int8(k2))) + ee.EncodeInt(int64(v[int8(k2)])) } - ee.EncodeInt(int64(v[int8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -11215,6 +11495,10 @@ func (e *Encoder) fastpathEncMapInt8Int16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt8Int16V(rv2i(rv).(map[int8]int16), e) } func (_ fastpathT) EncMapInt8Int16V(v map[int8]int16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11225,26 +11509,32 @@ func (_ fastpathT) EncMapInt8Int16V(v map[int8]int16, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int8(k2))) - if esep { + ee.EncodeInt(int64(int8(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int8(k2))) + ee.EncodeInt(int64(v[int8(k2)])) } - ee.EncodeInt(int64(v[int8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -11254,6 +11544,10 @@ func (e *Encoder) fastpathEncMapInt8Int32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt8Int32V(rv2i(rv).(map[int8]int32), e) } func (_ fastpathT) EncMapInt8Int32V(v map[int8]int32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11264,26 +11558,32 @@ func (_ fastpathT) EncMapInt8Int32V(v map[int8]int32, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int8(k2))) - if esep { + ee.EncodeInt(int64(int8(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int8(k2))) + ee.EncodeInt(int64(v[int8(k2)])) } - ee.EncodeInt(int64(v[int8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -11293,6 +11593,10 @@ func (e *Encoder) fastpathEncMapInt8Int64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt8Int64V(rv2i(rv).(map[int8]int64), e) } func (_ fastpathT) EncMapInt8Int64V(v map[int8]int64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11303,26 +11607,32 @@ func (_ fastpathT) EncMapInt8Int64V(v map[int8]int64, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int8(k2))) - if esep { + ee.EncodeInt(int64(int8(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int8(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int8(k2))) + ee.EncodeInt(int64(v[int8(k2)])) } - ee.EncodeInt(int64(v[int8(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -11332,6 +11642,10 @@ func (e *Encoder) fastpathEncMapInt8Float32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt8Float32V(rv2i(rv).(map[int8]float32), e) } func (_ fastpathT) EncMapInt8Float32V(v map[int8]float32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11342,26 +11656,32 @@ func (_ fastpathT) EncMapInt8Float32V(v map[int8]float32, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int8(k2))) - if esep { + ee.EncodeInt(int64(int8(k2))) ee.WriteMapElemValue() + ee.EncodeFloat32(v[int8(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int8(k2))) + ee.EncodeFloat32(v[int8(k2)]) } - ee.EncodeFloat32(v[int8(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat32(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeFloat32(v2) } - ee.EncodeFloat32(v2) } } ee.WriteMapEnd() @@ -11371,6 +11691,10 @@ func (e *Encoder) fastpathEncMapInt8Float64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt8Float64V(rv2i(rv).(map[int8]float64), e) } func (_ fastpathT) EncMapInt8Float64V(v map[int8]float64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11381,26 +11705,32 @@ func (_ fastpathT) EncMapInt8Float64V(v map[int8]float64, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int8(k2))) - if esep { + ee.EncodeInt(int64(int8(k2))) ee.WriteMapElemValue() + ee.EncodeFloat64(v[int8(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int8(k2))) + ee.EncodeFloat64(v[int8(k2)]) } - ee.EncodeFloat64(v[int8(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat64(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeFloat64(v2) } - ee.EncodeFloat64(v2) } } ee.WriteMapEnd() @@ -11410,6 +11740,10 @@ func (e *Encoder) fastpathEncMapInt8BoolR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt8BoolV(rv2i(rv).(map[int8]bool), e) } func (_ fastpathT) EncMapInt8BoolV(v map[int8]bool, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11420,26 +11754,32 @@ func (_ fastpathT) EncMapInt8BoolV(v map[int8]bool, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int8(k2))) - if esep { + ee.EncodeInt(int64(int8(k2))) ee.WriteMapElemValue() + ee.EncodeBool(v[int8(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int8(k2))) + ee.EncodeBool(v[int8(k2)]) } - ee.EncodeBool(v[int8(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeBool(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeBool(v2) } - ee.EncodeBool(v2) } } ee.WriteMapEnd() @@ -11449,6 +11789,10 @@ func (e *Encoder) fastpathEncMapInt16IntfR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt16IntfV(rv2i(rv).(map[int16]interface{}), e) } func (_ fastpathT) EncMapInt16IntfV(v map[int16]interface{}, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11459,26 +11803,32 @@ func (_ fastpathT) EncMapInt16IntfV(v map[int16]interface{}, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int16(k2))) - if esep { + ee.EncodeInt(int64(int16(k2))) ee.WriteMapElemValue() + e.encode(v[int16(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int16(k2))) + e.encode(v[int16(k2)]) } - e.encode(v[int16(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -11488,6 +11838,10 @@ func (e *Encoder) fastpathEncMapInt16StringR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt16StringV(rv2i(rv).(map[int16]string), e) } func (_ fastpathT) EncMapInt16StringV(v map[int16]string, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11498,26 +11852,32 @@ func (_ fastpathT) EncMapInt16StringV(v map[int16]string, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int16(k2))) - if esep { + ee.EncodeInt(int64(int16(k2))) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v[int16(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int16(k2))) + ee.EncodeString(cUTF8, v[int16(k2)]) } - ee.EncodeString(c_UTF8, v[int16(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeString(cUTF8, v2) } - ee.EncodeString(c_UTF8, v2) } } ee.WriteMapEnd() @@ -11527,6 +11887,10 @@ func (e *Encoder) fastpathEncMapInt16UintR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt16UintV(rv2i(rv).(map[int16]uint), e) } func (_ fastpathT) EncMapInt16UintV(v map[int16]uint, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11537,26 +11901,32 @@ func (_ fastpathT) EncMapInt16UintV(v map[int16]uint, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int16(k2))) - if esep { + ee.EncodeInt(int64(int16(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int16(k2))) + ee.EncodeUint(uint64(v[int16(k2)])) } - ee.EncodeUint(uint64(v[int16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -11566,6 +11936,10 @@ func (e *Encoder) fastpathEncMapInt16Uint8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt16Uint8V(rv2i(rv).(map[int16]uint8), e) } func (_ fastpathT) EncMapInt16Uint8V(v map[int16]uint8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11576,26 +11950,32 @@ func (_ fastpathT) EncMapInt16Uint8V(v map[int16]uint8, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int16(k2))) - if esep { + ee.EncodeInt(int64(int16(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int16(k2))) + ee.EncodeUint(uint64(v[int16(k2)])) } - ee.EncodeUint(uint64(v[int16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -11605,6 +11985,10 @@ func (e *Encoder) fastpathEncMapInt16Uint16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt16Uint16V(rv2i(rv).(map[int16]uint16), e) } func (_ fastpathT) EncMapInt16Uint16V(v map[int16]uint16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11615,26 +11999,32 @@ func (_ fastpathT) EncMapInt16Uint16V(v map[int16]uint16, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int16(k2))) - if esep { + ee.EncodeInt(int64(int16(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int16(k2))) + ee.EncodeUint(uint64(v[int16(k2)])) } - ee.EncodeUint(uint64(v[int16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -11644,6 +12034,10 @@ func (e *Encoder) fastpathEncMapInt16Uint32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt16Uint32V(rv2i(rv).(map[int16]uint32), e) } func (_ fastpathT) EncMapInt16Uint32V(v map[int16]uint32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11654,26 +12048,32 @@ func (_ fastpathT) EncMapInt16Uint32V(v map[int16]uint32, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int16(k2))) - if esep { + ee.EncodeInt(int64(int16(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int16(k2))) + ee.EncodeUint(uint64(v[int16(k2)])) } - ee.EncodeUint(uint64(v[int16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -11683,6 +12083,10 @@ func (e *Encoder) fastpathEncMapInt16Uint64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt16Uint64V(rv2i(rv).(map[int16]uint64), e) } func (_ fastpathT) EncMapInt16Uint64V(v map[int16]uint64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11693,26 +12097,32 @@ func (_ fastpathT) EncMapInt16Uint64V(v map[int16]uint64, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int16(k2))) - if esep { + ee.EncodeInt(int64(int16(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int16(k2))) + ee.EncodeUint(uint64(v[int16(k2)])) } - ee.EncodeUint(uint64(v[int16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -11722,6 +12132,10 @@ func (e *Encoder) fastpathEncMapInt16UintptrR(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapInt16UintptrV(rv2i(rv).(map[int16]uintptr), e) } func (_ fastpathT) EncMapInt16UintptrV(v map[int16]uintptr, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11732,26 +12146,32 @@ func (_ fastpathT) EncMapInt16UintptrV(v map[int16]uintptr, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int16(k2))) - if esep { + ee.EncodeInt(int64(int16(k2))) ee.WriteMapElemValue() + e.encode(v[int16(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int16(k2))) + e.encode(v[int16(k2)]) } - e.encode(v[int16(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -11761,6 +12181,10 @@ func (e *Encoder) fastpathEncMapInt16IntR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt16IntV(rv2i(rv).(map[int16]int), e) } func (_ fastpathT) EncMapInt16IntV(v map[int16]int, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11771,26 +12195,32 @@ func (_ fastpathT) EncMapInt16IntV(v map[int16]int, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int16(k2))) - if esep { + ee.EncodeInt(int64(int16(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int16(k2))) + ee.EncodeInt(int64(v[int16(k2)])) } - ee.EncodeInt(int64(v[int16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -11800,6 +12230,10 @@ func (e *Encoder) fastpathEncMapInt16Int8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt16Int8V(rv2i(rv).(map[int16]int8), e) } func (_ fastpathT) EncMapInt16Int8V(v map[int16]int8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11810,26 +12244,32 @@ func (_ fastpathT) EncMapInt16Int8V(v map[int16]int8, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int16(k2))) - if esep { + ee.EncodeInt(int64(int16(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int16(k2))) + ee.EncodeInt(int64(v[int16(k2)])) } - ee.EncodeInt(int64(v[int16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -11839,6 +12279,10 @@ func (e *Encoder) fastpathEncMapInt16Int16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt16Int16V(rv2i(rv).(map[int16]int16), e) } func (_ fastpathT) EncMapInt16Int16V(v map[int16]int16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11849,26 +12293,32 @@ func (_ fastpathT) EncMapInt16Int16V(v map[int16]int16, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int16(k2))) - if esep { + ee.EncodeInt(int64(int16(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int16(k2))) + ee.EncodeInt(int64(v[int16(k2)])) } - ee.EncodeInt(int64(v[int16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -11878,6 +12328,10 @@ func (e *Encoder) fastpathEncMapInt16Int32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt16Int32V(rv2i(rv).(map[int16]int32), e) } func (_ fastpathT) EncMapInt16Int32V(v map[int16]int32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11888,26 +12342,32 @@ func (_ fastpathT) EncMapInt16Int32V(v map[int16]int32, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int16(k2))) - if esep { + ee.EncodeInt(int64(int16(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int16(k2))) + ee.EncodeInt(int64(v[int16(k2)])) } - ee.EncodeInt(int64(v[int16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -11917,6 +12377,10 @@ func (e *Encoder) fastpathEncMapInt16Int64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt16Int64V(rv2i(rv).(map[int16]int64), e) } func (_ fastpathT) EncMapInt16Int64V(v map[int16]int64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11927,26 +12391,32 @@ func (_ fastpathT) EncMapInt16Int64V(v map[int16]int64, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int16(k2))) - if esep { + ee.EncodeInt(int64(int16(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int16(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int16(k2))) + ee.EncodeInt(int64(v[int16(k2)])) } - ee.EncodeInt(int64(v[int16(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -11956,6 +12426,10 @@ func (e *Encoder) fastpathEncMapInt16Float32R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapInt16Float32V(rv2i(rv).(map[int16]float32), e) } func (_ fastpathT) EncMapInt16Float32V(v map[int16]float32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -11966,26 +12440,32 @@ func (_ fastpathT) EncMapInt16Float32V(v map[int16]float32, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int16(k2))) - if esep { + ee.EncodeInt(int64(int16(k2))) ee.WriteMapElemValue() + ee.EncodeFloat32(v[int16(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int16(k2))) + ee.EncodeFloat32(v[int16(k2)]) } - ee.EncodeFloat32(v[int16(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat32(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeFloat32(v2) } - ee.EncodeFloat32(v2) } } ee.WriteMapEnd() @@ -11995,6 +12475,10 @@ func (e *Encoder) fastpathEncMapInt16Float64R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapInt16Float64V(rv2i(rv).(map[int16]float64), e) } func (_ fastpathT) EncMapInt16Float64V(v map[int16]float64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12005,26 +12489,32 @@ func (_ fastpathT) EncMapInt16Float64V(v map[int16]float64, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int16(k2))) - if esep { + ee.EncodeInt(int64(int16(k2))) ee.WriteMapElemValue() + ee.EncodeFloat64(v[int16(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int16(k2))) + ee.EncodeFloat64(v[int16(k2)]) } - ee.EncodeFloat64(v[int16(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat64(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeFloat64(v2) } - ee.EncodeFloat64(v2) } } ee.WriteMapEnd() @@ -12034,6 +12524,10 @@ func (e *Encoder) fastpathEncMapInt16BoolR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt16BoolV(rv2i(rv).(map[int16]bool), e) } func (_ fastpathT) EncMapInt16BoolV(v map[int16]bool, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12044,26 +12538,32 @@ func (_ fastpathT) EncMapInt16BoolV(v map[int16]bool, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int16(k2))) - if esep { + ee.EncodeInt(int64(int16(k2))) ee.WriteMapElemValue() + ee.EncodeBool(v[int16(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int16(k2))) + ee.EncodeBool(v[int16(k2)]) } - ee.EncodeBool(v[int16(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeBool(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeBool(v2) } - ee.EncodeBool(v2) } } ee.WriteMapEnd() @@ -12073,6 +12573,10 @@ func (e *Encoder) fastpathEncMapInt32IntfR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt32IntfV(rv2i(rv).(map[int32]interface{}), e) } func (_ fastpathT) EncMapInt32IntfV(v map[int32]interface{}, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12083,26 +12587,32 @@ func (_ fastpathT) EncMapInt32IntfV(v map[int32]interface{}, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int32(k2))) - if esep { + ee.EncodeInt(int64(int32(k2))) ee.WriteMapElemValue() + e.encode(v[int32(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int32(k2))) + e.encode(v[int32(k2)]) } - e.encode(v[int32(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -12112,6 +12622,10 @@ func (e *Encoder) fastpathEncMapInt32StringR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt32StringV(rv2i(rv).(map[int32]string), e) } func (_ fastpathT) EncMapInt32StringV(v map[int32]string, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12122,26 +12636,32 @@ func (_ fastpathT) EncMapInt32StringV(v map[int32]string, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int32(k2))) - if esep { + ee.EncodeInt(int64(int32(k2))) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v[int32(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int32(k2))) + ee.EncodeString(cUTF8, v[int32(k2)]) } - ee.EncodeString(c_UTF8, v[int32(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeString(cUTF8, v2) } - ee.EncodeString(c_UTF8, v2) } } ee.WriteMapEnd() @@ -12151,6 +12671,10 @@ func (e *Encoder) fastpathEncMapInt32UintR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt32UintV(rv2i(rv).(map[int32]uint), e) } func (_ fastpathT) EncMapInt32UintV(v map[int32]uint, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12161,26 +12685,32 @@ func (_ fastpathT) EncMapInt32UintV(v map[int32]uint, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int32(k2))) - if esep { + ee.EncodeInt(int64(int32(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int32(k2))) + ee.EncodeUint(uint64(v[int32(k2)])) } - ee.EncodeUint(uint64(v[int32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -12190,6 +12720,10 @@ func (e *Encoder) fastpathEncMapInt32Uint8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt32Uint8V(rv2i(rv).(map[int32]uint8), e) } func (_ fastpathT) EncMapInt32Uint8V(v map[int32]uint8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12200,26 +12734,32 @@ func (_ fastpathT) EncMapInt32Uint8V(v map[int32]uint8, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int32(k2))) - if esep { + ee.EncodeInt(int64(int32(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int32(k2))) + ee.EncodeUint(uint64(v[int32(k2)])) } - ee.EncodeUint(uint64(v[int32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -12229,6 +12769,10 @@ func (e *Encoder) fastpathEncMapInt32Uint16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt32Uint16V(rv2i(rv).(map[int32]uint16), e) } func (_ fastpathT) EncMapInt32Uint16V(v map[int32]uint16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12239,26 +12783,32 @@ func (_ fastpathT) EncMapInt32Uint16V(v map[int32]uint16, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int32(k2))) - if esep { + ee.EncodeInt(int64(int32(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int32(k2))) + ee.EncodeUint(uint64(v[int32(k2)])) } - ee.EncodeUint(uint64(v[int32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -12268,6 +12818,10 @@ func (e *Encoder) fastpathEncMapInt32Uint32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt32Uint32V(rv2i(rv).(map[int32]uint32), e) } func (_ fastpathT) EncMapInt32Uint32V(v map[int32]uint32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12278,26 +12832,32 @@ func (_ fastpathT) EncMapInt32Uint32V(v map[int32]uint32, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int32(k2))) - if esep { + ee.EncodeInt(int64(int32(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int32(k2))) + ee.EncodeUint(uint64(v[int32(k2)])) } - ee.EncodeUint(uint64(v[int32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -12307,6 +12867,10 @@ func (e *Encoder) fastpathEncMapInt32Uint64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt32Uint64V(rv2i(rv).(map[int32]uint64), e) } func (_ fastpathT) EncMapInt32Uint64V(v map[int32]uint64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12317,26 +12881,32 @@ func (_ fastpathT) EncMapInt32Uint64V(v map[int32]uint64, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int32(k2))) - if esep { + ee.EncodeInt(int64(int32(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int32(k2))) + ee.EncodeUint(uint64(v[int32(k2)])) } - ee.EncodeUint(uint64(v[int32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -12346,6 +12916,10 @@ func (e *Encoder) fastpathEncMapInt32UintptrR(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapInt32UintptrV(rv2i(rv).(map[int32]uintptr), e) } func (_ fastpathT) EncMapInt32UintptrV(v map[int32]uintptr, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12356,26 +12930,32 @@ func (_ fastpathT) EncMapInt32UintptrV(v map[int32]uintptr, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int32(k2))) - if esep { + ee.EncodeInt(int64(int32(k2))) ee.WriteMapElemValue() + e.encode(v[int32(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int32(k2))) + e.encode(v[int32(k2)]) } - e.encode(v[int32(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -12385,6 +12965,10 @@ func (e *Encoder) fastpathEncMapInt32IntR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt32IntV(rv2i(rv).(map[int32]int), e) } func (_ fastpathT) EncMapInt32IntV(v map[int32]int, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12395,26 +12979,32 @@ func (_ fastpathT) EncMapInt32IntV(v map[int32]int, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int32(k2))) - if esep { + ee.EncodeInt(int64(int32(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int32(k2))) + ee.EncodeInt(int64(v[int32(k2)])) } - ee.EncodeInt(int64(v[int32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -12424,6 +13014,10 @@ func (e *Encoder) fastpathEncMapInt32Int8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt32Int8V(rv2i(rv).(map[int32]int8), e) } func (_ fastpathT) EncMapInt32Int8V(v map[int32]int8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12434,26 +13028,32 @@ func (_ fastpathT) EncMapInt32Int8V(v map[int32]int8, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int32(k2))) - if esep { + ee.EncodeInt(int64(int32(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int32(k2))) + ee.EncodeInt(int64(v[int32(k2)])) } - ee.EncodeInt(int64(v[int32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -12463,6 +13063,10 @@ func (e *Encoder) fastpathEncMapInt32Int16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt32Int16V(rv2i(rv).(map[int32]int16), e) } func (_ fastpathT) EncMapInt32Int16V(v map[int32]int16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12473,26 +13077,32 @@ func (_ fastpathT) EncMapInt32Int16V(v map[int32]int16, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int32(k2))) - if esep { + ee.EncodeInt(int64(int32(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int32(k2))) + ee.EncodeInt(int64(v[int32(k2)])) } - ee.EncodeInt(int64(v[int32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -12502,6 +13112,10 @@ func (e *Encoder) fastpathEncMapInt32Int32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt32Int32V(rv2i(rv).(map[int32]int32), e) } func (_ fastpathT) EncMapInt32Int32V(v map[int32]int32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12512,26 +13126,32 @@ func (_ fastpathT) EncMapInt32Int32V(v map[int32]int32, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int32(k2))) - if esep { + ee.EncodeInt(int64(int32(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int32(k2))) + ee.EncodeInt(int64(v[int32(k2)])) } - ee.EncodeInt(int64(v[int32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -12541,6 +13161,10 @@ func (e *Encoder) fastpathEncMapInt32Int64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt32Int64V(rv2i(rv).(map[int32]int64), e) } func (_ fastpathT) EncMapInt32Int64V(v map[int32]int64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12551,26 +13175,32 @@ func (_ fastpathT) EncMapInt32Int64V(v map[int32]int64, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int32(k2))) - if esep { + ee.EncodeInt(int64(int32(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int32(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int32(k2))) + ee.EncodeInt(int64(v[int32(k2)])) } - ee.EncodeInt(int64(v[int32(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -12580,6 +13210,10 @@ func (e *Encoder) fastpathEncMapInt32Float32R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapInt32Float32V(rv2i(rv).(map[int32]float32), e) } func (_ fastpathT) EncMapInt32Float32V(v map[int32]float32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12590,26 +13224,32 @@ func (_ fastpathT) EncMapInt32Float32V(v map[int32]float32, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int32(k2))) - if esep { + ee.EncodeInt(int64(int32(k2))) ee.WriteMapElemValue() + ee.EncodeFloat32(v[int32(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int32(k2))) + ee.EncodeFloat32(v[int32(k2)]) } - ee.EncodeFloat32(v[int32(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat32(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeFloat32(v2) } - ee.EncodeFloat32(v2) } } ee.WriteMapEnd() @@ -12619,6 +13259,10 @@ func (e *Encoder) fastpathEncMapInt32Float64R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapInt32Float64V(rv2i(rv).(map[int32]float64), e) } func (_ fastpathT) EncMapInt32Float64V(v map[int32]float64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12629,26 +13273,32 @@ func (_ fastpathT) EncMapInt32Float64V(v map[int32]float64, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int32(k2))) - if esep { + ee.EncodeInt(int64(int32(k2))) ee.WriteMapElemValue() + ee.EncodeFloat64(v[int32(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int32(k2))) + ee.EncodeFloat64(v[int32(k2)]) } - ee.EncodeFloat64(v[int32(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat64(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeFloat64(v2) } - ee.EncodeFloat64(v2) } } ee.WriteMapEnd() @@ -12658,6 +13308,10 @@ func (e *Encoder) fastpathEncMapInt32BoolR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt32BoolV(rv2i(rv).(map[int32]bool), e) } func (_ fastpathT) EncMapInt32BoolV(v map[int32]bool, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12668,26 +13322,32 @@ func (_ fastpathT) EncMapInt32BoolV(v map[int32]bool, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int32(k2))) - if esep { + ee.EncodeInt(int64(int32(k2))) ee.WriteMapElemValue() + ee.EncodeBool(v[int32(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int32(k2))) + ee.EncodeBool(v[int32(k2)]) } - ee.EncodeBool(v[int32(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeBool(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeBool(v2) } - ee.EncodeBool(v2) } } ee.WriteMapEnd() @@ -12697,6 +13357,10 @@ func (e *Encoder) fastpathEncMapInt64IntfR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt64IntfV(rv2i(rv).(map[int64]interface{}), e) } func (_ fastpathT) EncMapInt64IntfV(v map[int64]interface{}, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12707,26 +13371,32 @@ func (_ fastpathT) EncMapInt64IntfV(v map[int64]interface{}, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int64(k2))) - if esep { + ee.EncodeInt(int64(int64(k2))) ee.WriteMapElemValue() + e.encode(v[int64(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int64(k2))) + e.encode(v[int64(k2)]) } - e.encode(v[int64(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -12736,6 +13406,10 @@ func (e *Encoder) fastpathEncMapInt64StringR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt64StringV(rv2i(rv).(map[int64]string), e) } func (_ fastpathT) EncMapInt64StringV(v map[int64]string, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12746,26 +13420,32 @@ func (_ fastpathT) EncMapInt64StringV(v map[int64]string, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int64(k2))) - if esep { + ee.EncodeInt(int64(int64(k2))) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v[int64(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int64(k2))) + ee.EncodeString(cUTF8, v[int64(k2)]) } - ee.EncodeString(c_UTF8, v[int64(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeString(cUTF8, v2) } - ee.EncodeString(c_UTF8, v2) } } ee.WriteMapEnd() @@ -12775,6 +13455,10 @@ func (e *Encoder) fastpathEncMapInt64UintR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt64UintV(rv2i(rv).(map[int64]uint), e) } func (_ fastpathT) EncMapInt64UintV(v map[int64]uint, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12785,26 +13469,32 @@ func (_ fastpathT) EncMapInt64UintV(v map[int64]uint, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int64(k2))) - if esep { + ee.EncodeInt(int64(int64(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int64(k2))) + ee.EncodeUint(uint64(v[int64(k2)])) } - ee.EncodeUint(uint64(v[int64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -12814,6 +13504,10 @@ func (e *Encoder) fastpathEncMapInt64Uint8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt64Uint8V(rv2i(rv).(map[int64]uint8), e) } func (_ fastpathT) EncMapInt64Uint8V(v map[int64]uint8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12824,26 +13518,32 @@ func (_ fastpathT) EncMapInt64Uint8V(v map[int64]uint8, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int64(k2))) - if esep { + ee.EncodeInt(int64(int64(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int64(k2))) + ee.EncodeUint(uint64(v[int64(k2)])) } - ee.EncodeUint(uint64(v[int64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -12853,6 +13553,10 @@ func (e *Encoder) fastpathEncMapInt64Uint16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt64Uint16V(rv2i(rv).(map[int64]uint16), e) } func (_ fastpathT) EncMapInt64Uint16V(v map[int64]uint16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12863,26 +13567,32 @@ func (_ fastpathT) EncMapInt64Uint16V(v map[int64]uint16, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int64(k2))) - if esep { + ee.EncodeInt(int64(int64(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int64(k2))) + ee.EncodeUint(uint64(v[int64(k2)])) } - ee.EncodeUint(uint64(v[int64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -12892,6 +13602,10 @@ func (e *Encoder) fastpathEncMapInt64Uint32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt64Uint32V(rv2i(rv).(map[int64]uint32), e) } func (_ fastpathT) EncMapInt64Uint32V(v map[int64]uint32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12902,26 +13616,32 @@ func (_ fastpathT) EncMapInt64Uint32V(v map[int64]uint32, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int64(k2))) - if esep { + ee.EncodeInt(int64(int64(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int64(k2))) + ee.EncodeUint(uint64(v[int64(k2)])) } - ee.EncodeUint(uint64(v[int64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -12931,6 +13651,10 @@ func (e *Encoder) fastpathEncMapInt64Uint64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt64Uint64V(rv2i(rv).(map[int64]uint64), e) } func (_ fastpathT) EncMapInt64Uint64V(v map[int64]uint64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12941,26 +13665,32 @@ func (_ fastpathT) EncMapInt64Uint64V(v map[int64]uint64, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int64(k2))) - if esep { + ee.EncodeInt(int64(int64(k2))) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[int64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int64(k2))) + ee.EncodeUint(uint64(v[int64(k2)])) } - ee.EncodeUint(uint64(v[int64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -12970,6 +13700,10 @@ func (e *Encoder) fastpathEncMapInt64UintptrR(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapInt64UintptrV(rv2i(rv).(map[int64]uintptr), e) } func (_ fastpathT) EncMapInt64UintptrV(v map[int64]uintptr, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -12980,26 +13714,32 @@ func (_ fastpathT) EncMapInt64UintptrV(v map[int64]uintptr, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int64(k2))) - if esep { + ee.EncodeInt(int64(int64(k2))) ee.WriteMapElemValue() + e.encode(v[int64(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int64(k2))) + e.encode(v[int64(k2)]) } - e.encode(v[int64(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -13009,6 +13749,10 @@ func (e *Encoder) fastpathEncMapInt64IntR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt64IntV(rv2i(rv).(map[int64]int), e) } func (_ fastpathT) EncMapInt64IntV(v map[int64]int, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13019,26 +13763,32 @@ func (_ fastpathT) EncMapInt64IntV(v map[int64]int, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int64(k2))) - if esep { + ee.EncodeInt(int64(int64(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int64(k2))) + ee.EncodeInt(int64(v[int64(k2)])) } - ee.EncodeInt(int64(v[int64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -13048,6 +13798,10 @@ func (e *Encoder) fastpathEncMapInt64Int8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt64Int8V(rv2i(rv).(map[int64]int8), e) } func (_ fastpathT) EncMapInt64Int8V(v map[int64]int8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13058,26 +13812,32 @@ func (_ fastpathT) EncMapInt64Int8V(v map[int64]int8, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int64(k2))) - if esep { + ee.EncodeInt(int64(int64(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int64(k2))) + ee.EncodeInt(int64(v[int64(k2)])) } - ee.EncodeInt(int64(v[int64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -13087,6 +13847,10 @@ func (e *Encoder) fastpathEncMapInt64Int16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt64Int16V(rv2i(rv).(map[int64]int16), e) } func (_ fastpathT) EncMapInt64Int16V(v map[int64]int16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13097,26 +13861,32 @@ func (_ fastpathT) EncMapInt64Int16V(v map[int64]int16, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int64(k2))) - if esep { + ee.EncodeInt(int64(int64(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int64(k2))) + ee.EncodeInt(int64(v[int64(k2)])) } - ee.EncodeInt(int64(v[int64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -13126,6 +13896,10 @@ func (e *Encoder) fastpathEncMapInt64Int32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt64Int32V(rv2i(rv).(map[int64]int32), e) } func (_ fastpathT) EncMapInt64Int32V(v map[int64]int32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13136,26 +13910,32 @@ func (_ fastpathT) EncMapInt64Int32V(v map[int64]int32, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int64(k2))) - if esep { + ee.EncodeInt(int64(int64(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int64(k2))) + ee.EncodeInt(int64(v[int64(k2)])) } - ee.EncodeInt(int64(v[int64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -13165,6 +13945,10 @@ func (e *Encoder) fastpathEncMapInt64Int64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt64Int64V(rv2i(rv).(map[int64]int64), e) } func (_ fastpathT) EncMapInt64Int64V(v map[int64]int64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13175,26 +13959,32 @@ func (_ fastpathT) EncMapInt64Int64V(v map[int64]int64, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int64(k2))) - if esep { + ee.EncodeInt(int64(int64(k2))) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[int64(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int64(k2))) + ee.EncodeInt(int64(v[int64(k2)])) } - ee.EncodeInt(int64(v[int64(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -13204,6 +13994,10 @@ func (e *Encoder) fastpathEncMapInt64Float32R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapInt64Float32V(rv2i(rv).(map[int64]float32), e) } func (_ fastpathT) EncMapInt64Float32V(v map[int64]float32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13214,26 +14008,32 @@ func (_ fastpathT) EncMapInt64Float32V(v map[int64]float32, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int64(k2))) - if esep { + ee.EncodeInt(int64(int64(k2))) ee.WriteMapElemValue() + ee.EncodeFloat32(v[int64(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int64(k2))) + ee.EncodeFloat32(v[int64(k2)]) } - ee.EncodeFloat32(v[int64(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat32(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeFloat32(v2) } - ee.EncodeFloat32(v2) } } ee.WriteMapEnd() @@ -13243,6 +14043,10 @@ func (e *Encoder) fastpathEncMapInt64Float64R(f *codecFnInfo, rv reflect.Value) fastpathTV.EncMapInt64Float64V(rv2i(rv).(map[int64]float64), e) } func (_ fastpathT) EncMapInt64Float64V(v map[int64]float64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13253,26 +14057,32 @@ func (_ fastpathT) EncMapInt64Float64V(v map[int64]float64, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int64(k2))) - if esep { + ee.EncodeInt(int64(int64(k2))) ee.WriteMapElemValue() + ee.EncodeFloat64(v[int64(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int64(k2))) + ee.EncodeFloat64(v[int64(k2)]) } - ee.EncodeFloat64(v[int64(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeFloat64(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeFloat64(v2) } - ee.EncodeFloat64(v2) } } ee.WriteMapEnd() @@ -13282,6 +14092,10 @@ func (e *Encoder) fastpathEncMapInt64BoolR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapInt64BoolV(rv2i(rv).(map[int64]bool), e) } func (_ fastpathT) EncMapInt64BoolV(v map[int64]bool, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13292,26 +14106,32 @@ func (_ fastpathT) EncMapInt64BoolV(v map[int64]bool, e *Encoder) { i++ } sort.Sort(intSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(int64(k2))) - if esep { + ee.EncodeInt(int64(int64(k2))) ee.WriteMapElemValue() + ee.EncodeBool(v[int64(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeInt(int64(int64(k2))) + ee.EncodeBool(v[int64(k2)]) } - ee.EncodeBool(v[int64(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeInt(int64(k2)) - if esep { + ee.EncodeInt(int64(k2)) ee.WriteMapElemValue() + ee.EncodeBool(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeInt(int64(k2)) + ee.EncodeBool(v2) } - ee.EncodeBool(v2) } } ee.WriteMapEnd() @@ -13321,6 +14141,10 @@ func (e *Encoder) fastpathEncMapBoolIntfR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapBoolIntfV(rv2i(rv).(map[bool]interface{}), e) } func (_ fastpathT) EncMapBoolIntfV(v map[bool]interface{}, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13331,26 +14155,32 @@ func (_ fastpathT) EncMapBoolIntfV(v map[bool]interface{}, e *Encoder) { i++ } sort.Sort(boolSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeBool(bool(k2)) - if esep { + ee.EncodeBool(bool(k2)) ee.WriteMapElemValue() + e.encode(v[bool(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeBool(bool(k2)) + e.encode(v[bool(k2)]) } - e.encode(v[bool(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeBool(k2) - if esep { + ee.EncodeBool(k2) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeBool(k2) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -13360,6 +14190,10 @@ func (e *Encoder) fastpathEncMapBoolStringR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapBoolStringV(rv2i(rv).(map[bool]string), e) } func (_ fastpathT) EncMapBoolStringV(v map[bool]string, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13370,26 +14204,32 @@ func (_ fastpathT) EncMapBoolStringV(v map[bool]string, e *Encoder) { i++ } sort.Sort(boolSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeBool(bool(k2)) - if esep { + ee.EncodeBool(bool(k2)) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v[bool(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeBool(bool(k2)) + ee.EncodeString(cUTF8, v[bool(k2)]) } - ee.EncodeString(c_UTF8, v[bool(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeBool(k2) - if esep { + ee.EncodeBool(k2) ee.WriteMapElemValue() + ee.EncodeString(cUTF8, v2) + } + } else { + for k2, v2 := range v { + ee.EncodeBool(k2) + ee.EncodeString(cUTF8, v2) } - ee.EncodeString(c_UTF8, v2) } } ee.WriteMapEnd() @@ -13399,6 +14239,10 @@ func (e *Encoder) fastpathEncMapBoolUintR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapBoolUintV(rv2i(rv).(map[bool]uint), e) } func (_ fastpathT) EncMapBoolUintV(v map[bool]uint, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13409,26 +14253,32 @@ func (_ fastpathT) EncMapBoolUintV(v map[bool]uint, e *Encoder) { i++ } sort.Sort(boolSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeBool(bool(k2)) - if esep { + ee.EncodeBool(bool(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[bool(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeBool(bool(k2)) + ee.EncodeUint(uint64(v[bool(k2)])) } - ee.EncodeUint(uint64(v[bool(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeBool(k2) - if esep { + ee.EncodeBool(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeBool(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -13438,6 +14288,10 @@ func (e *Encoder) fastpathEncMapBoolUint8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapBoolUint8V(rv2i(rv).(map[bool]uint8), e) } func (_ fastpathT) EncMapBoolUint8V(v map[bool]uint8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13448,26 +14302,32 @@ func (_ fastpathT) EncMapBoolUint8V(v map[bool]uint8, e *Encoder) { i++ } sort.Sort(boolSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeBool(bool(k2)) - if esep { + ee.EncodeBool(bool(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[bool(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeBool(bool(k2)) + ee.EncodeUint(uint64(v[bool(k2)])) } - ee.EncodeUint(uint64(v[bool(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeBool(k2) - if esep { + ee.EncodeBool(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeBool(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -13477,6 +14337,10 @@ func (e *Encoder) fastpathEncMapBoolUint16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapBoolUint16V(rv2i(rv).(map[bool]uint16), e) } func (_ fastpathT) EncMapBoolUint16V(v map[bool]uint16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13487,26 +14351,32 @@ func (_ fastpathT) EncMapBoolUint16V(v map[bool]uint16, e *Encoder) { i++ } sort.Sort(boolSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeBool(bool(k2)) - if esep { + ee.EncodeBool(bool(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[bool(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeBool(bool(k2)) + ee.EncodeUint(uint64(v[bool(k2)])) } - ee.EncodeUint(uint64(v[bool(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeBool(k2) - if esep { + ee.EncodeBool(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeBool(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -13516,6 +14386,10 @@ func (e *Encoder) fastpathEncMapBoolUint32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapBoolUint32V(rv2i(rv).(map[bool]uint32), e) } func (_ fastpathT) EncMapBoolUint32V(v map[bool]uint32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13526,26 +14400,32 @@ func (_ fastpathT) EncMapBoolUint32V(v map[bool]uint32, e *Encoder) { i++ } sort.Sort(boolSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeBool(bool(k2)) - if esep { + ee.EncodeBool(bool(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[bool(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeBool(bool(k2)) + ee.EncodeUint(uint64(v[bool(k2)])) } - ee.EncodeUint(uint64(v[bool(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeBool(k2) - if esep { + ee.EncodeBool(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeBool(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -13555,6 +14435,10 @@ func (e *Encoder) fastpathEncMapBoolUint64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapBoolUint64V(rv2i(rv).(map[bool]uint64), e) } func (_ fastpathT) EncMapBoolUint64V(v map[bool]uint64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13565,26 +14449,32 @@ func (_ fastpathT) EncMapBoolUint64V(v map[bool]uint64, e *Encoder) { i++ } sort.Sort(boolSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeBool(bool(k2)) - if esep { + ee.EncodeBool(bool(k2)) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v[bool(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeBool(bool(k2)) + ee.EncodeUint(uint64(v[bool(k2)])) } - ee.EncodeUint(uint64(v[bool(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeBool(k2) - if esep { + ee.EncodeBool(k2) ee.WriteMapElemValue() + ee.EncodeUint(uint64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeBool(k2) + ee.EncodeUint(uint64(v2)) } - ee.EncodeUint(uint64(v2)) } } ee.WriteMapEnd() @@ -13594,6 +14484,10 @@ func (e *Encoder) fastpathEncMapBoolUintptrR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapBoolUintptrV(rv2i(rv).(map[bool]uintptr), e) } func (_ fastpathT) EncMapBoolUintptrV(v map[bool]uintptr, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13604,26 +14498,32 @@ func (_ fastpathT) EncMapBoolUintptrV(v map[bool]uintptr, e *Encoder) { i++ } sort.Sort(boolSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeBool(bool(k2)) - if esep { + ee.EncodeBool(bool(k2)) ee.WriteMapElemValue() + e.encode(v[bool(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeBool(bool(k2)) + e.encode(v[bool(k2)]) } - e.encode(v[bool(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeBool(k2) - if esep { + ee.EncodeBool(k2) ee.WriteMapElemValue() + e.encode(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeBool(k2) + e.encode(v2) } - e.encode(v2) } } ee.WriteMapEnd() @@ -13633,6 +14533,10 @@ func (e *Encoder) fastpathEncMapBoolIntR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapBoolIntV(rv2i(rv).(map[bool]int), e) } func (_ fastpathT) EncMapBoolIntV(v map[bool]int, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13643,26 +14547,32 @@ func (_ fastpathT) EncMapBoolIntV(v map[bool]int, e *Encoder) { i++ } sort.Sort(boolSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeBool(bool(k2)) - if esep { + ee.EncodeBool(bool(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[bool(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeBool(bool(k2)) + ee.EncodeInt(int64(v[bool(k2)])) } - ee.EncodeInt(int64(v[bool(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeBool(k2) - if esep { + ee.EncodeBool(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeBool(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -13672,6 +14582,10 @@ func (e *Encoder) fastpathEncMapBoolInt8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapBoolInt8V(rv2i(rv).(map[bool]int8), e) } func (_ fastpathT) EncMapBoolInt8V(v map[bool]int8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13682,26 +14596,32 @@ func (_ fastpathT) EncMapBoolInt8V(v map[bool]int8, e *Encoder) { i++ } sort.Sort(boolSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeBool(bool(k2)) - if esep { + ee.EncodeBool(bool(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[bool(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeBool(bool(k2)) + ee.EncodeInt(int64(v[bool(k2)])) } - ee.EncodeInt(int64(v[bool(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeBool(k2) - if esep { + ee.EncodeBool(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeBool(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -13711,6 +14631,10 @@ func (e *Encoder) fastpathEncMapBoolInt16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapBoolInt16V(rv2i(rv).(map[bool]int16), e) } func (_ fastpathT) EncMapBoolInt16V(v map[bool]int16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13721,26 +14645,32 @@ func (_ fastpathT) EncMapBoolInt16V(v map[bool]int16, e *Encoder) { i++ } sort.Sort(boolSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeBool(bool(k2)) - if esep { + ee.EncodeBool(bool(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[bool(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeBool(bool(k2)) + ee.EncodeInt(int64(v[bool(k2)])) } - ee.EncodeInt(int64(v[bool(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeBool(k2) - if esep { + ee.EncodeBool(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeBool(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -13750,6 +14680,10 @@ func (e *Encoder) fastpathEncMapBoolInt32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapBoolInt32V(rv2i(rv).(map[bool]int32), e) } func (_ fastpathT) EncMapBoolInt32V(v map[bool]int32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13760,26 +14694,32 @@ func (_ fastpathT) EncMapBoolInt32V(v map[bool]int32, e *Encoder) { i++ } sort.Sort(boolSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeBool(bool(k2)) - if esep { + ee.EncodeBool(bool(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[bool(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeBool(bool(k2)) + ee.EncodeInt(int64(v[bool(k2)])) } - ee.EncodeInt(int64(v[bool(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeBool(k2) - if esep { + ee.EncodeBool(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeBool(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -13789,6 +14729,10 @@ func (e *Encoder) fastpathEncMapBoolInt64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapBoolInt64V(rv2i(rv).(map[bool]int64), e) } func (_ fastpathT) EncMapBoolInt64V(v map[bool]int64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13799,26 +14743,32 @@ func (_ fastpathT) EncMapBoolInt64V(v map[bool]int64, e *Encoder) { i++ } sort.Sort(boolSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeBool(bool(k2)) - if esep { + ee.EncodeBool(bool(k2)) ee.WriteMapElemValue() + ee.EncodeInt(int64(v[bool(k2)])) + } + } else { + for _, k2 := range v2 { + ee.EncodeBool(bool(k2)) + ee.EncodeInt(int64(v[bool(k2)])) } - ee.EncodeInt(int64(v[bool(k2)])) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeBool(k2) - if esep { + ee.EncodeBool(k2) ee.WriteMapElemValue() + ee.EncodeInt(int64(v2)) + } + } else { + for k2, v2 := range v { + ee.EncodeBool(k2) + ee.EncodeInt(int64(v2)) } - ee.EncodeInt(int64(v2)) } } ee.WriteMapEnd() @@ -13828,6 +14778,10 @@ func (e *Encoder) fastpathEncMapBoolFloat32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapBoolFloat32V(rv2i(rv).(map[bool]float32), e) } func (_ fastpathT) EncMapBoolFloat32V(v map[bool]float32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13838,26 +14792,32 @@ func (_ fastpathT) EncMapBoolFloat32V(v map[bool]float32, e *Encoder) { i++ } sort.Sort(boolSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeBool(bool(k2)) - if esep { + ee.EncodeBool(bool(k2)) ee.WriteMapElemValue() + ee.EncodeFloat32(v[bool(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeBool(bool(k2)) + ee.EncodeFloat32(v[bool(k2)]) } - ee.EncodeFloat32(v[bool(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeBool(k2) - if esep { + ee.EncodeBool(k2) ee.WriteMapElemValue() + ee.EncodeFloat32(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeBool(k2) + ee.EncodeFloat32(v2) } - ee.EncodeFloat32(v2) } } ee.WriteMapEnd() @@ -13867,6 +14827,10 @@ func (e *Encoder) fastpathEncMapBoolFloat64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapBoolFloat64V(rv2i(rv).(map[bool]float64), e) } func (_ fastpathT) EncMapBoolFloat64V(v map[bool]float64, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13877,26 +14841,32 @@ func (_ fastpathT) EncMapBoolFloat64V(v map[bool]float64, e *Encoder) { i++ } sort.Sort(boolSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeBool(bool(k2)) - if esep { + ee.EncodeBool(bool(k2)) ee.WriteMapElemValue() + ee.EncodeFloat64(v[bool(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeBool(bool(k2)) + ee.EncodeFloat64(v[bool(k2)]) } - ee.EncodeFloat64(v[bool(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeBool(k2) - if esep { + ee.EncodeBool(k2) ee.WriteMapElemValue() + ee.EncodeFloat64(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeBool(k2) + ee.EncodeFloat64(v2) } - ee.EncodeFloat64(v2) } } ee.WriteMapEnd() @@ -13906,6 +14876,10 @@ func (e *Encoder) fastpathEncMapBoolBoolR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncMapBoolBoolV(rv2i(rv).(map[bool]bool), e) } func (_ fastpathT) EncMapBoolBoolV(v map[bool]bool, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return + } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) if e.h.Canonical { @@ -13916,26 +14890,32 @@ func (_ fastpathT) EncMapBoolBoolV(v map[bool]bool, e *Encoder) { i++ } sort.Sort(boolSlice(v2)) - for _, k2 := range v2 { - if esep { + if esep { + for _, k2 := range v2 { ee.WriteMapElemKey() - } - ee.EncodeBool(bool(k2)) - if esep { + ee.EncodeBool(bool(k2)) ee.WriteMapElemValue() + ee.EncodeBool(v[bool(k2)]) + } + } else { + for _, k2 := range v2 { + ee.EncodeBool(bool(k2)) + ee.EncodeBool(v[bool(k2)]) } - ee.EncodeBool(v[bool(k2)]) } } else { - for k2, v2 := range v { - if esep { + if esep { + for k2, v2 := range v { ee.WriteMapElemKey() - } - ee.EncodeBool(k2) - if esep { + ee.EncodeBool(k2) ee.WriteMapElemValue() + ee.EncodeBool(v2) + } + } else { + for k2, v2 := range v { + ee.EncodeBool(k2) + ee.EncodeBool(v2) } - ee.EncodeBool(v2) } } ee.WriteMapEnd() @@ -13945,2730 +14925,2795 @@ func (_ fastpathT) EncMapBoolBoolV(v map[bool]bool, e *Encoder) { // -- -- fast path type switch func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { + var changed bool switch v := iv.(type) { case []interface{}: - fastpathTV.DecSliceIntfV(v, false, d) + var v2 []interface{} + v2, changed = fastpathTV.DecSliceIntfV(v, false, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } case *[]interface{}: - if v2, changed2 := fastpathTV.DecSliceIntfV(*v, true, d); changed2 { + var v2 []interface{} + v2, changed = fastpathTV.DecSliceIntfV(*v, true, d) + if changed { + *v = v2 + } + case []string: + var v2 []string + v2, changed = fastpathTV.DecSliceStringV(v, false, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } + case *[]string: + var v2 []string + v2, changed = fastpathTV.DecSliceStringV(*v, true, d) + if changed { + *v = v2 + } + case []float32: + var v2 []float32 + v2, changed = fastpathTV.DecSliceFloat32V(v, false, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } + case *[]float32: + var v2 []float32 + v2, changed = fastpathTV.DecSliceFloat32V(*v, true, d) + if changed { + *v = v2 + } + case []float64: + var v2 []float64 + v2, changed = fastpathTV.DecSliceFloat64V(v, false, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } + case *[]float64: + var v2 []float64 + v2, changed = fastpathTV.DecSliceFloat64V(*v, true, d) + if changed { + *v = v2 + } + case []uint: + var v2 []uint + v2, changed = fastpathTV.DecSliceUintV(v, false, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } + case *[]uint: + var v2 []uint + v2, changed = fastpathTV.DecSliceUintV(*v, true, d) + if changed { + *v = v2 + } + case []uint16: + var v2 []uint16 + v2, changed = fastpathTV.DecSliceUint16V(v, false, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } + case *[]uint16: + var v2 []uint16 + v2, changed = fastpathTV.DecSliceUint16V(*v, true, d) + if changed { + *v = v2 + } + case []uint32: + var v2 []uint32 + v2, changed = fastpathTV.DecSliceUint32V(v, false, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } + case *[]uint32: + var v2 []uint32 + v2, changed = fastpathTV.DecSliceUint32V(*v, true, d) + if changed { + *v = v2 + } + case []uint64: + var v2 []uint64 + v2, changed = fastpathTV.DecSliceUint64V(v, false, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } + case *[]uint64: + var v2 []uint64 + v2, changed = fastpathTV.DecSliceUint64V(*v, true, d) + if changed { + *v = v2 + } + case []uintptr: + var v2 []uintptr + v2, changed = fastpathTV.DecSliceUintptrV(v, false, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } + case *[]uintptr: + var v2 []uintptr + v2, changed = fastpathTV.DecSliceUintptrV(*v, true, d) + if changed { + *v = v2 + } + case []int: + var v2 []int + v2, changed = fastpathTV.DecSliceIntV(v, false, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } + case *[]int: + var v2 []int + v2, changed = fastpathTV.DecSliceIntV(*v, true, d) + if changed { + *v = v2 + } + case []int8: + var v2 []int8 + v2, changed = fastpathTV.DecSliceInt8V(v, false, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } + case *[]int8: + var v2 []int8 + v2, changed = fastpathTV.DecSliceInt8V(*v, true, d) + if changed { + *v = v2 + } + case []int16: + var v2 []int16 + v2, changed = fastpathTV.DecSliceInt16V(v, false, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } + case *[]int16: + var v2 []int16 + v2, changed = fastpathTV.DecSliceInt16V(*v, true, d) + if changed { + *v = v2 + } + case []int32: + var v2 []int32 + v2, changed = fastpathTV.DecSliceInt32V(v, false, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } + case *[]int32: + var v2 []int32 + v2, changed = fastpathTV.DecSliceInt32V(*v, true, d) + if changed { + *v = v2 + } + case []int64: + var v2 []int64 + v2, changed = fastpathTV.DecSliceInt64V(v, false, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } + case *[]int64: + var v2 []int64 + v2, changed = fastpathTV.DecSliceInt64V(*v, true, d) + if changed { + *v = v2 + } + case []bool: + var v2 []bool + v2, changed = fastpathTV.DecSliceBoolV(v, false, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } + case *[]bool: + var v2 []bool + v2, changed = fastpathTV.DecSliceBoolV(*v, true, d) + if changed { *v = v2 } case map[interface{}]interface{}: fastpathTV.DecMapIntfIntfV(v, false, d) case *map[interface{}]interface{}: - if v2, changed2 := fastpathTV.DecMapIntfIntfV(*v, true, d); changed2 { + var v2 map[interface{}]interface{} + v2, changed = fastpathTV.DecMapIntfIntfV(*v, true, d) + if changed { *v = v2 } - case map[interface{}]string: fastpathTV.DecMapIntfStringV(v, false, d) case *map[interface{}]string: - if v2, changed2 := fastpathTV.DecMapIntfStringV(*v, true, d); changed2 { + var v2 map[interface{}]string + v2, changed = fastpathTV.DecMapIntfStringV(*v, true, d) + if changed { *v = v2 } - case map[interface{}]uint: fastpathTV.DecMapIntfUintV(v, false, d) case *map[interface{}]uint: - if v2, changed2 := fastpathTV.DecMapIntfUintV(*v, true, d); changed2 { + var v2 map[interface{}]uint + v2, changed = fastpathTV.DecMapIntfUintV(*v, true, d) + if changed { *v = v2 } - case map[interface{}]uint8: fastpathTV.DecMapIntfUint8V(v, false, d) case *map[interface{}]uint8: - if v2, changed2 := fastpathTV.DecMapIntfUint8V(*v, true, d); changed2 { + var v2 map[interface{}]uint8 + v2, changed = fastpathTV.DecMapIntfUint8V(*v, true, d) + if changed { *v = v2 } - case map[interface{}]uint16: fastpathTV.DecMapIntfUint16V(v, false, d) case *map[interface{}]uint16: - if v2, changed2 := fastpathTV.DecMapIntfUint16V(*v, true, d); changed2 { + var v2 map[interface{}]uint16 + v2, changed = fastpathTV.DecMapIntfUint16V(*v, true, d) + if changed { *v = v2 } - case map[interface{}]uint32: fastpathTV.DecMapIntfUint32V(v, false, d) case *map[interface{}]uint32: - if v2, changed2 := fastpathTV.DecMapIntfUint32V(*v, true, d); changed2 { + var v2 map[interface{}]uint32 + v2, changed = fastpathTV.DecMapIntfUint32V(*v, true, d) + if changed { *v = v2 } - case map[interface{}]uint64: fastpathTV.DecMapIntfUint64V(v, false, d) case *map[interface{}]uint64: - if v2, changed2 := fastpathTV.DecMapIntfUint64V(*v, true, d); changed2 { + var v2 map[interface{}]uint64 + v2, changed = fastpathTV.DecMapIntfUint64V(*v, true, d) + if changed { *v = v2 } - case map[interface{}]uintptr: fastpathTV.DecMapIntfUintptrV(v, false, d) case *map[interface{}]uintptr: - if v2, changed2 := fastpathTV.DecMapIntfUintptrV(*v, true, d); changed2 { + var v2 map[interface{}]uintptr + v2, changed = fastpathTV.DecMapIntfUintptrV(*v, true, d) + if changed { *v = v2 } - case map[interface{}]int: fastpathTV.DecMapIntfIntV(v, false, d) case *map[interface{}]int: - if v2, changed2 := fastpathTV.DecMapIntfIntV(*v, true, d); changed2 { + var v2 map[interface{}]int + v2, changed = fastpathTV.DecMapIntfIntV(*v, true, d) + if changed { *v = v2 } - case map[interface{}]int8: fastpathTV.DecMapIntfInt8V(v, false, d) case *map[interface{}]int8: - if v2, changed2 := fastpathTV.DecMapIntfInt8V(*v, true, d); changed2 { + var v2 map[interface{}]int8 + v2, changed = fastpathTV.DecMapIntfInt8V(*v, true, d) + if changed { *v = v2 } - case map[interface{}]int16: fastpathTV.DecMapIntfInt16V(v, false, d) case *map[interface{}]int16: - if v2, changed2 := fastpathTV.DecMapIntfInt16V(*v, true, d); changed2 { + var v2 map[interface{}]int16 + v2, changed = fastpathTV.DecMapIntfInt16V(*v, true, d) + if changed { *v = v2 } - case map[interface{}]int32: fastpathTV.DecMapIntfInt32V(v, false, d) case *map[interface{}]int32: - if v2, changed2 := fastpathTV.DecMapIntfInt32V(*v, true, d); changed2 { + var v2 map[interface{}]int32 + v2, changed = fastpathTV.DecMapIntfInt32V(*v, true, d) + if changed { *v = v2 } - case map[interface{}]int64: fastpathTV.DecMapIntfInt64V(v, false, d) case *map[interface{}]int64: - if v2, changed2 := fastpathTV.DecMapIntfInt64V(*v, true, d); changed2 { + var v2 map[interface{}]int64 + v2, changed = fastpathTV.DecMapIntfInt64V(*v, true, d) + if changed { *v = v2 } - case map[interface{}]float32: fastpathTV.DecMapIntfFloat32V(v, false, d) case *map[interface{}]float32: - if v2, changed2 := fastpathTV.DecMapIntfFloat32V(*v, true, d); changed2 { + var v2 map[interface{}]float32 + v2, changed = fastpathTV.DecMapIntfFloat32V(*v, true, d) + if changed { *v = v2 } - case map[interface{}]float64: fastpathTV.DecMapIntfFloat64V(v, false, d) case *map[interface{}]float64: - if v2, changed2 := fastpathTV.DecMapIntfFloat64V(*v, true, d); changed2 { + var v2 map[interface{}]float64 + v2, changed = fastpathTV.DecMapIntfFloat64V(*v, true, d) + if changed { *v = v2 } - case map[interface{}]bool: fastpathTV.DecMapIntfBoolV(v, false, d) case *map[interface{}]bool: - if v2, changed2 := fastpathTV.DecMapIntfBoolV(*v, true, d); changed2 { - *v = v2 - } - - case []string: - fastpathTV.DecSliceStringV(v, false, d) - case *[]string: - if v2, changed2 := fastpathTV.DecSliceStringV(*v, true, d); changed2 { + var v2 map[interface{}]bool + v2, changed = fastpathTV.DecMapIntfBoolV(*v, true, d) + if changed { *v = v2 } - case map[string]interface{}: fastpathTV.DecMapStringIntfV(v, false, d) case *map[string]interface{}: - if v2, changed2 := fastpathTV.DecMapStringIntfV(*v, true, d); changed2 { + var v2 map[string]interface{} + v2, changed = fastpathTV.DecMapStringIntfV(*v, true, d) + if changed { *v = v2 } - case map[string]string: fastpathTV.DecMapStringStringV(v, false, d) case *map[string]string: - if v2, changed2 := fastpathTV.DecMapStringStringV(*v, true, d); changed2 { + var v2 map[string]string + v2, changed = fastpathTV.DecMapStringStringV(*v, true, d) + if changed { *v = v2 } - case map[string]uint: fastpathTV.DecMapStringUintV(v, false, d) case *map[string]uint: - if v2, changed2 := fastpathTV.DecMapStringUintV(*v, true, d); changed2 { + var v2 map[string]uint + v2, changed = fastpathTV.DecMapStringUintV(*v, true, d) + if changed { *v = v2 } - case map[string]uint8: fastpathTV.DecMapStringUint8V(v, false, d) case *map[string]uint8: - if v2, changed2 := fastpathTV.DecMapStringUint8V(*v, true, d); changed2 { + var v2 map[string]uint8 + v2, changed = fastpathTV.DecMapStringUint8V(*v, true, d) + if changed { *v = v2 } - case map[string]uint16: fastpathTV.DecMapStringUint16V(v, false, d) case *map[string]uint16: - if v2, changed2 := fastpathTV.DecMapStringUint16V(*v, true, d); changed2 { + var v2 map[string]uint16 + v2, changed = fastpathTV.DecMapStringUint16V(*v, true, d) + if changed { *v = v2 } - case map[string]uint32: fastpathTV.DecMapStringUint32V(v, false, d) case *map[string]uint32: - if v2, changed2 := fastpathTV.DecMapStringUint32V(*v, true, d); changed2 { + var v2 map[string]uint32 + v2, changed = fastpathTV.DecMapStringUint32V(*v, true, d) + if changed { *v = v2 } - case map[string]uint64: fastpathTV.DecMapStringUint64V(v, false, d) case *map[string]uint64: - if v2, changed2 := fastpathTV.DecMapStringUint64V(*v, true, d); changed2 { + var v2 map[string]uint64 + v2, changed = fastpathTV.DecMapStringUint64V(*v, true, d) + if changed { *v = v2 } - case map[string]uintptr: fastpathTV.DecMapStringUintptrV(v, false, d) case *map[string]uintptr: - if v2, changed2 := fastpathTV.DecMapStringUintptrV(*v, true, d); changed2 { + var v2 map[string]uintptr + v2, changed = fastpathTV.DecMapStringUintptrV(*v, true, d) + if changed { *v = v2 } - case map[string]int: fastpathTV.DecMapStringIntV(v, false, d) case *map[string]int: - if v2, changed2 := fastpathTV.DecMapStringIntV(*v, true, d); changed2 { + var v2 map[string]int + v2, changed = fastpathTV.DecMapStringIntV(*v, true, d) + if changed { *v = v2 } - case map[string]int8: fastpathTV.DecMapStringInt8V(v, false, d) case *map[string]int8: - if v2, changed2 := fastpathTV.DecMapStringInt8V(*v, true, d); changed2 { + var v2 map[string]int8 + v2, changed = fastpathTV.DecMapStringInt8V(*v, true, d) + if changed { *v = v2 } - case map[string]int16: fastpathTV.DecMapStringInt16V(v, false, d) case *map[string]int16: - if v2, changed2 := fastpathTV.DecMapStringInt16V(*v, true, d); changed2 { + var v2 map[string]int16 + v2, changed = fastpathTV.DecMapStringInt16V(*v, true, d) + if changed { *v = v2 } - case map[string]int32: fastpathTV.DecMapStringInt32V(v, false, d) case *map[string]int32: - if v2, changed2 := fastpathTV.DecMapStringInt32V(*v, true, d); changed2 { + var v2 map[string]int32 + v2, changed = fastpathTV.DecMapStringInt32V(*v, true, d) + if changed { *v = v2 } - case map[string]int64: fastpathTV.DecMapStringInt64V(v, false, d) case *map[string]int64: - if v2, changed2 := fastpathTV.DecMapStringInt64V(*v, true, d); changed2 { + var v2 map[string]int64 + v2, changed = fastpathTV.DecMapStringInt64V(*v, true, d) + if changed { *v = v2 } - case map[string]float32: fastpathTV.DecMapStringFloat32V(v, false, d) case *map[string]float32: - if v2, changed2 := fastpathTV.DecMapStringFloat32V(*v, true, d); changed2 { + var v2 map[string]float32 + v2, changed = fastpathTV.DecMapStringFloat32V(*v, true, d) + if changed { *v = v2 } - case map[string]float64: fastpathTV.DecMapStringFloat64V(v, false, d) case *map[string]float64: - if v2, changed2 := fastpathTV.DecMapStringFloat64V(*v, true, d); changed2 { + var v2 map[string]float64 + v2, changed = fastpathTV.DecMapStringFloat64V(*v, true, d) + if changed { *v = v2 } - case map[string]bool: fastpathTV.DecMapStringBoolV(v, false, d) case *map[string]bool: - if v2, changed2 := fastpathTV.DecMapStringBoolV(*v, true, d); changed2 { - *v = v2 - } - - case []float32: - fastpathTV.DecSliceFloat32V(v, false, d) - case *[]float32: - if v2, changed2 := fastpathTV.DecSliceFloat32V(*v, true, d); changed2 { + var v2 map[string]bool + v2, changed = fastpathTV.DecMapStringBoolV(*v, true, d) + if changed { *v = v2 } - case map[float32]interface{}: fastpathTV.DecMapFloat32IntfV(v, false, d) case *map[float32]interface{}: - if v2, changed2 := fastpathTV.DecMapFloat32IntfV(*v, true, d); changed2 { + var v2 map[float32]interface{} + v2, changed = fastpathTV.DecMapFloat32IntfV(*v, true, d) + if changed { *v = v2 } - case map[float32]string: fastpathTV.DecMapFloat32StringV(v, false, d) case *map[float32]string: - if v2, changed2 := fastpathTV.DecMapFloat32StringV(*v, true, d); changed2 { + var v2 map[float32]string + v2, changed = fastpathTV.DecMapFloat32StringV(*v, true, d) + if changed { *v = v2 } - case map[float32]uint: fastpathTV.DecMapFloat32UintV(v, false, d) case *map[float32]uint: - if v2, changed2 := fastpathTV.DecMapFloat32UintV(*v, true, d); changed2 { + var v2 map[float32]uint + v2, changed = fastpathTV.DecMapFloat32UintV(*v, true, d) + if changed { *v = v2 } - case map[float32]uint8: fastpathTV.DecMapFloat32Uint8V(v, false, d) case *map[float32]uint8: - if v2, changed2 := fastpathTV.DecMapFloat32Uint8V(*v, true, d); changed2 { + var v2 map[float32]uint8 + v2, changed = fastpathTV.DecMapFloat32Uint8V(*v, true, d) + if changed { *v = v2 } - case map[float32]uint16: fastpathTV.DecMapFloat32Uint16V(v, false, d) case *map[float32]uint16: - if v2, changed2 := fastpathTV.DecMapFloat32Uint16V(*v, true, d); changed2 { + var v2 map[float32]uint16 + v2, changed = fastpathTV.DecMapFloat32Uint16V(*v, true, d) + if changed { *v = v2 } - case map[float32]uint32: fastpathTV.DecMapFloat32Uint32V(v, false, d) case *map[float32]uint32: - if v2, changed2 := fastpathTV.DecMapFloat32Uint32V(*v, true, d); changed2 { + var v2 map[float32]uint32 + v2, changed = fastpathTV.DecMapFloat32Uint32V(*v, true, d) + if changed { *v = v2 } - case map[float32]uint64: fastpathTV.DecMapFloat32Uint64V(v, false, d) case *map[float32]uint64: - if v2, changed2 := fastpathTV.DecMapFloat32Uint64V(*v, true, d); changed2 { + var v2 map[float32]uint64 + v2, changed = fastpathTV.DecMapFloat32Uint64V(*v, true, d) + if changed { *v = v2 } - case map[float32]uintptr: fastpathTV.DecMapFloat32UintptrV(v, false, d) case *map[float32]uintptr: - if v2, changed2 := fastpathTV.DecMapFloat32UintptrV(*v, true, d); changed2 { + var v2 map[float32]uintptr + v2, changed = fastpathTV.DecMapFloat32UintptrV(*v, true, d) + if changed { *v = v2 } - case map[float32]int: fastpathTV.DecMapFloat32IntV(v, false, d) case *map[float32]int: - if v2, changed2 := fastpathTV.DecMapFloat32IntV(*v, true, d); changed2 { + var v2 map[float32]int + v2, changed = fastpathTV.DecMapFloat32IntV(*v, true, d) + if changed { *v = v2 } - case map[float32]int8: fastpathTV.DecMapFloat32Int8V(v, false, d) case *map[float32]int8: - if v2, changed2 := fastpathTV.DecMapFloat32Int8V(*v, true, d); changed2 { + var v2 map[float32]int8 + v2, changed = fastpathTV.DecMapFloat32Int8V(*v, true, d) + if changed { *v = v2 } - case map[float32]int16: fastpathTV.DecMapFloat32Int16V(v, false, d) case *map[float32]int16: - if v2, changed2 := fastpathTV.DecMapFloat32Int16V(*v, true, d); changed2 { + var v2 map[float32]int16 + v2, changed = fastpathTV.DecMapFloat32Int16V(*v, true, d) + if changed { *v = v2 } - case map[float32]int32: fastpathTV.DecMapFloat32Int32V(v, false, d) case *map[float32]int32: - if v2, changed2 := fastpathTV.DecMapFloat32Int32V(*v, true, d); changed2 { + var v2 map[float32]int32 + v2, changed = fastpathTV.DecMapFloat32Int32V(*v, true, d) + if changed { *v = v2 } - case map[float32]int64: fastpathTV.DecMapFloat32Int64V(v, false, d) case *map[float32]int64: - if v2, changed2 := fastpathTV.DecMapFloat32Int64V(*v, true, d); changed2 { + var v2 map[float32]int64 + v2, changed = fastpathTV.DecMapFloat32Int64V(*v, true, d) + if changed { *v = v2 } - case map[float32]float32: fastpathTV.DecMapFloat32Float32V(v, false, d) case *map[float32]float32: - if v2, changed2 := fastpathTV.DecMapFloat32Float32V(*v, true, d); changed2 { + var v2 map[float32]float32 + v2, changed = fastpathTV.DecMapFloat32Float32V(*v, true, d) + if changed { *v = v2 } - case map[float32]float64: fastpathTV.DecMapFloat32Float64V(v, false, d) case *map[float32]float64: - if v2, changed2 := fastpathTV.DecMapFloat32Float64V(*v, true, d); changed2 { + var v2 map[float32]float64 + v2, changed = fastpathTV.DecMapFloat32Float64V(*v, true, d) + if changed { *v = v2 } - case map[float32]bool: fastpathTV.DecMapFloat32BoolV(v, false, d) case *map[float32]bool: - if v2, changed2 := fastpathTV.DecMapFloat32BoolV(*v, true, d); changed2 { - *v = v2 - } - - case []float64: - fastpathTV.DecSliceFloat64V(v, false, d) - case *[]float64: - if v2, changed2 := fastpathTV.DecSliceFloat64V(*v, true, d); changed2 { + var v2 map[float32]bool + v2, changed = fastpathTV.DecMapFloat32BoolV(*v, true, d) + if changed { *v = v2 } - case map[float64]interface{}: fastpathTV.DecMapFloat64IntfV(v, false, d) case *map[float64]interface{}: - if v2, changed2 := fastpathTV.DecMapFloat64IntfV(*v, true, d); changed2 { + var v2 map[float64]interface{} + v2, changed = fastpathTV.DecMapFloat64IntfV(*v, true, d) + if changed { *v = v2 } - case map[float64]string: fastpathTV.DecMapFloat64StringV(v, false, d) case *map[float64]string: - if v2, changed2 := fastpathTV.DecMapFloat64StringV(*v, true, d); changed2 { + var v2 map[float64]string + v2, changed = fastpathTV.DecMapFloat64StringV(*v, true, d) + if changed { *v = v2 } - case map[float64]uint: fastpathTV.DecMapFloat64UintV(v, false, d) case *map[float64]uint: - if v2, changed2 := fastpathTV.DecMapFloat64UintV(*v, true, d); changed2 { + var v2 map[float64]uint + v2, changed = fastpathTV.DecMapFloat64UintV(*v, true, d) + if changed { *v = v2 } - case map[float64]uint8: fastpathTV.DecMapFloat64Uint8V(v, false, d) case *map[float64]uint8: - if v2, changed2 := fastpathTV.DecMapFloat64Uint8V(*v, true, d); changed2 { + var v2 map[float64]uint8 + v2, changed = fastpathTV.DecMapFloat64Uint8V(*v, true, d) + if changed { *v = v2 } - case map[float64]uint16: fastpathTV.DecMapFloat64Uint16V(v, false, d) case *map[float64]uint16: - if v2, changed2 := fastpathTV.DecMapFloat64Uint16V(*v, true, d); changed2 { + var v2 map[float64]uint16 + v2, changed = fastpathTV.DecMapFloat64Uint16V(*v, true, d) + if changed { *v = v2 } - case map[float64]uint32: fastpathTV.DecMapFloat64Uint32V(v, false, d) case *map[float64]uint32: - if v2, changed2 := fastpathTV.DecMapFloat64Uint32V(*v, true, d); changed2 { + var v2 map[float64]uint32 + v2, changed = fastpathTV.DecMapFloat64Uint32V(*v, true, d) + if changed { *v = v2 } - case map[float64]uint64: fastpathTV.DecMapFloat64Uint64V(v, false, d) case *map[float64]uint64: - if v2, changed2 := fastpathTV.DecMapFloat64Uint64V(*v, true, d); changed2 { + var v2 map[float64]uint64 + v2, changed = fastpathTV.DecMapFloat64Uint64V(*v, true, d) + if changed { *v = v2 } - case map[float64]uintptr: fastpathTV.DecMapFloat64UintptrV(v, false, d) case *map[float64]uintptr: - if v2, changed2 := fastpathTV.DecMapFloat64UintptrV(*v, true, d); changed2 { + var v2 map[float64]uintptr + v2, changed = fastpathTV.DecMapFloat64UintptrV(*v, true, d) + if changed { *v = v2 } - case map[float64]int: fastpathTV.DecMapFloat64IntV(v, false, d) case *map[float64]int: - if v2, changed2 := fastpathTV.DecMapFloat64IntV(*v, true, d); changed2 { + var v2 map[float64]int + v2, changed = fastpathTV.DecMapFloat64IntV(*v, true, d) + if changed { *v = v2 } - case map[float64]int8: fastpathTV.DecMapFloat64Int8V(v, false, d) case *map[float64]int8: - if v2, changed2 := fastpathTV.DecMapFloat64Int8V(*v, true, d); changed2 { + var v2 map[float64]int8 + v2, changed = fastpathTV.DecMapFloat64Int8V(*v, true, d) + if changed { *v = v2 } - case map[float64]int16: fastpathTV.DecMapFloat64Int16V(v, false, d) case *map[float64]int16: - if v2, changed2 := fastpathTV.DecMapFloat64Int16V(*v, true, d); changed2 { + var v2 map[float64]int16 + v2, changed = fastpathTV.DecMapFloat64Int16V(*v, true, d) + if changed { *v = v2 } - case map[float64]int32: fastpathTV.DecMapFloat64Int32V(v, false, d) case *map[float64]int32: - if v2, changed2 := fastpathTV.DecMapFloat64Int32V(*v, true, d); changed2 { + var v2 map[float64]int32 + v2, changed = fastpathTV.DecMapFloat64Int32V(*v, true, d) + if changed { *v = v2 } - case map[float64]int64: fastpathTV.DecMapFloat64Int64V(v, false, d) case *map[float64]int64: - if v2, changed2 := fastpathTV.DecMapFloat64Int64V(*v, true, d); changed2 { + var v2 map[float64]int64 + v2, changed = fastpathTV.DecMapFloat64Int64V(*v, true, d) + if changed { *v = v2 } - case map[float64]float32: fastpathTV.DecMapFloat64Float32V(v, false, d) case *map[float64]float32: - if v2, changed2 := fastpathTV.DecMapFloat64Float32V(*v, true, d); changed2 { + var v2 map[float64]float32 + v2, changed = fastpathTV.DecMapFloat64Float32V(*v, true, d) + if changed { *v = v2 } - case map[float64]float64: fastpathTV.DecMapFloat64Float64V(v, false, d) case *map[float64]float64: - if v2, changed2 := fastpathTV.DecMapFloat64Float64V(*v, true, d); changed2 { + var v2 map[float64]float64 + v2, changed = fastpathTV.DecMapFloat64Float64V(*v, true, d) + if changed { *v = v2 } - case map[float64]bool: fastpathTV.DecMapFloat64BoolV(v, false, d) case *map[float64]bool: - if v2, changed2 := fastpathTV.DecMapFloat64BoolV(*v, true, d); changed2 { - *v = v2 - } - - case []uint: - fastpathTV.DecSliceUintV(v, false, d) - case *[]uint: - if v2, changed2 := fastpathTV.DecSliceUintV(*v, true, d); changed2 { + var v2 map[float64]bool + v2, changed = fastpathTV.DecMapFloat64BoolV(*v, true, d) + if changed { *v = v2 } - case map[uint]interface{}: fastpathTV.DecMapUintIntfV(v, false, d) case *map[uint]interface{}: - if v2, changed2 := fastpathTV.DecMapUintIntfV(*v, true, d); changed2 { + var v2 map[uint]interface{} + v2, changed = fastpathTV.DecMapUintIntfV(*v, true, d) + if changed { *v = v2 } - case map[uint]string: fastpathTV.DecMapUintStringV(v, false, d) case *map[uint]string: - if v2, changed2 := fastpathTV.DecMapUintStringV(*v, true, d); changed2 { + var v2 map[uint]string + v2, changed = fastpathTV.DecMapUintStringV(*v, true, d) + if changed { *v = v2 } - case map[uint]uint: fastpathTV.DecMapUintUintV(v, false, d) case *map[uint]uint: - if v2, changed2 := fastpathTV.DecMapUintUintV(*v, true, d); changed2 { + var v2 map[uint]uint + v2, changed = fastpathTV.DecMapUintUintV(*v, true, d) + if changed { *v = v2 } - case map[uint]uint8: fastpathTV.DecMapUintUint8V(v, false, d) case *map[uint]uint8: - if v2, changed2 := fastpathTV.DecMapUintUint8V(*v, true, d); changed2 { + var v2 map[uint]uint8 + v2, changed = fastpathTV.DecMapUintUint8V(*v, true, d) + if changed { *v = v2 } - case map[uint]uint16: fastpathTV.DecMapUintUint16V(v, false, d) case *map[uint]uint16: - if v2, changed2 := fastpathTV.DecMapUintUint16V(*v, true, d); changed2 { + var v2 map[uint]uint16 + v2, changed = fastpathTV.DecMapUintUint16V(*v, true, d) + if changed { *v = v2 } - case map[uint]uint32: fastpathTV.DecMapUintUint32V(v, false, d) case *map[uint]uint32: - if v2, changed2 := fastpathTV.DecMapUintUint32V(*v, true, d); changed2 { + var v2 map[uint]uint32 + v2, changed = fastpathTV.DecMapUintUint32V(*v, true, d) + if changed { *v = v2 } - case map[uint]uint64: fastpathTV.DecMapUintUint64V(v, false, d) case *map[uint]uint64: - if v2, changed2 := fastpathTV.DecMapUintUint64V(*v, true, d); changed2 { + var v2 map[uint]uint64 + v2, changed = fastpathTV.DecMapUintUint64V(*v, true, d) + if changed { *v = v2 } - case map[uint]uintptr: fastpathTV.DecMapUintUintptrV(v, false, d) case *map[uint]uintptr: - if v2, changed2 := fastpathTV.DecMapUintUintptrV(*v, true, d); changed2 { + var v2 map[uint]uintptr + v2, changed = fastpathTV.DecMapUintUintptrV(*v, true, d) + if changed { *v = v2 } - case map[uint]int: fastpathTV.DecMapUintIntV(v, false, d) case *map[uint]int: - if v2, changed2 := fastpathTV.DecMapUintIntV(*v, true, d); changed2 { + var v2 map[uint]int + v2, changed = fastpathTV.DecMapUintIntV(*v, true, d) + if changed { *v = v2 } - case map[uint]int8: fastpathTV.DecMapUintInt8V(v, false, d) case *map[uint]int8: - if v2, changed2 := fastpathTV.DecMapUintInt8V(*v, true, d); changed2 { + var v2 map[uint]int8 + v2, changed = fastpathTV.DecMapUintInt8V(*v, true, d) + if changed { *v = v2 } - case map[uint]int16: fastpathTV.DecMapUintInt16V(v, false, d) case *map[uint]int16: - if v2, changed2 := fastpathTV.DecMapUintInt16V(*v, true, d); changed2 { + var v2 map[uint]int16 + v2, changed = fastpathTV.DecMapUintInt16V(*v, true, d) + if changed { *v = v2 } - case map[uint]int32: fastpathTV.DecMapUintInt32V(v, false, d) case *map[uint]int32: - if v2, changed2 := fastpathTV.DecMapUintInt32V(*v, true, d); changed2 { + var v2 map[uint]int32 + v2, changed = fastpathTV.DecMapUintInt32V(*v, true, d) + if changed { *v = v2 } - case map[uint]int64: fastpathTV.DecMapUintInt64V(v, false, d) case *map[uint]int64: - if v2, changed2 := fastpathTV.DecMapUintInt64V(*v, true, d); changed2 { + var v2 map[uint]int64 + v2, changed = fastpathTV.DecMapUintInt64V(*v, true, d) + if changed { *v = v2 } - case map[uint]float32: fastpathTV.DecMapUintFloat32V(v, false, d) case *map[uint]float32: - if v2, changed2 := fastpathTV.DecMapUintFloat32V(*v, true, d); changed2 { + var v2 map[uint]float32 + v2, changed = fastpathTV.DecMapUintFloat32V(*v, true, d) + if changed { *v = v2 } - case map[uint]float64: fastpathTV.DecMapUintFloat64V(v, false, d) case *map[uint]float64: - if v2, changed2 := fastpathTV.DecMapUintFloat64V(*v, true, d); changed2 { + var v2 map[uint]float64 + v2, changed = fastpathTV.DecMapUintFloat64V(*v, true, d) + if changed { *v = v2 } - case map[uint]bool: fastpathTV.DecMapUintBoolV(v, false, d) case *map[uint]bool: - if v2, changed2 := fastpathTV.DecMapUintBoolV(*v, true, d); changed2 { + var v2 map[uint]bool + v2, changed = fastpathTV.DecMapUintBoolV(*v, true, d) + if changed { *v = v2 } - case map[uint8]interface{}: fastpathTV.DecMapUint8IntfV(v, false, d) case *map[uint8]interface{}: - if v2, changed2 := fastpathTV.DecMapUint8IntfV(*v, true, d); changed2 { + var v2 map[uint8]interface{} + v2, changed = fastpathTV.DecMapUint8IntfV(*v, true, d) + if changed { *v = v2 } - case map[uint8]string: fastpathTV.DecMapUint8StringV(v, false, d) case *map[uint8]string: - if v2, changed2 := fastpathTV.DecMapUint8StringV(*v, true, d); changed2 { + var v2 map[uint8]string + v2, changed = fastpathTV.DecMapUint8StringV(*v, true, d) + if changed { *v = v2 } - case map[uint8]uint: fastpathTV.DecMapUint8UintV(v, false, d) case *map[uint8]uint: - if v2, changed2 := fastpathTV.DecMapUint8UintV(*v, true, d); changed2 { + var v2 map[uint8]uint + v2, changed = fastpathTV.DecMapUint8UintV(*v, true, d) + if changed { *v = v2 } - case map[uint8]uint8: fastpathTV.DecMapUint8Uint8V(v, false, d) case *map[uint8]uint8: - if v2, changed2 := fastpathTV.DecMapUint8Uint8V(*v, true, d); changed2 { + var v2 map[uint8]uint8 + v2, changed = fastpathTV.DecMapUint8Uint8V(*v, true, d) + if changed { *v = v2 } - case map[uint8]uint16: fastpathTV.DecMapUint8Uint16V(v, false, d) case *map[uint8]uint16: - if v2, changed2 := fastpathTV.DecMapUint8Uint16V(*v, true, d); changed2 { + var v2 map[uint8]uint16 + v2, changed = fastpathTV.DecMapUint8Uint16V(*v, true, d) + if changed { *v = v2 } - case map[uint8]uint32: fastpathTV.DecMapUint8Uint32V(v, false, d) case *map[uint8]uint32: - if v2, changed2 := fastpathTV.DecMapUint8Uint32V(*v, true, d); changed2 { + var v2 map[uint8]uint32 + v2, changed = fastpathTV.DecMapUint8Uint32V(*v, true, d) + if changed { *v = v2 } - case map[uint8]uint64: fastpathTV.DecMapUint8Uint64V(v, false, d) case *map[uint8]uint64: - if v2, changed2 := fastpathTV.DecMapUint8Uint64V(*v, true, d); changed2 { + var v2 map[uint8]uint64 + v2, changed = fastpathTV.DecMapUint8Uint64V(*v, true, d) + if changed { *v = v2 } - case map[uint8]uintptr: fastpathTV.DecMapUint8UintptrV(v, false, d) case *map[uint8]uintptr: - if v2, changed2 := fastpathTV.DecMapUint8UintptrV(*v, true, d); changed2 { + var v2 map[uint8]uintptr + v2, changed = fastpathTV.DecMapUint8UintptrV(*v, true, d) + if changed { *v = v2 } - case map[uint8]int: fastpathTV.DecMapUint8IntV(v, false, d) case *map[uint8]int: - if v2, changed2 := fastpathTV.DecMapUint8IntV(*v, true, d); changed2 { + var v2 map[uint8]int + v2, changed = fastpathTV.DecMapUint8IntV(*v, true, d) + if changed { *v = v2 } - case map[uint8]int8: fastpathTV.DecMapUint8Int8V(v, false, d) case *map[uint8]int8: - if v2, changed2 := fastpathTV.DecMapUint8Int8V(*v, true, d); changed2 { + var v2 map[uint8]int8 + v2, changed = fastpathTV.DecMapUint8Int8V(*v, true, d) + if changed { *v = v2 } - case map[uint8]int16: fastpathTV.DecMapUint8Int16V(v, false, d) case *map[uint8]int16: - if v2, changed2 := fastpathTV.DecMapUint8Int16V(*v, true, d); changed2 { + var v2 map[uint8]int16 + v2, changed = fastpathTV.DecMapUint8Int16V(*v, true, d) + if changed { *v = v2 } - case map[uint8]int32: fastpathTV.DecMapUint8Int32V(v, false, d) case *map[uint8]int32: - if v2, changed2 := fastpathTV.DecMapUint8Int32V(*v, true, d); changed2 { + var v2 map[uint8]int32 + v2, changed = fastpathTV.DecMapUint8Int32V(*v, true, d) + if changed { *v = v2 } - case map[uint8]int64: fastpathTV.DecMapUint8Int64V(v, false, d) case *map[uint8]int64: - if v2, changed2 := fastpathTV.DecMapUint8Int64V(*v, true, d); changed2 { + var v2 map[uint8]int64 + v2, changed = fastpathTV.DecMapUint8Int64V(*v, true, d) + if changed { *v = v2 } - case map[uint8]float32: fastpathTV.DecMapUint8Float32V(v, false, d) case *map[uint8]float32: - if v2, changed2 := fastpathTV.DecMapUint8Float32V(*v, true, d); changed2 { + var v2 map[uint8]float32 + v2, changed = fastpathTV.DecMapUint8Float32V(*v, true, d) + if changed { *v = v2 } - case map[uint8]float64: fastpathTV.DecMapUint8Float64V(v, false, d) case *map[uint8]float64: - if v2, changed2 := fastpathTV.DecMapUint8Float64V(*v, true, d); changed2 { + var v2 map[uint8]float64 + v2, changed = fastpathTV.DecMapUint8Float64V(*v, true, d) + if changed { *v = v2 } - case map[uint8]bool: fastpathTV.DecMapUint8BoolV(v, false, d) case *map[uint8]bool: - if v2, changed2 := fastpathTV.DecMapUint8BoolV(*v, true, d); changed2 { - *v = v2 - } - - case []uint16: - fastpathTV.DecSliceUint16V(v, false, d) - case *[]uint16: - if v2, changed2 := fastpathTV.DecSliceUint16V(*v, true, d); changed2 { + var v2 map[uint8]bool + v2, changed = fastpathTV.DecMapUint8BoolV(*v, true, d) + if changed { *v = v2 } - case map[uint16]interface{}: fastpathTV.DecMapUint16IntfV(v, false, d) case *map[uint16]interface{}: - if v2, changed2 := fastpathTV.DecMapUint16IntfV(*v, true, d); changed2 { + var v2 map[uint16]interface{} + v2, changed = fastpathTV.DecMapUint16IntfV(*v, true, d) + if changed { *v = v2 } - case map[uint16]string: fastpathTV.DecMapUint16StringV(v, false, d) case *map[uint16]string: - if v2, changed2 := fastpathTV.DecMapUint16StringV(*v, true, d); changed2 { + var v2 map[uint16]string + v2, changed = fastpathTV.DecMapUint16StringV(*v, true, d) + if changed { *v = v2 } - case map[uint16]uint: fastpathTV.DecMapUint16UintV(v, false, d) case *map[uint16]uint: - if v2, changed2 := fastpathTV.DecMapUint16UintV(*v, true, d); changed2 { + var v2 map[uint16]uint + v2, changed = fastpathTV.DecMapUint16UintV(*v, true, d) + if changed { *v = v2 } - case map[uint16]uint8: fastpathTV.DecMapUint16Uint8V(v, false, d) case *map[uint16]uint8: - if v2, changed2 := fastpathTV.DecMapUint16Uint8V(*v, true, d); changed2 { + var v2 map[uint16]uint8 + v2, changed = fastpathTV.DecMapUint16Uint8V(*v, true, d) + if changed { *v = v2 } - case map[uint16]uint16: fastpathTV.DecMapUint16Uint16V(v, false, d) case *map[uint16]uint16: - if v2, changed2 := fastpathTV.DecMapUint16Uint16V(*v, true, d); changed2 { + var v2 map[uint16]uint16 + v2, changed = fastpathTV.DecMapUint16Uint16V(*v, true, d) + if changed { *v = v2 } - case map[uint16]uint32: fastpathTV.DecMapUint16Uint32V(v, false, d) case *map[uint16]uint32: - if v2, changed2 := fastpathTV.DecMapUint16Uint32V(*v, true, d); changed2 { + var v2 map[uint16]uint32 + v2, changed = fastpathTV.DecMapUint16Uint32V(*v, true, d) + if changed { *v = v2 } - case map[uint16]uint64: fastpathTV.DecMapUint16Uint64V(v, false, d) case *map[uint16]uint64: - if v2, changed2 := fastpathTV.DecMapUint16Uint64V(*v, true, d); changed2 { + var v2 map[uint16]uint64 + v2, changed = fastpathTV.DecMapUint16Uint64V(*v, true, d) + if changed { *v = v2 } - case map[uint16]uintptr: fastpathTV.DecMapUint16UintptrV(v, false, d) case *map[uint16]uintptr: - if v2, changed2 := fastpathTV.DecMapUint16UintptrV(*v, true, d); changed2 { + var v2 map[uint16]uintptr + v2, changed = fastpathTV.DecMapUint16UintptrV(*v, true, d) + if changed { *v = v2 } - case map[uint16]int: fastpathTV.DecMapUint16IntV(v, false, d) case *map[uint16]int: - if v2, changed2 := fastpathTV.DecMapUint16IntV(*v, true, d); changed2 { + var v2 map[uint16]int + v2, changed = fastpathTV.DecMapUint16IntV(*v, true, d) + if changed { *v = v2 } - case map[uint16]int8: fastpathTV.DecMapUint16Int8V(v, false, d) case *map[uint16]int8: - if v2, changed2 := fastpathTV.DecMapUint16Int8V(*v, true, d); changed2 { + var v2 map[uint16]int8 + v2, changed = fastpathTV.DecMapUint16Int8V(*v, true, d) + if changed { *v = v2 } - case map[uint16]int16: fastpathTV.DecMapUint16Int16V(v, false, d) case *map[uint16]int16: - if v2, changed2 := fastpathTV.DecMapUint16Int16V(*v, true, d); changed2 { + var v2 map[uint16]int16 + v2, changed = fastpathTV.DecMapUint16Int16V(*v, true, d) + if changed { *v = v2 } - case map[uint16]int32: fastpathTV.DecMapUint16Int32V(v, false, d) case *map[uint16]int32: - if v2, changed2 := fastpathTV.DecMapUint16Int32V(*v, true, d); changed2 { + var v2 map[uint16]int32 + v2, changed = fastpathTV.DecMapUint16Int32V(*v, true, d) + if changed { *v = v2 } - case map[uint16]int64: fastpathTV.DecMapUint16Int64V(v, false, d) case *map[uint16]int64: - if v2, changed2 := fastpathTV.DecMapUint16Int64V(*v, true, d); changed2 { + var v2 map[uint16]int64 + v2, changed = fastpathTV.DecMapUint16Int64V(*v, true, d) + if changed { *v = v2 } - case map[uint16]float32: fastpathTV.DecMapUint16Float32V(v, false, d) case *map[uint16]float32: - if v2, changed2 := fastpathTV.DecMapUint16Float32V(*v, true, d); changed2 { + var v2 map[uint16]float32 + v2, changed = fastpathTV.DecMapUint16Float32V(*v, true, d) + if changed { *v = v2 } - case map[uint16]float64: fastpathTV.DecMapUint16Float64V(v, false, d) case *map[uint16]float64: - if v2, changed2 := fastpathTV.DecMapUint16Float64V(*v, true, d); changed2 { + var v2 map[uint16]float64 + v2, changed = fastpathTV.DecMapUint16Float64V(*v, true, d) + if changed { *v = v2 } - case map[uint16]bool: fastpathTV.DecMapUint16BoolV(v, false, d) case *map[uint16]bool: - if v2, changed2 := fastpathTV.DecMapUint16BoolV(*v, true, d); changed2 { - *v = v2 - } - - case []uint32: - fastpathTV.DecSliceUint32V(v, false, d) - case *[]uint32: - if v2, changed2 := fastpathTV.DecSliceUint32V(*v, true, d); changed2 { + var v2 map[uint16]bool + v2, changed = fastpathTV.DecMapUint16BoolV(*v, true, d) + if changed { *v = v2 } - case map[uint32]interface{}: fastpathTV.DecMapUint32IntfV(v, false, d) case *map[uint32]interface{}: - if v2, changed2 := fastpathTV.DecMapUint32IntfV(*v, true, d); changed2 { + var v2 map[uint32]interface{} + v2, changed = fastpathTV.DecMapUint32IntfV(*v, true, d) + if changed { *v = v2 } - case map[uint32]string: fastpathTV.DecMapUint32StringV(v, false, d) case *map[uint32]string: - if v2, changed2 := fastpathTV.DecMapUint32StringV(*v, true, d); changed2 { + var v2 map[uint32]string + v2, changed = fastpathTV.DecMapUint32StringV(*v, true, d) + if changed { *v = v2 } - case map[uint32]uint: fastpathTV.DecMapUint32UintV(v, false, d) case *map[uint32]uint: - if v2, changed2 := fastpathTV.DecMapUint32UintV(*v, true, d); changed2 { + var v2 map[uint32]uint + v2, changed = fastpathTV.DecMapUint32UintV(*v, true, d) + if changed { *v = v2 } - case map[uint32]uint8: fastpathTV.DecMapUint32Uint8V(v, false, d) case *map[uint32]uint8: - if v2, changed2 := fastpathTV.DecMapUint32Uint8V(*v, true, d); changed2 { + var v2 map[uint32]uint8 + v2, changed = fastpathTV.DecMapUint32Uint8V(*v, true, d) + if changed { *v = v2 } - case map[uint32]uint16: fastpathTV.DecMapUint32Uint16V(v, false, d) case *map[uint32]uint16: - if v2, changed2 := fastpathTV.DecMapUint32Uint16V(*v, true, d); changed2 { + var v2 map[uint32]uint16 + v2, changed = fastpathTV.DecMapUint32Uint16V(*v, true, d) + if changed { *v = v2 } - case map[uint32]uint32: fastpathTV.DecMapUint32Uint32V(v, false, d) case *map[uint32]uint32: - if v2, changed2 := fastpathTV.DecMapUint32Uint32V(*v, true, d); changed2 { + var v2 map[uint32]uint32 + v2, changed = fastpathTV.DecMapUint32Uint32V(*v, true, d) + if changed { *v = v2 } - case map[uint32]uint64: fastpathTV.DecMapUint32Uint64V(v, false, d) case *map[uint32]uint64: - if v2, changed2 := fastpathTV.DecMapUint32Uint64V(*v, true, d); changed2 { + var v2 map[uint32]uint64 + v2, changed = fastpathTV.DecMapUint32Uint64V(*v, true, d) + if changed { *v = v2 } - case map[uint32]uintptr: fastpathTV.DecMapUint32UintptrV(v, false, d) case *map[uint32]uintptr: - if v2, changed2 := fastpathTV.DecMapUint32UintptrV(*v, true, d); changed2 { + var v2 map[uint32]uintptr + v2, changed = fastpathTV.DecMapUint32UintptrV(*v, true, d) + if changed { *v = v2 } - case map[uint32]int: fastpathTV.DecMapUint32IntV(v, false, d) case *map[uint32]int: - if v2, changed2 := fastpathTV.DecMapUint32IntV(*v, true, d); changed2 { + var v2 map[uint32]int + v2, changed = fastpathTV.DecMapUint32IntV(*v, true, d) + if changed { *v = v2 } - case map[uint32]int8: fastpathTV.DecMapUint32Int8V(v, false, d) case *map[uint32]int8: - if v2, changed2 := fastpathTV.DecMapUint32Int8V(*v, true, d); changed2 { + var v2 map[uint32]int8 + v2, changed = fastpathTV.DecMapUint32Int8V(*v, true, d) + if changed { *v = v2 } - case map[uint32]int16: fastpathTV.DecMapUint32Int16V(v, false, d) case *map[uint32]int16: - if v2, changed2 := fastpathTV.DecMapUint32Int16V(*v, true, d); changed2 { + var v2 map[uint32]int16 + v2, changed = fastpathTV.DecMapUint32Int16V(*v, true, d) + if changed { *v = v2 } - case map[uint32]int32: fastpathTV.DecMapUint32Int32V(v, false, d) case *map[uint32]int32: - if v2, changed2 := fastpathTV.DecMapUint32Int32V(*v, true, d); changed2 { + var v2 map[uint32]int32 + v2, changed = fastpathTV.DecMapUint32Int32V(*v, true, d) + if changed { *v = v2 } - case map[uint32]int64: fastpathTV.DecMapUint32Int64V(v, false, d) case *map[uint32]int64: - if v2, changed2 := fastpathTV.DecMapUint32Int64V(*v, true, d); changed2 { + var v2 map[uint32]int64 + v2, changed = fastpathTV.DecMapUint32Int64V(*v, true, d) + if changed { *v = v2 } - case map[uint32]float32: fastpathTV.DecMapUint32Float32V(v, false, d) case *map[uint32]float32: - if v2, changed2 := fastpathTV.DecMapUint32Float32V(*v, true, d); changed2 { + var v2 map[uint32]float32 + v2, changed = fastpathTV.DecMapUint32Float32V(*v, true, d) + if changed { *v = v2 } - case map[uint32]float64: fastpathTV.DecMapUint32Float64V(v, false, d) case *map[uint32]float64: - if v2, changed2 := fastpathTV.DecMapUint32Float64V(*v, true, d); changed2 { + var v2 map[uint32]float64 + v2, changed = fastpathTV.DecMapUint32Float64V(*v, true, d) + if changed { *v = v2 } - case map[uint32]bool: fastpathTV.DecMapUint32BoolV(v, false, d) case *map[uint32]bool: - if v2, changed2 := fastpathTV.DecMapUint32BoolV(*v, true, d); changed2 { + var v2 map[uint32]bool + v2, changed = fastpathTV.DecMapUint32BoolV(*v, true, d) + if changed { *v = v2 } - - case []uint64: - fastpathTV.DecSliceUint64V(v, false, d) - case *[]uint64: - if v2, changed2 := fastpathTV.DecSliceUint64V(*v, true, d); changed2 { - *v = v2 - } - case map[uint64]interface{}: fastpathTV.DecMapUint64IntfV(v, false, d) case *map[uint64]interface{}: - if v2, changed2 := fastpathTV.DecMapUint64IntfV(*v, true, d); changed2 { + var v2 map[uint64]interface{} + v2, changed = fastpathTV.DecMapUint64IntfV(*v, true, d) + if changed { *v = v2 } - case map[uint64]string: fastpathTV.DecMapUint64StringV(v, false, d) case *map[uint64]string: - if v2, changed2 := fastpathTV.DecMapUint64StringV(*v, true, d); changed2 { + var v2 map[uint64]string + v2, changed = fastpathTV.DecMapUint64StringV(*v, true, d) + if changed { *v = v2 } - case map[uint64]uint: fastpathTV.DecMapUint64UintV(v, false, d) case *map[uint64]uint: - if v2, changed2 := fastpathTV.DecMapUint64UintV(*v, true, d); changed2 { + var v2 map[uint64]uint + v2, changed = fastpathTV.DecMapUint64UintV(*v, true, d) + if changed { *v = v2 } - case map[uint64]uint8: fastpathTV.DecMapUint64Uint8V(v, false, d) case *map[uint64]uint8: - if v2, changed2 := fastpathTV.DecMapUint64Uint8V(*v, true, d); changed2 { + var v2 map[uint64]uint8 + v2, changed = fastpathTV.DecMapUint64Uint8V(*v, true, d) + if changed { *v = v2 } - case map[uint64]uint16: fastpathTV.DecMapUint64Uint16V(v, false, d) case *map[uint64]uint16: - if v2, changed2 := fastpathTV.DecMapUint64Uint16V(*v, true, d); changed2 { + var v2 map[uint64]uint16 + v2, changed = fastpathTV.DecMapUint64Uint16V(*v, true, d) + if changed { *v = v2 } - case map[uint64]uint32: fastpathTV.DecMapUint64Uint32V(v, false, d) case *map[uint64]uint32: - if v2, changed2 := fastpathTV.DecMapUint64Uint32V(*v, true, d); changed2 { + var v2 map[uint64]uint32 + v2, changed = fastpathTV.DecMapUint64Uint32V(*v, true, d) + if changed { *v = v2 } - case map[uint64]uint64: fastpathTV.DecMapUint64Uint64V(v, false, d) case *map[uint64]uint64: - if v2, changed2 := fastpathTV.DecMapUint64Uint64V(*v, true, d); changed2 { + var v2 map[uint64]uint64 + v2, changed = fastpathTV.DecMapUint64Uint64V(*v, true, d) + if changed { *v = v2 } - case map[uint64]uintptr: fastpathTV.DecMapUint64UintptrV(v, false, d) case *map[uint64]uintptr: - if v2, changed2 := fastpathTV.DecMapUint64UintptrV(*v, true, d); changed2 { + var v2 map[uint64]uintptr + v2, changed = fastpathTV.DecMapUint64UintptrV(*v, true, d) + if changed { *v = v2 } - case map[uint64]int: fastpathTV.DecMapUint64IntV(v, false, d) case *map[uint64]int: - if v2, changed2 := fastpathTV.DecMapUint64IntV(*v, true, d); changed2 { + var v2 map[uint64]int + v2, changed = fastpathTV.DecMapUint64IntV(*v, true, d) + if changed { *v = v2 } - case map[uint64]int8: fastpathTV.DecMapUint64Int8V(v, false, d) case *map[uint64]int8: - if v2, changed2 := fastpathTV.DecMapUint64Int8V(*v, true, d); changed2 { + var v2 map[uint64]int8 + v2, changed = fastpathTV.DecMapUint64Int8V(*v, true, d) + if changed { *v = v2 } - case map[uint64]int16: fastpathTV.DecMapUint64Int16V(v, false, d) case *map[uint64]int16: - if v2, changed2 := fastpathTV.DecMapUint64Int16V(*v, true, d); changed2 { + var v2 map[uint64]int16 + v2, changed = fastpathTV.DecMapUint64Int16V(*v, true, d) + if changed { *v = v2 } - case map[uint64]int32: fastpathTV.DecMapUint64Int32V(v, false, d) case *map[uint64]int32: - if v2, changed2 := fastpathTV.DecMapUint64Int32V(*v, true, d); changed2 { + var v2 map[uint64]int32 + v2, changed = fastpathTV.DecMapUint64Int32V(*v, true, d) + if changed { *v = v2 } - case map[uint64]int64: fastpathTV.DecMapUint64Int64V(v, false, d) case *map[uint64]int64: - if v2, changed2 := fastpathTV.DecMapUint64Int64V(*v, true, d); changed2 { + var v2 map[uint64]int64 + v2, changed = fastpathTV.DecMapUint64Int64V(*v, true, d) + if changed { *v = v2 } - case map[uint64]float32: fastpathTV.DecMapUint64Float32V(v, false, d) case *map[uint64]float32: - if v2, changed2 := fastpathTV.DecMapUint64Float32V(*v, true, d); changed2 { + var v2 map[uint64]float32 + v2, changed = fastpathTV.DecMapUint64Float32V(*v, true, d) + if changed { *v = v2 } - case map[uint64]float64: fastpathTV.DecMapUint64Float64V(v, false, d) case *map[uint64]float64: - if v2, changed2 := fastpathTV.DecMapUint64Float64V(*v, true, d); changed2 { + var v2 map[uint64]float64 + v2, changed = fastpathTV.DecMapUint64Float64V(*v, true, d) + if changed { *v = v2 } - case map[uint64]bool: fastpathTV.DecMapUint64BoolV(v, false, d) case *map[uint64]bool: - if v2, changed2 := fastpathTV.DecMapUint64BoolV(*v, true, d); changed2 { - *v = v2 - } - - case []uintptr: - fastpathTV.DecSliceUintptrV(v, false, d) - case *[]uintptr: - if v2, changed2 := fastpathTV.DecSliceUintptrV(*v, true, d); changed2 { + var v2 map[uint64]bool + v2, changed = fastpathTV.DecMapUint64BoolV(*v, true, d) + if changed { *v = v2 } - case map[uintptr]interface{}: fastpathTV.DecMapUintptrIntfV(v, false, d) case *map[uintptr]interface{}: - if v2, changed2 := fastpathTV.DecMapUintptrIntfV(*v, true, d); changed2 { + var v2 map[uintptr]interface{} + v2, changed = fastpathTV.DecMapUintptrIntfV(*v, true, d) + if changed { *v = v2 } - case map[uintptr]string: fastpathTV.DecMapUintptrStringV(v, false, d) case *map[uintptr]string: - if v2, changed2 := fastpathTV.DecMapUintptrStringV(*v, true, d); changed2 { + var v2 map[uintptr]string + v2, changed = fastpathTV.DecMapUintptrStringV(*v, true, d) + if changed { *v = v2 } - case map[uintptr]uint: fastpathTV.DecMapUintptrUintV(v, false, d) case *map[uintptr]uint: - if v2, changed2 := fastpathTV.DecMapUintptrUintV(*v, true, d); changed2 { + var v2 map[uintptr]uint + v2, changed = fastpathTV.DecMapUintptrUintV(*v, true, d) + if changed { *v = v2 } - case map[uintptr]uint8: fastpathTV.DecMapUintptrUint8V(v, false, d) case *map[uintptr]uint8: - if v2, changed2 := fastpathTV.DecMapUintptrUint8V(*v, true, d); changed2 { + var v2 map[uintptr]uint8 + v2, changed = fastpathTV.DecMapUintptrUint8V(*v, true, d) + if changed { *v = v2 } - case map[uintptr]uint16: fastpathTV.DecMapUintptrUint16V(v, false, d) case *map[uintptr]uint16: - if v2, changed2 := fastpathTV.DecMapUintptrUint16V(*v, true, d); changed2 { + var v2 map[uintptr]uint16 + v2, changed = fastpathTV.DecMapUintptrUint16V(*v, true, d) + if changed { *v = v2 } - case map[uintptr]uint32: fastpathTV.DecMapUintptrUint32V(v, false, d) case *map[uintptr]uint32: - if v2, changed2 := fastpathTV.DecMapUintptrUint32V(*v, true, d); changed2 { + var v2 map[uintptr]uint32 + v2, changed = fastpathTV.DecMapUintptrUint32V(*v, true, d) + if changed { *v = v2 } - case map[uintptr]uint64: fastpathTV.DecMapUintptrUint64V(v, false, d) case *map[uintptr]uint64: - if v2, changed2 := fastpathTV.DecMapUintptrUint64V(*v, true, d); changed2 { + var v2 map[uintptr]uint64 + v2, changed = fastpathTV.DecMapUintptrUint64V(*v, true, d) + if changed { *v = v2 } - case map[uintptr]uintptr: fastpathTV.DecMapUintptrUintptrV(v, false, d) case *map[uintptr]uintptr: - if v2, changed2 := fastpathTV.DecMapUintptrUintptrV(*v, true, d); changed2 { + var v2 map[uintptr]uintptr + v2, changed = fastpathTV.DecMapUintptrUintptrV(*v, true, d) + if changed { *v = v2 } - case map[uintptr]int: fastpathTV.DecMapUintptrIntV(v, false, d) case *map[uintptr]int: - if v2, changed2 := fastpathTV.DecMapUintptrIntV(*v, true, d); changed2 { + var v2 map[uintptr]int + v2, changed = fastpathTV.DecMapUintptrIntV(*v, true, d) + if changed { *v = v2 } - case map[uintptr]int8: fastpathTV.DecMapUintptrInt8V(v, false, d) case *map[uintptr]int8: - if v2, changed2 := fastpathTV.DecMapUintptrInt8V(*v, true, d); changed2 { + var v2 map[uintptr]int8 + v2, changed = fastpathTV.DecMapUintptrInt8V(*v, true, d) + if changed { *v = v2 } - case map[uintptr]int16: fastpathTV.DecMapUintptrInt16V(v, false, d) case *map[uintptr]int16: - if v2, changed2 := fastpathTV.DecMapUintptrInt16V(*v, true, d); changed2 { + var v2 map[uintptr]int16 + v2, changed = fastpathTV.DecMapUintptrInt16V(*v, true, d) + if changed { *v = v2 } - case map[uintptr]int32: fastpathTV.DecMapUintptrInt32V(v, false, d) case *map[uintptr]int32: - if v2, changed2 := fastpathTV.DecMapUintptrInt32V(*v, true, d); changed2 { + var v2 map[uintptr]int32 + v2, changed = fastpathTV.DecMapUintptrInt32V(*v, true, d) + if changed { *v = v2 } - case map[uintptr]int64: fastpathTV.DecMapUintptrInt64V(v, false, d) case *map[uintptr]int64: - if v2, changed2 := fastpathTV.DecMapUintptrInt64V(*v, true, d); changed2 { + var v2 map[uintptr]int64 + v2, changed = fastpathTV.DecMapUintptrInt64V(*v, true, d) + if changed { *v = v2 } - case map[uintptr]float32: fastpathTV.DecMapUintptrFloat32V(v, false, d) case *map[uintptr]float32: - if v2, changed2 := fastpathTV.DecMapUintptrFloat32V(*v, true, d); changed2 { + var v2 map[uintptr]float32 + v2, changed = fastpathTV.DecMapUintptrFloat32V(*v, true, d) + if changed { *v = v2 } - case map[uintptr]float64: fastpathTV.DecMapUintptrFloat64V(v, false, d) case *map[uintptr]float64: - if v2, changed2 := fastpathTV.DecMapUintptrFloat64V(*v, true, d); changed2 { + var v2 map[uintptr]float64 + v2, changed = fastpathTV.DecMapUintptrFloat64V(*v, true, d) + if changed { *v = v2 } - case map[uintptr]bool: fastpathTV.DecMapUintptrBoolV(v, false, d) case *map[uintptr]bool: - if v2, changed2 := fastpathTV.DecMapUintptrBoolV(*v, true, d); changed2 { - *v = v2 - } - - case []int: - fastpathTV.DecSliceIntV(v, false, d) - case *[]int: - if v2, changed2 := fastpathTV.DecSliceIntV(*v, true, d); changed2 { + var v2 map[uintptr]bool + v2, changed = fastpathTV.DecMapUintptrBoolV(*v, true, d) + if changed { *v = v2 } - case map[int]interface{}: fastpathTV.DecMapIntIntfV(v, false, d) case *map[int]interface{}: - if v2, changed2 := fastpathTV.DecMapIntIntfV(*v, true, d); changed2 { + var v2 map[int]interface{} + v2, changed = fastpathTV.DecMapIntIntfV(*v, true, d) + if changed { *v = v2 } - case map[int]string: fastpathTV.DecMapIntStringV(v, false, d) case *map[int]string: - if v2, changed2 := fastpathTV.DecMapIntStringV(*v, true, d); changed2 { + var v2 map[int]string + v2, changed = fastpathTV.DecMapIntStringV(*v, true, d) + if changed { *v = v2 } - case map[int]uint: fastpathTV.DecMapIntUintV(v, false, d) case *map[int]uint: - if v2, changed2 := fastpathTV.DecMapIntUintV(*v, true, d); changed2 { + var v2 map[int]uint + v2, changed = fastpathTV.DecMapIntUintV(*v, true, d) + if changed { *v = v2 } - case map[int]uint8: fastpathTV.DecMapIntUint8V(v, false, d) case *map[int]uint8: - if v2, changed2 := fastpathTV.DecMapIntUint8V(*v, true, d); changed2 { + var v2 map[int]uint8 + v2, changed = fastpathTV.DecMapIntUint8V(*v, true, d) + if changed { *v = v2 } - case map[int]uint16: fastpathTV.DecMapIntUint16V(v, false, d) case *map[int]uint16: - if v2, changed2 := fastpathTV.DecMapIntUint16V(*v, true, d); changed2 { + var v2 map[int]uint16 + v2, changed = fastpathTV.DecMapIntUint16V(*v, true, d) + if changed { *v = v2 } - case map[int]uint32: fastpathTV.DecMapIntUint32V(v, false, d) case *map[int]uint32: - if v2, changed2 := fastpathTV.DecMapIntUint32V(*v, true, d); changed2 { + var v2 map[int]uint32 + v2, changed = fastpathTV.DecMapIntUint32V(*v, true, d) + if changed { *v = v2 } - case map[int]uint64: fastpathTV.DecMapIntUint64V(v, false, d) case *map[int]uint64: - if v2, changed2 := fastpathTV.DecMapIntUint64V(*v, true, d); changed2 { + var v2 map[int]uint64 + v2, changed = fastpathTV.DecMapIntUint64V(*v, true, d) + if changed { *v = v2 } - case map[int]uintptr: fastpathTV.DecMapIntUintptrV(v, false, d) case *map[int]uintptr: - if v2, changed2 := fastpathTV.DecMapIntUintptrV(*v, true, d); changed2 { + var v2 map[int]uintptr + v2, changed = fastpathTV.DecMapIntUintptrV(*v, true, d) + if changed { *v = v2 } - case map[int]int: fastpathTV.DecMapIntIntV(v, false, d) case *map[int]int: - if v2, changed2 := fastpathTV.DecMapIntIntV(*v, true, d); changed2 { + var v2 map[int]int + v2, changed = fastpathTV.DecMapIntIntV(*v, true, d) + if changed { *v = v2 } - case map[int]int8: fastpathTV.DecMapIntInt8V(v, false, d) case *map[int]int8: - if v2, changed2 := fastpathTV.DecMapIntInt8V(*v, true, d); changed2 { + var v2 map[int]int8 + v2, changed = fastpathTV.DecMapIntInt8V(*v, true, d) + if changed { *v = v2 } - case map[int]int16: fastpathTV.DecMapIntInt16V(v, false, d) case *map[int]int16: - if v2, changed2 := fastpathTV.DecMapIntInt16V(*v, true, d); changed2 { + var v2 map[int]int16 + v2, changed = fastpathTV.DecMapIntInt16V(*v, true, d) + if changed { *v = v2 } - case map[int]int32: fastpathTV.DecMapIntInt32V(v, false, d) case *map[int]int32: - if v2, changed2 := fastpathTV.DecMapIntInt32V(*v, true, d); changed2 { + var v2 map[int]int32 + v2, changed = fastpathTV.DecMapIntInt32V(*v, true, d) + if changed { *v = v2 } - case map[int]int64: fastpathTV.DecMapIntInt64V(v, false, d) case *map[int]int64: - if v2, changed2 := fastpathTV.DecMapIntInt64V(*v, true, d); changed2 { + var v2 map[int]int64 + v2, changed = fastpathTV.DecMapIntInt64V(*v, true, d) + if changed { *v = v2 } - case map[int]float32: fastpathTV.DecMapIntFloat32V(v, false, d) case *map[int]float32: - if v2, changed2 := fastpathTV.DecMapIntFloat32V(*v, true, d); changed2 { + var v2 map[int]float32 + v2, changed = fastpathTV.DecMapIntFloat32V(*v, true, d) + if changed { *v = v2 } - case map[int]float64: fastpathTV.DecMapIntFloat64V(v, false, d) case *map[int]float64: - if v2, changed2 := fastpathTV.DecMapIntFloat64V(*v, true, d); changed2 { + var v2 map[int]float64 + v2, changed = fastpathTV.DecMapIntFloat64V(*v, true, d) + if changed { *v = v2 } - case map[int]bool: fastpathTV.DecMapIntBoolV(v, false, d) case *map[int]bool: - if v2, changed2 := fastpathTV.DecMapIntBoolV(*v, true, d); changed2 { - *v = v2 - } - - case []int8: - fastpathTV.DecSliceInt8V(v, false, d) - case *[]int8: - if v2, changed2 := fastpathTV.DecSliceInt8V(*v, true, d); changed2 { + var v2 map[int]bool + v2, changed = fastpathTV.DecMapIntBoolV(*v, true, d) + if changed { *v = v2 } - case map[int8]interface{}: fastpathTV.DecMapInt8IntfV(v, false, d) case *map[int8]interface{}: - if v2, changed2 := fastpathTV.DecMapInt8IntfV(*v, true, d); changed2 { + var v2 map[int8]interface{} + v2, changed = fastpathTV.DecMapInt8IntfV(*v, true, d) + if changed { *v = v2 } - case map[int8]string: fastpathTV.DecMapInt8StringV(v, false, d) case *map[int8]string: - if v2, changed2 := fastpathTV.DecMapInt8StringV(*v, true, d); changed2 { + var v2 map[int8]string + v2, changed = fastpathTV.DecMapInt8StringV(*v, true, d) + if changed { *v = v2 } - case map[int8]uint: fastpathTV.DecMapInt8UintV(v, false, d) case *map[int8]uint: - if v2, changed2 := fastpathTV.DecMapInt8UintV(*v, true, d); changed2 { + var v2 map[int8]uint + v2, changed = fastpathTV.DecMapInt8UintV(*v, true, d) + if changed { *v = v2 } - case map[int8]uint8: fastpathTV.DecMapInt8Uint8V(v, false, d) case *map[int8]uint8: - if v2, changed2 := fastpathTV.DecMapInt8Uint8V(*v, true, d); changed2 { + var v2 map[int8]uint8 + v2, changed = fastpathTV.DecMapInt8Uint8V(*v, true, d) + if changed { *v = v2 } - case map[int8]uint16: fastpathTV.DecMapInt8Uint16V(v, false, d) case *map[int8]uint16: - if v2, changed2 := fastpathTV.DecMapInt8Uint16V(*v, true, d); changed2 { + var v2 map[int8]uint16 + v2, changed = fastpathTV.DecMapInt8Uint16V(*v, true, d) + if changed { *v = v2 } - case map[int8]uint32: fastpathTV.DecMapInt8Uint32V(v, false, d) case *map[int8]uint32: - if v2, changed2 := fastpathTV.DecMapInt8Uint32V(*v, true, d); changed2 { + var v2 map[int8]uint32 + v2, changed = fastpathTV.DecMapInt8Uint32V(*v, true, d) + if changed { *v = v2 } - case map[int8]uint64: fastpathTV.DecMapInt8Uint64V(v, false, d) case *map[int8]uint64: - if v2, changed2 := fastpathTV.DecMapInt8Uint64V(*v, true, d); changed2 { + var v2 map[int8]uint64 + v2, changed = fastpathTV.DecMapInt8Uint64V(*v, true, d) + if changed { *v = v2 } - case map[int8]uintptr: fastpathTV.DecMapInt8UintptrV(v, false, d) case *map[int8]uintptr: - if v2, changed2 := fastpathTV.DecMapInt8UintptrV(*v, true, d); changed2 { + var v2 map[int8]uintptr + v2, changed = fastpathTV.DecMapInt8UintptrV(*v, true, d) + if changed { *v = v2 } - case map[int8]int: fastpathTV.DecMapInt8IntV(v, false, d) case *map[int8]int: - if v2, changed2 := fastpathTV.DecMapInt8IntV(*v, true, d); changed2 { + var v2 map[int8]int + v2, changed = fastpathTV.DecMapInt8IntV(*v, true, d) + if changed { *v = v2 } - case map[int8]int8: fastpathTV.DecMapInt8Int8V(v, false, d) case *map[int8]int8: - if v2, changed2 := fastpathTV.DecMapInt8Int8V(*v, true, d); changed2 { + var v2 map[int8]int8 + v2, changed = fastpathTV.DecMapInt8Int8V(*v, true, d) + if changed { *v = v2 } - case map[int8]int16: fastpathTV.DecMapInt8Int16V(v, false, d) case *map[int8]int16: - if v2, changed2 := fastpathTV.DecMapInt8Int16V(*v, true, d); changed2 { + var v2 map[int8]int16 + v2, changed = fastpathTV.DecMapInt8Int16V(*v, true, d) + if changed { *v = v2 } - case map[int8]int32: fastpathTV.DecMapInt8Int32V(v, false, d) case *map[int8]int32: - if v2, changed2 := fastpathTV.DecMapInt8Int32V(*v, true, d); changed2 { + var v2 map[int8]int32 + v2, changed = fastpathTV.DecMapInt8Int32V(*v, true, d) + if changed { *v = v2 } - case map[int8]int64: fastpathTV.DecMapInt8Int64V(v, false, d) case *map[int8]int64: - if v2, changed2 := fastpathTV.DecMapInt8Int64V(*v, true, d); changed2 { + var v2 map[int8]int64 + v2, changed = fastpathTV.DecMapInt8Int64V(*v, true, d) + if changed { *v = v2 } - case map[int8]float32: fastpathTV.DecMapInt8Float32V(v, false, d) case *map[int8]float32: - if v2, changed2 := fastpathTV.DecMapInt8Float32V(*v, true, d); changed2 { + var v2 map[int8]float32 + v2, changed = fastpathTV.DecMapInt8Float32V(*v, true, d) + if changed { *v = v2 } - case map[int8]float64: fastpathTV.DecMapInt8Float64V(v, false, d) case *map[int8]float64: - if v2, changed2 := fastpathTV.DecMapInt8Float64V(*v, true, d); changed2 { + var v2 map[int8]float64 + v2, changed = fastpathTV.DecMapInt8Float64V(*v, true, d) + if changed { *v = v2 } - case map[int8]bool: fastpathTV.DecMapInt8BoolV(v, false, d) case *map[int8]bool: - if v2, changed2 := fastpathTV.DecMapInt8BoolV(*v, true, d); changed2 { - *v = v2 - } - - case []int16: - fastpathTV.DecSliceInt16V(v, false, d) - case *[]int16: - if v2, changed2 := fastpathTV.DecSliceInt16V(*v, true, d); changed2 { + var v2 map[int8]bool + v2, changed = fastpathTV.DecMapInt8BoolV(*v, true, d) + if changed { *v = v2 } - case map[int16]interface{}: fastpathTV.DecMapInt16IntfV(v, false, d) case *map[int16]interface{}: - if v2, changed2 := fastpathTV.DecMapInt16IntfV(*v, true, d); changed2 { + var v2 map[int16]interface{} + v2, changed = fastpathTV.DecMapInt16IntfV(*v, true, d) + if changed { *v = v2 } - case map[int16]string: fastpathTV.DecMapInt16StringV(v, false, d) case *map[int16]string: - if v2, changed2 := fastpathTV.DecMapInt16StringV(*v, true, d); changed2 { + var v2 map[int16]string + v2, changed = fastpathTV.DecMapInt16StringV(*v, true, d) + if changed { *v = v2 } - case map[int16]uint: fastpathTV.DecMapInt16UintV(v, false, d) case *map[int16]uint: - if v2, changed2 := fastpathTV.DecMapInt16UintV(*v, true, d); changed2 { + var v2 map[int16]uint + v2, changed = fastpathTV.DecMapInt16UintV(*v, true, d) + if changed { *v = v2 } - case map[int16]uint8: fastpathTV.DecMapInt16Uint8V(v, false, d) case *map[int16]uint8: - if v2, changed2 := fastpathTV.DecMapInt16Uint8V(*v, true, d); changed2 { + var v2 map[int16]uint8 + v2, changed = fastpathTV.DecMapInt16Uint8V(*v, true, d) + if changed { *v = v2 } - case map[int16]uint16: fastpathTV.DecMapInt16Uint16V(v, false, d) case *map[int16]uint16: - if v2, changed2 := fastpathTV.DecMapInt16Uint16V(*v, true, d); changed2 { + var v2 map[int16]uint16 + v2, changed = fastpathTV.DecMapInt16Uint16V(*v, true, d) + if changed { *v = v2 } - case map[int16]uint32: fastpathTV.DecMapInt16Uint32V(v, false, d) case *map[int16]uint32: - if v2, changed2 := fastpathTV.DecMapInt16Uint32V(*v, true, d); changed2 { + var v2 map[int16]uint32 + v2, changed = fastpathTV.DecMapInt16Uint32V(*v, true, d) + if changed { *v = v2 } - case map[int16]uint64: fastpathTV.DecMapInt16Uint64V(v, false, d) case *map[int16]uint64: - if v2, changed2 := fastpathTV.DecMapInt16Uint64V(*v, true, d); changed2 { + var v2 map[int16]uint64 + v2, changed = fastpathTV.DecMapInt16Uint64V(*v, true, d) + if changed { *v = v2 } - case map[int16]uintptr: fastpathTV.DecMapInt16UintptrV(v, false, d) case *map[int16]uintptr: - if v2, changed2 := fastpathTV.DecMapInt16UintptrV(*v, true, d); changed2 { + var v2 map[int16]uintptr + v2, changed = fastpathTV.DecMapInt16UintptrV(*v, true, d) + if changed { *v = v2 } - case map[int16]int: fastpathTV.DecMapInt16IntV(v, false, d) case *map[int16]int: - if v2, changed2 := fastpathTV.DecMapInt16IntV(*v, true, d); changed2 { + var v2 map[int16]int + v2, changed = fastpathTV.DecMapInt16IntV(*v, true, d) + if changed { *v = v2 } - case map[int16]int8: fastpathTV.DecMapInt16Int8V(v, false, d) case *map[int16]int8: - if v2, changed2 := fastpathTV.DecMapInt16Int8V(*v, true, d); changed2 { + var v2 map[int16]int8 + v2, changed = fastpathTV.DecMapInt16Int8V(*v, true, d) + if changed { *v = v2 } - case map[int16]int16: fastpathTV.DecMapInt16Int16V(v, false, d) case *map[int16]int16: - if v2, changed2 := fastpathTV.DecMapInt16Int16V(*v, true, d); changed2 { + var v2 map[int16]int16 + v2, changed = fastpathTV.DecMapInt16Int16V(*v, true, d) + if changed { *v = v2 } - case map[int16]int32: fastpathTV.DecMapInt16Int32V(v, false, d) case *map[int16]int32: - if v2, changed2 := fastpathTV.DecMapInt16Int32V(*v, true, d); changed2 { + var v2 map[int16]int32 + v2, changed = fastpathTV.DecMapInt16Int32V(*v, true, d) + if changed { *v = v2 } - case map[int16]int64: fastpathTV.DecMapInt16Int64V(v, false, d) case *map[int16]int64: - if v2, changed2 := fastpathTV.DecMapInt16Int64V(*v, true, d); changed2 { + var v2 map[int16]int64 + v2, changed = fastpathTV.DecMapInt16Int64V(*v, true, d) + if changed { *v = v2 } - case map[int16]float32: fastpathTV.DecMapInt16Float32V(v, false, d) case *map[int16]float32: - if v2, changed2 := fastpathTV.DecMapInt16Float32V(*v, true, d); changed2 { + var v2 map[int16]float32 + v2, changed = fastpathTV.DecMapInt16Float32V(*v, true, d) + if changed { *v = v2 } - case map[int16]float64: fastpathTV.DecMapInt16Float64V(v, false, d) case *map[int16]float64: - if v2, changed2 := fastpathTV.DecMapInt16Float64V(*v, true, d); changed2 { + var v2 map[int16]float64 + v2, changed = fastpathTV.DecMapInt16Float64V(*v, true, d) + if changed { *v = v2 } - case map[int16]bool: fastpathTV.DecMapInt16BoolV(v, false, d) case *map[int16]bool: - if v2, changed2 := fastpathTV.DecMapInt16BoolV(*v, true, d); changed2 { - *v = v2 - } - - case []int32: - fastpathTV.DecSliceInt32V(v, false, d) - case *[]int32: - if v2, changed2 := fastpathTV.DecSliceInt32V(*v, true, d); changed2 { + var v2 map[int16]bool + v2, changed = fastpathTV.DecMapInt16BoolV(*v, true, d) + if changed { *v = v2 } - case map[int32]interface{}: fastpathTV.DecMapInt32IntfV(v, false, d) case *map[int32]interface{}: - if v2, changed2 := fastpathTV.DecMapInt32IntfV(*v, true, d); changed2 { + var v2 map[int32]interface{} + v2, changed = fastpathTV.DecMapInt32IntfV(*v, true, d) + if changed { *v = v2 } - case map[int32]string: fastpathTV.DecMapInt32StringV(v, false, d) case *map[int32]string: - if v2, changed2 := fastpathTV.DecMapInt32StringV(*v, true, d); changed2 { + var v2 map[int32]string + v2, changed = fastpathTV.DecMapInt32StringV(*v, true, d) + if changed { *v = v2 } - case map[int32]uint: fastpathTV.DecMapInt32UintV(v, false, d) case *map[int32]uint: - if v2, changed2 := fastpathTV.DecMapInt32UintV(*v, true, d); changed2 { + var v2 map[int32]uint + v2, changed = fastpathTV.DecMapInt32UintV(*v, true, d) + if changed { *v = v2 } - case map[int32]uint8: fastpathTV.DecMapInt32Uint8V(v, false, d) case *map[int32]uint8: - if v2, changed2 := fastpathTV.DecMapInt32Uint8V(*v, true, d); changed2 { + var v2 map[int32]uint8 + v2, changed = fastpathTV.DecMapInt32Uint8V(*v, true, d) + if changed { *v = v2 } - case map[int32]uint16: fastpathTV.DecMapInt32Uint16V(v, false, d) case *map[int32]uint16: - if v2, changed2 := fastpathTV.DecMapInt32Uint16V(*v, true, d); changed2 { + var v2 map[int32]uint16 + v2, changed = fastpathTV.DecMapInt32Uint16V(*v, true, d) + if changed { *v = v2 } - case map[int32]uint32: fastpathTV.DecMapInt32Uint32V(v, false, d) case *map[int32]uint32: - if v2, changed2 := fastpathTV.DecMapInt32Uint32V(*v, true, d); changed2 { + var v2 map[int32]uint32 + v2, changed = fastpathTV.DecMapInt32Uint32V(*v, true, d) + if changed { *v = v2 } - case map[int32]uint64: fastpathTV.DecMapInt32Uint64V(v, false, d) case *map[int32]uint64: - if v2, changed2 := fastpathTV.DecMapInt32Uint64V(*v, true, d); changed2 { + var v2 map[int32]uint64 + v2, changed = fastpathTV.DecMapInt32Uint64V(*v, true, d) + if changed { *v = v2 } - case map[int32]uintptr: fastpathTV.DecMapInt32UintptrV(v, false, d) case *map[int32]uintptr: - if v2, changed2 := fastpathTV.DecMapInt32UintptrV(*v, true, d); changed2 { + var v2 map[int32]uintptr + v2, changed = fastpathTV.DecMapInt32UintptrV(*v, true, d) + if changed { *v = v2 } - case map[int32]int: fastpathTV.DecMapInt32IntV(v, false, d) case *map[int32]int: - if v2, changed2 := fastpathTV.DecMapInt32IntV(*v, true, d); changed2 { + var v2 map[int32]int + v2, changed = fastpathTV.DecMapInt32IntV(*v, true, d) + if changed { *v = v2 } - case map[int32]int8: fastpathTV.DecMapInt32Int8V(v, false, d) case *map[int32]int8: - if v2, changed2 := fastpathTV.DecMapInt32Int8V(*v, true, d); changed2 { + var v2 map[int32]int8 + v2, changed = fastpathTV.DecMapInt32Int8V(*v, true, d) + if changed { *v = v2 } - case map[int32]int16: fastpathTV.DecMapInt32Int16V(v, false, d) case *map[int32]int16: - if v2, changed2 := fastpathTV.DecMapInt32Int16V(*v, true, d); changed2 { + var v2 map[int32]int16 + v2, changed = fastpathTV.DecMapInt32Int16V(*v, true, d) + if changed { *v = v2 } - case map[int32]int32: fastpathTV.DecMapInt32Int32V(v, false, d) case *map[int32]int32: - if v2, changed2 := fastpathTV.DecMapInt32Int32V(*v, true, d); changed2 { + var v2 map[int32]int32 + v2, changed = fastpathTV.DecMapInt32Int32V(*v, true, d) + if changed { *v = v2 } - case map[int32]int64: fastpathTV.DecMapInt32Int64V(v, false, d) case *map[int32]int64: - if v2, changed2 := fastpathTV.DecMapInt32Int64V(*v, true, d); changed2 { + var v2 map[int32]int64 + v2, changed = fastpathTV.DecMapInt32Int64V(*v, true, d) + if changed { *v = v2 } - case map[int32]float32: fastpathTV.DecMapInt32Float32V(v, false, d) case *map[int32]float32: - if v2, changed2 := fastpathTV.DecMapInt32Float32V(*v, true, d); changed2 { + var v2 map[int32]float32 + v2, changed = fastpathTV.DecMapInt32Float32V(*v, true, d) + if changed { *v = v2 } - case map[int32]float64: fastpathTV.DecMapInt32Float64V(v, false, d) case *map[int32]float64: - if v2, changed2 := fastpathTV.DecMapInt32Float64V(*v, true, d); changed2 { + var v2 map[int32]float64 + v2, changed = fastpathTV.DecMapInt32Float64V(*v, true, d) + if changed { *v = v2 } - case map[int32]bool: fastpathTV.DecMapInt32BoolV(v, false, d) case *map[int32]bool: - if v2, changed2 := fastpathTV.DecMapInt32BoolV(*v, true, d); changed2 { - *v = v2 - } - - case []int64: - fastpathTV.DecSliceInt64V(v, false, d) - case *[]int64: - if v2, changed2 := fastpathTV.DecSliceInt64V(*v, true, d); changed2 { + var v2 map[int32]bool + v2, changed = fastpathTV.DecMapInt32BoolV(*v, true, d) + if changed { *v = v2 } - case map[int64]interface{}: fastpathTV.DecMapInt64IntfV(v, false, d) case *map[int64]interface{}: - if v2, changed2 := fastpathTV.DecMapInt64IntfV(*v, true, d); changed2 { + var v2 map[int64]interface{} + v2, changed = fastpathTV.DecMapInt64IntfV(*v, true, d) + if changed { *v = v2 } - case map[int64]string: fastpathTV.DecMapInt64StringV(v, false, d) case *map[int64]string: - if v2, changed2 := fastpathTV.DecMapInt64StringV(*v, true, d); changed2 { + var v2 map[int64]string + v2, changed = fastpathTV.DecMapInt64StringV(*v, true, d) + if changed { *v = v2 } - case map[int64]uint: fastpathTV.DecMapInt64UintV(v, false, d) case *map[int64]uint: - if v2, changed2 := fastpathTV.DecMapInt64UintV(*v, true, d); changed2 { + var v2 map[int64]uint + v2, changed = fastpathTV.DecMapInt64UintV(*v, true, d) + if changed { *v = v2 } - case map[int64]uint8: fastpathTV.DecMapInt64Uint8V(v, false, d) case *map[int64]uint8: - if v2, changed2 := fastpathTV.DecMapInt64Uint8V(*v, true, d); changed2 { + var v2 map[int64]uint8 + v2, changed = fastpathTV.DecMapInt64Uint8V(*v, true, d) + if changed { *v = v2 } - case map[int64]uint16: fastpathTV.DecMapInt64Uint16V(v, false, d) case *map[int64]uint16: - if v2, changed2 := fastpathTV.DecMapInt64Uint16V(*v, true, d); changed2 { + var v2 map[int64]uint16 + v2, changed = fastpathTV.DecMapInt64Uint16V(*v, true, d) + if changed { *v = v2 } - case map[int64]uint32: fastpathTV.DecMapInt64Uint32V(v, false, d) case *map[int64]uint32: - if v2, changed2 := fastpathTV.DecMapInt64Uint32V(*v, true, d); changed2 { + var v2 map[int64]uint32 + v2, changed = fastpathTV.DecMapInt64Uint32V(*v, true, d) + if changed { *v = v2 } - case map[int64]uint64: fastpathTV.DecMapInt64Uint64V(v, false, d) case *map[int64]uint64: - if v2, changed2 := fastpathTV.DecMapInt64Uint64V(*v, true, d); changed2 { + var v2 map[int64]uint64 + v2, changed = fastpathTV.DecMapInt64Uint64V(*v, true, d) + if changed { *v = v2 } - case map[int64]uintptr: fastpathTV.DecMapInt64UintptrV(v, false, d) case *map[int64]uintptr: - if v2, changed2 := fastpathTV.DecMapInt64UintptrV(*v, true, d); changed2 { + var v2 map[int64]uintptr + v2, changed = fastpathTV.DecMapInt64UintptrV(*v, true, d) + if changed { *v = v2 } - case map[int64]int: fastpathTV.DecMapInt64IntV(v, false, d) case *map[int64]int: - if v2, changed2 := fastpathTV.DecMapInt64IntV(*v, true, d); changed2 { + var v2 map[int64]int + v2, changed = fastpathTV.DecMapInt64IntV(*v, true, d) + if changed { *v = v2 } - case map[int64]int8: fastpathTV.DecMapInt64Int8V(v, false, d) case *map[int64]int8: - if v2, changed2 := fastpathTV.DecMapInt64Int8V(*v, true, d); changed2 { + var v2 map[int64]int8 + v2, changed = fastpathTV.DecMapInt64Int8V(*v, true, d) + if changed { *v = v2 } - case map[int64]int16: fastpathTV.DecMapInt64Int16V(v, false, d) case *map[int64]int16: - if v2, changed2 := fastpathTV.DecMapInt64Int16V(*v, true, d); changed2 { + var v2 map[int64]int16 + v2, changed = fastpathTV.DecMapInt64Int16V(*v, true, d) + if changed { *v = v2 } - case map[int64]int32: fastpathTV.DecMapInt64Int32V(v, false, d) case *map[int64]int32: - if v2, changed2 := fastpathTV.DecMapInt64Int32V(*v, true, d); changed2 { + var v2 map[int64]int32 + v2, changed = fastpathTV.DecMapInt64Int32V(*v, true, d) + if changed { *v = v2 } - case map[int64]int64: fastpathTV.DecMapInt64Int64V(v, false, d) case *map[int64]int64: - if v2, changed2 := fastpathTV.DecMapInt64Int64V(*v, true, d); changed2 { + var v2 map[int64]int64 + v2, changed = fastpathTV.DecMapInt64Int64V(*v, true, d) + if changed { *v = v2 } - case map[int64]float32: fastpathTV.DecMapInt64Float32V(v, false, d) case *map[int64]float32: - if v2, changed2 := fastpathTV.DecMapInt64Float32V(*v, true, d); changed2 { + var v2 map[int64]float32 + v2, changed = fastpathTV.DecMapInt64Float32V(*v, true, d) + if changed { *v = v2 } - case map[int64]float64: fastpathTV.DecMapInt64Float64V(v, false, d) case *map[int64]float64: - if v2, changed2 := fastpathTV.DecMapInt64Float64V(*v, true, d); changed2 { + var v2 map[int64]float64 + v2, changed = fastpathTV.DecMapInt64Float64V(*v, true, d) + if changed { *v = v2 } - case map[int64]bool: fastpathTV.DecMapInt64BoolV(v, false, d) case *map[int64]bool: - if v2, changed2 := fastpathTV.DecMapInt64BoolV(*v, true, d); changed2 { - *v = v2 - } - - case []bool: - fastpathTV.DecSliceBoolV(v, false, d) - case *[]bool: - if v2, changed2 := fastpathTV.DecSliceBoolV(*v, true, d); changed2 { + var v2 map[int64]bool + v2, changed = fastpathTV.DecMapInt64BoolV(*v, true, d) + if changed { *v = v2 } - case map[bool]interface{}: fastpathTV.DecMapBoolIntfV(v, false, d) case *map[bool]interface{}: - if v2, changed2 := fastpathTV.DecMapBoolIntfV(*v, true, d); changed2 { + var v2 map[bool]interface{} + v2, changed = fastpathTV.DecMapBoolIntfV(*v, true, d) + if changed { *v = v2 } - case map[bool]string: fastpathTV.DecMapBoolStringV(v, false, d) case *map[bool]string: - if v2, changed2 := fastpathTV.DecMapBoolStringV(*v, true, d); changed2 { + var v2 map[bool]string + v2, changed = fastpathTV.DecMapBoolStringV(*v, true, d) + if changed { *v = v2 } - case map[bool]uint: fastpathTV.DecMapBoolUintV(v, false, d) case *map[bool]uint: - if v2, changed2 := fastpathTV.DecMapBoolUintV(*v, true, d); changed2 { + var v2 map[bool]uint + v2, changed = fastpathTV.DecMapBoolUintV(*v, true, d) + if changed { *v = v2 } - case map[bool]uint8: fastpathTV.DecMapBoolUint8V(v, false, d) case *map[bool]uint8: - if v2, changed2 := fastpathTV.DecMapBoolUint8V(*v, true, d); changed2 { + var v2 map[bool]uint8 + v2, changed = fastpathTV.DecMapBoolUint8V(*v, true, d) + if changed { *v = v2 } - case map[bool]uint16: fastpathTV.DecMapBoolUint16V(v, false, d) case *map[bool]uint16: - if v2, changed2 := fastpathTV.DecMapBoolUint16V(*v, true, d); changed2 { + var v2 map[bool]uint16 + v2, changed = fastpathTV.DecMapBoolUint16V(*v, true, d) + if changed { *v = v2 } - case map[bool]uint32: fastpathTV.DecMapBoolUint32V(v, false, d) case *map[bool]uint32: - if v2, changed2 := fastpathTV.DecMapBoolUint32V(*v, true, d); changed2 { + var v2 map[bool]uint32 + v2, changed = fastpathTV.DecMapBoolUint32V(*v, true, d) + if changed { *v = v2 } - case map[bool]uint64: fastpathTV.DecMapBoolUint64V(v, false, d) case *map[bool]uint64: - if v2, changed2 := fastpathTV.DecMapBoolUint64V(*v, true, d); changed2 { + var v2 map[bool]uint64 + v2, changed = fastpathTV.DecMapBoolUint64V(*v, true, d) + if changed { *v = v2 } - case map[bool]uintptr: fastpathTV.DecMapBoolUintptrV(v, false, d) case *map[bool]uintptr: - if v2, changed2 := fastpathTV.DecMapBoolUintptrV(*v, true, d); changed2 { + var v2 map[bool]uintptr + v2, changed = fastpathTV.DecMapBoolUintptrV(*v, true, d) + if changed { *v = v2 } - case map[bool]int: fastpathTV.DecMapBoolIntV(v, false, d) case *map[bool]int: - if v2, changed2 := fastpathTV.DecMapBoolIntV(*v, true, d); changed2 { + var v2 map[bool]int + v2, changed = fastpathTV.DecMapBoolIntV(*v, true, d) + if changed { *v = v2 } - case map[bool]int8: fastpathTV.DecMapBoolInt8V(v, false, d) case *map[bool]int8: - if v2, changed2 := fastpathTV.DecMapBoolInt8V(*v, true, d); changed2 { + var v2 map[bool]int8 + v2, changed = fastpathTV.DecMapBoolInt8V(*v, true, d) + if changed { *v = v2 } - case map[bool]int16: fastpathTV.DecMapBoolInt16V(v, false, d) case *map[bool]int16: - if v2, changed2 := fastpathTV.DecMapBoolInt16V(*v, true, d); changed2 { + var v2 map[bool]int16 + v2, changed = fastpathTV.DecMapBoolInt16V(*v, true, d) + if changed { *v = v2 } - case map[bool]int32: fastpathTV.DecMapBoolInt32V(v, false, d) case *map[bool]int32: - if v2, changed2 := fastpathTV.DecMapBoolInt32V(*v, true, d); changed2 { + var v2 map[bool]int32 + v2, changed = fastpathTV.DecMapBoolInt32V(*v, true, d) + if changed { *v = v2 } - case map[bool]int64: fastpathTV.DecMapBoolInt64V(v, false, d) case *map[bool]int64: - if v2, changed2 := fastpathTV.DecMapBoolInt64V(*v, true, d); changed2 { + var v2 map[bool]int64 + v2, changed = fastpathTV.DecMapBoolInt64V(*v, true, d) + if changed { *v = v2 } - case map[bool]float32: fastpathTV.DecMapBoolFloat32V(v, false, d) case *map[bool]float32: - if v2, changed2 := fastpathTV.DecMapBoolFloat32V(*v, true, d); changed2 { + var v2 map[bool]float32 + v2, changed = fastpathTV.DecMapBoolFloat32V(*v, true, d) + if changed { *v = v2 } - case map[bool]float64: fastpathTV.DecMapBoolFloat64V(v, false, d) case *map[bool]float64: - if v2, changed2 := fastpathTV.DecMapBoolFloat64V(*v, true, d); changed2 { + var v2 map[bool]float64 + v2, changed = fastpathTV.DecMapBoolFloat64V(*v, true, d) + if changed { *v = v2 } - case map[bool]bool: fastpathTV.DecMapBoolBoolV(v, false, d) case *map[bool]bool: - if v2, changed2 := fastpathTV.DecMapBoolBoolV(*v, true, d); changed2 { + var v2 map[bool]bool + v2, changed = fastpathTV.DecMapBoolBoolV(*v, true, d) + if changed { *v = v2 } - default: - _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) + _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 return false } return true } -func fastpathDecodeSetZeroTypeSwitch(iv interface{}, d *Decoder) bool { +func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool { switch v := iv.(type) { case *[]interface{}: *v = nil + case *[]string: + *v = nil + case *[]float32: + *v = nil + case *[]float64: + *v = nil + case *[]uint: + *v = nil + case *[]uint8: + *v = nil + case *[]uint16: + *v = nil + case *[]uint32: + *v = nil + case *[]uint64: + *v = nil + case *[]uintptr: + *v = nil + case *[]int: + *v = nil + case *[]int8: + *v = nil + case *[]int16: + *v = nil + case *[]int32: + *v = nil + case *[]int64: + *v = nil + case *[]bool: + *v = nil case *map[interface{}]interface{}: *v = nil - case *map[interface{}]string: *v = nil - case *map[interface{}]uint: *v = nil - case *map[interface{}]uint8: *v = nil - case *map[interface{}]uint16: *v = nil - case *map[interface{}]uint32: *v = nil - case *map[interface{}]uint64: *v = nil - case *map[interface{}]uintptr: *v = nil - case *map[interface{}]int: *v = nil - case *map[interface{}]int8: *v = nil - case *map[interface{}]int16: *v = nil - case *map[interface{}]int32: *v = nil - case *map[interface{}]int64: *v = nil - case *map[interface{}]float32: *v = nil - case *map[interface{}]float64: *v = nil - case *map[interface{}]bool: *v = nil - - case *[]string: - *v = nil - case *map[string]interface{}: *v = nil - case *map[string]string: *v = nil - case *map[string]uint: *v = nil - case *map[string]uint8: *v = nil - case *map[string]uint16: *v = nil - case *map[string]uint32: *v = nil - case *map[string]uint64: *v = nil - case *map[string]uintptr: *v = nil - case *map[string]int: *v = nil - case *map[string]int8: *v = nil - case *map[string]int16: *v = nil - case *map[string]int32: *v = nil - case *map[string]int64: *v = nil - case *map[string]float32: *v = nil - case *map[string]float64: *v = nil - case *map[string]bool: *v = nil - - case *[]float32: - *v = nil - case *map[float32]interface{}: *v = nil - case *map[float32]string: *v = nil - case *map[float32]uint: *v = nil - case *map[float32]uint8: *v = nil - case *map[float32]uint16: *v = nil - case *map[float32]uint32: *v = nil - case *map[float32]uint64: *v = nil - case *map[float32]uintptr: *v = nil - case *map[float32]int: *v = nil - case *map[float32]int8: *v = nil - case *map[float32]int16: *v = nil - case *map[float32]int32: *v = nil - case *map[float32]int64: *v = nil - case *map[float32]float32: *v = nil - case *map[float32]float64: *v = nil - case *map[float32]bool: *v = nil - - case *[]float64: - *v = nil - case *map[float64]interface{}: *v = nil - case *map[float64]string: *v = nil - case *map[float64]uint: *v = nil - case *map[float64]uint8: *v = nil - case *map[float64]uint16: *v = nil - case *map[float64]uint32: *v = nil - case *map[float64]uint64: *v = nil - case *map[float64]uintptr: *v = nil - case *map[float64]int: *v = nil - case *map[float64]int8: *v = nil - case *map[float64]int16: *v = nil - case *map[float64]int32: *v = nil - case *map[float64]int64: *v = nil - case *map[float64]float32: *v = nil - case *map[float64]float64: *v = nil - case *map[float64]bool: *v = nil - - case *[]uint: - *v = nil - case *map[uint]interface{}: *v = nil - case *map[uint]string: *v = nil - case *map[uint]uint: *v = nil - case *map[uint]uint8: *v = nil - case *map[uint]uint16: *v = nil - case *map[uint]uint32: *v = nil - case *map[uint]uint64: *v = nil - case *map[uint]uintptr: *v = nil - case *map[uint]int: *v = nil - case *map[uint]int8: *v = nil - case *map[uint]int16: *v = nil - case *map[uint]int32: *v = nil - case *map[uint]int64: *v = nil - case *map[uint]float32: *v = nil - case *map[uint]float64: *v = nil - case *map[uint]bool: *v = nil - case *map[uint8]interface{}: *v = nil - case *map[uint8]string: *v = nil - case *map[uint8]uint: *v = nil - case *map[uint8]uint8: *v = nil - case *map[uint8]uint16: *v = nil - case *map[uint8]uint32: *v = nil - case *map[uint8]uint64: *v = nil - case *map[uint8]uintptr: *v = nil - case *map[uint8]int: *v = nil - case *map[uint8]int8: *v = nil - case *map[uint8]int16: *v = nil - case *map[uint8]int32: *v = nil - case *map[uint8]int64: *v = nil - case *map[uint8]float32: *v = nil - case *map[uint8]float64: *v = nil - case *map[uint8]bool: *v = nil - - case *[]uint16: - *v = nil - case *map[uint16]interface{}: *v = nil - case *map[uint16]string: *v = nil - case *map[uint16]uint: *v = nil - case *map[uint16]uint8: *v = nil - case *map[uint16]uint16: *v = nil - case *map[uint16]uint32: *v = nil - case *map[uint16]uint64: *v = nil - case *map[uint16]uintptr: *v = nil - case *map[uint16]int: *v = nil - case *map[uint16]int8: *v = nil - case *map[uint16]int16: *v = nil - case *map[uint16]int32: *v = nil - case *map[uint16]int64: *v = nil - case *map[uint16]float32: *v = nil - case *map[uint16]float64: *v = nil - case *map[uint16]bool: *v = nil - - case *[]uint32: - *v = nil - case *map[uint32]interface{}: *v = nil - case *map[uint32]string: *v = nil - case *map[uint32]uint: *v = nil - case *map[uint32]uint8: *v = nil - case *map[uint32]uint16: *v = nil - case *map[uint32]uint32: *v = nil - case *map[uint32]uint64: *v = nil - case *map[uint32]uintptr: *v = nil - case *map[uint32]int: *v = nil - case *map[uint32]int8: *v = nil - case *map[uint32]int16: *v = nil - case *map[uint32]int32: *v = nil - case *map[uint32]int64: *v = nil - case *map[uint32]float32: *v = nil - case *map[uint32]float64: *v = nil - case *map[uint32]bool: *v = nil - - case *[]uint64: - *v = nil - case *map[uint64]interface{}: *v = nil - case *map[uint64]string: *v = nil - case *map[uint64]uint: *v = nil - case *map[uint64]uint8: *v = nil - case *map[uint64]uint16: *v = nil - case *map[uint64]uint32: *v = nil - case *map[uint64]uint64: *v = nil - case *map[uint64]uintptr: *v = nil - case *map[uint64]int: *v = nil - case *map[uint64]int8: *v = nil - case *map[uint64]int16: *v = nil - case *map[uint64]int32: *v = nil - case *map[uint64]int64: *v = nil - case *map[uint64]float32: *v = nil - case *map[uint64]float64: *v = nil - case *map[uint64]bool: *v = nil - - case *[]uintptr: - *v = nil - case *map[uintptr]interface{}: *v = nil - case *map[uintptr]string: *v = nil - case *map[uintptr]uint: *v = nil - case *map[uintptr]uint8: *v = nil - case *map[uintptr]uint16: *v = nil - case *map[uintptr]uint32: *v = nil - case *map[uintptr]uint64: *v = nil - case *map[uintptr]uintptr: *v = nil - case *map[uintptr]int: *v = nil - case *map[uintptr]int8: *v = nil - case *map[uintptr]int16: *v = nil - case *map[uintptr]int32: *v = nil - case *map[uintptr]int64: *v = nil - case *map[uintptr]float32: *v = nil - case *map[uintptr]float64: *v = nil - case *map[uintptr]bool: *v = nil - - case *[]int: - *v = nil - case *map[int]interface{}: *v = nil - case *map[int]string: *v = nil - case *map[int]uint: *v = nil - case *map[int]uint8: *v = nil - case *map[int]uint16: *v = nil - case *map[int]uint32: *v = nil - case *map[int]uint64: *v = nil - case *map[int]uintptr: *v = nil - case *map[int]int: *v = nil - case *map[int]int8: *v = nil - case *map[int]int16: *v = nil - case *map[int]int32: *v = nil - case *map[int]int64: *v = nil - case *map[int]float32: *v = nil - case *map[int]float64: *v = nil - case *map[int]bool: *v = nil - - case *[]int8: - *v = nil - case *map[int8]interface{}: *v = nil - case *map[int8]string: *v = nil - case *map[int8]uint: *v = nil - case *map[int8]uint8: *v = nil - case *map[int8]uint16: *v = nil - case *map[int8]uint32: *v = nil - case *map[int8]uint64: *v = nil - case *map[int8]uintptr: *v = nil - case *map[int8]int: *v = nil - case *map[int8]int8: *v = nil - case *map[int8]int16: *v = nil - case *map[int8]int32: *v = nil - case *map[int8]int64: *v = nil - case *map[int8]float32: *v = nil - case *map[int8]float64: *v = nil - case *map[int8]bool: *v = nil - - case *[]int16: - *v = nil - case *map[int16]interface{}: *v = nil - case *map[int16]string: *v = nil - case *map[int16]uint: *v = nil - case *map[int16]uint8: *v = nil - case *map[int16]uint16: *v = nil - case *map[int16]uint32: *v = nil - case *map[int16]uint64: *v = nil - case *map[int16]uintptr: *v = nil - case *map[int16]int: *v = nil - case *map[int16]int8: *v = nil - case *map[int16]int16: *v = nil - case *map[int16]int32: *v = nil - case *map[int16]int64: *v = nil - case *map[int16]float32: *v = nil - case *map[int16]float64: *v = nil - case *map[int16]bool: *v = nil - - case *[]int32: - *v = nil - case *map[int32]interface{}: *v = nil - case *map[int32]string: *v = nil - case *map[int32]uint: *v = nil - case *map[int32]uint8: *v = nil - case *map[int32]uint16: *v = nil - case *map[int32]uint32: *v = nil - case *map[int32]uint64: *v = nil - case *map[int32]uintptr: *v = nil - case *map[int32]int: *v = nil - case *map[int32]int8: *v = nil - case *map[int32]int16: *v = nil - case *map[int32]int32: *v = nil - case *map[int32]int64: *v = nil - case *map[int32]float32: *v = nil - case *map[int32]float64: *v = nil - case *map[int32]bool: *v = nil - - case *[]int64: - *v = nil - case *map[int64]interface{}: *v = nil - case *map[int64]string: *v = nil - case *map[int64]uint: *v = nil - case *map[int64]uint8: *v = nil - case *map[int64]uint16: *v = nil - case *map[int64]uint32: *v = nil - case *map[int64]uint64: *v = nil - case *map[int64]uintptr: *v = nil - case *map[int64]int: *v = nil - case *map[int64]int8: *v = nil - case *map[int64]int16: *v = nil - case *map[int64]int32: *v = nil - case *map[int64]int64: *v = nil - case *map[int64]float32: *v = nil - case *map[int64]float64: *v = nil - case *map[int64]bool: *v = nil - - case *[]bool: - *v = nil - case *map[bool]interface{}: *v = nil - case *map[bool]string: *v = nil - case *map[bool]uint: *v = nil - case *map[bool]uint8: *v = nil - case *map[bool]uint16: *v = nil - case *map[bool]uint32: *v = nil - case *map[bool]uint64: *v = nil - case *map[bool]uintptr: *v = nil - case *map[bool]int: *v = nil - case *map[bool]int8: *v = nil - case *map[bool]int16: *v = nil - case *map[bool]int32: *v = nil - case *map[bool]int64: *v = nil - case *map[bool]float32: *v = nil - case *map[bool]float64: *v = nil - case *map[bool]bool: *v = nil - default: - _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) + _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 return false } return true @@ -16678,23 +17723,27 @@ func fastpathDecodeSetZeroTypeSwitch(iv interface{}, d *Decoder) bool { func (d *Decoder) fastpathDecSliceIntfR(f *codecFnInfo, rv reflect.Value) { if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { - var vp = rv2i(rv).(*[]interface{}) - if v, changed := fastpathTV.DecSliceIntfV(*vp, !array, d); changed { + vp := rv2i(rv).(*[]interface{}) + v, changed := fastpathTV.DecSliceIntfV(*vp, !array, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceIntfV(rv2i(rv).([]interface{}), !array, d) + v := rv2i(rv).([]interface{}) + v2, changed := fastpathTV.DecSliceIntfV(v, !array, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } } } - func (f fastpathT) DecSliceIntfX(vp *[]interface{}, d *Decoder) { - if v, changed := f.DecSliceIntfV(*vp, true, d); changed { + v, changed := f.DecSliceIntfV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecSliceIntfV(v []interface{}, canChange bool, d *Decoder) (_ []interface{}, changed bool) { dd := d.d - slh, containerLenS := d.decSliceHelperStart() if containerLenS == 0 { if canChange { @@ -16708,7 +17757,6 @@ func (_ fastpathT) DecSliceIntfV(v []interface{}, canChange bool, d *Decoder) (_ slh.End() return v, changed } - hasLen := containerLenS > 0 var xlen int if hasLen && canChange { @@ -16727,7 +17775,7 @@ func (_ fastpathT) DecSliceIntfV(v []interface{}, canChange bool, d *Decoder) (_ } j := 0 for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { - if j == 0 && len(v) == 0 { + if j == 0 && len(v) == 0 && canChange { if hasLen { xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16) } else { @@ -16750,6 +17798,8 @@ func (_ fastpathT) DecSliceIntfV(v []interface{}, canChange bool, d *Decoder) (_ slh.ElemContainerState(j) if decodeIntoBlank { d.swallow() + } else if dd.TryDecodeAsNil() { + v[j] = nil } else { d.decode(&v[j]) } @@ -16769,23 +17819,27 @@ func (_ fastpathT) DecSliceIntfV(v []interface{}, canChange bool, d *Decoder) (_ func (d *Decoder) fastpathDecSliceStringR(f *codecFnInfo, rv reflect.Value) { if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { - var vp = rv2i(rv).(*[]string) - if v, changed := fastpathTV.DecSliceStringV(*vp, !array, d); changed { + vp := rv2i(rv).(*[]string) + v, changed := fastpathTV.DecSliceStringV(*vp, !array, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceStringV(rv2i(rv).([]string), !array, d) + v := rv2i(rv).([]string) + v2, changed := fastpathTV.DecSliceStringV(v, !array, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } } } - func (f fastpathT) DecSliceStringX(vp *[]string, d *Decoder) { - if v, changed := f.DecSliceStringV(*vp, true, d); changed { + v, changed := f.DecSliceStringV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecSliceStringV(v []string, canChange bool, d *Decoder) (_ []string, changed bool) { dd := d.d - slh, containerLenS := d.decSliceHelperStart() if containerLenS == 0 { if canChange { @@ -16799,7 +17853,6 @@ func (_ fastpathT) DecSliceStringV(v []string, canChange bool, d *Decoder) (_ [] slh.End() return v, changed } - hasLen := containerLenS > 0 var xlen int if hasLen && canChange { @@ -16818,7 +17871,7 @@ func (_ fastpathT) DecSliceStringV(v []string, canChange bool, d *Decoder) (_ [] } j := 0 for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { - if j == 0 && len(v) == 0 { + if j == 0 && len(v) == 0 && canChange { if hasLen { xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16) } else { @@ -16841,6 +17894,8 @@ func (_ fastpathT) DecSliceStringV(v []string, canChange bool, d *Decoder) (_ [] slh.ElemContainerState(j) if decodeIntoBlank { d.swallow() + } else if dd.TryDecodeAsNil() { + v[j] = "" } else { v[j] = dd.DecodeString() } @@ -16860,23 +17915,27 @@ func (_ fastpathT) DecSliceStringV(v []string, canChange bool, d *Decoder) (_ [] func (d *Decoder) fastpathDecSliceFloat32R(f *codecFnInfo, rv reflect.Value) { if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { - var vp = rv2i(rv).(*[]float32) - if v, changed := fastpathTV.DecSliceFloat32V(*vp, !array, d); changed { + vp := rv2i(rv).(*[]float32) + v, changed := fastpathTV.DecSliceFloat32V(*vp, !array, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceFloat32V(rv2i(rv).([]float32), !array, d) + v := rv2i(rv).([]float32) + v2, changed := fastpathTV.DecSliceFloat32V(v, !array, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } } } - func (f fastpathT) DecSliceFloat32X(vp *[]float32, d *Decoder) { - if v, changed := f.DecSliceFloat32V(*vp, true, d); changed { + v, changed := f.DecSliceFloat32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecSliceFloat32V(v []float32, canChange bool, d *Decoder) (_ []float32, changed bool) { dd := d.d - slh, containerLenS := d.decSliceHelperStart() if containerLenS == 0 { if canChange { @@ -16890,7 +17949,6 @@ func (_ fastpathT) DecSliceFloat32V(v []float32, canChange bool, d *Decoder) (_ slh.End() return v, changed } - hasLen := containerLenS > 0 var xlen int if hasLen && canChange { @@ -16909,7 +17967,7 @@ func (_ fastpathT) DecSliceFloat32V(v []float32, canChange bool, d *Decoder) (_ } j := 0 for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { - if j == 0 && len(v) == 0 { + if j == 0 && len(v) == 0 && canChange { if hasLen { xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) } else { @@ -16932,8 +17990,10 @@ func (_ fastpathT) DecSliceFloat32V(v []float32, canChange bool, d *Decoder) (_ slh.ElemContainerState(j) if decodeIntoBlank { d.swallow() + } else if dd.TryDecodeAsNil() { + v[j] = 0 } else { - v[j] = float32(dd.DecodeFloat(true)) + v[j] = float32(chkOvf.Float32V(dd.DecodeFloat64())) } } if canChange { @@ -16951,23 +18011,27 @@ func (_ fastpathT) DecSliceFloat32V(v []float32, canChange bool, d *Decoder) (_ func (d *Decoder) fastpathDecSliceFloat64R(f *codecFnInfo, rv reflect.Value) { if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { - var vp = rv2i(rv).(*[]float64) - if v, changed := fastpathTV.DecSliceFloat64V(*vp, !array, d); changed { + vp := rv2i(rv).(*[]float64) + v, changed := fastpathTV.DecSliceFloat64V(*vp, !array, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceFloat64V(rv2i(rv).([]float64), !array, d) + v := rv2i(rv).([]float64) + v2, changed := fastpathTV.DecSliceFloat64V(v, !array, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } } } - func (f fastpathT) DecSliceFloat64X(vp *[]float64, d *Decoder) { - if v, changed := f.DecSliceFloat64V(*vp, true, d); changed { + v, changed := f.DecSliceFloat64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecSliceFloat64V(v []float64, canChange bool, d *Decoder) (_ []float64, changed bool) { dd := d.d - slh, containerLenS := d.decSliceHelperStart() if containerLenS == 0 { if canChange { @@ -16981,7 +18045,6 @@ func (_ fastpathT) DecSliceFloat64V(v []float64, canChange bool, d *Decoder) (_ slh.End() return v, changed } - hasLen := containerLenS > 0 var xlen int if hasLen && canChange { @@ -17000,7 +18063,7 @@ func (_ fastpathT) DecSliceFloat64V(v []float64, canChange bool, d *Decoder) (_ } j := 0 for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { - if j == 0 && len(v) == 0 { + if j == 0 && len(v) == 0 && canChange { if hasLen { xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) } else { @@ -17023,8 +18086,10 @@ func (_ fastpathT) DecSliceFloat64V(v []float64, canChange bool, d *Decoder) (_ slh.ElemContainerState(j) if decodeIntoBlank { d.swallow() + } else if dd.TryDecodeAsNil() { + v[j] = 0 } else { - v[j] = dd.DecodeFloat(false) + v[j] = dd.DecodeFloat64() } } if canChange { @@ -17042,23 +18107,27 @@ func (_ fastpathT) DecSliceFloat64V(v []float64, canChange bool, d *Decoder) (_ func (d *Decoder) fastpathDecSliceUintR(f *codecFnInfo, rv reflect.Value) { if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { - var vp = rv2i(rv).(*[]uint) - if v, changed := fastpathTV.DecSliceUintV(*vp, !array, d); changed { + vp := rv2i(rv).(*[]uint) + v, changed := fastpathTV.DecSliceUintV(*vp, !array, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceUintV(rv2i(rv).([]uint), !array, d) + v := rv2i(rv).([]uint) + v2, changed := fastpathTV.DecSliceUintV(v, !array, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } } } - func (f fastpathT) DecSliceUintX(vp *[]uint, d *Decoder) { - if v, changed := f.DecSliceUintV(*vp, true, d); changed { + v, changed := f.DecSliceUintV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecSliceUintV(v []uint, canChange bool, d *Decoder) (_ []uint, changed bool) { dd := d.d - slh, containerLenS := d.decSliceHelperStart() if containerLenS == 0 { if canChange { @@ -17072,7 +18141,6 @@ func (_ fastpathT) DecSliceUintV(v []uint, canChange bool, d *Decoder) (_ []uint slh.End() return v, changed } - hasLen := containerLenS > 0 var xlen int if hasLen && canChange { @@ -17091,7 +18159,7 @@ func (_ fastpathT) DecSliceUintV(v []uint, canChange bool, d *Decoder) (_ []uint } j := 0 for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { - if j == 0 && len(v) == 0 { + if j == 0 && len(v) == 0 && canChange { if hasLen { xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) } else { @@ -17114,8 +18182,10 @@ func (_ fastpathT) DecSliceUintV(v []uint, canChange bool, d *Decoder) (_ []uint slh.ElemContainerState(j) if decodeIntoBlank { d.swallow() + } else if dd.TryDecodeAsNil() { + v[j] = 0 } else { - v[j] = uint(dd.DecodeUint(uintBitsize)) + v[j] = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) } } if canChange { @@ -17131,25 +18201,125 @@ func (_ fastpathT) DecSliceUintV(v []uint, canChange bool, d *Decoder) (_ []uint return v, changed } -func (d *Decoder) fastpathDecSliceUint16R(f *codecFnInfo, rv reflect.Value) { +func (d *Decoder) fastpathDecSliceUint8R(f *codecFnInfo, rv reflect.Value) { if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { - var vp = rv2i(rv).(*[]uint16) - if v, changed := fastpathTV.DecSliceUint16V(*vp, !array, d); changed { + vp := rv2i(rv).(*[]uint8) + v, changed := fastpathTV.DecSliceUint8V(*vp, !array, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceUint16V(rv2i(rv).([]uint16), !array, d) + v := rv2i(rv).([]uint8) + v2, changed := fastpathTV.DecSliceUint8V(v, !array, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } + } +} +func (f fastpathT) DecSliceUint8X(vp *[]uint8, d *Decoder) { + v, changed := f.DecSliceUint8V(*vp, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecSliceUint8V(v []uint8, canChange bool, d *Decoder) (_ []uint8, changed bool) { + dd := d.d + slh, containerLenS := d.decSliceHelperStart() + if containerLenS == 0 { + if canChange { + if v == nil { + v = []uint8{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + hasLen := containerLenS > 0 + var xlen int + if hasLen && canChange { + if containerLenS > cap(v) { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1) + if xlen <= cap(v) { + v = v[:xlen] + } else { + v = make([]uint8, xlen) + } + changed = true + } else if containerLenS != len(v) { + v = v[:containerLenS] + changed = true + } + } + j := 0 + for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { + if j == 0 && len(v) == 0 && canChange { + if hasLen { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1) + } else { + xlen = 8 + } + v = make([]uint8, xlen) + changed = true + } + // if indefinite, etc, then expand the slice if necessary + var decodeIntoBlank bool + if j >= len(v) { + if canChange { + v = append(v, 0) + changed = true + } else { + d.arrayCannotExpand(len(v), j+1) + decodeIntoBlank = true + } + } + slh.ElemContainerState(j) + if decodeIntoBlank { + d.swallow() + } else if dd.TryDecodeAsNil() { + v[j] = 0 + } else { + v[j] = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + } + } + if canChange { + if j < len(v) { + v = v[:j] + changed = true + } else if j == 0 && v == nil { + v = make([]uint8, 0) + changed = true + } } + slh.End() + return v, changed } +func (d *Decoder) fastpathDecSliceUint16R(f *codecFnInfo, rv reflect.Value) { + if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*[]uint16) + v, changed := fastpathTV.DecSliceUint16V(*vp, !array, d) + if changed { + *vp = v + } + } else { + v := rv2i(rv).([]uint16) + v2, changed := fastpathTV.DecSliceUint16V(v, !array, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } + } +} func (f fastpathT) DecSliceUint16X(vp *[]uint16, d *Decoder) { - if v, changed := f.DecSliceUint16V(*vp, true, d); changed { + v, changed := f.DecSliceUint16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecSliceUint16V(v []uint16, canChange bool, d *Decoder) (_ []uint16, changed bool) { dd := d.d - slh, containerLenS := d.decSliceHelperStart() if containerLenS == 0 { if canChange { @@ -17163,7 +18333,6 @@ func (_ fastpathT) DecSliceUint16V(v []uint16, canChange bool, d *Decoder) (_ [] slh.End() return v, changed } - hasLen := containerLenS > 0 var xlen int if hasLen && canChange { @@ -17182,7 +18351,7 @@ func (_ fastpathT) DecSliceUint16V(v []uint16, canChange bool, d *Decoder) (_ [] } j := 0 for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { - if j == 0 && len(v) == 0 { + if j == 0 && len(v) == 0 && canChange { if hasLen { xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2) } else { @@ -17205,8 +18374,10 @@ func (_ fastpathT) DecSliceUint16V(v []uint16, canChange bool, d *Decoder) (_ [] slh.ElemContainerState(j) if decodeIntoBlank { d.swallow() + } else if dd.TryDecodeAsNil() { + v[j] = 0 } else { - v[j] = uint16(dd.DecodeUint(16)) + v[j] = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) } } if canChange { @@ -17224,23 +18395,27 @@ func (_ fastpathT) DecSliceUint16V(v []uint16, canChange bool, d *Decoder) (_ [] func (d *Decoder) fastpathDecSliceUint32R(f *codecFnInfo, rv reflect.Value) { if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { - var vp = rv2i(rv).(*[]uint32) - if v, changed := fastpathTV.DecSliceUint32V(*vp, !array, d); changed { + vp := rv2i(rv).(*[]uint32) + v, changed := fastpathTV.DecSliceUint32V(*vp, !array, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceUint32V(rv2i(rv).([]uint32), !array, d) + v := rv2i(rv).([]uint32) + v2, changed := fastpathTV.DecSliceUint32V(v, !array, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } } } - func (f fastpathT) DecSliceUint32X(vp *[]uint32, d *Decoder) { - if v, changed := f.DecSliceUint32V(*vp, true, d); changed { + v, changed := f.DecSliceUint32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecSliceUint32V(v []uint32, canChange bool, d *Decoder) (_ []uint32, changed bool) { dd := d.d - slh, containerLenS := d.decSliceHelperStart() if containerLenS == 0 { if canChange { @@ -17254,7 +18429,6 @@ func (_ fastpathT) DecSliceUint32V(v []uint32, canChange bool, d *Decoder) (_ [] slh.End() return v, changed } - hasLen := containerLenS > 0 var xlen int if hasLen && canChange { @@ -17273,7 +18447,7 @@ func (_ fastpathT) DecSliceUint32V(v []uint32, canChange bool, d *Decoder) (_ [] } j := 0 for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { - if j == 0 && len(v) == 0 { + if j == 0 && len(v) == 0 && canChange { if hasLen { xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) } else { @@ -17296,8 +18470,10 @@ func (_ fastpathT) DecSliceUint32V(v []uint32, canChange bool, d *Decoder) (_ [] slh.ElemContainerState(j) if decodeIntoBlank { d.swallow() + } else if dd.TryDecodeAsNil() { + v[j] = 0 } else { - v[j] = uint32(dd.DecodeUint(32)) + v[j] = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) } } if canChange { @@ -17315,23 +18491,27 @@ func (_ fastpathT) DecSliceUint32V(v []uint32, canChange bool, d *Decoder) (_ [] func (d *Decoder) fastpathDecSliceUint64R(f *codecFnInfo, rv reflect.Value) { if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { - var vp = rv2i(rv).(*[]uint64) - if v, changed := fastpathTV.DecSliceUint64V(*vp, !array, d); changed { + vp := rv2i(rv).(*[]uint64) + v, changed := fastpathTV.DecSliceUint64V(*vp, !array, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceUint64V(rv2i(rv).([]uint64), !array, d) + v := rv2i(rv).([]uint64) + v2, changed := fastpathTV.DecSliceUint64V(v, !array, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } } } - func (f fastpathT) DecSliceUint64X(vp *[]uint64, d *Decoder) { - if v, changed := f.DecSliceUint64V(*vp, true, d); changed { + v, changed := f.DecSliceUint64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecSliceUint64V(v []uint64, canChange bool, d *Decoder) (_ []uint64, changed bool) { dd := d.d - slh, containerLenS := d.decSliceHelperStart() if containerLenS == 0 { if canChange { @@ -17345,7 +18525,6 @@ func (_ fastpathT) DecSliceUint64V(v []uint64, canChange bool, d *Decoder) (_ [] slh.End() return v, changed } - hasLen := containerLenS > 0 var xlen int if hasLen && canChange { @@ -17364,7 +18543,7 @@ func (_ fastpathT) DecSliceUint64V(v []uint64, canChange bool, d *Decoder) (_ [] } j := 0 for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { - if j == 0 && len(v) == 0 { + if j == 0 && len(v) == 0 && canChange { if hasLen { xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) } else { @@ -17387,8 +18566,10 @@ func (_ fastpathT) DecSliceUint64V(v []uint64, canChange bool, d *Decoder) (_ [] slh.ElemContainerState(j) if decodeIntoBlank { d.swallow() + } else if dd.TryDecodeAsNil() { + v[j] = 0 } else { - v[j] = dd.DecodeUint(64) + v[j] = dd.DecodeUint64() } } if canChange { @@ -17406,23 +18587,27 @@ func (_ fastpathT) DecSliceUint64V(v []uint64, canChange bool, d *Decoder) (_ [] func (d *Decoder) fastpathDecSliceUintptrR(f *codecFnInfo, rv reflect.Value) { if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { - var vp = rv2i(rv).(*[]uintptr) - if v, changed := fastpathTV.DecSliceUintptrV(*vp, !array, d); changed { + vp := rv2i(rv).(*[]uintptr) + v, changed := fastpathTV.DecSliceUintptrV(*vp, !array, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceUintptrV(rv2i(rv).([]uintptr), !array, d) + v := rv2i(rv).([]uintptr) + v2, changed := fastpathTV.DecSliceUintptrV(v, !array, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } } } - func (f fastpathT) DecSliceUintptrX(vp *[]uintptr, d *Decoder) { - if v, changed := f.DecSliceUintptrV(*vp, true, d); changed { + v, changed := f.DecSliceUintptrV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecSliceUintptrV(v []uintptr, canChange bool, d *Decoder) (_ []uintptr, changed bool) { dd := d.d - slh, containerLenS := d.decSliceHelperStart() if containerLenS == 0 { if canChange { @@ -17436,7 +18621,6 @@ func (_ fastpathT) DecSliceUintptrV(v []uintptr, canChange bool, d *Decoder) (_ slh.End() return v, changed } - hasLen := containerLenS > 0 var xlen int if hasLen && canChange { @@ -17455,7 +18639,7 @@ func (_ fastpathT) DecSliceUintptrV(v []uintptr, canChange bool, d *Decoder) (_ } j := 0 for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { - if j == 0 && len(v) == 0 { + if j == 0 && len(v) == 0 && canChange { if hasLen { xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) } else { @@ -17478,8 +18662,10 @@ func (_ fastpathT) DecSliceUintptrV(v []uintptr, canChange bool, d *Decoder) (_ slh.ElemContainerState(j) if decodeIntoBlank { d.swallow() + } else if dd.TryDecodeAsNil() { + v[j] = 0 } else { - v[j] = uintptr(dd.DecodeUint(uintBitsize)) + v[j] = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) } } if canChange { @@ -17497,23 +18683,27 @@ func (_ fastpathT) DecSliceUintptrV(v []uintptr, canChange bool, d *Decoder) (_ func (d *Decoder) fastpathDecSliceIntR(f *codecFnInfo, rv reflect.Value) { if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { - var vp = rv2i(rv).(*[]int) - if v, changed := fastpathTV.DecSliceIntV(*vp, !array, d); changed { + vp := rv2i(rv).(*[]int) + v, changed := fastpathTV.DecSliceIntV(*vp, !array, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceIntV(rv2i(rv).([]int), !array, d) + v := rv2i(rv).([]int) + v2, changed := fastpathTV.DecSliceIntV(v, !array, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } } } - func (f fastpathT) DecSliceIntX(vp *[]int, d *Decoder) { - if v, changed := f.DecSliceIntV(*vp, true, d); changed { + v, changed := f.DecSliceIntV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecSliceIntV(v []int, canChange bool, d *Decoder) (_ []int, changed bool) { dd := d.d - slh, containerLenS := d.decSliceHelperStart() if containerLenS == 0 { if canChange { @@ -17527,7 +18717,6 @@ func (_ fastpathT) DecSliceIntV(v []int, canChange bool, d *Decoder) (_ []int, c slh.End() return v, changed } - hasLen := containerLenS > 0 var xlen int if hasLen && canChange { @@ -17546,7 +18735,7 @@ func (_ fastpathT) DecSliceIntV(v []int, canChange bool, d *Decoder) (_ []int, c } j := 0 for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { - if j == 0 && len(v) == 0 { + if j == 0 && len(v) == 0 && canChange { if hasLen { xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) } else { @@ -17569,8 +18758,10 @@ func (_ fastpathT) DecSliceIntV(v []int, canChange bool, d *Decoder) (_ []int, c slh.ElemContainerState(j) if decodeIntoBlank { d.swallow() + } else if dd.TryDecodeAsNil() { + v[j] = 0 } else { - v[j] = int(dd.DecodeInt(intBitsize)) + v[j] = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) } } if canChange { @@ -17588,23 +18779,27 @@ func (_ fastpathT) DecSliceIntV(v []int, canChange bool, d *Decoder) (_ []int, c func (d *Decoder) fastpathDecSliceInt8R(f *codecFnInfo, rv reflect.Value) { if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { - var vp = rv2i(rv).(*[]int8) - if v, changed := fastpathTV.DecSliceInt8V(*vp, !array, d); changed { + vp := rv2i(rv).(*[]int8) + v, changed := fastpathTV.DecSliceInt8V(*vp, !array, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceInt8V(rv2i(rv).([]int8), !array, d) + v := rv2i(rv).([]int8) + v2, changed := fastpathTV.DecSliceInt8V(v, !array, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } } } - func (f fastpathT) DecSliceInt8X(vp *[]int8, d *Decoder) { - if v, changed := f.DecSliceInt8V(*vp, true, d); changed { + v, changed := f.DecSliceInt8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecSliceInt8V(v []int8, canChange bool, d *Decoder) (_ []int8, changed bool) { dd := d.d - slh, containerLenS := d.decSliceHelperStart() if containerLenS == 0 { if canChange { @@ -17618,7 +18813,6 @@ func (_ fastpathT) DecSliceInt8V(v []int8, canChange bool, d *Decoder) (_ []int8 slh.End() return v, changed } - hasLen := containerLenS > 0 var xlen int if hasLen && canChange { @@ -17637,7 +18831,7 @@ func (_ fastpathT) DecSliceInt8V(v []int8, canChange bool, d *Decoder) (_ []int8 } j := 0 for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { - if j == 0 && len(v) == 0 { + if j == 0 && len(v) == 0 && canChange { if hasLen { xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1) } else { @@ -17660,8 +18854,10 @@ func (_ fastpathT) DecSliceInt8V(v []int8, canChange bool, d *Decoder) (_ []int8 slh.ElemContainerState(j) if decodeIntoBlank { d.swallow() + } else if dd.TryDecodeAsNil() { + v[j] = 0 } else { - v[j] = int8(dd.DecodeInt(8)) + v[j] = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) } } if canChange { @@ -17679,23 +18875,27 @@ func (_ fastpathT) DecSliceInt8V(v []int8, canChange bool, d *Decoder) (_ []int8 func (d *Decoder) fastpathDecSliceInt16R(f *codecFnInfo, rv reflect.Value) { if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { - var vp = rv2i(rv).(*[]int16) - if v, changed := fastpathTV.DecSliceInt16V(*vp, !array, d); changed { + vp := rv2i(rv).(*[]int16) + v, changed := fastpathTV.DecSliceInt16V(*vp, !array, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceInt16V(rv2i(rv).([]int16), !array, d) + v := rv2i(rv).([]int16) + v2, changed := fastpathTV.DecSliceInt16V(v, !array, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } } } - func (f fastpathT) DecSliceInt16X(vp *[]int16, d *Decoder) { - if v, changed := f.DecSliceInt16V(*vp, true, d); changed { + v, changed := f.DecSliceInt16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecSliceInt16V(v []int16, canChange bool, d *Decoder) (_ []int16, changed bool) { dd := d.d - slh, containerLenS := d.decSliceHelperStart() if containerLenS == 0 { if canChange { @@ -17709,7 +18909,6 @@ func (_ fastpathT) DecSliceInt16V(v []int16, canChange bool, d *Decoder) (_ []in slh.End() return v, changed } - hasLen := containerLenS > 0 var xlen int if hasLen && canChange { @@ -17728,7 +18927,7 @@ func (_ fastpathT) DecSliceInt16V(v []int16, canChange bool, d *Decoder) (_ []in } j := 0 for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { - if j == 0 && len(v) == 0 { + if j == 0 && len(v) == 0 && canChange { if hasLen { xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2) } else { @@ -17751,8 +18950,10 @@ func (_ fastpathT) DecSliceInt16V(v []int16, canChange bool, d *Decoder) (_ []in slh.ElemContainerState(j) if decodeIntoBlank { d.swallow() + } else if dd.TryDecodeAsNil() { + v[j] = 0 } else { - v[j] = int16(dd.DecodeInt(16)) + v[j] = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) } } if canChange { @@ -17770,23 +18971,27 @@ func (_ fastpathT) DecSliceInt16V(v []int16, canChange bool, d *Decoder) (_ []in func (d *Decoder) fastpathDecSliceInt32R(f *codecFnInfo, rv reflect.Value) { if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { - var vp = rv2i(rv).(*[]int32) - if v, changed := fastpathTV.DecSliceInt32V(*vp, !array, d); changed { + vp := rv2i(rv).(*[]int32) + v, changed := fastpathTV.DecSliceInt32V(*vp, !array, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceInt32V(rv2i(rv).([]int32), !array, d) + v := rv2i(rv).([]int32) + v2, changed := fastpathTV.DecSliceInt32V(v, !array, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } } } - func (f fastpathT) DecSliceInt32X(vp *[]int32, d *Decoder) { - if v, changed := f.DecSliceInt32V(*vp, true, d); changed { + v, changed := f.DecSliceInt32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecSliceInt32V(v []int32, canChange bool, d *Decoder) (_ []int32, changed bool) { dd := d.d - slh, containerLenS := d.decSliceHelperStart() if containerLenS == 0 { if canChange { @@ -17800,7 +19005,6 @@ func (_ fastpathT) DecSliceInt32V(v []int32, canChange bool, d *Decoder) (_ []in slh.End() return v, changed } - hasLen := containerLenS > 0 var xlen int if hasLen && canChange { @@ -17819,7 +19023,7 @@ func (_ fastpathT) DecSliceInt32V(v []int32, canChange bool, d *Decoder) (_ []in } j := 0 for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { - if j == 0 && len(v) == 0 { + if j == 0 && len(v) == 0 && canChange { if hasLen { xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) } else { @@ -17842,8 +19046,10 @@ func (_ fastpathT) DecSliceInt32V(v []int32, canChange bool, d *Decoder) (_ []in slh.ElemContainerState(j) if decodeIntoBlank { d.swallow() + } else if dd.TryDecodeAsNil() { + v[j] = 0 } else { - v[j] = int32(dd.DecodeInt(32)) + v[j] = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) } } if canChange { @@ -17861,23 +19067,27 @@ func (_ fastpathT) DecSliceInt32V(v []int32, canChange bool, d *Decoder) (_ []in func (d *Decoder) fastpathDecSliceInt64R(f *codecFnInfo, rv reflect.Value) { if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { - var vp = rv2i(rv).(*[]int64) - if v, changed := fastpathTV.DecSliceInt64V(*vp, !array, d); changed { + vp := rv2i(rv).(*[]int64) + v, changed := fastpathTV.DecSliceInt64V(*vp, !array, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceInt64V(rv2i(rv).([]int64), !array, d) + v := rv2i(rv).([]int64) + v2, changed := fastpathTV.DecSliceInt64V(v, !array, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } } } - func (f fastpathT) DecSliceInt64X(vp *[]int64, d *Decoder) { - if v, changed := f.DecSliceInt64V(*vp, true, d); changed { + v, changed := f.DecSliceInt64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecSliceInt64V(v []int64, canChange bool, d *Decoder) (_ []int64, changed bool) { dd := d.d - slh, containerLenS := d.decSliceHelperStart() if containerLenS == 0 { if canChange { @@ -17891,7 +19101,6 @@ func (_ fastpathT) DecSliceInt64V(v []int64, canChange bool, d *Decoder) (_ []in slh.End() return v, changed } - hasLen := containerLenS > 0 var xlen int if hasLen && canChange { @@ -17910,7 +19119,7 @@ func (_ fastpathT) DecSliceInt64V(v []int64, canChange bool, d *Decoder) (_ []in } j := 0 for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { - if j == 0 && len(v) == 0 { + if j == 0 && len(v) == 0 && canChange { if hasLen { xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) } else { @@ -17933,8 +19142,10 @@ func (_ fastpathT) DecSliceInt64V(v []int64, canChange bool, d *Decoder) (_ []in slh.ElemContainerState(j) if decodeIntoBlank { d.swallow() + } else if dd.TryDecodeAsNil() { + v[j] = 0 } else { - v[j] = dd.DecodeInt(64) + v[j] = dd.DecodeInt64() } } if canChange { @@ -17952,23 +19163,27 @@ func (_ fastpathT) DecSliceInt64V(v []int64, canChange bool, d *Decoder) (_ []in func (d *Decoder) fastpathDecSliceBoolR(f *codecFnInfo, rv reflect.Value) { if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { - var vp = rv2i(rv).(*[]bool) - if v, changed := fastpathTV.DecSliceBoolV(*vp, !array, d); changed { + vp := rv2i(rv).(*[]bool) + v, changed := fastpathTV.DecSliceBoolV(*vp, !array, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceBoolV(rv2i(rv).([]bool), !array, d) + v := rv2i(rv).([]bool) + v2, changed := fastpathTV.DecSliceBoolV(v, !array, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } } } - func (f fastpathT) DecSliceBoolX(vp *[]bool, d *Decoder) { - if v, changed := f.DecSliceBoolV(*vp, true, d); changed { + v, changed := f.DecSliceBoolV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecSliceBoolV(v []bool, canChange bool, d *Decoder) (_ []bool, changed bool) { dd := d.d - slh, containerLenS := d.decSliceHelperStart() if containerLenS == 0 { if canChange { @@ -17982,7 +19197,6 @@ func (_ fastpathT) DecSliceBoolV(v []bool, canChange bool, d *Decoder) (_ []bool slh.End() return v, changed } - hasLen := containerLenS > 0 var xlen int if hasLen && canChange { @@ -18001,7 +19215,7 @@ func (_ fastpathT) DecSliceBoolV(v []bool, canChange bool, d *Decoder) (_ []bool } j := 0 for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { - if j == 0 && len(v) == 0 { + if j == 0 && len(v) == 0 && canChange { if hasLen { xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1) } else { @@ -18024,6 +19238,8 @@ func (_ fastpathT) DecSliceBoolV(v []bool, canChange bool, d *Decoder) (_ []bool slh.ElemContainerState(j) if decodeIntoBlank { d.swallow() + } else if dd.TryDecodeAsNil() { + v[j] = false } else { v[j] = dd.DecodeBool() } @@ -18044,22 +19260,23 @@ func (_ fastpathT) DecSliceBoolV(v []bool, canChange bool, d *Decoder) (_ []bool func (d *Decoder) fastpathDecMapIntfIntfR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[interface{}]interface{}) - if v, changed := fastpathTV.DecMapIntfIntfV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntfIntfV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntfIntfV(rv2i(rv).(map[interface{}]interface{}), false, d) } - fastpathTV.DecMapIntfIntfV(rv2i(rv).(map[interface{}]interface{}), false, d) } func (f fastpathT) DecMapIntfIntfX(vp *map[interface{}]interface{}, d *Decoder) { - if v, changed := f.DecMapIntfIntfV(*vp, true, d); changed { + v, changed := f.DecMapIntfIntfV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntfIntfV(v map[interface{}]interface{}, canChange bool, d *Decoder) (_ map[interface{}]interface{}, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 32) @@ -18070,7 +19287,7 @@ func (_ fastpathT) DecMapIntfIntfV(v map[interface{}]interface{}, canChange bool dd.ReadMapEnd() return v, changed } - mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset var mk interface{} var mv interface{} hasLen := containerLen > 0 @@ -18087,7 +19304,8 @@ func (_ fastpathT) DecMapIntfIntfV(v map[interface{}]interface{}, canChange bool dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = nil @@ -18111,22 +19329,23 @@ func (_ fastpathT) DecMapIntfIntfV(v map[interface{}]interface{}, canChange bool func (d *Decoder) fastpathDecMapIntfStringR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[interface{}]string) - if v, changed := fastpathTV.DecMapIntfStringV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntfStringV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntfStringV(rv2i(rv).(map[interface{}]string), false, d) } - fastpathTV.DecMapIntfStringV(rv2i(rv).(map[interface{}]string), false, d) } func (f fastpathT) DecMapIntfStringX(vp *map[interface{}]string, d *Decoder) { - if v, changed := f.DecMapIntfStringV(*vp, true, d); changed { + v, changed := f.DecMapIntfStringV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntfStringV(v map[interface{}]string, canChange bool, d *Decoder) (_ map[interface{}]string, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 32) @@ -18137,7 +19356,6 @@ func (_ fastpathT) DecMapIntfStringV(v map[interface{}]string, canChange bool, dd.ReadMapEnd() return v, changed } - var mk interface{} var mv string hasLen := containerLen > 0 @@ -18154,7 +19372,8 @@ func (_ fastpathT) DecMapIntfStringV(v map[interface{}]string, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = "" @@ -18173,22 +19392,23 @@ func (_ fastpathT) DecMapIntfStringV(v map[interface{}]string, canChange bool, func (d *Decoder) fastpathDecMapIntfUintR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[interface{}]uint) - if v, changed := fastpathTV.DecMapIntfUintV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntfUintV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntfUintV(rv2i(rv).(map[interface{}]uint), false, d) } - fastpathTV.DecMapIntfUintV(rv2i(rv).(map[interface{}]uint), false, d) } func (f fastpathT) DecMapIntfUintX(vp *map[interface{}]uint, d *Decoder) { - if v, changed := f.DecMapIntfUintV(*vp, true, d); changed { + v, changed := f.DecMapIntfUintV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntfUintV(v map[interface{}]uint, canChange bool, d *Decoder) (_ map[interface{}]uint, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -18199,7 +19419,6 @@ func (_ fastpathT) DecMapIntfUintV(v map[interface{}]uint, canChange bool, dd.ReadMapEnd() return v, changed } - var mk interface{} var mv uint hasLen := containerLen > 0 @@ -18216,14 +19435,15 @@ func (_ fastpathT) DecMapIntfUintV(v map[interface{}]uint, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint(dd.DecodeUint(uintBitsize)) + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -18235,22 +19455,23 @@ func (_ fastpathT) DecMapIntfUintV(v map[interface{}]uint, canChange bool, func (d *Decoder) fastpathDecMapIntfUint8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[interface{}]uint8) - if v, changed := fastpathTV.DecMapIntfUint8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntfUint8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntfUint8V(rv2i(rv).(map[interface{}]uint8), false, d) } - fastpathTV.DecMapIntfUint8V(rv2i(rv).(map[interface{}]uint8), false, d) } func (f fastpathT) DecMapIntfUint8X(vp *map[interface{}]uint8, d *Decoder) { - if v, changed := f.DecMapIntfUint8V(*vp, true, d); changed { + v, changed := f.DecMapIntfUint8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntfUint8V(v map[interface{}]uint8, canChange bool, d *Decoder) (_ map[interface{}]uint8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 17) @@ -18261,7 +19482,6 @@ func (_ fastpathT) DecMapIntfUint8V(v map[interface{}]uint8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk interface{} var mv uint8 hasLen := containerLen > 0 @@ -18278,14 +19498,15 @@ func (_ fastpathT) DecMapIntfUint8V(v map[interface{}]uint8, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint8(dd.DecodeUint(8)) + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } @@ -18297,22 +19518,23 @@ func (_ fastpathT) DecMapIntfUint8V(v map[interface{}]uint8, canChange bool, func (d *Decoder) fastpathDecMapIntfUint16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[interface{}]uint16) - if v, changed := fastpathTV.DecMapIntfUint16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntfUint16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntfUint16V(rv2i(rv).(map[interface{}]uint16), false, d) } - fastpathTV.DecMapIntfUint16V(rv2i(rv).(map[interface{}]uint16), false, d) } func (f fastpathT) DecMapIntfUint16X(vp *map[interface{}]uint16, d *Decoder) { - if v, changed := f.DecMapIntfUint16V(*vp, true, d); changed { + v, changed := f.DecMapIntfUint16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntfUint16V(v map[interface{}]uint16, canChange bool, d *Decoder) (_ map[interface{}]uint16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 18) @@ -18323,7 +19545,6 @@ func (_ fastpathT) DecMapIntfUint16V(v map[interface{}]uint16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk interface{} var mv uint16 hasLen := containerLen > 0 @@ -18340,14 +19561,15 @@ func (_ fastpathT) DecMapIntfUint16V(v map[interface{}]uint16, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint16(dd.DecodeUint(16)) + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } @@ -18359,22 +19581,23 @@ func (_ fastpathT) DecMapIntfUint16V(v map[interface{}]uint16, canChange bool, func (d *Decoder) fastpathDecMapIntfUint32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[interface{}]uint32) - if v, changed := fastpathTV.DecMapIntfUint32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntfUint32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntfUint32V(rv2i(rv).(map[interface{}]uint32), false, d) } - fastpathTV.DecMapIntfUint32V(rv2i(rv).(map[interface{}]uint32), false, d) } func (f fastpathT) DecMapIntfUint32X(vp *map[interface{}]uint32, d *Decoder) { - if v, changed := f.DecMapIntfUint32V(*vp, true, d); changed { + v, changed := f.DecMapIntfUint32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntfUint32V(v map[interface{}]uint32, canChange bool, d *Decoder) (_ map[interface{}]uint32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 20) @@ -18385,7 +19608,6 @@ func (_ fastpathT) DecMapIntfUint32V(v map[interface{}]uint32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk interface{} var mv uint32 hasLen := containerLen > 0 @@ -18402,14 +19624,15 @@ func (_ fastpathT) DecMapIntfUint32V(v map[interface{}]uint32, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint32(dd.DecodeUint(32)) + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } @@ -18421,22 +19644,23 @@ func (_ fastpathT) DecMapIntfUint32V(v map[interface{}]uint32, canChange bool, func (d *Decoder) fastpathDecMapIntfUint64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[interface{}]uint64) - if v, changed := fastpathTV.DecMapIntfUint64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntfUint64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntfUint64V(rv2i(rv).(map[interface{}]uint64), false, d) } - fastpathTV.DecMapIntfUint64V(rv2i(rv).(map[interface{}]uint64), false, d) } func (f fastpathT) DecMapIntfUint64X(vp *map[interface{}]uint64, d *Decoder) { - if v, changed := f.DecMapIntfUint64V(*vp, true, d); changed { + v, changed := f.DecMapIntfUint64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntfUint64V(v map[interface{}]uint64, canChange bool, d *Decoder) (_ map[interface{}]uint64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -18447,7 +19671,6 @@ func (_ fastpathT) DecMapIntfUint64V(v map[interface{}]uint64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk interface{} var mv uint64 hasLen := containerLen > 0 @@ -18464,14 +19687,15 @@ func (_ fastpathT) DecMapIntfUint64V(v map[interface{}]uint64, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeUint(64) + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } @@ -18483,22 +19707,23 @@ func (_ fastpathT) DecMapIntfUint64V(v map[interface{}]uint64, canChange bool, func (d *Decoder) fastpathDecMapIntfUintptrR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[interface{}]uintptr) - if v, changed := fastpathTV.DecMapIntfUintptrV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntfUintptrV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntfUintptrV(rv2i(rv).(map[interface{}]uintptr), false, d) } - fastpathTV.DecMapIntfUintptrV(rv2i(rv).(map[interface{}]uintptr), false, d) } func (f fastpathT) DecMapIntfUintptrX(vp *map[interface{}]uintptr, d *Decoder) { - if v, changed := f.DecMapIntfUintptrV(*vp, true, d); changed { + v, changed := f.DecMapIntfUintptrV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntfUintptrV(v map[interface{}]uintptr, canChange bool, d *Decoder) (_ map[interface{}]uintptr, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -18509,7 +19734,6 @@ func (_ fastpathT) DecMapIntfUintptrV(v map[interface{}]uintptr, canChange bool, dd.ReadMapEnd() return v, changed } - var mk interface{} var mv uintptr hasLen := containerLen > 0 @@ -18526,14 +19750,15 @@ func (_ fastpathT) DecMapIntfUintptrV(v map[interface{}]uintptr, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uintptr(dd.DecodeUint(uintBitsize)) + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -18545,22 +19770,23 @@ func (_ fastpathT) DecMapIntfUintptrV(v map[interface{}]uintptr, canChange bool, func (d *Decoder) fastpathDecMapIntfIntR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[interface{}]int) - if v, changed := fastpathTV.DecMapIntfIntV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntfIntV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntfIntV(rv2i(rv).(map[interface{}]int), false, d) } - fastpathTV.DecMapIntfIntV(rv2i(rv).(map[interface{}]int), false, d) } func (f fastpathT) DecMapIntfIntX(vp *map[interface{}]int, d *Decoder) { - if v, changed := f.DecMapIntfIntV(*vp, true, d); changed { + v, changed := f.DecMapIntfIntV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntfIntV(v map[interface{}]int, canChange bool, d *Decoder) (_ map[interface{}]int, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -18571,7 +19797,6 @@ func (_ fastpathT) DecMapIntfIntV(v map[interface{}]int, canChange bool, dd.ReadMapEnd() return v, changed } - var mk interface{} var mv int hasLen := containerLen > 0 @@ -18588,14 +19813,15 @@ func (_ fastpathT) DecMapIntfIntV(v map[interface{}]int, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int(dd.DecodeInt(intBitsize)) + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } @@ -18607,22 +19833,23 @@ func (_ fastpathT) DecMapIntfIntV(v map[interface{}]int, canChange bool, func (d *Decoder) fastpathDecMapIntfInt8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[interface{}]int8) - if v, changed := fastpathTV.DecMapIntfInt8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntfInt8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntfInt8V(rv2i(rv).(map[interface{}]int8), false, d) } - fastpathTV.DecMapIntfInt8V(rv2i(rv).(map[interface{}]int8), false, d) } func (f fastpathT) DecMapIntfInt8X(vp *map[interface{}]int8, d *Decoder) { - if v, changed := f.DecMapIntfInt8V(*vp, true, d); changed { + v, changed := f.DecMapIntfInt8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntfInt8V(v map[interface{}]int8, canChange bool, d *Decoder) (_ map[interface{}]int8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 17) @@ -18633,7 +19860,6 @@ func (_ fastpathT) DecMapIntfInt8V(v map[interface{}]int8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk interface{} var mv int8 hasLen := containerLen > 0 @@ -18650,14 +19876,15 @@ func (_ fastpathT) DecMapIntfInt8V(v map[interface{}]int8, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int8(dd.DecodeInt(8)) + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } @@ -18669,22 +19896,23 @@ func (_ fastpathT) DecMapIntfInt8V(v map[interface{}]int8, canChange bool, func (d *Decoder) fastpathDecMapIntfInt16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[interface{}]int16) - if v, changed := fastpathTV.DecMapIntfInt16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntfInt16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntfInt16V(rv2i(rv).(map[interface{}]int16), false, d) } - fastpathTV.DecMapIntfInt16V(rv2i(rv).(map[interface{}]int16), false, d) } func (f fastpathT) DecMapIntfInt16X(vp *map[interface{}]int16, d *Decoder) { - if v, changed := f.DecMapIntfInt16V(*vp, true, d); changed { + v, changed := f.DecMapIntfInt16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntfInt16V(v map[interface{}]int16, canChange bool, d *Decoder) (_ map[interface{}]int16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 18) @@ -18695,7 +19923,6 @@ func (_ fastpathT) DecMapIntfInt16V(v map[interface{}]int16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk interface{} var mv int16 hasLen := containerLen > 0 @@ -18712,14 +19939,15 @@ func (_ fastpathT) DecMapIntfInt16V(v map[interface{}]int16, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int16(dd.DecodeInt(16)) + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } @@ -18731,22 +19959,23 @@ func (_ fastpathT) DecMapIntfInt16V(v map[interface{}]int16, canChange bool, func (d *Decoder) fastpathDecMapIntfInt32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[interface{}]int32) - if v, changed := fastpathTV.DecMapIntfInt32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntfInt32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntfInt32V(rv2i(rv).(map[interface{}]int32), false, d) } - fastpathTV.DecMapIntfInt32V(rv2i(rv).(map[interface{}]int32), false, d) } func (f fastpathT) DecMapIntfInt32X(vp *map[interface{}]int32, d *Decoder) { - if v, changed := f.DecMapIntfInt32V(*vp, true, d); changed { + v, changed := f.DecMapIntfInt32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntfInt32V(v map[interface{}]int32, canChange bool, d *Decoder) (_ map[interface{}]int32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 20) @@ -18757,7 +19986,6 @@ func (_ fastpathT) DecMapIntfInt32V(v map[interface{}]int32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk interface{} var mv int32 hasLen := containerLen > 0 @@ -18774,14 +20002,15 @@ func (_ fastpathT) DecMapIntfInt32V(v map[interface{}]int32, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int32(dd.DecodeInt(32)) + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } @@ -18793,22 +20022,23 @@ func (_ fastpathT) DecMapIntfInt32V(v map[interface{}]int32, canChange bool, func (d *Decoder) fastpathDecMapIntfInt64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[interface{}]int64) - if v, changed := fastpathTV.DecMapIntfInt64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntfInt64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntfInt64V(rv2i(rv).(map[interface{}]int64), false, d) } - fastpathTV.DecMapIntfInt64V(rv2i(rv).(map[interface{}]int64), false, d) } func (f fastpathT) DecMapIntfInt64X(vp *map[interface{}]int64, d *Decoder) { - if v, changed := f.DecMapIntfInt64V(*vp, true, d); changed { + v, changed := f.DecMapIntfInt64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntfInt64V(v map[interface{}]int64, canChange bool, d *Decoder) (_ map[interface{}]int64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -18819,7 +20049,6 @@ func (_ fastpathT) DecMapIntfInt64V(v map[interface{}]int64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk interface{} var mv int64 hasLen := containerLen > 0 @@ -18836,14 +20065,15 @@ func (_ fastpathT) DecMapIntfInt64V(v map[interface{}]int64, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeInt(64) + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } @@ -18855,22 +20085,23 @@ func (_ fastpathT) DecMapIntfInt64V(v map[interface{}]int64, canChange bool, func (d *Decoder) fastpathDecMapIntfFloat32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[interface{}]float32) - if v, changed := fastpathTV.DecMapIntfFloat32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntfFloat32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntfFloat32V(rv2i(rv).(map[interface{}]float32), false, d) } - fastpathTV.DecMapIntfFloat32V(rv2i(rv).(map[interface{}]float32), false, d) } func (f fastpathT) DecMapIntfFloat32X(vp *map[interface{}]float32, d *Decoder) { - if v, changed := f.DecMapIntfFloat32V(*vp, true, d); changed { + v, changed := f.DecMapIntfFloat32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntfFloat32V(v map[interface{}]float32, canChange bool, d *Decoder) (_ map[interface{}]float32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 20) @@ -18881,7 +20112,6 @@ func (_ fastpathT) DecMapIntfFloat32V(v map[interface{}]float32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk interface{} var mv float32 hasLen := containerLen > 0 @@ -18898,14 +20128,15 @@ func (_ fastpathT) DecMapIntfFloat32V(v map[interface{}]float32, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = float32(dd.DecodeFloat(true)) + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } @@ -18917,22 +20148,23 @@ func (_ fastpathT) DecMapIntfFloat32V(v map[interface{}]float32, canChange bool, func (d *Decoder) fastpathDecMapIntfFloat64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[interface{}]float64) - if v, changed := fastpathTV.DecMapIntfFloat64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntfFloat64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntfFloat64V(rv2i(rv).(map[interface{}]float64), false, d) } - fastpathTV.DecMapIntfFloat64V(rv2i(rv).(map[interface{}]float64), false, d) } func (f fastpathT) DecMapIntfFloat64X(vp *map[interface{}]float64, d *Decoder) { - if v, changed := f.DecMapIntfFloat64V(*vp, true, d); changed { + v, changed := f.DecMapIntfFloat64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntfFloat64V(v map[interface{}]float64, canChange bool, d *Decoder) (_ map[interface{}]float64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -18943,7 +20175,6 @@ func (_ fastpathT) DecMapIntfFloat64V(v map[interface{}]float64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk interface{} var mv float64 hasLen := containerLen > 0 @@ -18960,14 +20191,15 @@ func (_ fastpathT) DecMapIntfFloat64V(v map[interface{}]float64, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeFloat(false) + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } @@ -18979,22 +20211,23 @@ func (_ fastpathT) DecMapIntfFloat64V(v map[interface{}]float64, canChange bool, func (d *Decoder) fastpathDecMapIntfBoolR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[interface{}]bool) - if v, changed := fastpathTV.DecMapIntfBoolV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntfBoolV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntfBoolV(rv2i(rv).(map[interface{}]bool), false, d) } - fastpathTV.DecMapIntfBoolV(rv2i(rv).(map[interface{}]bool), false, d) } func (f fastpathT) DecMapIntfBoolX(vp *map[interface{}]bool, d *Decoder) { - if v, changed := f.DecMapIntfBoolV(*vp, true, d); changed { + v, changed := f.DecMapIntfBoolV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntfBoolV(v map[interface{}]bool, canChange bool, d *Decoder) (_ map[interface{}]bool, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 17) @@ -19005,7 +20238,6 @@ func (_ fastpathT) DecMapIntfBoolV(v map[interface{}]bool, canChange bool, dd.ReadMapEnd() return v, changed } - var mk interface{} var mv bool hasLen := containerLen > 0 @@ -19022,7 +20254,8 @@ func (_ fastpathT) DecMapIntfBoolV(v map[interface{}]bool, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = false @@ -19041,22 +20274,23 @@ func (_ fastpathT) DecMapIntfBoolV(v map[interface{}]bool, canChange bool, func (d *Decoder) fastpathDecMapStringIntfR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[string]interface{}) - if v, changed := fastpathTV.DecMapStringIntfV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapStringIntfV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapStringIntfV(rv2i(rv).(map[string]interface{}), false, d) } - fastpathTV.DecMapStringIntfV(rv2i(rv).(map[string]interface{}), false, d) } func (f fastpathT) DecMapStringIntfX(vp *map[string]interface{}, d *Decoder) { - if v, changed := f.DecMapStringIntfV(*vp, true, d); changed { + v, changed := f.DecMapStringIntfV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapStringIntfV(v map[string]interface{}, canChange bool, d *Decoder) (_ map[string]interface{}, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 32) @@ -19067,7 +20301,7 @@ func (_ fastpathT) DecMapStringIntfV(v map[string]interface{}, canChange bool, dd.ReadMapEnd() return v, changed } - mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset var mk string var mv interface{} hasLen := containerLen > 0 @@ -19080,7 +20314,8 @@ func (_ fastpathT) DecMapStringIntfV(v map[string]interface{}, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = nil @@ -19104,22 +20339,23 @@ func (_ fastpathT) DecMapStringIntfV(v map[string]interface{}, canChange bool, func (d *Decoder) fastpathDecMapStringStringR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[string]string) - if v, changed := fastpathTV.DecMapStringStringV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapStringStringV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapStringStringV(rv2i(rv).(map[string]string), false, d) } - fastpathTV.DecMapStringStringV(rv2i(rv).(map[string]string), false, d) } func (f fastpathT) DecMapStringStringX(vp *map[string]string, d *Decoder) { - if v, changed := f.DecMapStringStringV(*vp, true, d); changed { + v, changed := f.DecMapStringStringV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapStringStringV(v map[string]string, canChange bool, d *Decoder) (_ map[string]string, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 32) @@ -19130,7 +20366,6 @@ func (_ fastpathT) DecMapStringStringV(v map[string]string, canChange bool, dd.ReadMapEnd() return v, changed } - var mk string var mv string hasLen := containerLen > 0 @@ -19143,7 +20378,8 @@ func (_ fastpathT) DecMapStringStringV(v map[string]string, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = "" @@ -19162,22 +20398,23 @@ func (_ fastpathT) DecMapStringStringV(v map[string]string, canChange bool, func (d *Decoder) fastpathDecMapStringUintR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[string]uint) - if v, changed := fastpathTV.DecMapStringUintV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapStringUintV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapStringUintV(rv2i(rv).(map[string]uint), false, d) } - fastpathTV.DecMapStringUintV(rv2i(rv).(map[string]uint), false, d) } func (f fastpathT) DecMapStringUintX(vp *map[string]uint, d *Decoder) { - if v, changed := f.DecMapStringUintV(*vp, true, d); changed { + v, changed := f.DecMapStringUintV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapStringUintV(v map[string]uint, canChange bool, d *Decoder) (_ map[string]uint, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -19188,7 +20425,6 @@ func (_ fastpathT) DecMapStringUintV(v map[string]uint, canChange bool, dd.ReadMapEnd() return v, changed } - var mk string var mv uint hasLen := containerLen > 0 @@ -19201,14 +20437,15 @@ func (_ fastpathT) DecMapStringUintV(v map[string]uint, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint(dd.DecodeUint(uintBitsize)) + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -19220,22 +20457,23 @@ func (_ fastpathT) DecMapStringUintV(v map[string]uint, canChange bool, func (d *Decoder) fastpathDecMapStringUint8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[string]uint8) - if v, changed := fastpathTV.DecMapStringUint8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapStringUint8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapStringUint8V(rv2i(rv).(map[string]uint8), false, d) } - fastpathTV.DecMapStringUint8V(rv2i(rv).(map[string]uint8), false, d) } func (f fastpathT) DecMapStringUint8X(vp *map[string]uint8, d *Decoder) { - if v, changed := f.DecMapStringUint8V(*vp, true, d); changed { + v, changed := f.DecMapStringUint8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapStringUint8V(v map[string]uint8, canChange bool, d *Decoder) (_ map[string]uint8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 17) @@ -19246,7 +20484,6 @@ func (_ fastpathT) DecMapStringUint8V(v map[string]uint8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk string var mv uint8 hasLen := containerLen > 0 @@ -19259,14 +20496,15 @@ func (_ fastpathT) DecMapStringUint8V(v map[string]uint8, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint8(dd.DecodeUint(8)) + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } @@ -19278,22 +20516,23 @@ func (_ fastpathT) DecMapStringUint8V(v map[string]uint8, canChange bool, func (d *Decoder) fastpathDecMapStringUint16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[string]uint16) - if v, changed := fastpathTV.DecMapStringUint16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapStringUint16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapStringUint16V(rv2i(rv).(map[string]uint16), false, d) } - fastpathTV.DecMapStringUint16V(rv2i(rv).(map[string]uint16), false, d) } func (f fastpathT) DecMapStringUint16X(vp *map[string]uint16, d *Decoder) { - if v, changed := f.DecMapStringUint16V(*vp, true, d); changed { + v, changed := f.DecMapStringUint16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapStringUint16V(v map[string]uint16, canChange bool, d *Decoder) (_ map[string]uint16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 18) @@ -19304,7 +20543,6 @@ func (_ fastpathT) DecMapStringUint16V(v map[string]uint16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk string var mv uint16 hasLen := containerLen > 0 @@ -19317,14 +20555,15 @@ func (_ fastpathT) DecMapStringUint16V(v map[string]uint16, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint16(dd.DecodeUint(16)) + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } @@ -19336,22 +20575,23 @@ func (_ fastpathT) DecMapStringUint16V(v map[string]uint16, canChange bool, func (d *Decoder) fastpathDecMapStringUint32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[string]uint32) - if v, changed := fastpathTV.DecMapStringUint32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapStringUint32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapStringUint32V(rv2i(rv).(map[string]uint32), false, d) } - fastpathTV.DecMapStringUint32V(rv2i(rv).(map[string]uint32), false, d) } func (f fastpathT) DecMapStringUint32X(vp *map[string]uint32, d *Decoder) { - if v, changed := f.DecMapStringUint32V(*vp, true, d); changed { + v, changed := f.DecMapStringUint32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapStringUint32V(v map[string]uint32, canChange bool, d *Decoder) (_ map[string]uint32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 20) @@ -19362,7 +20602,6 @@ func (_ fastpathT) DecMapStringUint32V(v map[string]uint32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk string var mv uint32 hasLen := containerLen > 0 @@ -19375,14 +20614,15 @@ func (_ fastpathT) DecMapStringUint32V(v map[string]uint32, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint32(dd.DecodeUint(32)) + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } @@ -19394,22 +20634,23 @@ func (_ fastpathT) DecMapStringUint32V(v map[string]uint32, canChange bool, func (d *Decoder) fastpathDecMapStringUint64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[string]uint64) - if v, changed := fastpathTV.DecMapStringUint64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapStringUint64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapStringUint64V(rv2i(rv).(map[string]uint64), false, d) } - fastpathTV.DecMapStringUint64V(rv2i(rv).(map[string]uint64), false, d) } func (f fastpathT) DecMapStringUint64X(vp *map[string]uint64, d *Decoder) { - if v, changed := f.DecMapStringUint64V(*vp, true, d); changed { + v, changed := f.DecMapStringUint64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapStringUint64V(v map[string]uint64, canChange bool, d *Decoder) (_ map[string]uint64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -19420,7 +20661,6 @@ func (_ fastpathT) DecMapStringUint64V(v map[string]uint64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk string var mv uint64 hasLen := containerLen > 0 @@ -19433,14 +20673,15 @@ func (_ fastpathT) DecMapStringUint64V(v map[string]uint64, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeUint(64) + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } @@ -19452,22 +20693,23 @@ func (_ fastpathT) DecMapStringUint64V(v map[string]uint64, canChange bool, func (d *Decoder) fastpathDecMapStringUintptrR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[string]uintptr) - if v, changed := fastpathTV.DecMapStringUintptrV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapStringUintptrV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapStringUintptrV(rv2i(rv).(map[string]uintptr), false, d) } - fastpathTV.DecMapStringUintptrV(rv2i(rv).(map[string]uintptr), false, d) } func (f fastpathT) DecMapStringUintptrX(vp *map[string]uintptr, d *Decoder) { - if v, changed := f.DecMapStringUintptrV(*vp, true, d); changed { + v, changed := f.DecMapStringUintptrV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapStringUintptrV(v map[string]uintptr, canChange bool, d *Decoder) (_ map[string]uintptr, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -19478,7 +20720,6 @@ func (_ fastpathT) DecMapStringUintptrV(v map[string]uintptr, canChange bool, dd.ReadMapEnd() return v, changed } - var mk string var mv uintptr hasLen := containerLen > 0 @@ -19491,14 +20732,15 @@ func (_ fastpathT) DecMapStringUintptrV(v map[string]uintptr, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uintptr(dd.DecodeUint(uintBitsize)) + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -19510,22 +20752,23 @@ func (_ fastpathT) DecMapStringUintptrV(v map[string]uintptr, canChange bool, func (d *Decoder) fastpathDecMapStringIntR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[string]int) - if v, changed := fastpathTV.DecMapStringIntV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapStringIntV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapStringIntV(rv2i(rv).(map[string]int), false, d) } - fastpathTV.DecMapStringIntV(rv2i(rv).(map[string]int), false, d) } func (f fastpathT) DecMapStringIntX(vp *map[string]int, d *Decoder) { - if v, changed := f.DecMapStringIntV(*vp, true, d); changed { + v, changed := f.DecMapStringIntV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapStringIntV(v map[string]int, canChange bool, d *Decoder) (_ map[string]int, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -19536,7 +20779,6 @@ func (_ fastpathT) DecMapStringIntV(v map[string]int, canChange bool, dd.ReadMapEnd() return v, changed } - var mk string var mv int hasLen := containerLen > 0 @@ -19549,14 +20791,15 @@ func (_ fastpathT) DecMapStringIntV(v map[string]int, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int(dd.DecodeInt(intBitsize)) + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } @@ -19568,22 +20811,23 @@ func (_ fastpathT) DecMapStringIntV(v map[string]int, canChange bool, func (d *Decoder) fastpathDecMapStringInt8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[string]int8) - if v, changed := fastpathTV.DecMapStringInt8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapStringInt8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapStringInt8V(rv2i(rv).(map[string]int8), false, d) } - fastpathTV.DecMapStringInt8V(rv2i(rv).(map[string]int8), false, d) } func (f fastpathT) DecMapStringInt8X(vp *map[string]int8, d *Decoder) { - if v, changed := f.DecMapStringInt8V(*vp, true, d); changed { + v, changed := f.DecMapStringInt8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapStringInt8V(v map[string]int8, canChange bool, d *Decoder) (_ map[string]int8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 17) @@ -19594,7 +20838,6 @@ func (_ fastpathT) DecMapStringInt8V(v map[string]int8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk string var mv int8 hasLen := containerLen > 0 @@ -19607,14 +20850,15 @@ func (_ fastpathT) DecMapStringInt8V(v map[string]int8, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int8(dd.DecodeInt(8)) + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } @@ -19626,22 +20870,23 @@ func (_ fastpathT) DecMapStringInt8V(v map[string]int8, canChange bool, func (d *Decoder) fastpathDecMapStringInt16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[string]int16) - if v, changed := fastpathTV.DecMapStringInt16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapStringInt16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapStringInt16V(rv2i(rv).(map[string]int16), false, d) } - fastpathTV.DecMapStringInt16V(rv2i(rv).(map[string]int16), false, d) } func (f fastpathT) DecMapStringInt16X(vp *map[string]int16, d *Decoder) { - if v, changed := f.DecMapStringInt16V(*vp, true, d); changed { + v, changed := f.DecMapStringInt16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapStringInt16V(v map[string]int16, canChange bool, d *Decoder) (_ map[string]int16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 18) @@ -19652,7 +20897,6 @@ func (_ fastpathT) DecMapStringInt16V(v map[string]int16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk string var mv int16 hasLen := containerLen > 0 @@ -19665,14 +20909,15 @@ func (_ fastpathT) DecMapStringInt16V(v map[string]int16, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int16(dd.DecodeInt(16)) + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } @@ -19684,22 +20929,23 @@ func (_ fastpathT) DecMapStringInt16V(v map[string]int16, canChange bool, func (d *Decoder) fastpathDecMapStringInt32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[string]int32) - if v, changed := fastpathTV.DecMapStringInt32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapStringInt32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapStringInt32V(rv2i(rv).(map[string]int32), false, d) } - fastpathTV.DecMapStringInt32V(rv2i(rv).(map[string]int32), false, d) } func (f fastpathT) DecMapStringInt32X(vp *map[string]int32, d *Decoder) { - if v, changed := f.DecMapStringInt32V(*vp, true, d); changed { + v, changed := f.DecMapStringInt32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapStringInt32V(v map[string]int32, canChange bool, d *Decoder) (_ map[string]int32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 20) @@ -19710,7 +20956,6 @@ func (_ fastpathT) DecMapStringInt32V(v map[string]int32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk string var mv int32 hasLen := containerLen > 0 @@ -19723,14 +20968,15 @@ func (_ fastpathT) DecMapStringInt32V(v map[string]int32, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int32(dd.DecodeInt(32)) + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } @@ -19742,22 +20988,23 @@ func (_ fastpathT) DecMapStringInt32V(v map[string]int32, canChange bool, func (d *Decoder) fastpathDecMapStringInt64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[string]int64) - if v, changed := fastpathTV.DecMapStringInt64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapStringInt64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapStringInt64V(rv2i(rv).(map[string]int64), false, d) } - fastpathTV.DecMapStringInt64V(rv2i(rv).(map[string]int64), false, d) } func (f fastpathT) DecMapStringInt64X(vp *map[string]int64, d *Decoder) { - if v, changed := f.DecMapStringInt64V(*vp, true, d); changed { + v, changed := f.DecMapStringInt64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapStringInt64V(v map[string]int64, canChange bool, d *Decoder) (_ map[string]int64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -19768,7 +21015,6 @@ func (_ fastpathT) DecMapStringInt64V(v map[string]int64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk string var mv int64 hasLen := containerLen > 0 @@ -19781,14 +21027,15 @@ func (_ fastpathT) DecMapStringInt64V(v map[string]int64, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeInt(64) + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } @@ -19800,22 +21047,23 @@ func (_ fastpathT) DecMapStringInt64V(v map[string]int64, canChange bool, func (d *Decoder) fastpathDecMapStringFloat32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[string]float32) - if v, changed := fastpathTV.DecMapStringFloat32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapStringFloat32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapStringFloat32V(rv2i(rv).(map[string]float32), false, d) } - fastpathTV.DecMapStringFloat32V(rv2i(rv).(map[string]float32), false, d) } func (f fastpathT) DecMapStringFloat32X(vp *map[string]float32, d *Decoder) { - if v, changed := f.DecMapStringFloat32V(*vp, true, d); changed { + v, changed := f.DecMapStringFloat32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapStringFloat32V(v map[string]float32, canChange bool, d *Decoder) (_ map[string]float32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 20) @@ -19826,7 +21074,6 @@ func (_ fastpathT) DecMapStringFloat32V(v map[string]float32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk string var mv float32 hasLen := containerLen > 0 @@ -19839,14 +21086,15 @@ func (_ fastpathT) DecMapStringFloat32V(v map[string]float32, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = float32(dd.DecodeFloat(true)) + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } @@ -19858,22 +21106,23 @@ func (_ fastpathT) DecMapStringFloat32V(v map[string]float32, canChange bool, func (d *Decoder) fastpathDecMapStringFloat64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[string]float64) - if v, changed := fastpathTV.DecMapStringFloat64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapStringFloat64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapStringFloat64V(rv2i(rv).(map[string]float64), false, d) } - fastpathTV.DecMapStringFloat64V(rv2i(rv).(map[string]float64), false, d) } func (f fastpathT) DecMapStringFloat64X(vp *map[string]float64, d *Decoder) { - if v, changed := f.DecMapStringFloat64V(*vp, true, d); changed { + v, changed := f.DecMapStringFloat64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapStringFloat64V(v map[string]float64, canChange bool, d *Decoder) (_ map[string]float64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -19884,7 +21133,6 @@ func (_ fastpathT) DecMapStringFloat64V(v map[string]float64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk string var mv float64 hasLen := containerLen > 0 @@ -19897,14 +21145,15 @@ func (_ fastpathT) DecMapStringFloat64V(v map[string]float64, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeFloat(false) + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } @@ -19916,22 +21165,23 @@ func (_ fastpathT) DecMapStringFloat64V(v map[string]float64, canChange bool, func (d *Decoder) fastpathDecMapStringBoolR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[string]bool) - if v, changed := fastpathTV.DecMapStringBoolV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapStringBoolV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapStringBoolV(rv2i(rv).(map[string]bool), false, d) } - fastpathTV.DecMapStringBoolV(rv2i(rv).(map[string]bool), false, d) } func (f fastpathT) DecMapStringBoolX(vp *map[string]bool, d *Decoder) { - if v, changed := f.DecMapStringBoolV(*vp, true, d); changed { + v, changed := f.DecMapStringBoolV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapStringBoolV(v map[string]bool, canChange bool, d *Decoder) (_ map[string]bool, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 17) @@ -19942,7 +21192,6 @@ func (_ fastpathT) DecMapStringBoolV(v map[string]bool, canChange bool, dd.ReadMapEnd() return v, changed } - var mk string var mv bool hasLen := containerLen > 0 @@ -19955,7 +21204,8 @@ func (_ fastpathT) DecMapStringBoolV(v map[string]bool, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = false @@ -19974,22 +21224,23 @@ func (_ fastpathT) DecMapStringBoolV(v map[string]bool, canChange bool, func (d *Decoder) fastpathDecMapFloat32IntfR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float32]interface{}) - if v, changed := fastpathTV.DecMapFloat32IntfV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat32IntfV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat32IntfV(rv2i(rv).(map[float32]interface{}), false, d) } - fastpathTV.DecMapFloat32IntfV(rv2i(rv).(map[float32]interface{}), false, d) } func (f fastpathT) DecMapFloat32IntfX(vp *map[float32]interface{}, d *Decoder) { - if v, changed := f.DecMapFloat32IntfV(*vp, true, d); changed { + v, changed := f.DecMapFloat32IntfV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat32IntfV(v map[float32]interface{}, canChange bool, d *Decoder) (_ map[float32]interface{}, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 20) @@ -20000,7 +21251,7 @@ func (_ fastpathT) DecMapFloat32IntfV(v map[float32]interface{}, canChange bool, dd.ReadMapEnd() return v, changed } - mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset var mk float32 var mv interface{} hasLen := containerLen > 0 @@ -20008,12 +21259,13 @@ func (_ fastpathT) DecMapFloat32IntfV(v map[float32]interface{}, canChange bool, if esep { dd.ReadMapElemKey() } - mk = float32(dd.DecodeFloat(true)) + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = nil @@ -20037,22 +21289,23 @@ func (_ fastpathT) DecMapFloat32IntfV(v map[float32]interface{}, canChange bool, func (d *Decoder) fastpathDecMapFloat32StringR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float32]string) - if v, changed := fastpathTV.DecMapFloat32StringV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat32StringV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat32StringV(rv2i(rv).(map[float32]string), false, d) } - fastpathTV.DecMapFloat32StringV(rv2i(rv).(map[float32]string), false, d) } func (f fastpathT) DecMapFloat32StringX(vp *map[float32]string, d *Decoder) { - if v, changed := f.DecMapFloat32StringV(*vp, true, d); changed { + v, changed := f.DecMapFloat32StringV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat32StringV(v map[float32]string, canChange bool, d *Decoder) (_ map[float32]string, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 20) @@ -20063,7 +21316,6 @@ func (_ fastpathT) DecMapFloat32StringV(v map[float32]string, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float32 var mv string hasLen := containerLen > 0 @@ -20071,12 +21323,13 @@ func (_ fastpathT) DecMapFloat32StringV(v map[float32]string, canChange bool, if esep { dd.ReadMapElemKey() } - mk = float32(dd.DecodeFloat(true)) + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = "" @@ -20095,22 +21348,23 @@ func (_ fastpathT) DecMapFloat32StringV(v map[float32]string, canChange bool, func (d *Decoder) fastpathDecMapFloat32UintR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float32]uint) - if v, changed := fastpathTV.DecMapFloat32UintV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat32UintV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat32UintV(rv2i(rv).(map[float32]uint), false, d) } - fastpathTV.DecMapFloat32UintV(rv2i(rv).(map[float32]uint), false, d) } func (f fastpathT) DecMapFloat32UintX(vp *map[float32]uint, d *Decoder) { - if v, changed := f.DecMapFloat32UintV(*vp, true, d); changed { + v, changed := f.DecMapFloat32UintV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat32UintV(v map[float32]uint, canChange bool, d *Decoder) (_ map[float32]uint, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -20121,7 +21375,6 @@ func (_ fastpathT) DecMapFloat32UintV(v map[float32]uint, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float32 var mv uint hasLen := containerLen > 0 @@ -20129,19 +21382,20 @@ func (_ fastpathT) DecMapFloat32UintV(v map[float32]uint, canChange bool, if esep { dd.ReadMapElemKey() } - mk = float32(dd.DecodeFloat(true)) + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint(dd.DecodeUint(uintBitsize)) + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -20153,22 +21407,23 @@ func (_ fastpathT) DecMapFloat32UintV(v map[float32]uint, canChange bool, func (d *Decoder) fastpathDecMapFloat32Uint8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float32]uint8) - if v, changed := fastpathTV.DecMapFloat32Uint8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat32Uint8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat32Uint8V(rv2i(rv).(map[float32]uint8), false, d) } - fastpathTV.DecMapFloat32Uint8V(rv2i(rv).(map[float32]uint8), false, d) } func (f fastpathT) DecMapFloat32Uint8X(vp *map[float32]uint8, d *Decoder) { - if v, changed := f.DecMapFloat32Uint8V(*vp, true, d); changed { + v, changed := f.DecMapFloat32Uint8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat32Uint8V(v map[float32]uint8, canChange bool, d *Decoder) (_ map[float32]uint8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 5) @@ -20179,7 +21434,6 @@ func (_ fastpathT) DecMapFloat32Uint8V(v map[float32]uint8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float32 var mv uint8 hasLen := containerLen > 0 @@ -20187,19 +21441,20 @@ func (_ fastpathT) DecMapFloat32Uint8V(v map[float32]uint8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = float32(dd.DecodeFloat(true)) + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint8(dd.DecodeUint(8)) + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } @@ -20211,22 +21466,23 @@ func (_ fastpathT) DecMapFloat32Uint8V(v map[float32]uint8, canChange bool, func (d *Decoder) fastpathDecMapFloat32Uint16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float32]uint16) - if v, changed := fastpathTV.DecMapFloat32Uint16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat32Uint16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat32Uint16V(rv2i(rv).(map[float32]uint16), false, d) } - fastpathTV.DecMapFloat32Uint16V(rv2i(rv).(map[float32]uint16), false, d) } func (f fastpathT) DecMapFloat32Uint16X(vp *map[float32]uint16, d *Decoder) { - if v, changed := f.DecMapFloat32Uint16V(*vp, true, d); changed { + v, changed := f.DecMapFloat32Uint16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat32Uint16V(v map[float32]uint16, canChange bool, d *Decoder) (_ map[float32]uint16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 6) @@ -20237,7 +21493,6 @@ func (_ fastpathT) DecMapFloat32Uint16V(v map[float32]uint16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float32 var mv uint16 hasLen := containerLen > 0 @@ -20245,19 +21500,20 @@ func (_ fastpathT) DecMapFloat32Uint16V(v map[float32]uint16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = float32(dd.DecodeFloat(true)) + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint16(dd.DecodeUint(16)) + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } @@ -20269,22 +21525,23 @@ func (_ fastpathT) DecMapFloat32Uint16V(v map[float32]uint16, canChange bool, func (d *Decoder) fastpathDecMapFloat32Uint32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float32]uint32) - if v, changed := fastpathTV.DecMapFloat32Uint32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat32Uint32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat32Uint32V(rv2i(rv).(map[float32]uint32), false, d) } - fastpathTV.DecMapFloat32Uint32V(rv2i(rv).(map[float32]uint32), false, d) } func (f fastpathT) DecMapFloat32Uint32X(vp *map[float32]uint32, d *Decoder) { - if v, changed := f.DecMapFloat32Uint32V(*vp, true, d); changed { + v, changed := f.DecMapFloat32Uint32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat32Uint32V(v map[float32]uint32, canChange bool, d *Decoder) (_ map[float32]uint32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 8) @@ -20295,7 +21552,6 @@ func (_ fastpathT) DecMapFloat32Uint32V(v map[float32]uint32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float32 var mv uint32 hasLen := containerLen > 0 @@ -20303,19 +21559,20 @@ func (_ fastpathT) DecMapFloat32Uint32V(v map[float32]uint32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = float32(dd.DecodeFloat(true)) + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint32(dd.DecodeUint(32)) + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } @@ -20327,22 +21584,23 @@ func (_ fastpathT) DecMapFloat32Uint32V(v map[float32]uint32, canChange bool, func (d *Decoder) fastpathDecMapFloat32Uint64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float32]uint64) - if v, changed := fastpathTV.DecMapFloat32Uint64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat32Uint64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat32Uint64V(rv2i(rv).(map[float32]uint64), false, d) } - fastpathTV.DecMapFloat32Uint64V(rv2i(rv).(map[float32]uint64), false, d) } func (f fastpathT) DecMapFloat32Uint64X(vp *map[float32]uint64, d *Decoder) { - if v, changed := f.DecMapFloat32Uint64V(*vp, true, d); changed { + v, changed := f.DecMapFloat32Uint64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat32Uint64V(v map[float32]uint64, canChange bool, d *Decoder) (_ map[float32]uint64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -20353,7 +21611,6 @@ func (_ fastpathT) DecMapFloat32Uint64V(v map[float32]uint64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float32 var mv uint64 hasLen := containerLen > 0 @@ -20361,19 +21618,20 @@ func (_ fastpathT) DecMapFloat32Uint64V(v map[float32]uint64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = float32(dd.DecodeFloat(true)) + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeUint(64) + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } @@ -20385,22 +21643,23 @@ func (_ fastpathT) DecMapFloat32Uint64V(v map[float32]uint64, canChange bool, func (d *Decoder) fastpathDecMapFloat32UintptrR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float32]uintptr) - if v, changed := fastpathTV.DecMapFloat32UintptrV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat32UintptrV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat32UintptrV(rv2i(rv).(map[float32]uintptr), false, d) } - fastpathTV.DecMapFloat32UintptrV(rv2i(rv).(map[float32]uintptr), false, d) } func (f fastpathT) DecMapFloat32UintptrX(vp *map[float32]uintptr, d *Decoder) { - if v, changed := f.DecMapFloat32UintptrV(*vp, true, d); changed { + v, changed := f.DecMapFloat32UintptrV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat32UintptrV(v map[float32]uintptr, canChange bool, d *Decoder) (_ map[float32]uintptr, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -20411,7 +21670,6 @@ func (_ fastpathT) DecMapFloat32UintptrV(v map[float32]uintptr, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float32 var mv uintptr hasLen := containerLen > 0 @@ -20419,19 +21677,20 @@ func (_ fastpathT) DecMapFloat32UintptrV(v map[float32]uintptr, canChange bool, if esep { dd.ReadMapElemKey() } - mk = float32(dd.DecodeFloat(true)) + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uintptr(dd.DecodeUint(uintBitsize)) + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -20443,22 +21702,23 @@ func (_ fastpathT) DecMapFloat32UintptrV(v map[float32]uintptr, canChange bool, func (d *Decoder) fastpathDecMapFloat32IntR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float32]int) - if v, changed := fastpathTV.DecMapFloat32IntV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat32IntV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat32IntV(rv2i(rv).(map[float32]int), false, d) } - fastpathTV.DecMapFloat32IntV(rv2i(rv).(map[float32]int), false, d) } func (f fastpathT) DecMapFloat32IntX(vp *map[float32]int, d *Decoder) { - if v, changed := f.DecMapFloat32IntV(*vp, true, d); changed { + v, changed := f.DecMapFloat32IntV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat32IntV(v map[float32]int, canChange bool, d *Decoder) (_ map[float32]int, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -20469,7 +21729,6 @@ func (_ fastpathT) DecMapFloat32IntV(v map[float32]int, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float32 var mv int hasLen := containerLen > 0 @@ -20477,19 +21736,20 @@ func (_ fastpathT) DecMapFloat32IntV(v map[float32]int, canChange bool, if esep { dd.ReadMapElemKey() } - mk = float32(dd.DecodeFloat(true)) + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int(dd.DecodeInt(intBitsize)) + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } @@ -20501,22 +21761,23 @@ func (_ fastpathT) DecMapFloat32IntV(v map[float32]int, canChange bool, func (d *Decoder) fastpathDecMapFloat32Int8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float32]int8) - if v, changed := fastpathTV.DecMapFloat32Int8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat32Int8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat32Int8V(rv2i(rv).(map[float32]int8), false, d) } - fastpathTV.DecMapFloat32Int8V(rv2i(rv).(map[float32]int8), false, d) } func (f fastpathT) DecMapFloat32Int8X(vp *map[float32]int8, d *Decoder) { - if v, changed := f.DecMapFloat32Int8V(*vp, true, d); changed { + v, changed := f.DecMapFloat32Int8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat32Int8V(v map[float32]int8, canChange bool, d *Decoder) (_ map[float32]int8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 5) @@ -20527,7 +21788,6 @@ func (_ fastpathT) DecMapFloat32Int8V(v map[float32]int8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float32 var mv int8 hasLen := containerLen > 0 @@ -20535,19 +21795,20 @@ func (_ fastpathT) DecMapFloat32Int8V(v map[float32]int8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = float32(dd.DecodeFloat(true)) + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int8(dd.DecodeInt(8)) + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } @@ -20559,22 +21820,23 @@ func (_ fastpathT) DecMapFloat32Int8V(v map[float32]int8, canChange bool, func (d *Decoder) fastpathDecMapFloat32Int16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float32]int16) - if v, changed := fastpathTV.DecMapFloat32Int16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat32Int16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat32Int16V(rv2i(rv).(map[float32]int16), false, d) } - fastpathTV.DecMapFloat32Int16V(rv2i(rv).(map[float32]int16), false, d) } func (f fastpathT) DecMapFloat32Int16X(vp *map[float32]int16, d *Decoder) { - if v, changed := f.DecMapFloat32Int16V(*vp, true, d); changed { + v, changed := f.DecMapFloat32Int16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat32Int16V(v map[float32]int16, canChange bool, d *Decoder) (_ map[float32]int16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 6) @@ -20585,7 +21847,6 @@ func (_ fastpathT) DecMapFloat32Int16V(v map[float32]int16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float32 var mv int16 hasLen := containerLen > 0 @@ -20593,19 +21854,20 @@ func (_ fastpathT) DecMapFloat32Int16V(v map[float32]int16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = float32(dd.DecodeFloat(true)) + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int16(dd.DecodeInt(16)) + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } @@ -20617,22 +21879,23 @@ func (_ fastpathT) DecMapFloat32Int16V(v map[float32]int16, canChange bool, func (d *Decoder) fastpathDecMapFloat32Int32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float32]int32) - if v, changed := fastpathTV.DecMapFloat32Int32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat32Int32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat32Int32V(rv2i(rv).(map[float32]int32), false, d) } - fastpathTV.DecMapFloat32Int32V(rv2i(rv).(map[float32]int32), false, d) } func (f fastpathT) DecMapFloat32Int32X(vp *map[float32]int32, d *Decoder) { - if v, changed := f.DecMapFloat32Int32V(*vp, true, d); changed { + v, changed := f.DecMapFloat32Int32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat32Int32V(v map[float32]int32, canChange bool, d *Decoder) (_ map[float32]int32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 8) @@ -20643,7 +21906,6 @@ func (_ fastpathT) DecMapFloat32Int32V(v map[float32]int32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float32 var mv int32 hasLen := containerLen > 0 @@ -20651,19 +21913,20 @@ func (_ fastpathT) DecMapFloat32Int32V(v map[float32]int32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = float32(dd.DecodeFloat(true)) + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int32(dd.DecodeInt(32)) + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } @@ -20675,22 +21938,23 @@ func (_ fastpathT) DecMapFloat32Int32V(v map[float32]int32, canChange bool, func (d *Decoder) fastpathDecMapFloat32Int64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float32]int64) - if v, changed := fastpathTV.DecMapFloat32Int64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat32Int64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat32Int64V(rv2i(rv).(map[float32]int64), false, d) } - fastpathTV.DecMapFloat32Int64V(rv2i(rv).(map[float32]int64), false, d) } func (f fastpathT) DecMapFloat32Int64X(vp *map[float32]int64, d *Decoder) { - if v, changed := f.DecMapFloat32Int64V(*vp, true, d); changed { + v, changed := f.DecMapFloat32Int64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat32Int64V(v map[float32]int64, canChange bool, d *Decoder) (_ map[float32]int64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -20701,7 +21965,6 @@ func (_ fastpathT) DecMapFloat32Int64V(v map[float32]int64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float32 var mv int64 hasLen := containerLen > 0 @@ -20709,19 +21972,20 @@ func (_ fastpathT) DecMapFloat32Int64V(v map[float32]int64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = float32(dd.DecodeFloat(true)) + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeInt(64) + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } @@ -20733,22 +21997,23 @@ func (_ fastpathT) DecMapFloat32Int64V(v map[float32]int64, canChange bool, func (d *Decoder) fastpathDecMapFloat32Float32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float32]float32) - if v, changed := fastpathTV.DecMapFloat32Float32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat32Float32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat32Float32V(rv2i(rv).(map[float32]float32), false, d) } - fastpathTV.DecMapFloat32Float32V(rv2i(rv).(map[float32]float32), false, d) } func (f fastpathT) DecMapFloat32Float32X(vp *map[float32]float32, d *Decoder) { - if v, changed := f.DecMapFloat32Float32V(*vp, true, d); changed { + v, changed := f.DecMapFloat32Float32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat32Float32V(v map[float32]float32, canChange bool, d *Decoder) (_ map[float32]float32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 8) @@ -20759,7 +22024,6 @@ func (_ fastpathT) DecMapFloat32Float32V(v map[float32]float32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float32 var mv float32 hasLen := containerLen > 0 @@ -20767,19 +22031,20 @@ func (_ fastpathT) DecMapFloat32Float32V(v map[float32]float32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = float32(dd.DecodeFloat(true)) + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = float32(dd.DecodeFloat(true)) + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } @@ -20791,22 +22056,23 @@ func (_ fastpathT) DecMapFloat32Float32V(v map[float32]float32, canChange bool, func (d *Decoder) fastpathDecMapFloat32Float64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float32]float64) - if v, changed := fastpathTV.DecMapFloat32Float64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat32Float64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat32Float64V(rv2i(rv).(map[float32]float64), false, d) } - fastpathTV.DecMapFloat32Float64V(rv2i(rv).(map[float32]float64), false, d) } func (f fastpathT) DecMapFloat32Float64X(vp *map[float32]float64, d *Decoder) { - if v, changed := f.DecMapFloat32Float64V(*vp, true, d); changed { + v, changed := f.DecMapFloat32Float64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat32Float64V(v map[float32]float64, canChange bool, d *Decoder) (_ map[float32]float64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -20817,7 +22083,6 @@ func (_ fastpathT) DecMapFloat32Float64V(v map[float32]float64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float32 var mv float64 hasLen := containerLen > 0 @@ -20825,19 +22090,20 @@ func (_ fastpathT) DecMapFloat32Float64V(v map[float32]float64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = float32(dd.DecodeFloat(true)) + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeFloat(false) + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } @@ -20849,22 +22115,23 @@ func (_ fastpathT) DecMapFloat32Float64V(v map[float32]float64, canChange bool, func (d *Decoder) fastpathDecMapFloat32BoolR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float32]bool) - if v, changed := fastpathTV.DecMapFloat32BoolV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat32BoolV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat32BoolV(rv2i(rv).(map[float32]bool), false, d) } - fastpathTV.DecMapFloat32BoolV(rv2i(rv).(map[float32]bool), false, d) } func (f fastpathT) DecMapFloat32BoolX(vp *map[float32]bool, d *Decoder) { - if v, changed := f.DecMapFloat32BoolV(*vp, true, d); changed { + v, changed := f.DecMapFloat32BoolV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat32BoolV(v map[float32]bool, canChange bool, d *Decoder) (_ map[float32]bool, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 5) @@ -20875,7 +22142,6 @@ func (_ fastpathT) DecMapFloat32BoolV(v map[float32]bool, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float32 var mv bool hasLen := containerLen > 0 @@ -20883,12 +22149,13 @@ func (_ fastpathT) DecMapFloat32BoolV(v map[float32]bool, canChange bool, if esep { dd.ReadMapElemKey() } - mk = float32(dd.DecodeFloat(true)) + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = false @@ -20907,22 +22174,23 @@ func (_ fastpathT) DecMapFloat32BoolV(v map[float32]bool, canChange bool, func (d *Decoder) fastpathDecMapFloat64IntfR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float64]interface{}) - if v, changed := fastpathTV.DecMapFloat64IntfV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat64IntfV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat64IntfV(rv2i(rv).(map[float64]interface{}), false, d) } - fastpathTV.DecMapFloat64IntfV(rv2i(rv).(map[float64]interface{}), false, d) } func (f fastpathT) DecMapFloat64IntfX(vp *map[float64]interface{}, d *Decoder) { - if v, changed := f.DecMapFloat64IntfV(*vp, true, d); changed { + v, changed := f.DecMapFloat64IntfV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat64IntfV(v map[float64]interface{}, canChange bool, d *Decoder) (_ map[float64]interface{}, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -20933,7 +22201,7 @@ func (_ fastpathT) DecMapFloat64IntfV(v map[float64]interface{}, canChange bool, dd.ReadMapEnd() return v, changed } - mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset var mk float64 var mv interface{} hasLen := containerLen > 0 @@ -20941,12 +22209,13 @@ func (_ fastpathT) DecMapFloat64IntfV(v map[float64]interface{}, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeFloat(false) + mk = dd.DecodeFloat64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = nil @@ -20970,22 +22239,23 @@ func (_ fastpathT) DecMapFloat64IntfV(v map[float64]interface{}, canChange bool, func (d *Decoder) fastpathDecMapFloat64StringR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float64]string) - if v, changed := fastpathTV.DecMapFloat64StringV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat64StringV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat64StringV(rv2i(rv).(map[float64]string), false, d) } - fastpathTV.DecMapFloat64StringV(rv2i(rv).(map[float64]string), false, d) } func (f fastpathT) DecMapFloat64StringX(vp *map[float64]string, d *Decoder) { - if v, changed := f.DecMapFloat64StringV(*vp, true, d); changed { + v, changed := f.DecMapFloat64StringV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat64StringV(v map[float64]string, canChange bool, d *Decoder) (_ map[float64]string, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -20996,7 +22266,6 @@ func (_ fastpathT) DecMapFloat64StringV(v map[float64]string, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float64 var mv string hasLen := containerLen > 0 @@ -21004,12 +22273,13 @@ func (_ fastpathT) DecMapFloat64StringV(v map[float64]string, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeFloat(false) + mk = dd.DecodeFloat64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = "" @@ -21028,22 +22298,23 @@ func (_ fastpathT) DecMapFloat64StringV(v map[float64]string, canChange bool, func (d *Decoder) fastpathDecMapFloat64UintR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float64]uint) - if v, changed := fastpathTV.DecMapFloat64UintV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat64UintV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat64UintV(rv2i(rv).(map[float64]uint), false, d) } - fastpathTV.DecMapFloat64UintV(rv2i(rv).(map[float64]uint), false, d) } func (f fastpathT) DecMapFloat64UintX(vp *map[float64]uint, d *Decoder) { - if v, changed := f.DecMapFloat64UintV(*vp, true, d); changed { + v, changed := f.DecMapFloat64UintV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat64UintV(v map[float64]uint, canChange bool, d *Decoder) (_ map[float64]uint, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -21054,7 +22325,6 @@ func (_ fastpathT) DecMapFloat64UintV(v map[float64]uint, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float64 var mv uint hasLen := containerLen > 0 @@ -21062,19 +22332,20 @@ func (_ fastpathT) DecMapFloat64UintV(v map[float64]uint, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeFloat(false) + mk = dd.DecodeFloat64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint(dd.DecodeUint(uintBitsize)) + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -21086,22 +22357,23 @@ func (_ fastpathT) DecMapFloat64UintV(v map[float64]uint, canChange bool, func (d *Decoder) fastpathDecMapFloat64Uint8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float64]uint8) - if v, changed := fastpathTV.DecMapFloat64Uint8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat64Uint8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat64Uint8V(rv2i(rv).(map[float64]uint8), false, d) } - fastpathTV.DecMapFloat64Uint8V(rv2i(rv).(map[float64]uint8), false, d) } func (f fastpathT) DecMapFloat64Uint8X(vp *map[float64]uint8, d *Decoder) { - if v, changed := f.DecMapFloat64Uint8V(*vp, true, d); changed { + v, changed := f.DecMapFloat64Uint8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat64Uint8V(v map[float64]uint8, canChange bool, d *Decoder) (_ map[float64]uint8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -21112,7 +22384,6 @@ func (_ fastpathT) DecMapFloat64Uint8V(v map[float64]uint8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float64 var mv uint8 hasLen := containerLen > 0 @@ -21120,19 +22391,20 @@ func (_ fastpathT) DecMapFloat64Uint8V(v map[float64]uint8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeFloat(false) + mk = dd.DecodeFloat64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint8(dd.DecodeUint(8)) + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } @@ -21144,22 +22416,23 @@ func (_ fastpathT) DecMapFloat64Uint8V(v map[float64]uint8, canChange bool, func (d *Decoder) fastpathDecMapFloat64Uint16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float64]uint16) - if v, changed := fastpathTV.DecMapFloat64Uint16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat64Uint16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat64Uint16V(rv2i(rv).(map[float64]uint16), false, d) } - fastpathTV.DecMapFloat64Uint16V(rv2i(rv).(map[float64]uint16), false, d) } func (f fastpathT) DecMapFloat64Uint16X(vp *map[float64]uint16, d *Decoder) { - if v, changed := f.DecMapFloat64Uint16V(*vp, true, d); changed { + v, changed := f.DecMapFloat64Uint16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat64Uint16V(v map[float64]uint16, canChange bool, d *Decoder) (_ map[float64]uint16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -21170,7 +22443,6 @@ func (_ fastpathT) DecMapFloat64Uint16V(v map[float64]uint16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float64 var mv uint16 hasLen := containerLen > 0 @@ -21178,19 +22450,20 @@ func (_ fastpathT) DecMapFloat64Uint16V(v map[float64]uint16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeFloat(false) + mk = dd.DecodeFloat64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint16(dd.DecodeUint(16)) + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } @@ -21202,22 +22475,23 @@ func (_ fastpathT) DecMapFloat64Uint16V(v map[float64]uint16, canChange bool, func (d *Decoder) fastpathDecMapFloat64Uint32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float64]uint32) - if v, changed := fastpathTV.DecMapFloat64Uint32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat64Uint32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat64Uint32V(rv2i(rv).(map[float64]uint32), false, d) } - fastpathTV.DecMapFloat64Uint32V(rv2i(rv).(map[float64]uint32), false, d) } func (f fastpathT) DecMapFloat64Uint32X(vp *map[float64]uint32, d *Decoder) { - if v, changed := f.DecMapFloat64Uint32V(*vp, true, d); changed { + v, changed := f.DecMapFloat64Uint32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat64Uint32V(v map[float64]uint32, canChange bool, d *Decoder) (_ map[float64]uint32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -21228,7 +22502,6 @@ func (_ fastpathT) DecMapFloat64Uint32V(v map[float64]uint32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float64 var mv uint32 hasLen := containerLen > 0 @@ -21236,19 +22509,20 @@ func (_ fastpathT) DecMapFloat64Uint32V(v map[float64]uint32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeFloat(false) + mk = dd.DecodeFloat64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint32(dd.DecodeUint(32)) + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } @@ -21260,22 +22534,23 @@ func (_ fastpathT) DecMapFloat64Uint32V(v map[float64]uint32, canChange bool, func (d *Decoder) fastpathDecMapFloat64Uint64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float64]uint64) - if v, changed := fastpathTV.DecMapFloat64Uint64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat64Uint64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat64Uint64V(rv2i(rv).(map[float64]uint64), false, d) } - fastpathTV.DecMapFloat64Uint64V(rv2i(rv).(map[float64]uint64), false, d) } func (f fastpathT) DecMapFloat64Uint64X(vp *map[float64]uint64, d *Decoder) { - if v, changed := f.DecMapFloat64Uint64V(*vp, true, d); changed { + v, changed := f.DecMapFloat64Uint64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat64Uint64V(v map[float64]uint64, canChange bool, d *Decoder) (_ map[float64]uint64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -21286,7 +22561,6 @@ func (_ fastpathT) DecMapFloat64Uint64V(v map[float64]uint64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float64 var mv uint64 hasLen := containerLen > 0 @@ -21294,19 +22568,20 @@ func (_ fastpathT) DecMapFloat64Uint64V(v map[float64]uint64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeFloat(false) + mk = dd.DecodeFloat64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeUint(64) + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } @@ -21318,22 +22593,23 @@ func (_ fastpathT) DecMapFloat64Uint64V(v map[float64]uint64, canChange bool, func (d *Decoder) fastpathDecMapFloat64UintptrR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float64]uintptr) - if v, changed := fastpathTV.DecMapFloat64UintptrV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat64UintptrV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat64UintptrV(rv2i(rv).(map[float64]uintptr), false, d) } - fastpathTV.DecMapFloat64UintptrV(rv2i(rv).(map[float64]uintptr), false, d) } func (f fastpathT) DecMapFloat64UintptrX(vp *map[float64]uintptr, d *Decoder) { - if v, changed := f.DecMapFloat64UintptrV(*vp, true, d); changed { + v, changed := f.DecMapFloat64UintptrV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat64UintptrV(v map[float64]uintptr, canChange bool, d *Decoder) (_ map[float64]uintptr, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -21344,7 +22620,6 @@ func (_ fastpathT) DecMapFloat64UintptrV(v map[float64]uintptr, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float64 var mv uintptr hasLen := containerLen > 0 @@ -21352,19 +22627,20 @@ func (_ fastpathT) DecMapFloat64UintptrV(v map[float64]uintptr, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeFloat(false) + mk = dd.DecodeFloat64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uintptr(dd.DecodeUint(uintBitsize)) + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -21376,22 +22652,23 @@ func (_ fastpathT) DecMapFloat64UintptrV(v map[float64]uintptr, canChange bool, func (d *Decoder) fastpathDecMapFloat64IntR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float64]int) - if v, changed := fastpathTV.DecMapFloat64IntV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat64IntV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat64IntV(rv2i(rv).(map[float64]int), false, d) } - fastpathTV.DecMapFloat64IntV(rv2i(rv).(map[float64]int), false, d) } func (f fastpathT) DecMapFloat64IntX(vp *map[float64]int, d *Decoder) { - if v, changed := f.DecMapFloat64IntV(*vp, true, d); changed { + v, changed := f.DecMapFloat64IntV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat64IntV(v map[float64]int, canChange bool, d *Decoder) (_ map[float64]int, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -21402,7 +22679,6 @@ func (_ fastpathT) DecMapFloat64IntV(v map[float64]int, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float64 var mv int hasLen := containerLen > 0 @@ -21410,19 +22686,20 @@ func (_ fastpathT) DecMapFloat64IntV(v map[float64]int, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeFloat(false) + mk = dd.DecodeFloat64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int(dd.DecodeInt(intBitsize)) + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } @@ -21434,22 +22711,23 @@ func (_ fastpathT) DecMapFloat64IntV(v map[float64]int, canChange bool, func (d *Decoder) fastpathDecMapFloat64Int8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float64]int8) - if v, changed := fastpathTV.DecMapFloat64Int8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat64Int8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat64Int8V(rv2i(rv).(map[float64]int8), false, d) } - fastpathTV.DecMapFloat64Int8V(rv2i(rv).(map[float64]int8), false, d) } func (f fastpathT) DecMapFloat64Int8X(vp *map[float64]int8, d *Decoder) { - if v, changed := f.DecMapFloat64Int8V(*vp, true, d); changed { + v, changed := f.DecMapFloat64Int8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat64Int8V(v map[float64]int8, canChange bool, d *Decoder) (_ map[float64]int8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -21460,7 +22738,6 @@ func (_ fastpathT) DecMapFloat64Int8V(v map[float64]int8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float64 var mv int8 hasLen := containerLen > 0 @@ -21468,19 +22745,20 @@ func (_ fastpathT) DecMapFloat64Int8V(v map[float64]int8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeFloat(false) + mk = dd.DecodeFloat64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int8(dd.DecodeInt(8)) + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } @@ -21492,22 +22770,23 @@ func (_ fastpathT) DecMapFloat64Int8V(v map[float64]int8, canChange bool, func (d *Decoder) fastpathDecMapFloat64Int16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float64]int16) - if v, changed := fastpathTV.DecMapFloat64Int16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat64Int16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat64Int16V(rv2i(rv).(map[float64]int16), false, d) } - fastpathTV.DecMapFloat64Int16V(rv2i(rv).(map[float64]int16), false, d) } func (f fastpathT) DecMapFloat64Int16X(vp *map[float64]int16, d *Decoder) { - if v, changed := f.DecMapFloat64Int16V(*vp, true, d); changed { + v, changed := f.DecMapFloat64Int16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat64Int16V(v map[float64]int16, canChange bool, d *Decoder) (_ map[float64]int16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -21518,7 +22797,6 @@ func (_ fastpathT) DecMapFloat64Int16V(v map[float64]int16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float64 var mv int16 hasLen := containerLen > 0 @@ -21526,19 +22804,20 @@ func (_ fastpathT) DecMapFloat64Int16V(v map[float64]int16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeFloat(false) + mk = dd.DecodeFloat64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int16(dd.DecodeInt(16)) + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } @@ -21550,22 +22829,23 @@ func (_ fastpathT) DecMapFloat64Int16V(v map[float64]int16, canChange bool, func (d *Decoder) fastpathDecMapFloat64Int32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float64]int32) - if v, changed := fastpathTV.DecMapFloat64Int32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat64Int32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat64Int32V(rv2i(rv).(map[float64]int32), false, d) } - fastpathTV.DecMapFloat64Int32V(rv2i(rv).(map[float64]int32), false, d) } func (f fastpathT) DecMapFloat64Int32X(vp *map[float64]int32, d *Decoder) { - if v, changed := f.DecMapFloat64Int32V(*vp, true, d); changed { + v, changed := f.DecMapFloat64Int32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat64Int32V(v map[float64]int32, canChange bool, d *Decoder) (_ map[float64]int32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -21576,7 +22856,6 @@ func (_ fastpathT) DecMapFloat64Int32V(v map[float64]int32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float64 var mv int32 hasLen := containerLen > 0 @@ -21584,19 +22863,20 @@ func (_ fastpathT) DecMapFloat64Int32V(v map[float64]int32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeFloat(false) + mk = dd.DecodeFloat64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int32(dd.DecodeInt(32)) + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } @@ -21608,22 +22888,23 @@ func (_ fastpathT) DecMapFloat64Int32V(v map[float64]int32, canChange bool, func (d *Decoder) fastpathDecMapFloat64Int64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float64]int64) - if v, changed := fastpathTV.DecMapFloat64Int64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat64Int64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat64Int64V(rv2i(rv).(map[float64]int64), false, d) } - fastpathTV.DecMapFloat64Int64V(rv2i(rv).(map[float64]int64), false, d) } func (f fastpathT) DecMapFloat64Int64X(vp *map[float64]int64, d *Decoder) { - if v, changed := f.DecMapFloat64Int64V(*vp, true, d); changed { + v, changed := f.DecMapFloat64Int64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat64Int64V(v map[float64]int64, canChange bool, d *Decoder) (_ map[float64]int64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -21634,7 +22915,6 @@ func (_ fastpathT) DecMapFloat64Int64V(v map[float64]int64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float64 var mv int64 hasLen := containerLen > 0 @@ -21642,19 +22922,20 @@ func (_ fastpathT) DecMapFloat64Int64V(v map[float64]int64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeFloat(false) + mk = dd.DecodeFloat64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeInt(64) + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } @@ -21666,22 +22947,23 @@ func (_ fastpathT) DecMapFloat64Int64V(v map[float64]int64, canChange bool, func (d *Decoder) fastpathDecMapFloat64Float32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float64]float32) - if v, changed := fastpathTV.DecMapFloat64Float32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat64Float32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat64Float32V(rv2i(rv).(map[float64]float32), false, d) } - fastpathTV.DecMapFloat64Float32V(rv2i(rv).(map[float64]float32), false, d) } func (f fastpathT) DecMapFloat64Float32X(vp *map[float64]float32, d *Decoder) { - if v, changed := f.DecMapFloat64Float32V(*vp, true, d); changed { + v, changed := f.DecMapFloat64Float32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat64Float32V(v map[float64]float32, canChange bool, d *Decoder) (_ map[float64]float32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -21692,7 +22974,6 @@ func (_ fastpathT) DecMapFloat64Float32V(v map[float64]float32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float64 var mv float32 hasLen := containerLen > 0 @@ -21700,19 +22981,20 @@ func (_ fastpathT) DecMapFloat64Float32V(v map[float64]float32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeFloat(false) + mk = dd.DecodeFloat64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = float32(dd.DecodeFloat(true)) + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } @@ -21724,22 +23006,23 @@ func (_ fastpathT) DecMapFloat64Float32V(v map[float64]float32, canChange bool, func (d *Decoder) fastpathDecMapFloat64Float64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float64]float64) - if v, changed := fastpathTV.DecMapFloat64Float64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat64Float64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat64Float64V(rv2i(rv).(map[float64]float64), false, d) } - fastpathTV.DecMapFloat64Float64V(rv2i(rv).(map[float64]float64), false, d) } func (f fastpathT) DecMapFloat64Float64X(vp *map[float64]float64, d *Decoder) { - if v, changed := f.DecMapFloat64Float64V(*vp, true, d); changed { + v, changed := f.DecMapFloat64Float64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat64Float64V(v map[float64]float64, canChange bool, d *Decoder) (_ map[float64]float64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -21750,7 +23033,6 @@ func (_ fastpathT) DecMapFloat64Float64V(v map[float64]float64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float64 var mv float64 hasLen := containerLen > 0 @@ -21758,19 +23040,20 @@ func (_ fastpathT) DecMapFloat64Float64V(v map[float64]float64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeFloat(false) + mk = dd.DecodeFloat64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeFloat(false) + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } @@ -21782,22 +23065,23 @@ func (_ fastpathT) DecMapFloat64Float64V(v map[float64]float64, canChange bool, func (d *Decoder) fastpathDecMapFloat64BoolR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[float64]bool) - if v, changed := fastpathTV.DecMapFloat64BoolV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapFloat64BoolV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapFloat64BoolV(rv2i(rv).(map[float64]bool), false, d) } - fastpathTV.DecMapFloat64BoolV(rv2i(rv).(map[float64]bool), false, d) } func (f fastpathT) DecMapFloat64BoolX(vp *map[float64]bool, d *Decoder) { - if v, changed := f.DecMapFloat64BoolV(*vp, true, d); changed { + v, changed := f.DecMapFloat64BoolV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapFloat64BoolV(v map[float64]bool, canChange bool, d *Decoder) (_ map[float64]bool, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -21808,7 +23092,6 @@ func (_ fastpathT) DecMapFloat64BoolV(v map[float64]bool, canChange bool, dd.ReadMapEnd() return v, changed } - var mk float64 var mv bool hasLen := containerLen > 0 @@ -21816,12 +23099,13 @@ func (_ fastpathT) DecMapFloat64BoolV(v map[float64]bool, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeFloat(false) + mk = dd.DecodeFloat64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = false @@ -21840,22 +23124,23 @@ func (_ fastpathT) DecMapFloat64BoolV(v map[float64]bool, canChange bool, func (d *Decoder) fastpathDecMapUintIntfR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint]interface{}) - if v, changed := fastpathTV.DecMapUintIntfV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintIntfV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintIntfV(rv2i(rv).(map[uint]interface{}), false, d) } - fastpathTV.DecMapUintIntfV(rv2i(rv).(map[uint]interface{}), false, d) } func (f fastpathT) DecMapUintIntfX(vp *map[uint]interface{}, d *Decoder) { - if v, changed := f.DecMapUintIntfV(*vp, true, d); changed { + v, changed := f.DecMapUintIntfV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintIntfV(v map[uint]interface{}, canChange bool, d *Decoder) (_ map[uint]interface{}, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -21866,7 +23151,7 @@ func (_ fastpathT) DecMapUintIntfV(v map[uint]interface{}, canChange bool, dd.ReadMapEnd() return v, changed } - mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset var mk uint var mv interface{} hasLen := containerLen > 0 @@ -21874,12 +23159,13 @@ func (_ fastpathT) DecMapUintIntfV(v map[uint]interface{}, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint(dd.DecodeUint(uintBitsize)) + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = nil @@ -21903,22 +23189,23 @@ func (_ fastpathT) DecMapUintIntfV(v map[uint]interface{}, canChange bool, func (d *Decoder) fastpathDecMapUintStringR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint]string) - if v, changed := fastpathTV.DecMapUintStringV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintStringV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintStringV(rv2i(rv).(map[uint]string), false, d) } - fastpathTV.DecMapUintStringV(rv2i(rv).(map[uint]string), false, d) } func (f fastpathT) DecMapUintStringX(vp *map[uint]string, d *Decoder) { - if v, changed := f.DecMapUintStringV(*vp, true, d); changed { + v, changed := f.DecMapUintStringV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintStringV(v map[uint]string, canChange bool, d *Decoder) (_ map[uint]string, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -21929,7 +23216,6 @@ func (_ fastpathT) DecMapUintStringV(v map[uint]string, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint var mv string hasLen := containerLen > 0 @@ -21937,12 +23223,13 @@ func (_ fastpathT) DecMapUintStringV(v map[uint]string, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint(dd.DecodeUint(uintBitsize)) + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = "" @@ -21961,22 +23248,23 @@ func (_ fastpathT) DecMapUintStringV(v map[uint]string, canChange bool, func (d *Decoder) fastpathDecMapUintUintR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint]uint) - if v, changed := fastpathTV.DecMapUintUintV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintUintV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintUintV(rv2i(rv).(map[uint]uint), false, d) } - fastpathTV.DecMapUintUintV(rv2i(rv).(map[uint]uint), false, d) } func (f fastpathT) DecMapUintUintX(vp *map[uint]uint, d *Decoder) { - if v, changed := f.DecMapUintUintV(*vp, true, d); changed { + v, changed := f.DecMapUintUintV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintUintV(v map[uint]uint, canChange bool, d *Decoder) (_ map[uint]uint, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -21987,7 +23275,6 @@ func (_ fastpathT) DecMapUintUintV(v map[uint]uint, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint var mv uint hasLen := containerLen > 0 @@ -21995,19 +23282,20 @@ func (_ fastpathT) DecMapUintUintV(v map[uint]uint, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint(dd.DecodeUint(uintBitsize)) + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint(dd.DecodeUint(uintBitsize)) + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -22019,22 +23307,23 @@ func (_ fastpathT) DecMapUintUintV(v map[uint]uint, canChange bool, func (d *Decoder) fastpathDecMapUintUint8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint]uint8) - if v, changed := fastpathTV.DecMapUintUint8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintUint8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintUint8V(rv2i(rv).(map[uint]uint8), false, d) } - fastpathTV.DecMapUintUint8V(rv2i(rv).(map[uint]uint8), false, d) } func (f fastpathT) DecMapUintUint8X(vp *map[uint]uint8, d *Decoder) { - if v, changed := f.DecMapUintUint8V(*vp, true, d); changed { + v, changed := f.DecMapUintUint8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintUint8V(v map[uint]uint8, canChange bool, d *Decoder) (_ map[uint]uint8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -22045,7 +23334,6 @@ func (_ fastpathT) DecMapUintUint8V(v map[uint]uint8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint var mv uint8 hasLen := containerLen > 0 @@ -22053,19 +23341,20 @@ func (_ fastpathT) DecMapUintUint8V(v map[uint]uint8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint(dd.DecodeUint(uintBitsize)) + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint8(dd.DecodeUint(8)) + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } @@ -22077,22 +23366,23 @@ func (_ fastpathT) DecMapUintUint8V(v map[uint]uint8, canChange bool, func (d *Decoder) fastpathDecMapUintUint16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint]uint16) - if v, changed := fastpathTV.DecMapUintUint16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintUint16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintUint16V(rv2i(rv).(map[uint]uint16), false, d) } - fastpathTV.DecMapUintUint16V(rv2i(rv).(map[uint]uint16), false, d) } func (f fastpathT) DecMapUintUint16X(vp *map[uint]uint16, d *Decoder) { - if v, changed := f.DecMapUintUint16V(*vp, true, d); changed { + v, changed := f.DecMapUintUint16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintUint16V(v map[uint]uint16, canChange bool, d *Decoder) (_ map[uint]uint16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -22103,7 +23393,6 @@ func (_ fastpathT) DecMapUintUint16V(v map[uint]uint16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint var mv uint16 hasLen := containerLen > 0 @@ -22111,19 +23400,20 @@ func (_ fastpathT) DecMapUintUint16V(v map[uint]uint16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint(dd.DecodeUint(uintBitsize)) + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint16(dd.DecodeUint(16)) + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } @@ -22135,22 +23425,23 @@ func (_ fastpathT) DecMapUintUint16V(v map[uint]uint16, canChange bool, func (d *Decoder) fastpathDecMapUintUint32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint]uint32) - if v, changed := fastpathTV.DecMapUintUint32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintUint32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintUint32V(rv2i(rv).(map[uint]uint32), false, d) } - fastpathTV.DecMapUintUint32V(rv2i(rv).(map[uint]uint32), false, d) } func (f fastpathT) DecMapUintUint32X(vp *map[uint]uint32, d *Decoder) { - if v, changed := f.DecMapUintUint32V(*vp, true, d); changed { + v, changed := f.DecMapUintUint32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintUint32V(v map[uint]uint32, canChange bool, d *Decoder) (_ map[uint]uint32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -22161,7 +23452,6 @@ func (_ fastpathT) DecMapUintUint32V(v map[uint]uint32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint var mv uint32 hasLen := containerLen > 0 @@ -22169,19 +23459,20 @@ func (_ fastpathT) DecMapUintUint32V(v map[uint]uint32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint(dd.DecodeUint(uintBitsize)) + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint32(dd.DecodeUint(32)) + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } @@ -22193,22 +23484,23 @@ func (_ fastpathT) DecMapUintUint32V(v map[uint]uint32, canChange bool, func (d *Decoder) fastpathDecMapUintUint64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint]uint64) - if v, changed := fastpathTV.DecMapUintUint64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintUint64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintUint64V(rv2i(rv).(map[uint]uint64), false, d) } - fastpathTV.DecMapUintUint64V(rv2i(rv).(map[uint]uint64), false, d) } func (f fastpathT) DecMapUintUint64X(vp *map[uint]uint64, d *Decoder) { - if v, changed := f.DecMapUintUint64V(*vp, true, d); changed { + v, changed := f.DecMapUintUint64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintUint64V(v map[uint]uint64, canChange bool, d *Decoder) (_ map[uint]uint64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -22219,7 +23511,6 @@ func (_ fastpathT) DecMapUintUint64V(v map[uint]uint64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint var mv uint64 hasLen := containerLen > 0 @@ -22227,19 +23518,20 @@ func (_ fastpathT) DecMapUintUint64V(v map[uint]uint64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint(dd.DecodeUint(uintBitsize)) + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeUint(64) + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } @@ -22251,22 +23543,23 @@ func (_ fastpathT) DecMapUintUint64V(v map[uint]uint64, canChange bool, func (d *Decoder) fastpathDecMapUintUintptrR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint]uintptr) - if v, changed := fastpathTV.DecMapUintUintptrV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintUintptrV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintUintptrV(rv2i(rv).(map[uint]uintptr), false, d) } - fastpathTV.DecMapUintUintptrV(rv2i(rv).(map[uint]uintptr), false, d) } func (f fastpathT) DecMapUintUintptrX(vp *map[uint]uintptr, d *Decoder) { - if v, changed := f.DecMapUintUintptrV(*vp, true, d); changed { + v, changed := f.DecMapUintUintptrV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintUintptrV(v map[uint]uintptr, canChange bool, d *Decoder) (_ map[uint]uintptr, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -22277,7 +23570,6 @@ func (_ fastpathT) DecMapUintUintptrV(v map[uint]uintptr, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint var mv uintptr hasLen := containerLen > 0 @@ -22285,19 +23577,20 @@ func (_ fastpathT) DecMapUintUintptrV(v map[uint]uintptr, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint(dd.DecodeUint(uintBitsize)) + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uintptr(dd.DecodeUint(uintBitsize)) + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -22309,22 +23602,23 @@ func (_ fastpathT) DecMapUintUintptrV(v map[uint]uintptr, canChange bool, func (d *Decoder) fastpathDecMapUintIntR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint]int) - if v, changed := fastpathTV.DecMapUintIntV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintIntV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintIntV(rv2i(rv).(map[uint]int), false, d) } - fastpathTV.DecMapUintIntV(rv2i(rv).(map[uint]int), false, d) } func (f fastpathT) DecMapUintIntX(vp *map[uint]int, d *Decoder) { - if v, changed := f.DecMapUintIntV(*vp, true, d); changed { + v, changed := f.DecMapUintIntV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintIntV(v map[uint]int, canChange bool, d *Decoder) (_ map[uint]int, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -22335,7 +23629,6 @@ func (_ fastpathT) DecMapUintIntV(v map[uint]int, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint var mv int hasLen := containerLen > 0 @@ -22343,19 +23636,20 @@ func (_ fastpathT) DecMapUintIntV(v map[uint]int, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint(dd.DecodeUint(uintBitsize)) + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int(dd.DecodeInt(intBitsize)) + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } @@ -22367,22 +23661,23 @@ func (_ fastpathT) DecMapUintIntV(v map[uint]int, canChange bool, func (d *Decoder) fastpathDecMapUintInt8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint]int8) - if v, changed := fastpathTV.DecMapUintInt8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintInt8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintInt8V(rv2i(rv).(map[uint]int8), false, d) } - fastpathTV.DecMapUintInt8V(rv2i(rv).(map[uint]int8), false, d) } func (f fastpathT) DecMapUintInt8X(vp *map[uint]int8, d *Decoder) { - if v, changed := f.DecMapUintInt8V(*vp, true, d); changed { + v, changed := f.DecMapUintInt8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintInt8V(v map[uint]int8, canChange bool, d *Decoder) (_ map[uint]int8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -22393,7 +23688,6 @@ func (_ fastpathT) DecMapUintInt8V(v map[uint]int8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint var mv int8 hasLen := containerLen > 0 @@ -22401,19 +23695,20 @@ func (_ fastpathT) DecMapUintInt8V(v map[uint]int8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint(dd.DecodeUint(uintBitsize)) + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int8(dd.DecodeInt(8)) + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } @@ -22425,22 +23720,23 @@ func (_ fastpathT) DecMapUintInt8V(v map[uint]int8, canChange bool, func (d *Decoder) fastpathDecMapUintInt16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint]int16) - if v, changed := fastpathTV.DecMapUintInt16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintInt16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintInt16V(rv2i(rv).(map[uint]int16), false, d) } - fastpathTV.DecMapUintInt16V(rv2i(rv).(map[uint]int16), false, d) } func (f fastpathT) DecMapUintInt16X(vp *map[uint]int16, d *Decoder) { - if v, changed := f.DecMapUintInt16V(*vp, true, d); changed { + v, changed := f.DecMapUintInt16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintInt16V(v map[uint]int16, canChange bool, d *Decoder) (_ map[uint]int16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -22451,7 +23747,6 @@ func (_ fastpathT) DecMapUintInt16V(v map[uint]int16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint var mv int16 hasLen := containerLen > 0 @@ -22459,19 +23754,20 @@ func (_ fastpathT) DecMapUintInt16V(v map[uint]int16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint(dd.DecodeUint(uintBitsize)) + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int16(dd.DecodeInt(16)) + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } @@ -22483,22 +23779,23 @@ func (_ fastpathT) DecMapUintInt16V(v map[uint]int16, canChange bool, func (d *Decoder) fastpathDecMapUintInt32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint]int32) - if v, changed := fastpathTV.DecMapUintInt32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintInt32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintInt32V(rv2i(rv).(map[uint]int32), false, d) } - fastpathTV.DecMapUintInt32V(rv2i(rv).(map[uint]int32), false, d) } func (f fastpathT) DecMapUintInt32X(vp *map[uint]int32, d *Decoder) { - if v, changed := f.DecMapUintInt32V(*vp, true, d); changed { + v, changed := f.DecMapUintInt32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintInt32V(v map[uint]int32, canChange bool, d *Decoder) (_ map[uint]int32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -22509,7 +23806,6 @@ func (_ fastpathT) DecMapUintInt32V(v map[uint]int32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint var mv int32 hasLen := containerLen > 0 @@ -22517,19 +23813,20 @@ func (_ fastpathT) DecMapUintInt32V(v map[uint]int32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint(dd.DecodeUint(uintBitsize)) + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int32(dd.DecodeInt(32)) + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } @@ -22541,22 +23838,23 @@ func (_ fastpathT) DecMapUintInt32V(v map[uint]int32, canChange bool, func (d *Decoder) fastpathDecMapUintInt64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint]int64) - if v, changed := fastpathTV.DecMapUintInt64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintInt64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintInt64V(rv2i(rv).(map[uint]int64), false, d) } - fastpathTV.DecMapUintInt64V(rv2i(rv).(map[uint]int64), false, d) } func (f fastpathT) DecMapUintInt64X(vp *map[uint]int64, d *Decoder) { - if v, changed := f.DecMapUintInt64V(*vp, true, d); changed { + v, changed := f.DecMapUintInt64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintInt64V(v map[uint]int64, canChange bool, d *Decoder) (_ map[uint]int64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -22567,7 +23865,6 @@ func (_ fastpathT) DecMapUintInt64V(v map[uint]int64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint var mv int64 hasLen := containerLen > 0 @@ -22575,19 +23872,20 @@ func (_ fastpathT) DecMapUintInt64V(v map[uint]int64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint(dd.DecodeUint(uintBitsize)) + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeInt(64) + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } @@ -22599,22 +23897,23 @@ func (_ fastpathT) DecMapUintInt64V(v map[uint]int64, canChange bool, func (d *Decoder) fastpathDecMapUintFloat32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint]float32) - if v, changed := fastpathTV.DecMapUintFloat32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintFloat32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintFloat32V(rv2i(rv).(map[uint]float32), false, d) } - fastpathTV.DecMapUintFloat32V(rv2i(rv).(map[uint]float32), false, d) } func (f fastpathT) DecMapUintFloat32X(vp *map[uint]float32, d *Decoder) { - if v, changed := f.DecMapUintFloat32V(*vp, true, d); changed { + v, changed := f.DecMapUintFloat32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintFloat32V(v map[uint]float32, canChange bool, d *Decoder) (_ map[uint]float32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -22625,7 +23924,6 @@ func (_ fastpathT) DecMapUintFloat32V(v map[uint]float32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint var mv float32 hasLen := containerLen > 0 @@ -22633,19 +23931,20 @@ func (_ fastpathT) DecMapUintFloat32V(v map[uint]float32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint(dd.DecodeUint(uintBitsize)) + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = float32(dd.DecodeFloat(true)) + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } @@ -22657,22 +23956,23 @@ func (_ fastpathT) DecMapUintFloat32V(v map[uint]float32, canChange bool, func (d *Decoder) fastpathDecMapUintFloat64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint]float64) - if v, changed := fastpathTV.DecMapUintFloat64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintFloat64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintFloat64V(rv2i(rv).(map[uint]float64), false, d) } - fastpathTV.DecMapUintFloat64V(rv2i(rv).(map[uint]float64), false, d) } func (f fastpathT) DecMapUintFloat64X(vp *map[uint]float64, d *Decoder) { - if v, changed := f.DecMapUintFloat64V(*vp, true, d); changed { + v, changed := f.DecMapUintFloat64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintFloat64V(v map[uint]float64, canChange bool, d *Decoder) (_ map[uint]float64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -22683,7 +23983,6 @@ func (_ fastpathT) DecMapUintFloat64V(v map[uint]float64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint var mv float64 hasLen := containerLen > 0 @@ -22691,19 +23990,20 @@ func (_ fastpathT) DecMapUintFloat64V(v map[uint]float64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint(dd.DecodeUint(uintBitsize)) + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeFloat(false) + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } @@ -22715,22 +24015,23 @@ func (_ fastpathT) DecMapUintFloat64V(v map[uint]float64, canChange bool, func (d *Decoder) fastpathDecMapUintBoolR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint]bool) - if v, changed := fastpathTV.DecMapUintBoolV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintBoolV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintBoolV(rv2i(rv).(map[uint]bool), false, d) } - fastpathTV.DecMapUintBoolV(rv2i(rv).(map[uint]bool), false, d) } func (f fastpathT) DecMapUintBoolX(vp *map[uint]bool, d *Decoder) { - if v, changed := f.DecMapUintBoolV(*vp, true, d); changed { + v, changed := f.DecMapUintBoolV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintBoolV(v map[uint]bool, canChange bool, d *Decoder) (_ map[uint]bool, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -22741,7 +24042,6 @@ func (_ fastpathT) DecMapUintBoolV(v map[uint]bool, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint var mv bool hasLen := containerLen > 0 @@ -22749,12 +24049,13 @@ func (_ fastpathT) DecMapUintBoolV(v map[uint]bool, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint(dd.DecodeUint(uintBitsize)) + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = false @@ -22773,22 +24074,23 @@ func (_ fastpathT) DecMapUintBoolV(v map[uint]bool, canChange bool, func (d *Decoder) fastpathDecMapUint8IntfR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint8]interface{}) - if v, changed := fastpathTV.DecMapUint8IntfV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint8IntfV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint8IntfV(rv2i(rv).(map[uint8]interface{}), false, d) } - fastpathTV.DecMapUint8IntfV(rv2i(rv).(map[uint8]interface{}), false, d) } func (f fastpathT) DecMapUint8IntfX(vp *map[uint8]interface{}, d *Decoder) { - if v, changed := f.DecMapUint8IntfV(*vp, true, d); changed { + v, changed := f.DecMapUint8IntfV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint8IntfV(v map[uint8]interface{}, canChange bool, d *Decoder) (_ map[uint8]interface{}, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 17) @@ -22799,7 +24101,7 @@ func (_ fastpathT) DecMapUint8IntfV(v map[uint8]interface{}, canChange bool, dd.ReadMapEnd() return v, changed } - mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset var mk uint8 var mv interface{} hasLen := containerLen > 0 @@ -22807,12 +24109,13 @@ func (_ fastpathT) DecMapUint8IntfV(v map[uint8]interface{}, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint8(dd.DecodeUint(8)) + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = nil @@ -22836,22 +24139,23 @@ func (_ fastpathT) DecMapUint8IntfV(v map[uint8]interface{}, canChange bool, func (d *Decoder) fastpathDecMapUint8StringR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint8]string) - if v, changed := fastpathTV.DecMapUint8StringV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint8StringV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint8StringV(rv2i(rv).(map[uint8]string), false, d) } - fastpathTV.DecMapUint8StringV(rv2i(rv).(map[uint8]string), false, d) } func (f fastpathT) DecMapUint8StringX(vp *map[uint8]string, d *Decoder) { - if v, changed := f.DecMapUint8StringV(*vp, true, d); changed { + v, changed := f.DecMapUint8StringV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint8StringV(v map[uint8]string, canChange bool, d *Decoder) (_ map[uint8]string, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 17) @@ -22862,7 +24166,6 @@ func (_ fastpathT) DecMapUint8StringV(v map[uint8]string, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint8 var mv string hasLen := containerLen > 0 @@ -22870,12 +24173,13 @@ func (_ fastpathT) DecMapUint8StringV(v map[uint8]string, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint8(dd.DecodeUint(8)) + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = "" @@ -22894,22 +24198,23 @@ func (_ fastpathT) DecMapUint8StringV(v map[uint8]string, canChange bool, func (d *Decoder) fastpathDecMapUint8UintR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint8]uint) - if v, changed := fastpathTV.DecMapUint8UintV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint8UintV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint8UintV(rv2i(rv).(map[uint8]uint), false, d) } - fastpathTV.DecMapUint8UintV(rv2i(rv).(map[uint8]uint), false, d) } func (f fastpathT) DecMapUint8UintX(vp *map[uint8]uint, d *Decoder) { - if v, changed := f.DecMapUint8UintV(*vp, true, d); changed { + v, changed := f.DecMapUint8UintV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint8UintV(v map[uint8]uint, canChange bool, d *Decoder) (_ map[uint8]uint, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -22920,7 +24225,6 @@ func (_ fastpathT) DecMapUint8UintV(v map[uint8]uint, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint8 var mv uint hasLen := containerLen > 0 @@ -22928,19 +24232,20 @@ func (_ fastpathT) DecMapUint8UintV(v map[uint8]uint, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint8(dd.DecodeUint(8)) + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint(dd.DecodeUint(uintBitsize)) + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -22952,22 +24257,23 @@ func (_ fastpathT) DecMapUint8UintV(v map[uint8]uint, canChange bool, func (d *Decoder) fastpathDecMapUint8Uint8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint8]uint8) - if v, changed := fastpathTV.DecMapUint8Uint8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint8Uint8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint8Uint8V(rv2i(rv).(map[uint8]uint8), false, d) } - fastpathTV.DecMapUint8Uint8V(rv2i(rv).(map[uint8]uint8), false, d) } func (f fastpathT) DecMapUint8Uint8X(vp *map[uint8]uint8, d *Decoder) { - if v, changed := f.DecMapUint8Uint8V(*vp, true, d); changed { + v, changed := f.DecMapUint8Uint8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint8Uint8V(v map[uint8]uint8, canChange bool, d *Decoder) (_ map[uint8]uint8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 2) @@ -22978,7 +24284,6 @@ func (_ fastpathT) DecMapUint8Uint8V(v map[uint8]uint8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint8 var mv uint8 hasLen := containerLen > 0 @@ -22986,19 +24291,20 @@ func (_ fastpathT) DecMapUint8Uint8V(v map[uint8]uint8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint8(dd.DecodeUint(8)) + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint8(dd.DecodeUint(8)) + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } @@ -23010,22 +24316,23 @@ func (_ fastpathT) DecMapUint8Uint8V(v map[uint8]uint8, canChange bool, func (d *Decoder) fastpathDecMapUint8Uint16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint8]uint16) - if v, changed := fastpathTV.DecMapUint8Uint16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint8Uint16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint8Uint16V(rv2i(rv).(map[uint8]uint16), false, d) } - fastpathTV.DecMapUint8Uint16V(rv2i(rv).(map[uint8]uint16), false, d) } func (f fastpathT) DecMapUint8Uint16X(vp *map[uint8]uint16, d *Decoder) { - if v, changed := f.DecMapUint8Uint16V(*vp, true, d); changed { + v, changed := f.DecMapUint8Uint16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint8Uint16V(v map[uint8]uint16, canChange bool, d *Decoder) (_ map[uint8]uint16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 3) @@ -23036,7 +24343,6 @@ func (_ fastpathT) DecMapUint8Uint16V(v map[uint8]uint16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint8 var mv uint16 hasLen := containerLen > 0 @@ -23044,19 +24350,20 @@ func (_ fastpathT) DecMapUint8Uint16V(v map[uint8]uint16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint8(dd.DecodeUint(8)) + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint16(dd.DecodeUint(16)) + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } @@ -23068,22 +24375,23 @@ func (_ fastpathT) DecMapUint8Uint16V(v map[uint8]uint16, canChange bool, func (d *Decoder) fastpathDecMapUint8Uint32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint8]uint32) - if v, changed := fastpathTV.DecMapUint8Uint32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint8Uint32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint8Uint32V(rv2i(rv).(map[uint8]uint32), false, d) } - fastpathTV.DecMapUint8Uint32V(rv2i(rv).(map[uint8]uint32), false, d) } func (f fastpathT) DecMapUint8Uint32X(vp *map[uint8]uint32, d *Decoder) { - if v, changed := f.DecMapUint8Uint32V(*vp, true, d); changed { + v, changed := f.DecMapUint8Uint32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint8Uint32V(v map[uint8]uint32, canChange bool, d *Decoder) (_ map[uint8]uint32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 5) @@ -23094,7 +24402,6 @@ func (_ fastpathT) DecMapUint8Uint32V(v map[uint8]uint32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint8 var mv uint32 hasLen := containerLen > 0 @@ -23102,19 +24409,20 @@ func (_ fastpathT) DecMapUint8Uint32V(v map[uint8]uint32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint8(dd.DecodeUint(8)) + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint32(dd.DecodeUint(32)) + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } @@ -23126,22 +24434,23 @@ func (_ fastpathT) DecMapUint8Uint32V(v map[uint8]uint32, canChange bool, func (d *Decoder) fastpathDecMapUint8Uint64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint8]uint64) - if v, changed := fastpathTV.DecMapUint8Uint64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint8Uint64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint8Uint64V(rv2i(rv).(map[uint8]uint64), false, d) } - fastpathTV.DecMapUint8Uint64V(rv2i(rv).(map[uint8]uint64), false, d) } func (f fastpathT) DecMapUint8Uint64X(vp *map[uint8]uint64, d *Decoder) { - if v, changed := f.DecMapUint8Uint64V(*vp, true, d); changed { + v, changed := f.DecMapUint8Uint64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint8Uint64V(v map[uint8]uint64, canChange bool, d *Decoder) (_ map[uint8]uint64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -23152,7 +24461,6 @@ func (_ fastpathT) DecMapUint8Uint64V(v map[uint8]uint64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint8 var mv uint64 hasLen := containerLen > 0 @@ -23160,19 +24468,20 @@ func (_ fastpathT) DecMapUint8Uint64V(v map[uint8]uint64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint8(dd.DecodeUint(8)) + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeUint(64) + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } @@ -23184,22 +24493,23 @@ func (_ fastpathT) DecMapUint8Uint64V(v map[uint8]uint64, canChange bool, func (d *Decoder) fastpathDecMapUint8UintptrR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint8]uintptr) - if v, changed := fastpathTV.DecMapUint8UintptrV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint8UintptrV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint8UintptrV(rv2i(rv).(map[uint8]uintptr), false, d) } - fastpathTV.DecMapUint8UintptrV(rv2i(rv).(map[uint8]uintptr), false, d) } func (f fastpathT) DecMapUint8UintptrX(vp *map[uint8]uintptr, d *Decoder) { - if v, changed := f.DecMapUint8UintptrV(*vp, true, d); changed { + v, changed := f.DecMapUint8UintptrV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint8UintptrV(v map[uint8]uintptr, canChange bool, d *Decoder) (_ map[uint8]uintptr, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -23210,7 +24520,6 @@ func (_ fastpathT) DecMapUint8UintptrV(v map[uint8]uintptr, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint8 var mv uintptr hasLen := containerLen > 0 @@ -23218,19 +24527,20 @@ func (_ fastpathT) DecMapUint8UintptrV(v map[uint8]uintptr, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint8(dd.DecodeUint(8)) + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uintptr(dd.DecodeUint(uintBitsize)) + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -23242,22 +24552,23 @@ func (_ fastpathT) DecMapUint8UintptrV(v map[uint8]uintptr, canChange bool, func (d *Decoder) fastpathDecMapUint8IntR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint8]int) - if v, changed := fastpathTV.DecMapUint8IntV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint8IntV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint8IntV(rv2i(rv).(map[uint8]int), false, d) } - fastpathTV.DecMapUint8IntV(rv2i(rv).(map[uint8]int), false, d) } func (f fastpathT) DecMapUint8IntX(vp *map[uint8]int, d *Decoder) { - if v, changed := f.DecMapUint8IntV(*vp, true, d); changed { + v, changed := f.DecMapUint8IntV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint8IntV(v map[uint8]int, canChange bool, d *Decoder) (_ map[uint8]int, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -23268,7 +24579,6 @@ func (_ fastpathT) DecMapUint8IntV(v map[uint8]int, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint8 var mv int hasLen := containerLen > 0 @@ -23276,19 +24586,20 @@ func (_ fastpathT) DecMapUint8IntV(v map[uint8]int, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint8(dd.DecodeUint(8)) + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int(dd.DecodeInt(intBitsize)) + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } @@ -23300,22 +24611,23 @@ func (_ fastpathT) DecMapUint8IntV(v map[uint8]int, canChange bool, func (d *Decoder) fastpathDecMapUint8Int8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint8]int8) - if v, changed := fastpathTV.DecMapUint8Int8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint8Int8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint8Int8V(rv2i(rv).(map[uint8]int8), false, d) } - fastpathTV.DecMapUint8Int8V(rv2i(rv).(map[uint8]int8), false, d) } func (f fastpathT) DecMapUint8Int8X(vp *map[uint8]int8, d *Decoder) { - if v, changed := f.DecMapUint8Int8V(*vp, true, d); changed { + v, changed := f.DecMapUint8Int8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint8Int8V(v map[uint8]int8, canChange bool, d *Decoder) (_ map[uint8]int8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 2) @@ -23326,7 +24638,6 @@ func (_ fastpathT) DecMapUint8Int8V(v map[uint8]int8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint8 var mv int8 hasLen := containerLen > 0 @@ -23334,19 +24645,20 @@ func (_ fastpathT) DecMapUint8Int8V(v map[uint8]int8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint8(dd.DecodeUint(8)) + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int8(dd.DecodeInt(8)) + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } @@ -23358,22 +24670,23 @@ func (_ fastpathT) DecMapUint8Int8V(v map[uint8]int8, canChange bool, func (d *Decoder) fastpathDecMapUint8Int16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint8]int16) - if v, changed := fastpathTV.DecMapUint8Int16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint8Int16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint8Int16V(rv2i(rv).(map[uint8]int16), false, d) } - fastpathTV.DecMapUint8Int16V(rv2i(rv).(map[uint8]int16), false, d) } func (f fastpathT) DecMapUint8Int16X(vp *map[uint8]int16, d *Decoder) { - if v, changed := f.DecMapUint8Int16V(*vp, true, d); changed { + v, changed := f.DecMapUint8Int16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint8Int16V(v map[uint8]int16, canChange bool, d *Decoder) (_ map[uint8]int16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 3) @@ -23384,7 +24697,6 @@ func (_ fastpathT) DecMapUint8Int16V(v map[uint8]int16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint8 var mv int16 hasLen := containerLen > 0 @@ -23392,19 +24704,20 @@ func (_ fastpathT) DecMapUint8Int16V(v map[uint8]int16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint8(dd.DecodeUint(8)) + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int16(dd.DecodeInt(16)) + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } @@ -23416,22 +24729,23 @@ func (_ fastpathT) DecMapUint8Int16V(v map[uint8]int16, canChange bool, func (d *Decoder) fastpathDecMapUint8Int32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint8]int32) - if v, changed := fastpathTV.DecMapUint8Int32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint8Int32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint8Int32V(rv2i(rv).(map[uint8]int32), false, d) } - fastpathTV.DecMapUint8Int32V(rv2i(rv).(map[uint8]int32), false, d) } func (f fastpathT) DecMapUint8Int32X(vp *map[uint8]int32, d *Decoder) { - if v, changed := f.DecMapUint8Int32V(*vp, true, d); changed { + v, changed := f.DecMapUint8Int32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint8Int32V(v map[uint8]int32, canChange bool, d *Decoder) (_ map[uint8]int32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 5) @@ -23442,7 +24756,6 @@ func (_ fastpathT) DecMapUint8Int32V(v map[uint8]int32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint8 var mv int32 hasLen := containerLen > 0 @@ -23450,19 +24763,20 @@ func (_ fastpathT) DecMapUint8Int32V(v map[uint8]int32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint8(dd.DecodeUint(8)) + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int32(dd.DecodeInt(32)) + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } @@ -23474,22 +24788,23 @@ func (_ fastpathT) DecMapUint8Int32V(v map[uint8]int32, canChange bool, func (d *Decoder) fastpathDecMapUint8Int64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint8]int64) - if v, changed := fastpathTV.DecMapUint8Int64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint8Int64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint8Int64V(rv2i(rv).(map[uint8]int64), false, d) } - fastpathTV.DecMapUint8Int64V(rv2i(rv).(map[uint8]int64), false, d) } func (f fastpathT) DecMapUint8Int64X(vp *map[uint8]int64, d *Decoder) { - if v, changed := f.DecMapUint8Int64V(*vp, true, d); changed { + v, changed := f.DecMapUint8Int64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint8Int64V(v map[uint8]int64, canChange bool, d *Decoder) (_ map[uint8]int64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -23500,7 +24815,6 @@ func (_ fastpathT) DecMapUint8Int64V(v map[uint8]int64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint8 var mv int64 hasLen := containerLen > 0 @@ -23508,19 +24822,20 @@ func (_ fastpathT) DecMapUint8Int64V(v map[uint8]int64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint8(dd.DecodeUint(8)) + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeInt(64) + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } @@ -23532,22 +24847,23 @@ func (_ fastpathT) DecMapUint8Int64V(v map[uint8]int64, canChange bool, func (d *Decoder) fastpathDecMapUint8Float32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint8]float32) - if v, changed := fastpathTV.DecMapUint8Float32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint8Float32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint8Float32V(rv2i(rv).(map[uint8]float32), false, d) } - fastpathTV.DecMapUint8Float32V(rv2i(rv).(map[uint8]float32), false, d) } func (f fastpathT) DecMapUint8Float32X(vp *map[uint8]float32, d *Decoder) { - if v, changed := f.DecMapUint8Float32V(*vp, true, d); changed { + v, changed := f.DecMapUint8Float32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint8Float32V(v map[uint8]float32, canChange bool, d *Decoder) (_ map[uint8]float32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 5) @@ -23558,7 +24874,6 @@ func (_ fastpathT) DecMapUint8Float32V(v map[uint8]float32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint8 var mv float32 hasLen := containerLen > 0 @@ -23566,19 +24881,20 @@ func (_ fastpathT) DecMapUint8Float32V(v map[uint8]float32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint8(dd.DecodeUint(8)) + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = float32(dd.DecodeFloat(true)) + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } @@ -23590,22 +24906,23 @@ func (_ fastpathT) DecMapUint8Float32V(v map[uint8]float32, canChange bool, func (d *Decoder) fastpathDecMapUint8Float64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint8]float64) - if v, changed := fastpathTV.DecMapUint8Float64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint8Float64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint8Float64V(rv2i(rv).(map[uint8]float64), false, d) } - fastpathTV.DecMapUint8Float64V(rv2i(rv).(map[uint8]float64), false, d) } func (f fastpathT) DecMapUint8Float64X(vp *map[uint8]float64, d *Decoder) { - if v, changed := f.DecMapUint8Float64V(*vp, true, d); changed { + v, changed := f.DecMapUint8Float64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint8Float64V(v map[uint8]float64, canChange bool, d *Decoder) (_ map[uint8]float64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -23616,7 +24933,6 @@ func (_ fastpathT) DecMapUint8Float64V(v map[uint8]float64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint8 var mv float64 hasLen := containerLen > 0 @@ -23624,19 +24940,20 @@ func (_ fastpathT) DecMapUint8Float64V(v map[uint8]float64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint8(dd.DecodeUint(8)) + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeFloat(false) + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } @@ -23648,22 +24965,23 @@ func (_ fastpathT) DecMapUint8Float64V(v map[uint8]float64, canChange bool, func (d *Decoder) fastpathDecMapUint8BoolR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint8]bool) - if v, changed := fastpathTV.DecMapUint8BoolV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint8BoolV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint8BoolV(rv2i(rv).(map[uint8]bool), false, d) } - fastpathTV.DecMapUint8BoolV(rv2i(rv).(map[uint8]bool), false, d) } func (f fastpathT) DecMapUint8BoolX(vp *map[uint8]bool, d *Decoder) { - if v, changed := f.DecMapUint8BoolV(*vp, true, d); changed { + v, changed := f.DecMapUint8BoolV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint8BoolV(v map[uint8]bool, canChange bool, d *Decoder) (_ map[uint8]bool, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 2) @@ -23674,7 +24992,6 @@ func (_ fastpathT) DecMapUint8BoolV(v map[uint8]bool, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint8 var mv bool hasLen := containerLen > 0 @@ -23682,12 +24999,13 @@ func (_ fastpathT) DecMapUint8BoolV(v map[uint8]bool, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint8(dd.DecodeUint(8)) + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = false @@ -23706,22 +25024,23 @@ func (_ fastpathT) DecMapUint8BoolV(v map[uint8]bool, canChange bool, func (d *Decoder) fastpathDecMapUint16IntfR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint16]interface{}) - if v, changed := fastpathTV.DecMapUint16IntfV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint16IntfV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint16IntfV(rv2i(rv).(map[uint16]interface{}), false, d) } - fastpathTV.DecMapUint16IntfV(rv2i(rv).(map[uint16]interface{}), false, d) } func (f fastpathT) DecMapUint16IntfX(vp *map[uint16]interface{}, d *Decoder) { - if v, changed := f.DecMapUint16IntfV(*vp, true, d); changed { + v, changed := f.DecMapUint16IntfV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint16IntfV(v map[uint16]interface{}, canChange bool, d *Decoder) (_ map[uint16]interface{}, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 18) @@ -23732,7 +25051,7 @@ func (_ fastpathT) DecMapUint16IntfV(v map[uint16]interface{}, canChange bool, dd.ReadMapEnd() return v, changed } - mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset var mk uint16 var mv interface{} hasLen := containerLen > 0 @@ -23740,12 +25059,13 @@ func (_ fastpathT) DecMapUint16IntfV(v map[uint16]interface{}, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint16(dd.DecodeUint(16)) + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = nil @@ -23769,22 +25089,23 @@ func (_ fastpathT) DecMapUint16IntfV(v map[uint16]interface{}, canChange bool, func (d *Decoder) fastpathDecMapUint16StringR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint16]string) - if v, changed := fastpathTV.DecMapUint16StringV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint16StringV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint16StringV(rv2i(rv).(map[uint16]string), false, d) } - fastpathTV.DecMapUint16StringV(rv2i(rv).(map[uint16]string), false, d) } func (f fastpathT) DecMapUint16StringX(vp *map[uint16]string, d *Decoder) { - if v, changed := f.DecMapUint16StringV(*vp, true, d); changed { + v, changed := f.DecMapUint16StringV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint16StringV(v map[uint16]string, canChange bool, d *Decoder) (_ map[uint16]string, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 18) @@ -23795,7 +25116,6 @@ func (_ fastpathT) DecMapUint16StringV(v map[uint16]string, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint16 var mv string hasLen := containerLen > 0 @@ -23803,12 +25123,13 @@ func (_ fastpathT) DecMapUint16StringV(v map[uint16]string, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint16(dd.DecodeUint(16)) + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = "" @@ -23827,22 +25148,23 @@ func (_ fastpathT) DecMapUint16StringV(v map[uint16]string, canChange bool, func (d *Decoder) fastpathDecMapUint16UintR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint16]uint) - if v, changed := fastpathTV.DecMapUint16UintV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint16UintV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint16UintV(rv2i(rv).(map[uint16]uint), false, d) } - fastpathTV.DecMapUint16UintV(rv2i(rv).(map[uint16]uint), false, d) } func (f fastpathT) DecMapUint16UintX(vp *map[uint16]uint, d *Decoder) { - if v, changed := f.DecMapUint16UintV(*vp, true, d); changed { + v, changed := f.DecMapUint16UintV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint16UintV(v map[uint16]uint, canChange bool, d *Decoder) (_ map[uint16]uint, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -23853,7 +25175,6 @@ func (_ fastpathT) DecMapUint16UintV(v map[uint16]uint, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint16 var mv uint hasLen := containerLen > 0 @@ -23861,19 +25182,20 @@ func (_ fastpathT) DecMapUint16UintV(v map[uint16]uint, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint16(dd.DecodeUint(16)) + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint(dd.DecodeUint(uintBitsize)) + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -23885,22 +25207,23 @@ func (_ fastpathT) DecMapUint16UintV(v map[uint16]uint, canChange bool, func (d *Decoder) fastpathDecMapUint16Uint8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint16]uint8) - if v, changed := fastpathTV.DecMapUint16Uint8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint16Uint8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint16Uint8V(rv2i(rv).(map[uint16]uint8), false, d) } - fastpathTV.DecMapUint16Uint8V(rv2i(rv).(map[uint16]uint8), false, d) } func (f fastpathT) DecMapUint16Uint8X(vp *map[uint16]uint8, d *Decoder) { - if v, changed := f.DecMapUint16Uint8V(*vp, true, d); changed { + v, changed := f.DecMapUint16Uint8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint16Uint8V(v map[uint16]uint8, canChange bool, d *Decoder) (_ map[uint16]uint8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 3) @@ -23911,7 +25234,6 @@ func (_ fastpathT) DecMapUint16Uint8V(v map[uint16]uint8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint16 var mv uint8 hasLen := containerLen > 0 @@ -23919,19 +25241,20 @@ func (_ fastpathT) DecMapUint16Uint8V(v map[uint16]uint8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint16(dd.DecodeUint(16)) + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint8(dd.DecodeUint(8)) + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } @@ -23943,22 +25266,23 @@ func (_ fastpathT) DecMapUint16Uint8V(v map[uint16]uint8, canChange bool, func (d *Decoder) fastpathDecMapUint16Uint16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint16]uint16) - if v, changed := fastpathTV.DecMapUint16Uint16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint16Uint16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint16Uint16V(rv2i(rv).(map[uint16]uint16), false, d) } - fastpathTV.DecMapUint16Uint16V(rv2i(rv).(map[uint16]uint16), false, d) } func (f fastpathT) DecMapUint16Uint16X(vp *map[uint16]uint16, d *Decoder) { - if v, changed := f.DecMapUint16Uint16V(*vp, true, d); changed { + v, changed := f.DecMapUint16Uint16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint16Uint16V(v map[uint16]uint16, canChange bool, d *Decoder) (_ map[uint16]uint16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 4) @@ -23969,7 +25293,6 @@ func (_ fastpathT) DecMapUint16Uint16V(v map[uint16]uint16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint16 var mv uint16 hasLen := containerLen > 0 @@ -23977,19 +25300,20 @@ func (_ fastpathT) DecMapUint16Uint16V(v map[uint16]uint16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint16(dd.DecodeUint(16)) + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint16(dd.DecodeUint(16)) + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } @@ -24001,22 +25325,23 @@ func (_ fastpathT) DecMapUint16Uint16V(v map[uint16]uint16, canChange bool, func (d *Decoder) fastpathDecMapUint16Uint32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint16]uint32) - if v, changed := fastpathTV.DecMapUint16Uint32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint16Uint32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint16Uint32V(rv2i(rv).(map[uint16]uint32), false, d) } - fastpathTV.DecMapUint16Uint32V(rv2i(rv).(map[uint16]uint32), false, d) } func (f fastpathT) DecMapUint16Uint32X(vp *map[uint16]uint32, d *Decoder) { - if v, changed := f.DecMapUint16Uint32V(*vp, true, d); changed { + v, changed := f.DecMapUint16Uint32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint16Uint32V(v map[uint16]uint32, canChange bool, d *Decoder) (_ map[uint16]uint32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 6) @@ -24027,7 +25352,6 @@ func (_ fastpathT) DecMapUint16Uint32V(v map[uint16]uint32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint16 var mv uint32 hasLen := containerLen > 0 @@ -24035,19 +25359,20 @@ func (_ fastpathT) DecMapUint16Uint32V(v map[uint16]uint32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint16(dd.DecodeUint(16)) + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint32(dd.DecodeUint(32)) + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } @@ -24059,22 +25384,23 @@ func (_ fastpathT) DecMapUint16Uint32V(v map[uint16]uint32, canChange bool, func (d *Decoder) fastpathDecMapUint16Uint64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint16]uint64) - if v, changed := fastpathTV.DecMapUint16Uint64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint16Uint64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint16Uint64V(rv2i(rv).(map[uint16]uint64), false, d) } - fastpathTV.DecMapUint16Uint64V(rv2i(rv).(map[uint16]uint64), false, d) } func (f fastpathT) DecMapUint16Uint64X(vp *map[uint16]uint64, d *Decoder) { - if v, changed := f.DecMapUint16Uint64V(*vp, true, d); changed { + v, changed := f.DecMapUint16Uint64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint16Uint64V(v map[uint16]uint64, canChange bool, d *Decoder) (_ map[uint16]uint64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -24085,7 +25411,6 @@ func (_ fastpathT) DecMapUint16Uint64V(v map[uint16]uint64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint16 var mv uint64 hasLen := containerLen > 0 @@ -24093,19 +25418,20 @@ func (_ fastpathT) DecMapUint16Uint64V(v map[uint16]uint64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint16(dd.DecodeUint(16)) + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeUint(64) + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } @@ -24117,22 +25443,23 @@ func (_ fastpathT) DecMapUint16Uint64V(v map[uint16]uint64, canChange bool, func (d *Decoder) fastpathDecMapUint16UintptrR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint16]uintptr) - if v, changed := fastpathTV.DecMapUint16UintptrV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint16UintptrV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint16UintptrV(rv2i(rv).(map[uint16]uintptr), false, d) } - fastpathTV.DecMapUint16UintptrV(rv2i(rv).(map[uint16]uintptr), false, d) } func (f fastpathT) DecMapUint16UintptrX(vp *map[uint16]uintptr, d *Decoder) { - if v, changed := f.DecMapUint16UintptrV(*vp, true, d); changed { + v, changed := f.DecMapUint16UintptrV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint16UintptrV(v map[uint16]uintptr, canChange bool, d *Decoder) (_ map[uint16]uintptr, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -24143,7 +25470,6 @@ func (_ fastpathT) DecMapUint16UintptrV(v map[uint16]uintptr, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint16 var mv uintptr hasLen := containerLen > 0 @@ -24151,19 +25477,20 @@ func (_ fastpathT) DecMapUint16UintptrV(v map[uint16]uintptr, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint16(dd.DecodeUint(16)) + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uintptr(dd.DecodeUint(uintBitsize)) + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -24175,22 +25502,23 @@ func (_ fastpathT) DecMapUint16UintptrV(v map[uint16]uintptr, canChange bool, func (d *Decoder) fastpathDecMapUint16IntR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint16]int) - if v, changed := fastpathTV.DecMapUint16IntV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint16IntV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint16IntV(rv2i(rv).(map[uint16]int), false, d) } - fastpathTV.DecMapUint16IntV(rv2i(rv).(map[uint16]int), false, d) } func (f fastpathT) DecMapUint16IntX(vp *map[uint16]int, d *Decoder) { - if v, changed := f.DecMapUint16IntV(*vp, true, d); changed { + v, changed := f.DecMapUint16IntV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint16IntV(v map[uint16]int, canChange bool, d *Decoder) (_ map[uint16]int, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -24201,7 +25529,6 @@ func (_ fastpathT) DecMapUint16IntV(v map[uint16]int, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint16 var mv int hasLen := containerLen > 0 @@ -24209,19 +25536,20 @@ func (_ fastpathT) DecMapUint16IntV(v map[uint16]int, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint16(dd.DecodeUint(16)) + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int(dd.DecodeInt(intBitsize)) + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } @@ -24233,22 +25561,23 @@ func (_ fastpathT) DecMapUint16IntV(v map[uint16]int, canChange bool, func (d *Decoder) fastpathDecMapUint16Int8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint16]int8) - if v, changed := fastpathTV.DecMapUint16Int8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint16Int8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint16Int8V(rv2i(rv).(map[uint16]int8), false, d) } - fastpathTV.DecMapUint16Int8V(rv2i(rv).(map[uint16]int8), false, d) } func (f fastpathT) DecMapUint16Int8X(vp *map[uint16]int8, d *Decoder) { - if v, changed := f.DecMapUint16Int8V(*vp, true, d); changed { + v, changed := f.DecMapUint16Int8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint16Int8V(v map[uint16]int8, canChange bool, d *Decoder) (_ map[uint16]int8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 3) @@ -24259,7 +25588,6 @@ func (_ fastpathT) DecMapUint16Int8V(v map[uint16]int8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint16 var mv int8 hasLen := containerLen > 0 @@ -24267,19 +25595,20 @@ func (_ fastpathT) DecMapUint16Int8V(v map[uint16]int8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint16(dd.DecodeUint(16)) + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int8(dd.DecodeInt(8)) + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } @@ -24291,22 +25620,23 @@ func (_ fastpathT) DecMapUint16Int8V(v map[uint16]int8, canChange bool, func (d *Decoder) fastpathDecMapUint16Int16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint16]int16) - if v, changed := fastpathTV.DecMapUint16Int16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint16Int16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint16Int16V(rv2i(rv).(map[uint16]int16), false, d) } - fastpathTV.DecMapUint16Int16V(rv2i(rv).(map[uint16]int16), false, d) } func (f fastpathT) DecMapUint16Int16X(vp *map[uint16]int16, d *Decoder) { - if v, changed := f.DecMapUint16Int16V(*vp, true, d); changed { + v, changed := f.DecMapUint16Int16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint16Int16V(v map[uint16]int16, canChange bool, d *Decoder) (_ map[uint16]int16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 4) @@ -24317,7 +25647,6 @@ func (_ fastpathT) DecMapUint16Int16V(v map[uint16]int16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint16 var mv int16 hasLen := containerLen > 0 @@ -24325,19 +25654,20 @@ func (_ fastpathT) DecMapUint16Int16V(v map[uint16]int16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint16(dd.DecodeUint(16)) + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int16(dd.DecodeInt(16)) + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } @@ -24349,22 +25679,23 @@ func (_ fastpathT) DecMapUint16Int16V(v map[uint16]int16, canChange bool, func (d *Decoder) fastpathDecMapUint16Int32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint16]int32) - if v, changed := fastpathTV.DecMapUint16Int32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint16Int32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint16Int32V(rv2i(rv).(map[uint16]int32), false, d) } - fastpathTV.DecMapUint16Int32V(rv2i(rv).(map[uint16]int32), false, d) } func (f fastpathT) DecMapUint16Int32X(vp *map[uint16]int32, d *Decoder) { - if v, changed := f.DecMapUint16Int32V(*vp, true, d); changed { + v, changed := f.DecMapUint16Int32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint16Int32V(v map[uint16]int32, canChange bool, d *Decoder) (_ map[uint16]int32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 6) @@ -24375,7 +25706,6 @@ func (_ fastpathT) DecMapUint16Int32V(v map[uint16]int32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint16 var mv int32 hasLen := containerLen > 0 @@ -24383,19 +25713,20 @@ func (_ fastpathT) DecMapUint16Int32V(v map[uint16]int32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint16(dd.DecodeUint(16)) + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int32(dd.DecodeInt(32)) + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } @@ -24407,22 +25738,23 @@ func (_ fastpathT) DecMapUint16Int32V(v map[uint16]int32, canChange bool, func (d *Decoder) fastpathDecMapUint16Int64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint16]int64) - if v, changed := fastpathTV.DecMapUint16Int64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint16Int64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint16Int64V(rv2i(rv).(map[uint16]int64), false, d) } - fastpathTV.DecMapUint16Int64V(rv2i(rv).(map[uint16]int64), false, d) } func (f fastpathT) DecMapUint16Int64X(vp *map[uint16]int64, d *Decoder) { - if v, changed := f.DecMapUint16Int64V(*vp, true, d); changed { + v, changed := f.DecMapUint16Int64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint16Int64V(v map[uint16]int64, canChange bool, d *Decoder) (_ map[uint16]int64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -24433,7 +25765,6 @@ func (_ fastpathT) DecMapUint16Int64V(v map[uint16]int64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint16 var mv int64 hasLen := containerLen > 0 @@ -24441,19 +25772,20 @@ func (_ fastpathT) DecMapUint16Int64V(v map[uint16]int64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint16(dd.DecodeUint(16)) + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeInt(64) + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } @@ -24465,22 +25797,23 @@ func (_ fastpathT) DecMapUint16Int64V(v map[uint16]int64, canChange bool, func (d *Decoder) fastpathDecMapUint16Float32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint16]float32) - if v, changed := fastpathTV.DecMapUint16Float32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint16Float32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint16Float32V(rv2i(rv).(map[uint16]float32), false, d) } - fastpathTV.DecMapUint16Float32V(rv2i(rv).(map[uint16]float32), false, d) } func (f fastpathT) DecMapUint16Float32X(vp *map[uint16]float32, d *Decoder) { - if v, changed := f.DecMapUint16Float32V(*vp, true, d); changed { + v, changed := f.DecMapUint16Float32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint16Float32V(v map[uint16]float32, canChange bool, d *Decoder) (_ map[uint16]float32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 6) @@ -24491,7 +25824,6 @@ func (_ fastpathT) DecMapUint16Float32V(v map[uint16]float32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint16 var mv float32 hasLen := containerLen > 0 @@ -24499,19 +25831,20 @@ func (_ fastpathT) DecMapUint16Float32V(v map[uint16]float32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint16(dd.DecodeUint(16)) + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = float32(dd.DecodeFloat(true)) + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } @@ -24523,22 +25856,23 @@ func (_ fastpathT) DecMapUint16Float32V(v map[uint16]float32, canChange bool, func (d *Decoder) fastpathDecMapUint16Float64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint16]float64) - if v, changed := fastpathTV.DecMapUint16Float64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint16Float64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint16Float64V(rv2i(rv).(map[uint16]float64), false, d) } - fastpathTV.DecMapUint16Float64V(rv2i(rv).(map[uint16]float64), false, d) } func (f fastpathT) DecMapUint16Float64X(vp *map[uint16]float64, d *Decoder) { - if v, changed := f.DecMapUint16Float64V(*vp, true, d); changed { + v, changed := f.DecMapUint16Float64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint16Float64V(v map[uint16]float64, canChange bool, d *Decoder) (_ map[uint16]float64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -24549,7 +25883,6 @@ func (_ fastpathT) DecMapUint16Float64V(v map[uint16]float64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint16 var mv float64 hasLen := containerLen > 0 @@ -24557,19 +25890,20 @@ func (_ fastpathT) DecMapUint16Float64V(v map[uint16]float64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint16(dd.DecodeUint(16)) + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeFloat(false) + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } @@ -24581,22 +25915,23 @@ func (_ fastpathT) DecMapUint16Float64V(v map[uint16]float64, canChange bool, func (d *Decoder) fastpathDecMapUint16BoolR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint16]bool) - if v, changed := fastpathTV.DecMapUint16BoolV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint16BoolV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint16BoolV(rv2i(rv).(map[uint16]bool), false, d) } - fastpathTV.DecMapUint16BoolV(rv2i(rv).(map[uint16]bool), false, d) } func (f fastpathT) DecMapUint16BoolX(vp *map[uint16]bool, d *Decoder) { - if v, changed := f.DecMapUint16BoolV(*vp, true, d); changed { + v, changed := f.DecMapUint16BoolV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint16BoolV(v map[uint16]bool, canChange bool, d *Decoder) (_ map[uint16]bool, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 3) @@ -24607,7 +25942,6 @@ func (_ fastpathT) DecMapUint16BoolV(v map[uint16]bool, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint16 var mv bool hasLen := containerLen > 0 @@ -24615,12 +25949,13 @@ func (_ fastpathT) DecMapUint16BoolV(v map[uint16]bool, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint16(dd.DecodeUint(16)) + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = false @@ -24639,22 +25974,23 @@ func (_ fastpathT) DecMapUint16BoolV(v map[uint16]bool, canChange bool, func (d *Decoder) fastpathDecMapUint32IntfR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint32]interface{}) - if v, changed := fastpathTV.DecMapUint32IntfV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint32IntfV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint32IntfV(rv2i(rv).(map[uint32]interface{}), false, d) } - fastpathTV.DecMapUint32IntfV(rv2i(rv).(map[uint32]interface{}), false, d) } func (f fastpathT) DecMapUint32IntfX(vp *map[uint32]interface{}, d *Decoder) { - if v, changed := f.DecMapUint32IntfV(*vp, true, d); changed { + v, changed := f.DecMapUint32IntfV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint32IntfV(v map[uint32]interface{}, canChange bool, d *Decoder) (_ map[uint32]interface{}, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 20) @@ -24665,7 +26001,7 @@ func (_ fastpathT) DecMapUint32IntfV(v map[uint32]interface{}, canChange bool, dd.ReadMapEnd() return v, changed } - mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset var mk uint32 var mv interface{} hasLen := containerLen > 0 @@ -24673,12 +26009,13 @@ func (_ fastpathT) DecMapUint32IntfV(v map[uint32]interface{}, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint32(dd.DecodeUint(32)) + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = nil @@ -24702,22 +26039,23 @@ func (_ fastpathT) DecMapUint32IntfV(v map[uint32]interface{}, canChange bool, func (d *Decoder) fastpathDecMapUint32StringR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint32]string) - if v, changed := fastpathTV.DecMapUint32StringV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint32StringV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint32StringV(rv2i(rv).(map[uint32]string), false, d) } - fastpathTV.DecMapUint32StringV(rv2i(rv).(map[uint32]string), false, d) } func (f fastpathT) DecMapUint32StringX(vp *map[uint32]string, d *Decoder) { - if v, changed := f.DecMapUint32StringV(*vp, true, d); changed { + v, changed := f.DecMapUint32StringV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint32StringV(v map[uint32]string, canChange bool, d *Decoder) (_ map[uint32]string, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 20) @@ -24728,7 +26066,6 @@ func (_ fastpathT) DecMapUint32StringV(v map[uint32]string, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint32 var mv string hasLen := containerLen > 0 @@ -24736,12 +26073,13 @@ func (_ fastpathT) DecMapUint32StringV(v map[uint32]string, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint32(dd.DecodeUint(32)) + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = "" @@ -24760,22 +26098,23 @@ func (_ fastpathT) DecMapUint32StringV(v map[uint32]string, canChange bool, func (d *Decoder) fastpathDecMapUint32UintR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint32]uint) - if v, changed := fastpathTV.DecMapUint32UintV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint32UintV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint32UintV(rv2i(rv).(map[uint32]uint), false, d) } - fastpathTV.DecMapUint32UintV(rv2i(rv).(map[uint32]uint), false, d) } func (f fastpathT) DecMapUint32UintX(vp *map[uint32]uint, d *Decoder) { - if v, changed := f.DecMapUint32UintV(*vp, true, d); changed { + v, changed := f.DecMapUint32UintV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint32UintV(v map[uint32]uint, canChange bool, d *Decoder) (_ map[uint32]uint, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -24786,7 +26125,6 @@ func (_ fastpathT) DecMapUint32UintV(v map[uint32]uint, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint32 var mv uint hasLen := containerLen > 0 @@ -24794,19 +26132,20 @@ func (_ fastpathT) DecMapUint32UintV(v map[uint32]uint, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint32(dd.DecodeUint(32)) + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint(dd.DecodeUint(uintBitsize)) + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -24818,22 +26157,23 @@ func (_ fastpathT) DecMapUint32UintV(v map[uint32]uint, canChange bool, func (d *Decoder) fastpathDecMapUint32Uint8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint32]uint8) - if v, changed := fastpathTV.DecMapUint32Uint8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint32Uint8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint32Uint8V(rv2i(rv).(map[uint32]uint8), false, d) } - fastpathTV.DecMapUint32Uint8V(rv2i(rv).(map[uint32]uint8), false, d) } func (f fastpathT) DecMapUint32Uint8X(vp *map[uint32]uint8, d *Decoder) { - if v, changed := f.DecMapUint32Uint8V(*vp, true, d); changed { + v, changed := f.DecMapUint32Uint8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint32Uint8V(v map[uint32]uint8, canChange bool, d *Decoder) (_ map[uint32]uint8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 5) @@ -24844,7 +26184,6 @@ func (_ fastpathT) DecMapUint32Uint8V(v map[uint32]uint8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint32 var mv uint8 hasLen := containerLen > 0 @@ -24852,19 +26191,20 @@ func (_ fastpathT) DecMapUint32Uint8V(v map[uint32]uint8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint32(dd.DecodeUint(32)) + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint8(dd.DecodeUint(8)) + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } @@ -24876,22 +26216,23 @@ func (_ fastpathT) DecMapUint32Uint8V(v map[uint32]uint8, canChange bool, func (d *Decoder) fastpathDecMapUint32Uint16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint32]uint16) - if v, changed := fastpathTV.DecMapUint32Uint16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint32Uint16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint32Uint16V(rv2i(rv).(map[uint32]uint16), false, d) } - fastpathTV.DecMapUint32Uint16V(rv2i(rv).(map[uint32]uint16), false, d) } func (f fastpathT) DecMapUint32Uint16X(vp *map[uint32]uint16, d *Decoder) { - if v, changed := f.DecMapUint32Uint16V(*vp, true, d); changed { + v, changed := f.DecMapUint32Uint16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint32Uint16V(v map[uint32]uint16, canChange bool, d *Decoder) (_ map[uint32]uint16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 6) @@ -24902,7 +26243,6 @@ func (_ fastpathT) DecMapUint32Uint16V(v map[uint32]uint16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint32 var mv uint16 hasLen := containerLen > 0 @@ -24910,19 +26250,20 @@ func (_ fastpathT) DecMapUint32Uint16V(v map[uint32]uint16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint32(dd.DecodeUint(32)) + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint16(dd.DecodeUint(16)) + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } @@ -24934,22 +26275,23 @@ func (_ fastpathT) DecMapUint32Uint16V(v map[uint32]uint16, canChange bool, func (d *Decoder) fastpathDecMapUint32Uint32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint32]uint32) - if v, changed := fastpathTV.DecMapUint32Uint32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint32Uint32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint32Uint32V(rv2i(rv).(map[uint32]uint32), false, d) } - fastpathTV.DecMapUint32Uint32V(rv2i(rv).(map[uint32]uint32), false, d) } func (f fastpathT) DecMapUint32Uint32X(vp *map[uint32]uint32, d *Decoder) { - if v, changed := f.DecMapUint32Uint32V(*vp, true, d); changed { + v, changed := f.DecMapUint32Uint32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint32Uint32V(v map[uint32]uint32, canChange bool, d *Decoder) (_ map[uint32]uint32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 8) @@ -24960,7 +26302,6 @@ func (_ fastpathT) DecMapUint32Uint32V(v map[uint32]uint32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint32 var mv uint32 hasLen := containerLen > 0 @@ -24968,19 +26309,20 @@ func (_ fastpathT) DecMapUint32Uint32V(v map[uint32]uint32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint32(dd.DecodeUint(32)) + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint32(dd.DecodeUint(32)) + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } @@ -24992,22 +26334,23 @@ func (_ fastpathT) DecMapUint32Uint32V(v map[uint32]uint32, canChange bool, func (d *Decoder) fastpathDecMapUint32Uint64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint32]uint64) - if v, changed := fastpathTV.DecMapUint32Uint64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint32Uint64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint32Uint64V(rv2i(rv).(map[uint32]uint64), false, d) } - fastpathTV.DecMapUint32Uint64V(rv2i(rv).(map[uint32]uint64), false, d) } func (f fastpathT) DecMapUint32Uint64X(vp *map[uint32]uint64, d *Decoder) { - if v, changed := f.DecMapUint32Uint64V(*vp, true, d); changed { + v, changed := f.DecMapUint32Uint64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint32Uint64V(v map[uint32]uint64, canChange bool, d *Decoder) (_ map[uint32]uint64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -25018,7 +26361,6 @@ func (_ fastpathT) DecMapUint32Uint64V(v map[uint32]uint64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint32 var mv uint64 hasLen := containerLen > 0 @@ -25026,19 +26368,20 @@ func (_ fastpathT) DecMapUint32Uint64V(v map[uint32]uint64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint32(dd.DecodeUint(32)) + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeUint(64) + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } @@ -25050,22 +26393,23 @@ func (_ fastpathT) DecMapUint32Uint64V(v map[uint32]uint64, canChange bool, func (d *Decoder) fastpathDecMapUint32UintptrR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint32]uintptr) - if v, changed := fastpathTV.DecMapUint32UintptrV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint32UintptrV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint32UintptrV(rv2i(rv).(map[uint32]uintptr), false, d) } - fastpathTV.DecMapUint32UintptrV(rv2i(rv).(map[uint32]uintptr), false, d) } func (f fastpathT) DecMapUint32UintptrX(vp *map[uint32]uintptr, d *Decoder) { - if v, changed := f.DecMapUint32UintptrV(*vp, true, d); changed { + v, changed := f.DecMapUint32UintptrV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint32UintptrV(v map[uint32]uintptr, canChange bool, d *Decoder) (_ map[uint32]uintptr, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -25076,7 +26420,6 @@ func (_ fastpathT) DecMapUint32UintptrV(v map[uint32]uintptr, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint32 var mv uintptr hasLen := containerLen > 0 @@ -25084,19 +26427,20 @@ func (_ fastpathT) DecMapUint32UintptrV(v map[uint32]uintptr, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint32(dd.DecodeUint(32)) + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uintptr(dd.DecodeUint(uintBitsize)) + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -25108,22 +26452,23 @@ func (_ fastpathT) DecMapUint32UintptrV(v map[uint32]uintptr, canChange bool, func (d *Decoder) fastpathDecMapUint32IntR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint32]int) - if v, changed := fastpathTV.DecMapUint32IntV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint32IntV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint32IntV(rv2i(rv).(map[uint32]int), false, d) } - fastpathTV.DecMapUint32IntV(rv2i(rv).(map[uint32]int), false, d) } func (f fastpathT) DecMapUint32IntX(vp *map[uint32]int, d *Decoder) { - if v, changed := f.DecMapUint32IntV(*vp, true, d); changed { + v, changed := f.DecMapUint32IntV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint32IntV(v map[uint32]int, canChange bool, d *Decoder) (_ map[uint32]int, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -25134,7 +26479,6 @@ func (_ fastpathT) DecMapUint32IntV(v map[uint32]int, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint32 var mv int hasLen := containerLen > 0 @@ -25142,19 +26486,20 @@ func (_ fastpathT) DecMapUint32IntV(v map[uint32]int, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint32(dd.DecodeUint(32)) + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int(dd.DecodeInt(intBitsize)) + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } @@ -25166,22 +26511,23 @@ func (_ fastpathT) DecMapUint32IntV(v map[uint32]int, canChange bool, func (d *Decoder) fastpathDecMapUint32Int8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint32]int8) - if v, changed := fastpathTV.DecMapUint32Int8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint32Int8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint32Int8V(rv2i(rv).(map[uint32]int8), false, d) } - fastpathTV.DecMapUint32Int8V(rv2i(rv).(map[uint32]int8), false, d) } func (f fastpathT) DecMapUint32Int8X(vp *map[uint32]int8, d *Decoder) { - if v, changed := f.DecMapUint32Int8V(*vp, true, d); changed { + v, changed := f.DecMapUint32Int8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint32Int8V(v map[uint32]int8, canChange bool, d *Decoder) (_ map[uint32]int8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 5) @@ -25192,7 +26538,6 @@ func (_ fastpathT) DecMapUint32Int8V(v map[uint32]int8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint32 var mv int8 hasLen := containerLen > 0 @@ -25200,19 +26545,20 @@ func (_ fastpathT) DecMapUint32Int8V(v map[uint32]int8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint32(dd.DecodeUint(32)) + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int8(dd.DecodeInt(8)) + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } @@ -25224,22 +26570,23 @@ func (_ fastpathT) DecMapUint32Int8V(v map[uint32]int8, canChange bool, func (d *Decoder) fastpathDecMapUint32Int16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint32]int16) - if v, changed := fastpathTV.DecMapUint32Int16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint32Int16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint32Int16V(rv2i(rv).(map[uint32]int16), false, d) } - fastpathTV.DecMapUint32Int16V(rv2i(rv).(map[uint32]int16), false, d) } func (f fastpathT) DecMapUint32Int16X(vp *map[uint32]int16, d *Decoder) { - if v, changed := f.DecMapUint32Int16V(*vp, true, d); changed { + v, changed := f.DecMapUint32Int16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint32Int16V(v map[uint32]int16, canChange bool, d *Decoder) (_ map[uint32]int16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 6) @@ -25250,7 +26597,6 @@ func (_ fastpathT) DecMapUint32Int16V(v map[uint32]int16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint32 var mv int16 hasLen := containerLen > 0 @@ -25258,19 +26604,20 @@ func (_ fastpathT) DecMapUint32Int16V(v map[uint32]int16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint32(dd.DecodeUint(32)) + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int16(dd.DecodeInt(16)) + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } @@ -25282,22 +26629,23 @@ func (_ fastpathT) DecMapUint32Int16V(v map[uint32]int16, canChange bool, func (d *Decoder) fastpathDecMapUint32Int32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint32]int32) - if v, changed := fastpathTV.DecMapUint32Int32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint32Int32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint32Int32V(rv2i(rv).(map[uint32]int32), false, d) } - fastpathTV.DecMapUint32Int32V(rv2i(rv).(map[uint32]int32), false, d) } func (f fastpathT) DecMapUint32Int32X(vp *map[uint32]int32, d *Decoder) { - if v, changed := f.DecMapUint32Int32V(*vp, true, d); changed { + v, changed := f.DecMapUint32Int32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint32Int32V(v map[uint32]int32, canChange bool, d *Decoder) (_ map[uint32]int32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 8) @@ -25308,7 +26656,6 @@ func (_ fastpathT) DecMapUint32Int32V(v map[uint32]int32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint32 var mv int32 hasLen := containerLen > 0 @@ -25316,19 +26663,20 @@ func (_ fastpathT) DecMapUint32Int32V(v map[uint32]int32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint32(dd.DecodeUint(32)) + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int32(dd.DecodeInt(32)) + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } @@ -25340,22 +26688,23 @@ func (_ fastpathT) DecMapUint32Int32V(v map[uint32]int32, canChange bool, func (d *Decoder) fastpathDecMapUint32Int64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint32]int64) - if v, changed := fastpathTV.DecMapUint32Int64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint32Int64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint32Int64V(rv2i(rv).(map[uint32]int64), false, d) } - fastpathTV.DecMapUint32Int64V(rv2i(rv).(map[uint32]int64), false, d) } func (f fastpathT) DecMapUint32Int64X(vp *map[uint32]int64, d *Decoder) { - if v, changed := f.DecMapUint32Int64V(*vp, true, d); changed { + v, changed := f.DecMapUint32Int64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint32Int64V(v map[uint32]int64, canChange bool, d *Decoder) (_ map[uint32]int64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -25366,7 +26715,6 @@ func (_ fastpathT) DecMapUint32Int64V(v map[uint32]int64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint32 var mv int64 hasLen := containerLen > 0 @@ -25374,19 +26722,20 @@ func (_ fastpathT) DecMapUint32Int64V(v map[uint32]int64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint32(dd.DecodeUint(32)) + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeInt(64) + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } @@ -25398,22 +26747,23 @@ func (_ fastpathT) DecMapUint32Int64V(v map[uint32]int64, canChange bool, func (d *Decoder) fastpathDecMapUint32Float32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint32]float32) - if v, changed := fastpathTV.DecMapUint32Float32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint32Float32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint32Float32V(rv2i(rv).(map[uint32]float32), false, d) } - fastpathTV.DecMapUint32Float32V(rv2i(rv).(map[uint32]float32), false, d) } func (f fastpathT) DecMapUint32Float32X(vp *map[uint32]float32, d *Decoder) { - if v, changed := f.DecMapUint32Float32V(*vp, true, d); changed { + v, changed := f.DecMapUint32Float32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint32Float32V(v map[uint32]float32, canChange bool, d *Decoder) (_ map[uint32]float32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 8) @@ -25424,7 +26774,6 @@ func (_ fastpathT) DecMapUint32Float32V(v map[uint32]float32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint32 var mv float32 hasLen := containerLen > 0 @@ -25432,19 +26781,20 @@ func (_ fastpathT) DecMapUint32Float32V(v map[uint32]float32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint32(dd.DecodeUint(32)) + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = float32(dd.DecodeFloat(true)) + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } @@ -25456,22 +26806,23 @@ func (_ fastpathT) DecMapUint32Float32V(v map[uint32]float32, canChange bool, func (d *Decoder) fastpathDecMapUint32Float64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint32]float64) - if v, changed := fastpathTV.DecMapUint32Float64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint32Float64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint32Float64V(rv2i(rv).(map[uint32]float64), false, d) } - fastpathTV.DecMapUint32Float64V(rv2i(rv).(map[uint32]float64), false, d) } func (f fastpathT) DecMapUint32Float64X(vp *map[uint32]float64, d *Decoder) { - if v, changed := f.DecMapUint32Float64V(*vp, true, d); changed { + v, changed := f.DecMapUint32Float64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint32Float64V(v map[uint32]float64, canChange bool, d *Decoder) (_ map[uint32]float64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -25482,7 +26833,6 @@ func (_ fastpathT) DecMapUint32Float64V(v map[uint32]float64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint32 var mv float64 hasLen := containerLen > 0 @@ -25490,19 +26840,20 @@ func (_ fastpathT) DecMapUint32Float64V(v map[uint32]float64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint32(dd.DecodeUint(32)) + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeFloat(false) + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } @@ -25514,22 +26865,23 @@ func (_ fastpathT) DecMapUint32Float64V(v map[uint32]float64, canChange bool, func (d *Decoder) fastpathDecMapUint32BoolR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint32]bool) - if v, changed := fastpathTV.DecMapUint32BoolV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint32BoolV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint32BoolV(rv2i(rv).(map[uint32]bool), false, d) } - fastpathTV.DecMapUint32BoolV(rv2i(rv).(map[uint32]bool), false, d) } func (f fastpathT) DecMapUint32BoolX(vp *map[uint32]bool, d *Decoder) { - if v, changed := f.DecMapUint32BoolV(*vp, true, d); changed { + v, changed := f.DecMapUint32BoolV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint32BoolV(v map[uint32]bool, canChange bool, d *Decoder) (_ map[uint32]bool, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 5) @@ -25540,7 +26892,6 @@ func (_ fastpathT) DecMapUint32BoolV(v map[uint32]bool, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint32 var mv bool hasLen := containerLen > 0 @@ -25548,12 +26899,13 @@ func (_ fastpathT) DecMapUint32BoolV(v map[uint32]bool, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uint32(dd.DecodeUint(32)) + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = false @@ -25572,22 +26924,23 @@ func (_ fastpathT) DecMapUint32BoolV(v map[uint32]bool, canChange bool, func (d *Decoder) fastpathDecMapUint64IntfR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint64]interface{}) - if v, changed := fastpathTV.DecMapUint64IntfV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint64IntfV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint64IntfV(rv2i(rv).(map[uint64]interface{}), false, d) } - fastpathTV.DecMapUint64IntfV(rv2i(rv).(map[uint64]interface{}), false, d) } func (f fastpathT) DecMapUint64IntfX(vp *map[uint64]interface{}, d *Decoder) { - if v, changed := f.DecMapUint64IntfV(*vp, true, d); changed { + v, changed := f.DecMapUint64IntfV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint64IntfV(v map[uint64]interface{}, canChange bool, d *Decoder) (_ map[uint64]interface{}, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -25598,7 +26951,7 @@ func (_ fastpathT) DecMapUint64IntfV(v map[uint64]interface{}, canChange bool, dd.ReadMapEnd() return v, changed } - mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset var mk uint64 var mv interface{} hasLen := containerLen > 0 @@ -25606,12 +26959,13 @@ func (_ fastpathT) DecMapUint64IntfV(v map[uint64]interface{}, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeUint(64) + mk = dd.DecodeUint64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = nil @@ -25635,22 +26989,23 @@ func (_ fastpathT) DecMapUint64IntfV(v map[uint64]interface{}, canChange bool, func (d *Decoder) fastpathDecMapUint64StringR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint64]string) - if v, changed := fastpathTV.DecMapUint64StringV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint64StringV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint64StringV(rv2i(rv).(map[uint64]string), false, d) } - fastpathTV.DecMapUint64StringV(rv2i(rv).(map[uint64]string), false, d) } func (f fastpathT) DecMapUint64StringX(vp *map[uint64]string, d *Decoder) { - if v, changed := f.DecMapUint64StringV(*vp, true, d); changed { + v, changed := f.DecMapUint64StringV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint64StringV(v map[uint64]string, canChange bool, d *Decoder) (_ map[uint64]string, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -25661,7 +27016,6 @@ func (_ fastpathT) DecMapUint64StringV(v map[uint64]string, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint64 var mv string hasLen := containerLen > 0 @@ -25669,12 +27023,13 @@ func (_ fastpathT) DecMapUint64StringV(v map[uint64]string, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeUint(64) + mk = dd.DecodeUint64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = "" @@ -25693,22 +27048,23 @@ func (_ fastpathT) DecMapUint64StringV(v map[uint64]string, canChange bool, func (d *Decoder) fastpathDecMapUint64UintR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint64]uint) - if v, changed := fastpathTV.DecMapUint64UintV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint64UintV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint64UintV(rv2i(rv).(map[uint64]uint), false, d) } - fastpathTV.DecMapUint64UintV(rv2i(rv).(map[uint64]uint), false, d) } func (f fastpathT) DecMapUint64UintX(vp *map[uint64]uint, d *Decoder) { - if v, changed := f.DecMapUint64UintV(*vp, true, d); changed { + v, changed := f.DecMapUint64UintV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint64UintV(v map[uint64]uint, canChange bool, d *Decoder) (_ map[uint64]uint, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -25719,7 +27075,6 @@ func (_ fastpathT) DecMapUint64UintV(v map[uint64]uint, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint64 var mv uint hasLen := containerLen > 0 @@ -25727,19 +27082,20 @@ func (_ fastpathT) DecMapUint64UintV(v map[uint64]uint, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeUint(64) + mk = dd.DecodeUint64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint(dd.DecodeUint(uintBitsize)) + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -25751,22 +27107,23 @@ func (_ fastpathT) DecMapUint64UintV(v map[uint64]uint, canChange bool, func (d *Decoder) fastpathDecMapUint64Uint8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint64]uint8) - if v, changed := fastpathTV.DecMapUint64Uint8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint64Uint8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint64Uint8V(rv2i(rv).(map[uint64]uint8), false, d) } - fastpathTV.DecMapUint64Uint8V(rv2i(rv).(map[uint64]uint8), false, d) } func (f fastpathT) DecMapUint64Uint8X(vp *map[uint64]uint8, d *Decoder) { - if v, changed := f.DecMapUint64Uint8V(*vp, true, d); changed { + v, changed := f.DecMapUint64Uint8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint64Uint8V(v map[uint64]uint8, canChange bool, d *Decoder) (_ map[uint64]uint8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -25777,7 +27134,6 @@ func (_ fastpathT) DecMapUint64Uint8V(v map[uint64]uint8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint64 var mv uint8 hasLen := containerLen > 0 @@ -25785,19 +27141,20 @@ func (_ fastpathT) DecMapUint64Uint8V(v map[uint64]uint8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeUint(64) + mk = dd.DecodeUint64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint8(dd.DecodeUint(8)) + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } @@ -25809,22 +27166,23 @@ func (_ fastpathT) DecMapUint64Uint8V(v map[uint64]uint8, canChange bool, func (d *Decoder) fastpathDecMapUint64Uint16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint64]uint16) - if v, changed := fastpathTV.DecMapUint64Uint16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint64Uint16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint64Uint16V(rv2i(rv).(map[uint64]uint16), false, d) } - fastpathTV.DecMapUint64Uint16V(rv2i(rv).(map[uint64]uint16), false, d) } func (f fastpathT) DecMapUint64Uint16X(vp *map[uint64]uint16, d *Decoder) { - if v, changed := f.DecMapUint64Uint16V(*vp, true, d); changed { + v, changed := f.DecMapUint64Uint16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint64Uint16V(v map[uint64]uint16, canChange bool, d *Decoder) (_ map[uint64]uint16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -25835,7 +27193,6 @@ func (_ fastpathT) DecMapUint64Uint16V(v map[uint64]uint16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint64 var mv uint16 hasLen := containerLen > 0 @@ -25843,19 +27200,20 @@ func (_ fastpathT) DecMapUint64Uint16V(v map[uint64]uint16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeUint(64) + mk = dd.DecodeUint64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint16(dd.DecodeUint(16)) + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } @@ -25867,22 +27225,23 @@ func (_ fastpathT) DecMapUint64Uint16V(v map[uint64]uint16, canChange bool, func (d *Decoder) fastpathDecMapUint64Uint32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint64]uint32) - if v, changed := fastpathTV.DecMapUint64Uint32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint64Uint32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint64Uint32V(rv2i(rv).(map[uint64]uint32), false, d) } - fastpathTV.DecMapUint64Uint32V(rv2i(rv).(map[uint64]uint32), false, d) } func (f fastpathT) DecMapUint64Uint32X(vp *map[uint64]uint32, d *Decoder) { - if v, changed := f.DecMapUint64Uint32V(*vp, true, d); changed { + v, changed := f.DecMapUint64Uint32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint64Uint32V(v map[uint64]uint32, canChange bool, d *Decoder) (_ map[uint64]uint32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -25893,7 +27252,6 @@ func (_ fastpathT) DecMapUint64Uint32V(v map[uint64]uint32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint64 var mv uint32 hasLen := containerLen > 0 @@ -25901,19 +27259,20 @@ func (_ fastpathT) DecMapUint64Uint32V(v map[uint64]uint32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeUint(64) + mk = dd.DecodeUint64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint32(dd.DecodeUint(32)) + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } @@ -25925,22 +27284,23 @@ func (_ fastpathT) DecMapUint64Uint32V(v map[uint64]uint32, canChange bool, func (d *Decoder) fastpathDecMapUint64Uint64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint64]uint64) - if v, changed := fastpathTV.DecMapUint64Uint64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint64Uint64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint64Uint64V(rv2i(rv).(map[uint64]uint64), false, d) } - fastpathTV.DecMapUint64Uint64V(rv2i(rv).(map[uint64]uint64), false, d) } func (f fastpathT) DecMapUint64Uint64X(vp *map[uint64]uint64, d *Decoder) { - if v, changed := f.DecMapUint64Uint64V(*vp, true, d); changed { + v, changed := f.DecMapUint64Uint64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint64Uint64V(v map[uint64]uint64, canChange bool, d *Decoder) (_ map[uint64]uint64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -25951,7 +27311,6 @@ func (_ fastpathT) DecMapUint64Uint64V(v map[uint64]uint64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint64 var mv uint64 hasLen := containerLen > 0 @@ -25959,19 +27318,20 @@ func (_ fastpathT) DecMapUint64Uint64V(v map[uint64]uint64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeUint(64) + mk = dd.DecodeUint64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeUint(64) + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } @@ -25983,22 +27343,23 @@ func (_ fastpathT) DecMapUint64Uint64V(v map[uint64]uint64, canChange bool, func (d *Decoder) fastpathDecMapUint64UintptrR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint64]uintptr) - if v, changed := fastpathTV.DecMapUint64UintptrV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint64UintptrV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint64UintptrV(rv2i(rv).(map[uint64]uintptr), false, d) } - fastpathTV.DecMapUint64UintptrV(rv2i(rv).(map[uint64]uintptr), false, d) } func (f fastpathT) DecMapUint64UintptrX(vp *map[uint64]uintptr, d *Decoder) { - if v, changed := f.DecMapUint64UintptrV(*vp, true, d); changed { + v, changed := f.DecMapUint64UintptrV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint64UintptrV(v map[uint64]uintptr, canChange bool, d *Decoder) (_ map[uint64]uintptr, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -26009,7 +27370,6 @@ func (_ fastpathT) DecMapUint64UintptrV(v map[uint64]uintptr, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint64 var mv uintptr hasLen := containerLen > 0 @@ -26017,19 +27377,20 @@ func (_ fastpathT) DecMapUint64UintptrV(v map[uint64]uintptr, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeUint(64) + mk = dd.DecodeUint64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uintptr(dd.DecodeUint(uintBitsize)) + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -26041,22 +27402,23 @@ func (_ fastpathT) DecMapUint64UintptrV(v map[uint64]uintptr, canChange bool, func (d *Decoder) fastpathDecMapUint64IntR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint64]int) - if v, changed := fastpathTV.DecMapUint64IntV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint64IntV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint64IntV(rv2i(rv).(map[uint64]int), false, d) } - fastpathTV.DecMapUint64IntV(rv2i(rv).(map[uint64]int), false, d) } func (f fastpathT) DecMapUint64IntX(vp *map[uint64]int, d *Decoder) { - if v, changed := f.DecMapUint64IntV(*vp, true, d); changed { + v, changed := f.DecMapUint64IntV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint64IntV(v map[uint64]int, canChange bool, d *Decoder) (_ map[uint64]int, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -26067,7 +27429,6 @@ func (_ fastpathT) DecMapUint64IntV(v map[uint64]int, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint64 var mv int hasLen := containerLen > 0 @@ -26075,19 +27436,20 @@ func (_ fastpathT) DecMapUint64IntV(v map[uint64]int, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeUint(64) + mk = dd.DecodeUint64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int(dd.DecodeInt(intBitsize)) + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } @@ -26099,22 +27461,23 @@ func (_ fastpathT) DecMapUint64IntV(v map[uint64]int, canChange bool, func (d *Decoder) fastpathDecMapUint64Int8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint64]int8) - if v, changed := fastpathTV.DecMapUint64Int8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint64Int8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint64Int8V(rv2i(rv).(map[uint64]int8), false, d) } - fastpathTV.DecMapUint64Int8V(rv2i(rv).(map[uint64]int8), false, d) } func (f fastpathT) DecMapUint64Int8X(vp *map[uint64]int8, d *Decoder) { - if v, changed := f.DecMapUint64Int8V(*vp, true, d); changed { + v, changed := f.DecMapUint64Int8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint64Int8V(v map[uint64]int8, canChange bool, d *Decoder) (_ map[uint64]int8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -26125,7 +27488,6 @@ func (_ fastpathT) DecMapUint64Int8V(v map[uint64]int8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint64 var mv int8 hasLen := containerLen > 0 @@ -26133,19 +27495,20 @@ func (_ fastpathT) DecMapUint64Int8V(v map[uint64]int8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeUint(64) + mk = dd.DecodeUint64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int8(dd.DecodeInt(8)) + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } @@ -26157,22 +27520,23 @@ func (_ fastpathT) DecMapUint64Int8V(v map[uint64]int8, canChange bool, func (d *Decoder) fastpathDecMapUint64Int16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint64]int16) - if v, changed := fastpathTV.DecMapUint64Int16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint64Int16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint64Int16V(rv2i(rv).(map[uint64]int16), false, d) } - fastpathTV.DecMapUint64Int16V(rv2i(rv).(map[uint64]int16), false, d) } func (f fastpathT) DecMapUint64Int16X(vp *map[uint64]int16, d *Decoder) { - if v, changed := f.DecMapUint64Int16V(*vp, true, d); changed { + v, changed := f.DecMapUint64Int16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint64Int16V(v map[uint64]int16, canChange bool, d *Decoder) (_ map[uint64]int16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -26183,7 +27547,6 @@ func (_ fastpathT) DecMapUint64Int16V(v map[uint64]int16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint64 var mv int16 hasLen := containerLen > 0 @@ -26191,19 +27554,20 @@ func (_ fastpathT) DecMapUint64Int16V(v map[uint64]int16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeUint(64) + mk = dd.DecodeUint64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int16(dd.DecodeInt(16)) + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } @@ -26215,22 +27579,23 @@ func (_ fastpathT) DecMapUint64Int16V(v map[uint64]int16, canChange bool, func (d *Decoder) fastpathDecMapUint64Int32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint64]int32) - if v, changed := fastpathTV.DecMapUint64Int32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint64Int32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint64Int32V(rv2i(rv).(map[uint64]int32), false, d) } - fastpathTV.DecMapUint64Int32V(rv2i(rv).(map[uint64]int32), false, d) } func (f fastpathT) DecMapUint64Int32X(vp *map[uint64]int32, d *Decoder) { - if v, changed := f.DecMapUint64Int32V(*vp, true, d); changed { + v, changed := f.DecMapUint64Int32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint64Int32V(v map[uint64]int32, canChange bool, d *Decoder) (_ map[uint64]int32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -26241,7 +27606,6 @@ func (_ fastpathT) DecMapUint64Int32V(v map[uint64]int32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint64 var mv int32 hasLen := containerLen > 0 @@ -26249,19 +27613,20 @@ func (_ fastpathT) DecMapUint64Int32V(v map[uint64]int32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeUint(64) + mk = dd.DecodeUint64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int32(dd.DecodeInt(32)) + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } @@ -26273,22 +27638,23 @@ func (_ fastpathT) DecMapUint64Int32V(v map[uint64]int32, canChange bool, func (d *Decoder) fastpathDecMapUint64Int64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint64]int64) - if v, changed := fastpathTV.DecMapUint64Int64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint64Int64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint64Int64V(rv2i(rv).(map[uint64]int64), false, d) } - fastpathTV.DecMapUint64Int64V(rv2i(rv).(map[uint64]int64), false, d) } func (f fastpathT) DecMapUint64Int64X(vp *map[uint64]int64, d *Decoder) { - if v, changed := f.DecMapUint64Int64V(*vp, true, d); changed { + v, changed := f.DecMapUint64Int64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint64Int64V(v map[uint64]int64, canChange bool, d *Decoder) (_ map[uint64]int64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -26299,7 +27665,6 @@ func (_ fastpathT) DecMapUint64Int64V(v map[uint64]int64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint64 var mv int64 hasLen := containerLen > 0 @@ -26307,19 +27672,20 @@ func (_ fastpathT) DecMapUint64Int64V(v map[uint64]int64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeUint(64) + mk = dd.DecodeUint64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeInt(64) + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } @@ -26331,22 +27697,23 @@ func (_ fastpathT) DecMapUint64Int64V(v map[uint64]int64, canChange bool, func (d *Decoder) fastpathDecMapUint64Float32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint64]float32) - if v, changed := fastpathTV.DecMapUint64Float32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint64Float32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint64Float32V(rv2i(rv).(map[uint64]float32), false, d) } - fastpathTV.DecMapUint64Float32V(rv2i(rv).(map[uint64]float32), false, d) } func (f fastpathT) DecMapUint64Float32X(vp *map[uint64]float32, d *Decoder) { - if v, changed := f.DecMapUint64Float32V(*vp, true, d); changed { + v, changed := f.DecMapUint64Float32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint64Float32V(v map[uint64]float32, canChange bool, d *Decoder) (_ map[uint64]float32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -26357,7 +27724,6 @@ func (_ fastpathT) DecMapUint64Float32V(v map[uint64]float32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint64 var mv float32 hasLen := containerLen > 0 @@ -26365,19 +27731,20 @@ func (_ fastpathT) DecMapUint64Float32V(v map[uint64]float32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeUint(64) + mk = dd.DecodeUint64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = float32(dd.DecodeFloat(true)) + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } @@ -26389,22 +27756,23 @@ func (_ fastpathT) DecMapUint64Float32V(v map[uint64]float32, canChange bool, func (d *Decoder) fastpathDecMapUint64Float64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint64]float64) - if v, changed := fastpathTV.DecMapUint64Float64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint64Float64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint64Float64V(rv2i(rv).(map[uint64]float64), false, d) } - fastpathTV.DecMapUint64Float64V(rv2i(rv).(map[uint64]float64), false, d) } func (f fastpathT) DecMapUint64Float64X(vp *map[uint64]float64, d *Decoder) { - if v, changed := f.DecMapUint64Float64V(*vp, true, d); changed { + v, changed := f.DecMapUint64Float64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint64Float64V(v map[uint64]float64, canChange bool, d *Decoder) (_ map[uint64]float64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -26415,7 +27783,6 @@ func (_ fastpathT) DecMapUint64Float64V(v map[uint64]float64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint64 var mv float64 hasLen := containerLen > 0 @@ -26423,19 +27790,20 @@ func (_ fastpathT) DecMapUint64Float64V(v map[uint64]float64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeUint(64) + mk = dd.DecodeUint64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeFloat(false) + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } @@ -26447,22 +27815,23 @@ func (_ fastpathT) DecMapUint64Float64V(v map[uint64]float64, canChange bool, func (d *Decoder) fastpathDecMapUint64BoolR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uint64]bool) - if v, changed := fastpathTV.DecMapUint64BoolV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUint64BoolV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUint64BoolV(rv2i(rv).(map[uint64]bool), false, d) } - fastpathTV.DecMapUint64BoolV(rv2i(rv).(map[uint64]bool), false, d) } func (f fastpathT) DecMapUint64BoolX(vp *map[uint64]bool, d *Decoder) { - if v, changed := f.DecMapUint64BoolV(*vp, true, d); changed { + v, changed := f.DecMapUint64BoolV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUint64BoolV(v map[uint64]bool, canChange bool, d *Decoder) (_ map[uint64]bool, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -26473,7 +27842,6 @@ func (_ fastpathT) DecMapUint64BoolV(v map[uint64]bool, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uint64 var mv bool hasLen := containerLen > 0 @@ -26481,12 +27849,13 @@ func (_ fastpathT) DecMapUint64BoolV(v map[uint64]bool, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeUint(64) + mk = dd.DecodeUint64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = false @@ -26505,22 +27874,23 @@ func (_ fastpathT) DecMapUint64BoolV(v map[uint64]bool, canChange bool, func (d *Decoder) fastpathDecMapUintptrIntfR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uintptr]interface{}) - if v, changed := fastpathTV.DecMapUintptrIntfV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintptrIntfV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintptrIntfV(rv2i(rv).(map[uintptr]interface{}), false, d) } - fastpathTV.DecMapUintptrIntfV(rv2i(rv).(map[uintptr]interface{}), false, d) } func (f fastpathT) DecMapUintptrIntfX(vp *map[uintptr]interface{}, d *Decoder) { - if v, changed := f.DecMapUintptrIntfV(*vp, true, d); changed { + v, changed := f.DecMapUintptrIntfV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintptrIntfV(v map[uintptr]interface{}, canChange bool, d *Decoder) (_ map[uintptr]interface{}, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -26531,7 +27901,7 @@ func (_ fastpathT) DecMapUintptrIntfV(v map[uintptr]interface{}, canChange bool, dd.ReadMapEnd() return v, changed } - mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset var mk uintptr var mv interface{} hasLen := containerLen > 0 @@ -26539,12 +27909,13 @@ func (_ fastpathT) DecMapUintptrIntfV(v map[uintptr]interface{}, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uintptr(dd.DecodeUint(uintBitsize)) + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = nil @@ -26568,22 +27939,23 @@ func (_ fastpathT) DecMapUintptrIntfV(v map[uintptr]interface{}, canChange bool, func (d *Decoder) fastpathDecMapUintptrStringR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uintptr]string) - if v, changed := fastpathTV.DecMapUintptrStringV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintptrStringV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintptrStringV(rv2i(rv).(map[uintptr]string), false, d) } - fastpathTV.DecMapUintptrStringV(rv2i(rv).(map[uintptr]string), false, d) } func (f fastpathT) DecMapUintptrStringX(vp *map[uintptr]string, d *Decoder) { - if v, changed := f.DecMapUintptrStringV(*vp, true, d); changed { + v, changed := f.DecMapUintptrStringV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintptrStringV(v map[uintptr]string, canChange bool, d *Decoder) (_ map[uintptr]string, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -26594,7 +27966,6 @@ func (_ fastpathT) DecMapUintptrStringV(v map[uintptr]string, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uintptr var mv string hasLen := containerLen > 0 @@ -26602,12 +27973,13 @@ func (_ fastpathT) DecMapUintptrStringV(v map[uintptr]string, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uintptr(dd.DecodeUint(uintBitsize)) + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = "" @@ -26626,22 +27998,23 @@ func (_ fastpathT) DecMapUintptrStringV(v map[uintptr]string, canChange bool, func (d *Decoder) fastpathDecMapUintptrUintR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uintptr]uint) - if v, changed := fastpathTV.DecMapUintptrUintV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintptrUintV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintptrUintV(rv2i(rv).(map[uintptr]uint), false, d) } - fastpathTV.DecMapUintptrUintV(rv2i(rv).(map[uintptr]uint), false, d) } func (f fastpathT) DecMapUintptrUintX(vp *map[uintptr]uint, d *Decoder) { - if v, changed := f.DecMapUintptrUintV(*vp, true, d); changed { + v, changed := f.DecMapUintptrUintV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintptrUintV(v map[uintptr]uint, canChange bool, d *Decoder) (_ map[uintptr]uint, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -26652,7 +28025,6 @@ func (_ fastpathT) DecMapUintptrUintV(v map[uintptr]uint, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uintptr var mv uint hasLen := containerLen > 0 @@ -26660,19 +28032,20 @@ func (_ fastpathT) DecMapUintptrUintV(v map[uintptr]uint, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uintptr(dd.DecodeUint(uintBitsize)) + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint(dd.DecodeUint(uintBitsize)) + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -26684,22 +28057,23 @@ func (_ fastpathT) DecMapUintptrUintV(v map[uintptr]uint, canChange bool, func (d *Decoder) fastpathDecMapUintptrUint8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uintptr]uint8) - if v, changed := fastpathTV.DecMapUintptrUint8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintptrUint8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintptrUint8V(rv2i(rv).(map[uintptr]uint8), false, d) } - fastpathTV.DecMapUintptrUint8V(rv2i(rv).(map[uintptr]uint8), false, d) } func (f fastpathT) DecMapUintptrUint8X(vp *map[uintptr]uint8, d *Decoder) { - if v, changed := f.DecMapUintptrUint8V(*vp, true, d); changed { + v, changed := f.DecMapUintptrUint8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintptrUint8V(v map[uintptr]uint8, canChange bool, d *Decoder) (_ map[uintptr]uint8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -26710,7 +28084,6 @@ func (_ fastpathT) DecMapUintptrUint8V(v map[uintptr]uint8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uintptr var mv uint8 hasLen := containerLen > 0 @@ -26718,19 +28091,20 @@ func (_ fastpathT) DecMapUintptrUint8V(v map[uintptr]uint8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uintptr(dd.DecodeUint(uintBitsize)) + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint8(dd.DecodeUint(8)) + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } @@ -26742,22 +28116,23 @@ func (_ fastpathT) DecMapUintptrUint8V(v map[uintptr]uint8, canChange bool, func (d *Decoder) fastpathDecMapUintptrUint16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uintptr]uint16) - if v, changed := fastpathTV.DecMapUintptrUint16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintptrUint16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintptrUint16V(rv2i(rv).(map[uintptr]uint16), false, d) } - fastpathTV.DecMapUintptrUint16V(rv2i(rv).(map[uintptr]uint16), false, d) } func (f fastpathT) DecMapUintptrUint16X(vp *map[uintptr]uint16, d *Decoder) { - if v, changed := f.DecMapUintptrUint16V(*vp, true, d); changed { + v, changed := f.DecMapUintptrUint16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintptrUint16V(v map[uintptr]uint16, canChange bool, d *Decoder) (_ map[uintptr]uint16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -26768,7 +28143,6 @@ func (_ fastpathT) DecMapUintptrUint16V(v map[uintptr]uint16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uintptr var mv uint16 hasLen := containerLen > 0 @@ -26776,19 +28150,20 @@ func (_ fastpathT) DecMapUintptrUint16V(v map[uintptr]uint16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uintptr(dd.DecodeUint(uintBitsize)) + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint16(dd.DecodeUint(16)) + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } @@ -26800,22 +28175,23 @@ func (_ fastpathT) DecMapUintptrUint16V(v map[uintptr]uint16, canChange bool, func (d *Decoder) fastpathDecMapUintptrUint32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uintptr]uint32) - if v, changed := fastpathTV.DecMapUintptrUint32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintptrUint32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintptrUint32V(rv2i(rv).(map[uintptr]uint32), false, d) } - fastpathTV.DecMapUintptrUint32V(rv2i(rv).(map[uintptr]uint32), false, d) } func (f fastpathT) DecMapUintptrUint32X(vp *map[uintptr]uint32, d *Decoder) { - if v, changed := f.DecMapUintptrUint32V(*vp, true, d); changed { + v, changed := f.DecMapUintptrUint32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintptrUint32V(v map[uintptr]uint32, canChange bool, d *Decoder) (_ map[uintptr]uint32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -26826,7 +28202,6 @@ func (_ fastpathT) DecMapUintptrUint32V(v map[uintptr]uint32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uintptr var mv uint32 hasLen := containerLen > 0 @@ -26834,19 +28209,20 @@ func (_ fastpathT) DecMapUintptrUint32V(v map[uintptr]uint32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uintptr(dd.DecodeUint(uintBitsize)) + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint32(dd.DecodeUint(32)) + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } @@ -26858,22 +28234,23 @@ func (_ fastpathT) DecMapUintptrUint32V(v map[uintptr]uint32, canChange bool, func (d *Decoder) fastpathDecMapUintptrUint64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uintptr]uint64) - if v, changed := fastpathTV.DecMapUintptrUint64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintptrUint64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintptrUint64V(rv2i(rv).(map[uintptr]uint64), false, d) } - fastpathTV.DecMapUintptrUint64V(rv2i(rv).(map[uintptr]uint64), false, d) } func (f fastpathT) DecMapUintptrUint64X(vp *map[uintptr]uint64, d *Decoder) { - if v, changed := f.DecMapUintptrUint64V(*vp, true, d); changed { + v, changed := f.DecMapUintptrUint64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintptrUint64V(v map[uintptr]uint64, canChange bool, d *Decoder) (_ map[uintptr]uint64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -26884,7 +28261,6 @@ func (_ fastpathT) DecMapUintptrUint64V(v map[uintptr]uint64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uintptr var mv uint64 hasLen := containerLen > 0 @@ -26892,19 +28268,20 @@ func (_ fastpathT) DecMapUintptrUint64V(v map[uintptr]uint64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uintptr(dd.DecodeUint(uintBitsize)) + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeUint(64) + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } @@ -26916,22 +28293,23 @@ func (_ fastpathT) DecMapUintptrUint64V(v map[uintptr]uint64, canChange bool, func (d *Decoder) fastpathDecMapUintptrUintptrR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uintptr]uintptr) - if v, changed := fastpathTV.DecMapUintptrUintptrV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintptrUintptrV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintptrUintptrV(rv2i(rv).(map[uintptr]uintptr), false, d) } - fastpathTV.DecMapUintptrUintptrV(rv2i(rv).(map[uintptr]uintptr), false, d) } func (f fastpathT) DecMapUintptrUintptrX(vp *map[uintptr]uintptr, d *Decoder) { - if v, changed := f.DecMapUintptrUintptrV(*vp, true, d); changed { + v, changed := f.DecMapUintptrUintptrV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintptrUintptrV(v map[uintptr]uintptr, canChange bool, d *Decoder) (_ map[uintptr]uintptr, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -26942,7 +28320,6 @@ func (_ fastpathT) DecMapUintptrUintptrV(v map[uintptr]uintptr, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uintptr var mv uintptr hasLen := containerLen > 0 @@ -26950,19 +28327,20 @@ func (_ fastpathT) DecMapUintptrUintptrV(v map[uintptr]uintptr, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uintptr(dd.DecodeUint(uintBitsize)) + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uintptr(dd.DecodeUint(uintBitsize)) + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -26974,22 +28352,23 @@ func (_ fastpathT) DecMapUintptrUintptrV(v map[uintptr]uintptr, canChange bool, func (d *Decoder) fastpathDecMapUintptrIntR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uintptr]int) - if v, changed := fastpathTV.DecMapUintptrIntV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintptrIntV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintptrIntV(rv2i(rv).(map[uintptr]int), false, d) } - fastpathTV.DecMapUintptrIntV(rv2i(rv).(map[uintptr]int), false, d) } func (f fastpathT) DecMapUintptrIntX(vp *map[uintptr]int, d *Decoder) { - if v, changed := f.DecMapUintptrIntV(*vp, true, d); changed { + v, changed := f.DecMapUintptrIntV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintptrIntV(v map[uintptr]int, canChange bool, d *Decoder) (_ map[uintptr]int, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -27000,7 +28379,6 @@ func (_ fastpathT) DecMapUintptrIntV(v map[uintptr]int, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uintptr var mv int hasLen := containerLen > 0 @@ -27008,19 +28386,20 @@ func (_ fastpathT) DecMapUintptrIntV(v map[uintptr]int, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uintptr(dd.DecodeUint(uintBitsize)) + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int(dd.DecodeInt(intBitsize)) + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } @@ -27032,22 +28411,23 @@ func (_ fastpathT) DecMapUintptrIntV(v map[uintptr]int, canChange bool, func (d *Decoder) fastpathDecMapUintptrInt8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uintptr]int8) - if v, changed := fastpathTV.DecMapUintptrInt8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintptrInt8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintptrInt8V(rv2i(rv).(map[uintptr]int8), false, d) } - fastpathTV.DecMapUintptrInt8V(rv2i(rv).(map[uintptr]int8), false, d) } func (f fastpathT) DecMapUintptrInt8X(vp *map[uintptr]int8, d *Decoder) { - if v, changed := f.DecMapUintptrInt8V(*vp, true, d); changed { + v, changed := f.DecMapUintptrInt8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintptrInt8V(v map[uintptr]int8, canChange bool, d *Decoder) (_ map[uintptr]int8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -27058,7 +28438,6 @@ func (_ fastpathT) DecMapUintptrInt8V(v map[uintptr]int8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uintptr var mv int8 hasLen := containerLen > 0 @@ -27066,19 +28445,20 @@ func (_ fastpathT) DecMapUintptrInt8V(v map[uintptr]int8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uintptr(dd.DecodeUint(uintBitsize)) + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int8(dd.DecodeInt(8)) + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } @@ -27090,22 +28470,23 @@ func (_ fastpathT) DecMapUintptrInt8V(v map[uintptr]int8, canChange bool, func (d *Decoder) fastpathDecMapUintptrInt16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uintptr]int16) - if v, changed := fastpathTV.DecMapUintptrInt16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintptrInt16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintptrInt16V(rv2i(rv).(map[uintptr]int16), false, d) } - fastpathTV.DecMapUintptrInt16V(rv2i(rv).(map[uintptr]int16), false, d) } func (f fastpathT) DecMapUintptrInt16X(vp *map[uintptr]int16, d *Decoder) { - if v, changed := f.DecMapUintptrInt16V(*vp, true, d); changed { + v, changed := f.DecMapUintptrInt16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintptrInt16V(v map[uintptr]int16, canChange bool, d *Decoder) (_ map[uintptr]int16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -27116,7 +28497,6 @@ func (_ fastpathT) DecMapUintptrInt16V(v map[uintptr]int16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uintptr var mv int16 hasLen := containerLen > 0 @@ -27124,19 +28504,20 @@ func (_ fastpathT) DecMapUintptrInt16V(v map[uintptr]int16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uintptr(dd.DecodeUint(uintBitsize)) + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int16(dd.DecodeInt(16)) + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } @@ -27148,22 +28529,23 @@ func (_ fastpathT) DecMapUintptrInt16V(v map[uintptr]int16, canChange bool, func (d *Decoder) fastpathDecMapUintptrInt32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uintptr]int32) - if v, changed := fastpathTV.DecMapUintptrInt32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintptrInt32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintptrInt32V(rv2i(rv).(map[uintptr]int32), false, d) } - fastpathTV.DecMapUintptrInt32V(rv2i(rv).(map[uintptr]int32), false, d) } func (f fastpathT) DecMapUintptrInt32X(vp *map[uintptr]int32, d *Decoder) { - if v, changed := f.DecMapUintptrInt32V(*vp, true, d); changed { + v, changed := f.DecMapUintptrInt32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintptrInt32V(v map[uintptr]int32, canChange bool, d *Decoder) (_ map[uintptr]int32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -27174,7 +28556,6 @@ func (_ fastpathT) DecMapUintptrInt32V(v map[uintptr]int32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uintptr var mv int32 hasLen := containerLen > 0 @@ -27182,19 +28563,20 @@ func (_ fastpathT) DecMapUintptrInt32V(v map[uintptr]int32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uintptr(dd.DecodeUint(uintBitsize)) + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int32(dd.DecodeInt(32)) + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } @@ -27206,22 +28588,23 @@ func (_ fastpathT) DecMapUintptrInt32V(v map[uintptr]int32, canChange bool, func (d *Decoder) fastpathDecMapUintptrInt64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uintptr]int64) - if v, changed := fastpathTV.DecMapUintptrInt64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintptrInt64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintptrInt64V(rv2i(rv).(map[uintptr]int64), false, d) } - fastpathTV.DecMapUintptrInt64V(rv2i(rv).(map[uintptr]int64), false, d) } func (f fastpathT) DecMapUintptrInt64X(vp *map[uintptr]int64, d *Decoder) { - if v, changed := f.DecMapUintptrInt64V(*vp, true, d); changed { + v, changed := f.DecMapUintptrInt64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintptrInt64V(v map[uintptr]int64, canChange bool, d *Decoder) (_ map[uintptr]int64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -27232,7 +28615,6 @@ func (_ fastpathT) DecMapUintptrInt64V(v map[uintptr]int64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uintptr var mv int64 hasLen := containerLen > 0 @@ -27240,19 +28622,20 @@ func (_ fastpathT) DecMapUintptrInt64V(v map[uintptr]int64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uintptr(dd.DecodeUint(uintBitsize)) + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeInt(64) + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } @@ -27264,22 +28647,23 @@ func (_ fastpathT) DecMapUintptrInt64V(v map[uintptr]int64, canChange bool, func (d *Decoder) fastpathDecMapUintptrFloat32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uintptr]float32) - if v, changed := fastpathTV.DecMapUintptrFloat32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintptrFloat32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintptrFloat32V(rv2i(rv).(map[uintptr]float32), false, d) } - fastpathTV.DecMapUintptrFloat32V(rv2i(rv).(map[uintptr]float32), false, d) } func (f fastpathT) DecMapUintptrFloat32X(vp *map[uintptr]float32, d *Decoder) { - if v, changed := f.DecMapUintptrFloat32V(*vp, true, d); changed { + v, changed := f.DecMapUintptrFloat32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintptrFloat32V(v map[uintptr]float32, canChange bool, d *Decoder) (_ map[uintptr]float32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -27290,7 +28674,6 @@ func (_ fastpathT) DecMapUintptrFloat32V(v map[uintptr]float32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uintptr var mv float32 hasLen := containerLen > 0 @@ -27298,19 +28681,20 @@ func (_ fastpathT) DecMapUintptrFloat32V(v map[uintptr]float32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uintptr(dd.DecodeUint(uintBitsize)) + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = float32(dd.DecodeFloat(true)) + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } @@ -27322,22 +28706,23 @@ func (_ fastpathT) DecMapUintptrFloat32V(v map[uintptr]float32, canChange bool, func (d *Decoder) fastpathDecMapUintptrFloat64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uintptr]float64) - if v, changed := fastpathTV.DecMapUintptrFloat64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintptrFloat64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintptrFloat64V(rv2i(rv).(map[uintptr]float64), false, d) } - fastpathTV.DecMapUintptrFloat64V(rv2i(rv).(map[uintptr]float64), false, d) } func (f fastpathT) DecMapUintptrFloat64X(vp *map[uintptr]float64, d *Decoder) { - if v, changed := f.DecMapUintptrFloat64V(*vp, true, d); changed { + v, changed := f.DecMapUintptrFloat64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintptrFloat64V(v map[uintptr]float64, canChange bool, d *Decoder) (_ map[uintptr]float64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -27348,7 +28733,6 @@ func (_ fastpathT) DecMapUintptrFloat64V(v map[uintptr]float64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uintptr var mv float64 hasLen := containerLen > 0 @@ -27356,19 +28740,20 @@ func (_ fastpathT) DecMapUintptrFloat64V(v map[uintptr]float64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uintptr(dd.DecodeUint(uintBitsize)) + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeFloat(false) + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } @@ -27380,22 +28765,23 @@ func (_ fastpathT) DecMapUintptrFloat64V(v map[uintptr]float64, canChange bool, func (d *Decoder) fastpathDecMapUintptrBoolR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[uintptr]bool) - if v, changed := fastpathTV.DecMapUintptrBoolV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapUintptrBoolV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapUintptrBoolV(rv2i(rv).(map[uintptr]bool), false, d) } - fastpathTV.DecMapUintptrBoolV(rv2i(rv).(map[uintptr]bool), false, d) } func (f fastpathT) DecMapUintptrBoolX(vp *map[uintptr]bool, d *Decoder) { - if v, changed := f.DecMapUintptrBoolV(*vp, true, d); changed { + v, changed := f.DecMapUintptrBoolV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapUintptrBoolV(v map[uintptr]bool, canChange bool, d *Decoder) (_ map[uintptr]bool, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -27406,7 +28792,6 @@ func (_ fastpathT) DecMapUintptrBoolV(v map[uintptr]bool, canChange bool, dd.ReadMapEnd() return v, changed } - var mk uintptr var mv bool hasLen := containerLen > 0 @@ -27414,12 +28799,13 @@ func (_ fastpathT) DecMapUintptrBoolV(v map[uintptr]bool, canChange bool, if esep { dd.ReadMapElemKey() } - mk = uintptr(dd.DecodeUint(uintBitsize)) + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = false @@ -27438,22 +28824,23 @@ func (_ fastpathT) DecMapUintptrBoolV(v map[uintptr]bool, canChange bool, func (d *Decoder) fastpathDecMapIntIntfR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int]interface{}) - if v, changed := fastpathTV.DecMapIntIntfV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntIntfV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntIntfV(rv2i(rv).(map[int]interface{}), false, d) } - fastpathTV.DecMapIntIntfV(rv2i(rv).(map[int]interface{}), false, d) } func (f fastpathT) DecMapIntIntfX(vp *map[int]interface{}, d *Decoder) { - if v, changed := f.DecMapIntIntfV(*vp, true, d); changed { + v, changed := f.DecMapIntIntfV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntIntfV(v map[int]interface{}, canChange bool, d *Decoder) (_ map[int]interface{}, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -27464,7 +28851,7 @@ func (_ fastpathT) DecMapIntIntfV(v map[int]interface{}, canChange bool, dd.ReadMapEnd() return v, changed } - mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset var mk int var mv interface{} hasLen := containerLen > 0 @@ -27472,12 +28859,13 @@ func (_ fastpathT) DecMapIntIntfV(v map[int]interface{}, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int(dd.DecodeInt(intBitsize)) + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = nil @@ -27501,22 +28889,23 @@ func (_ fastpathT) DecMapIntIntfV(v map[int]interface{}, canChange bool, func (d *Decoder) fastpathDecMapIntStringR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int]string) - if v, changed := fastpathTV.DecMapIntStringV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntStringV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntStringV(rv2i(rv).(map[int]string), false, d) } - fastpathTV.DecMapIntStringV(rv2i(rv).(map[int]string), false, d) } func (f fastpathT) DecMapIntStringX(vp *map[int]string, d *Decoder) { - if v, changed := f.DecMapIntStringV(*vp, true, d); changed { + v, changed := f.DecMapIntStringV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntStringV(v map[int]string, canChange bool, d *Decoder) (_ map[int]string, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -27527,7 +28916,6 @@ func (_ fastpathT) DecMapIntStringV(v map[int]string, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int var mv string hasLen := containerLen > 0 @@ -27535,12 +28923,13 @@ func (_ fastpathT) DecMapIntStringV(v map[int]string, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int(dd.DecodeInt(intBitsize)) + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = "" @@ -27559,22 +28948,23 @@ func (_ fastpathT) DecMapIntStringV(v map[int]string, canChange bool, func (d *Decoder) fastpathDecMapIntUintR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int]uint) - if v, changed := fastpathTV.DecMapIntUintV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntUintV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntUintV(rv2i(rv).(map[int]uint), false, d) } - fastpathTV.DecMapIntUintV(rv2i(rv).(map[int]uint), false, d) } func (f fastpathT) DecMapIntUintX(vp *map[int]uint, d *Decoder) { - if v, changed := f.DecMapIntUintV(*vp, true, d); changed { + v, changed := f.DecMapIntUintV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntUintV(v map[int]uint, canChange bool, d *Decoder) (_ map[int]uint, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -27585,7 +28975,6 @@ func (_ fastpathT) DecMapIntUintV(v map[int]uint, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int var mv uint hasLen := containerLen > 0 @@ -27593,19 +28982,20 @@ func (_ fastpathT) DecMapIntUintV(v map[int]uint, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int(dd.DecodeInt(intBitsize)) + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint(dd.DecodeUint(uintBitsize)) + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -27617,22 +29007,23 @@ func (_ fastpathT) DecMapIntUintV(v map[int]uint, canChange bool, func (d *Decoder) fastpathDecMapIntUint8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int]uint8) - if v, changed := fastpathTV.DecMapIntUint8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntUint8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntUint8V(rv2i(rv).(map[int]uint8), false, d) } - fastpathTV.DecMapIntUint8V(rv2i(rv).(map[int]uint8), false, d) } func (f fastpathT) DecMapIntUint8X(vp *map[int]uint8, d *Decoder) { - if v, changed := f.DecMapIntUint8V(*vp, true, d); changed { + v, changed := f.DecMapIntUint8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntUint8V(v map[int]uint8, canChange bool, d *Decoder) (_ map[int]uint8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -27643,7 +29034,6 @@ func (_ fastpathT) DecMapIntUint8V(v map[int]uint8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int var mv uint8 hasLen := containerLen > 0 @@ -27651,19 +29041,20 @@ func (_ fastpathT) DecMapIntUint8V(v map[int]uint8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int(dd.DecodeInt(intBitsize)) + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint8(dd.DecodeUint(8)) + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } @@ -27675,22 +29066,23 @@ func (_ fastpathT) DecMapIntUint8V(v map[int]uint8, canChange bool, func (d *Decoder) fastpathDecMapIntUint16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int]uint16) - if v, changed := fastpathTV.DecMapIntUint16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntUint16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntUint16V(rv2i(rv).(map[int]uint16), false, d) } - fastpathTV.DecMapIntUint16V(rv2i(rv).(map[int]uint16), false, d) } func (f fastpathT) DecMapIntUint16X(vp *map[int]uint16, d *Decoder) { - if v, changed := f.DecMapIntUint16V(*vp, true, d); changed { + v, changed := f.DecMapIntUint16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntUint16V(v map[int]uint16, canChange bool, d *Decoder) (_ map[int]uint16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -27701,7 +29093,6 @@ func (_ fastpathT) DecMapIntUint16V(v map[int]uint16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int var mv uint16 hasLen := containerLen > 0 @@ -27709,19 +29100,20 @@ func (_ fastpathT) DecMapIntUint16V(v map[int]uint16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int(dd.DecodeInt(intBitsize)) + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint16(dd.DecodeUint(16)) + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } @@ -27733,22 +29125,23 @@ func (_ fastpathT) DecMapIntUint16V(v map[int]uint16, canChange bool, func (d *Decoder) fastpathDecMapIntUint32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int]uint32) - if v, changed := fastpathTV.DecMapIntUint32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntUint32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntUint32V(rv2i(rv).(map[int]uint32), false, d) } - fastpathTV.DecMapIntUint32V(rv2i(rv).(map[int]uint32), false, d) } func (f fastpathT) DecMapIntUint32X(vp *map[int]uint32, d *Decoder) { - if v, changed := f.DecMapIntUint32V(*vp, true, d); changed { + v, changed := f.DecMapIntUint32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntUint32V(v map[int]uint32, canChange bool, d *Decoder) (_ map[int]uint32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -27759,7 +29152,6 @@ func (_ fastpathT) DecMapIntUint32V(v map[int]uint32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int var mv uint32 hasLen := containerLen > 0 @@ -27767,19 +29159,20 @@ func (_ fastpathT) DecMapIntUint32V(v map[int]uint32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int(dd.DecodeInt(intBitsize)) + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint32(dd.DecodeUint(32)) + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } @@ -27791,22 +29184,23 @@ func (_ fastpathT) DecMapIntUint32V(v map[int]uint32, canChange bool, func (d *Decoder) fastpathDecMapIntUint64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int]uint64) - if v, changed := fastpathTV.DecMapIntUint64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntUint64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntUint64V(rv2i(rv).(map[int]uint64), false, d) } - fastpathTV.DecMapIntUint64V(rv2i(rv).(map[int]uint64), false, d) } func (f fastpathT) DecMapIntUint64X(vp *map[int]uint64, d *Decoder) { - if v, changed := f.DecMapIntUint64V(*vp, true, d); changed { + v, changed := f.DecMapIntUint64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntUint64V(v map[int]uint64, canChange bool, d *Decoder) (_ map[int]uint64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -27817,7 +29211,6 @@ func (_ fastpathT) DecMapIntUint64V(v map[int]uint64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int var mv uint64 hasLen := containerLen > 0 @@ -27825,19 +29218,20 @@ func (_ fastpathT) DecMapIntUint64V(v map[int]uint64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int(dd.DecodeInt(intBitsize)) + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeUint(64) + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } @@ -27849,22 +29243,23 @@ func (_ fastpathT) DecMapIntUint64V(v map[int]uint64, canChange bool, func (d *Decoder) fastpathDecMapIntUintptrR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int]uintptr) - if v, changed := fastpathTV.DecMapIntUintptrV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntUintptrV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntUintptrV(rv2i(rv).(map[int]uintptr), false, d) } - fastpathTV.DecMapIntUintptrV(rv2i(rv).(map[int]uintptr), false, d) } func (f fastpathT) DecMapIntUintptrX(vp *map[int]uintptr, d *Decoder) { - if v, changed := f.DecMapIntUintptrV(*vp, true, d); changed { + v, changed := f.DecMapIntUintptrV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntUintptrV(v map[int]uintptr, canChange bool, d *Decoder) (_ map[int]uintptr, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -27875,7 +29270,6 @@ func (_ fastpathT) DecMapIntUintptrV(v map[int]uintptr, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int var mv uintptr hasLen := containerLen > 0 @@ -27883,19 +29277,20 @@ func (_ fastpathT) DecMapIntUintptrV(v map[int]uintptr, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int(dd.DecodeInt(intBitsize)) + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uintptr(dd.DecodeUint(uintBitsize)) + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -27907,22 +29302,23 @@ func (_ fastpathT) DecMapIntUintptrV(v map[int]uintptr, canChange bool, func (d *Decoder) fastpathDecMapIntIntR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int]int) - if v, changed := fastpathTV.DecMapIntIntV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntIntV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntIntV(rv2i(rv).(map[int]int), false, d) } - fastpathTV.DecMapIntIntV(rv2i(rv).(map[int]int), false, d) } func (f fastpathT) DecMapIntIntX(vp *map[int]int, d *Decoder) { - if v, changed := f.DecMapIntIntV(*vp, true, d); changed { + v, changed := f.DecMapIntIntV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntIntV(v map[int]int, canChange bool, d *Decoder) (_ map[int]int, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -27933,7 +29329,6 @@ func (_ fastpathT) DecMapIntIntV(v map[int]int, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int var mv int hasLen := containerLen > 0 @@ -27941,19 +29336,20 @@ func (_ fastpathT) DecMapIntIntV(v map[int]int, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int(dd.DecodeInt(intBitsize)) + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int(dd.DecodeInt(intBitsize)) + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } @@ -27965,22 +29361,23 @@ func (_ fastpathT) DecMapIntIntV(v map[int]int, canChange bool, func (d *Decoder) fastpathDecMapIntInt8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int]int8) - if v, changed := fastpathTV.DecMapIntInt8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntInt8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntInt8V(rv2i(rv).(map[int]int8), false, d) } - fastpathTV.DecMapIntInt8V(rv2i(rv).(map[int]int8), false, d) } func (f fastpathT) DecMapIntInt8X(vp *map[int]int8, d *Decoder) { - if v, changed := f.DecMapIntInt8V(*vp, true, d); changed { + v, changed := f.DecMapIntInt8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntInt8V(v map[int]int8, canChange bool, d *Decoder) (_ map[int]int8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -27991,7 +29388,6 @@ func (_ fastpathT) DecMapIntInt8V(v map[int]int8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int var mv int8 hasLen := containerLen > 0 @@ -27999,19 +29395,20 @@ func (_ fastpathT) DecMapIntInt8V(v map[int]int8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int(dd.DecodeInt(intBitsize)) + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int8(dd.DecodeInt(8)) + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } @@ -28023,22 +29420,23 @@ func (_ fastpathT) DecMapIntInt8V(v map[int]int8, canChange bool, func (d *Decoder) fastpathDecMapIntInt16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int]int16) - if v, changed := fastpathTV.DecMapIntInt16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntInt16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntInt16V(rv2i(rv).(map[int]int16), false, d) } - fastpathTV.DecMapIntInt16V(rv2i(rv).(map[int]int16), false, d) } func (f fastpathT) DecMapIntInt16X(vp *map[int]int16, d *Decoder) { - if v, changed := f.DecMapIntInt16V(*vp, true, d); changed { + v, changed := f.DecMapIntInt16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntInt16V(v map[int]int16, canChange bool, d *Decoder) (_ map[int]int16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -28049,7 +29447,6 @@ func (_ fastpathT) DecMapIntInt16V(v map[int]int16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int var mv int16 hasLen := containerLen > 0 @@ -28057,19 +29454,20 @@ func (_ fastpathT) DecMapIntInt16V(v map[int]int16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int(dd.DecodeInt(intBitsize)) + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int16(dd.DecodeInt(16)) + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } @@ -28081,22 +29479,23 @@ func (_ fastpathT) DecMapIntInt16V(v map[int]int16, canChange bool, func (d *Decoder) fastpathDecMapIntInt32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int]int32) - if v, changed := fastpathTV.DecMapIntInt32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntInt32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntInt32V(rv2i(rv).(map[int]int32), false, d) } - fastpathTV.DecMapIntInt32V(rv2i(rv).(map[int]int32), false, d) } func (f fastpathT) DecMapIntInt32X(vp *map[int]int32, d *Decoder) { - if v, changed := f.DecMapIntInt32V(*vp, true, d); changed { + v, changed := f.DecMapIntInt32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntInt32V(v map[int]int32, canChange bool, d *Decoder) (_ map[int]int32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -28107,7 +29506,6 @@ func (_ fastpathT) DecMapIntInt32V(v map[int]int32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int var mv int32 hasLen := containerLen > 0 @@ -28115,19 +29513,20 @@ func (_ fastpathT) DecMapIntInt32V(v map[int]int32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int(dd.DecodeInt(intBitsize)) + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int32(dd.DecodeInt(32)) + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } @@ -28139,22 +29538,23 @@ func (_ fastpathT) DecMapIntInt32V(v map[int]int32, canChange bool, func (d *Decoder) fastpathDecMapIntInt64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int]int64) - if v, changed := fastpathTV.DecMapIntInt64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntInt64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntInt64V(rv2i(rv).(map[int]int64), false, d) } - fastpathTV.DecMapIntInt64V(rv2i(rv).(map[int]int64), false, d) } func (f fastpathT) DecMapIntInt64X(vp *map[int]int64, d *Decoder) { - if v, changed := f.DecMapIntInt64V(*vp, true, d); changed { + v, changed := f.DecMapIntInt64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntInt64V(v map[int]int64, canChange bool, d *Decoder) (_ map[int]int64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -28165,7 +29565,6 @@ func (_ fastpathT) DecMapIntInt64V(v map[int]int64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int var mv int64 hasLen := containerLen > 0 @@ -28173,19 +29572,20 @@ func (_ fastpathT) DecMapIntInt64V(v map[int]int64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int(dd.DecodeInt(intBitsize)) + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeInt(64) + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } @@ -28197,22 +29597,23 @@ func (_ fastpathT) DecMapIntInt64V(v map[int]int64, canChange bool, func (d *Decoder) fastpathDecMapIntFloat32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int]float32) - if v, changed := fastpathTV.DecMapIntFloat32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntFloat32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntFloat32V(rv2i(rv).(map[int]float32), false, d) } - fastpathTV.DecMapIntFloat32V(rv2i(rv).(map[int]float32), false, d) } func (f fastpathT) DecMapIntFloat32X(vp *map[int]float32, d *Decoder) { - if v, changed := f.DecMapIntFloat32V(*vp, true, d); changed { + v, changed := f.DecMapIntFloat32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntFloat32V(v map[int]float32, canChange bool, d *Decoder) (_ map[int]float32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -28223,7 +29624,6 @@ func (_ fastpathT) DecMapIntFloat32V(v map[int]float32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int var mv float32 hasLen := containerLen > 0 @@ -28231,19 +29631,20 @@ func (_ fastpathT) DecMapIntFloat32V(v map[int]float32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int(dd.DecodeInt(intBitsize)) + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = float32(dd.DecodeFloat(true)) + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } @@ -28255,22 +29656,23 @@ func (_ fastpathT) DecMapIntFloat32V(v map[int]float32, canChange bool, func (d *Decoder) fastpathDecMapIntFloat64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int]float64) - if v, changed := fastpathTV.DecMapIntFloat64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntFloat64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntFloat64V(rv2i(rv).(map[int]float64), false, d) } - fastpathTV.DecMapIntFloat64V(rv2i(rv).(map[int]float64), false, d) } func (f fastpathT) DecMapIntFloat64X(vp *map[int]float64, d *Decoder) { - if v, changed := f.DecMapIntFloat64V(*vp, true, d); changed { + v, changed := f.DecMapIntFloat64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntFloat64V(v map[int]float64, canChange bool, d *Decoder) (_ map[int]float64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -28281,7 +29683,6 @@ func (_ fastpathT) DecMapIntFloat64V(v map[int]float64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int var mv float64 hasLen := containerLen > 0 @@ -28289,19 +29690,20 @@ func (_ fastpathT) DecMapIntFloat64V(v map[int]float64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int(dd.DecodeInt(intBitsize)) + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeFloat(false) + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } @@ -28313,22 +29715,23 @@ func (_ fastpathT) DecMapIntFloat64V(v map[int]float64, canChange bool, func (d *Decoder) fastpathDecMapIntBoolR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int]bool) - if v, changed := fastpathTV.DecMapIntBoolV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapIntBoolV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapIntBoolV(rv2i(rv).(map[int]bool), false, d) } - fastpathTV.DecMapIntBoolV(rv2i(rv).(map[int]bool), false, d) } func (f fastpathT) DecMapIntBoolX(vp *map[int]bool, d *Decoder) { - if v, changed := f.DecMapIntBoolV(*vp, true, d); changed { + v, changed := f.DecMapIntBoolV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapIntBoolV(v map[int]bool, canChange bool, d *Decoder) (_ map[int]bool, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -28339,7 +29742,6 @@ func (_ fastpathT) DecMapIntBoolV(v map[int]bool, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int var mv bool hasLen := containerLen > 0 @@ -28347,12 +29749,13 @@ func (_ fastpathT) DecMapIntBoolV(v map[int]bool, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int(dd.DecodeInt(intBitsize)) + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = false @@ -28371,22 +29774,23 @@ func (_ fastpathT) DecMapIntBoolV(v map[int]bool, canChange bool, func (d *Decoder) fastpathDecMapInt8IntfR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int8]interface{}) - if v, changed := fastpathTV.DecMapInt8IntfV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt8IntfV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt8IntfV(rv2i(rv).(map[int8]interface{}), false, d) } - fastpathTV.DecMapInt8IntfV(rv2i(rv).(map[int8]interface{}), false, d) } func (f fastpathT) DecMapInt8IntfX(vp *map[int8]interface{}, d *Decoder) { - if v, changed := f.DecMapInt8IntfV(*vp, true, d); changed { + v, changed := f.DecMapInt8IntfV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt8IntfV(v map[int8]interface{}, canChange bool, d *Decoder) (_ map[int8]interface{}, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 17) @@ -28397,7 +29801,7 @@ func (_ fastpathT) DecMapInt8IntfV(v map[int8]interface{}, canChange bool, dd.ReadMapEnd() return v, changed } - mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset var mk int8 var mv interface{} hasLen := containerLen > 0 @@ -28405,12 +29809,13 @@ func (_ fastpathT) DecMapInt8IntfV(v map[int8]interface{}, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int8(dd.DecodeInt(8)) + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = nil @@ -28434,22 +29839,23 @@ func (_ fastpathT) DecMapInt8IntfV(v map[int8]interface{}, canChange bool, func (d *Decoder) fastpathDecMapInt8StringR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int8]string) - if v, changed := fastpathTV.DecMapInt8StringV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt8StringV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt8StringV(rv2i(rv).(map[int8]string), false, d) } - fastpathTV.DecMapInt8StringV(rv2i(rv).(map[int8]string), false, d) } func (f fastpathT) DecMapInt8StringX(vp *map[int8]string, d *Decoder) { - if v, changed := f.DecMapInt8StringV(*vp, true, d); changed { + v, changed := f.DecMapInt8StringV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt8StringV(v map[int8]string, canChange bool, d *Decoder) (_ map[int8]string, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 17) @@ -28460,7 +29866,6 @@ func (_ fastpathT) DecMapInt8StringV(v map[int8]string, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int8 var mv string hasLen := containerLen > 0 @@ -28468,12 +29873,13 @@ func (_ fastpathT) DecMapInt8StringV(v map[int8]string, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int8(dd.DecodeInt(8)) + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = "" @@ -28492,22 +29898,23 @@ func (_ fastpathT) DecMapInt8StringV(v map[int8]string, canChange bool, func (d *Decoder) fastpathDecMapInt8UintR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int8]uint) - if v, changed := fastpathTV.DecMapInt8UintV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt8UintV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt8UintV(rv2i(rv).(map[int8]uint), false, d) } - fastpathTV.DecMapInt8UintV(rv2i(rv).(map[int8]uint), false, d) } func (f fastpathT) DecMapInt8UintX(vp *map[int8]uint, d *Decoder) { - if v, changed := f.DecMapInt8UintV(*vp, true, d); changed { + v, changed := f.DecMapInt8UintV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt8UintV(v map[int8]uint, canChange bool, d *Decoder) (_ map[int8]uint, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -28518,7 +29925,6 @@ func (_ fastpathT) DecMapInt8UintV(v map[int8]uint, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int8 var mv uint hasLen := containerLen > 0 @@ -28526,19 +29932,20 @@ func (_ fastpathT) DecMapInt8UintV(v map[int8]uint, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int8(dd.DecodeInt(8)) + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint(dd.DecodeUint(uintBitsize)) + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -28550,22 +29957,23 @@ func (_ fastpathT) DecMapInt8UintV(v map[int8]uint, canChange bool, func (d *Decoder) fastpathDecMapInt8Uint8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int8]uint8) - if v, changed := fastpathTV.DecMapInt8Uint8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt8Uint8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt8Uint8V(rv2i(rv).(map[int8]uint8), false, d) } - fastpathTV.DecMapInt8Uint8V(rv2i(rv).(map[int8]uint8), false, d) } func (f fastpathT) DecMapInt8Uint8X(vp *map[int8]uint8, d *Decoder) { - if v, changed := f.DecMapInt8Uint8V(*vp, true, d); changed { + v, changed := f.DecMapInt8Uint8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt8Uint8V(v map[int8]uint8, canChange bool, d *Decoder) (_ map[int8]uint8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 2) @@ -28576,7 +29984,6 @@ func (_ fastpathT) DecMapInt8Uint8V(v map[int8]uint8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int8 var mv uint8 hasLen := containerLen > 0 @@ -28584,19 +29991,20 @@ func (_ fastpathT) DecMapInt8Uint8V(v map[int8]uint8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int8(dd.DecodeInt(8)) + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint8(dd.DecodeUint(8)) + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } @@ -28608,22 +30016,23 @@ func (_ fastpathT) DecMapInt8Uint8V(v map[int8]uint8, canChange bool, func (d *Decoder) fastpathDecMapInt8Uint16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int8]uint16) - if v, changed := fastpathTV.DecMapInt8Uint16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt8Uint16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt8Uint16V(rv2i(rv).(map[int8]uint16), false, d) } - fastpathTV.DecMapInt8Uint16V(rv2i(rv).(map[int8]uint16), false, d) } func (f fastpathT) DecMapInt8Uint16X(vp *map[int8]uint16, d *Decoder) { - if v, changed := f.DecMapInt8Uint16V(*vp, true, d); changed { + v, changed := f.DecMapInt8Uint16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt8Uint16V(v map[int8]uint16, canChange bool, d *Decoder) (_ map[int8]uint16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 3) @@ -28634,7 +30043,6 @@ func (_ fastpathT) DecMapInt8Uint16V(v map[int8]uint16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int8 var mv uint16 hasLen := containerLen > 0 @@ -28642,19 +30050,20 @@ func (_ fastpathT) DecMapInt8Uint16V(v map[int8]uint16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int8(dd.DecodeInt(8)) + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint16(dd.DecodeUint(16)) + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } @@ -28666,22 +30075,23 @@ func (_ fastpathT) DecMapInt8Uint16V(v map[int8]uint16, canChange bool, func (d *Decoder) fastpathDecMapInt8Uint32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int8]uint32) - if v, changed := fastpathTV.DecMapInt8Uint32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt8Uint32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt8Uint32V(rv2i(rv).(map[int8]uint32), false, d) } - fastpathTV.DecMapInt8Uint32V(rv2i(rv).(map[int8]uint32), false, d) } func (f fastpathT) DecMapInt8Uint32X(vp *map[int8]uint32, d *Decoder) { - if v, changed := f.DecMapInt8Uint32V(*vp, true, d); changed { + v, changed := f.DecMapInt8Uint32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt8Uint32V(v map[int8]uint32, canChange bool, d *Decoder) (_ map[int8]uint32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 5) @@ -28692,7 +30102,6 @@ func (_ fastpathT) DecMapInt8Uint32V(v map[int8]uint32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int8 var mv uint32 hasLen := containerLen > 0 @@ -28700,19 +30109,20 @@ func (_ fastpathT) DecMapInt8Uint32V(v map[int8]uint32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int8(dd.DecodeInt(8)) + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint32(dd.DecodeUint(32)) + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } @@ -28724,22 +30134,23 @@ func (_ fastpathT) DecMapInt8Uint32V(v map[int8]uint32, canChange bool, func (d *Decoder) fastpathDecMapInt8Uint64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int8]uint64) - if v, changed := fastpathTV.DecMapInt8Uint64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt8Uint64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt8Uint64V(rv2i(rv).(map[int8]uint64), false, d) } - fastpathTV.DecMapInt8Uint64V(rv2i(rv).(map[int8]uint64), false, d) } func (f fastpathT) DecMapInt8Uint64X(vp *map[int8]uint64, d *Decoder) { - if v, changed := f.DecMapInt8Uint64V(*vp, true, d); changed { + v, changed := f.DecMapInt8Uint64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt8Uint64V(v map[int8]uint64, canChange bool, d *Decoder) (_ map[int8]uint64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -28750,7 +30161,6 @@ func (_ fastpathT) DecMapInt8Uint64V(v map[int8]uint64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int8 var mv uint64 hasLen := containerLen > 0 @@ -28758,19 +30168,20 @@ func (_ fastpathT) DecMapInt8Uint64V(v map[int8]uint64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int8(dd.DecodeInt(8)) + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeUint(64) + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } @@ -28782,22 +30193,23 @@ func (_ fastpathT) DecMapInt8Uint64V(v map[int8]uint64, canChange bool, func (d *Decoder) fastpathDecMapInt8UintptrR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int8]uintptr) - if v, changed := fastpathTV.DecMapInt8UintptrV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt8UintptrV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt8UintptrV(rv2i(rv).(map[int8]uintptr), false, d) } - fastpathTV.DecMapInt8UintptrV(rv2i(rv).(map[int8]uintptr), false, d) } func (f fastpathT) DecMapInt8UintptrX(vp *map[int8]uintptr, d *Decoder) { - if v, changed := f.DecMapInt8UintptrV(*vp, true, d); changed { + v, changed := f.DecMapInt8UintptrV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt8UintptrV(v map[int8]uintptr, canChange bool, d *Decoder) (_ map[int8]uintptr, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -28808,7 +30220,6 @@ func (_ fastpathT) DecMapInt8UintptrV(v map[int8]uintptr, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int8 var mv uintptr hasLen := containerLen > 0 @@ -28816,19 +30227,20 @@ func (_ fastpathT) DecMapInt8UintptrV(v map[int8]uintptr, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int8(dd.DecodeInt(8)) + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uintptr(dd.DecodeUint(uintBitsize)) + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -28840,22 +30252,23 @@ func (_ fastpathT) DecMapInt8UintptrV(v map[int8]uintptr, canChange bool, func (d *Decoder) fastpathDecMapInt8IntR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int8]int) - if v, changed := fastpathTV.DecMapInt8IntV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt8IntV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt8IntV(rv2i(rv).(map[int8]int), false, d) } - fastpathTV.DecMapInt8IntV(rv2i(rv).(map[int8]int), false, d) } func (f fastpathT) DecMapInt8IntX(vp *map[int8]int, d *Decoder) { - if v, changed := f.DecMapInt8IntV(*vp, true, d); changed { + v, changed := f.DecMapInt8IntV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt8IntV(v map[int8]int, canChange bool, d *Decoder) (_ map[int8]int, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -28866,7 +30279,6 @@ func (_ fastpathT) DecMapInt8IntV(v map[int8]int, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int8 var mv int hasLen := containerLen > 0 @@ -28874,19 +30286,20 @@ func (_ fastpathT) DecMapInt8IntV(v map[int8]int, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int8(dd.DecodeInt(8)) + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int(dd.DecodeInt(intBitsize)) + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } @@ -28898,22 +30311,23 @@ func (_ fastpathT) DecMapInt8IntV(v map[int8]int, canChange bool, func (d *Decoder) fastpathDecMapInt8Int8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int8]int8) - if v, changed := fastpathTV.DecMapInt8Int8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt8Int8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt8Int8V(rv2i(rv).(map[int8]int8), false, d) } - fastpathTV.DecMapInt8Int8V(rv2i(rv).(map[int8]int8), false, d) } func (f fastpathT) DecMapInt8Int8X(vp *map[int8]int8, d *Decoder) { - if v, changed := f.DecMapInt8Int8V(*vp, true, d); changed { + v, changed := f.DecMapInt8Int8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt8Int8V(v map[int8]int8, canChange bool, d *Decoder) (_ map[int8]int8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 2) @@ -28924,7 +30338,6 @@ func (_ fastpathT) DecMapInt8Int8V(v map[int8]int8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int8 var mv int8 hasLen := containerLen > 0 @@ -28932,19 +30345,20 @@ func (_ fastpathT) DecMapInt8Int8V(v map[int8]int8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int8(dd.DecodeInt(8)) + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int8(dd.DecodeInt(8)) + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } @@ -28956,22 +30370,23 @@ func (_ fastpathT) DecMapInt8Int8V(v map[int8]int8, canChange bool, func (d *Decoder) fastpathDecMapInt8Int16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int8]int16) - if v, changed := fastpathTV.DecMapInt8Int16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt8Int16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt8Int16V(rv2i(rv).(map[int8]int16), false, d) } - fastpathTV.DecMapInt8Int16V(rv2i(rv).(map[int8]int16), false, d) } func (f fastpathT) DecMapInt8Int16X(vp *map[int8]int16, d *Decoder) { - if v, changed := f.DecMapInt8Int16V(*vp, true, d); changed { + v, changed := f.DecMapInt8Int16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt8Int16V(v map[int8]int16, canChange bool, d *Decoder) (_ map[int8]int16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 3) @@ -28982,7 +30397,6 @@ func (_ fastpathT) DecMapInt8Int16V(v map[int8]int16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int8 var mv int16 hasLen := containerLen > 0 @@ -28990,19 +30404,20 @@ func (_ fastpathT) DecMapInt8Int16V(v map[int8]int16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int8(dd.DecodeInt(8)) + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int16(dd.DecodeInt(16)) + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } @@ -29014,22 +30429,23 @@ func (_ fastpathT) DecMapInt8Int16V(v map[int8]int16, canChange bool, func (d *Decoder) fastpathDecMapInt8Int32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int8]int32) - if v, changed := fastpathTV.DecMapInt8Int32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt8Int32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt8Int32V(rv2i(rv).(map[int8]int32), false, d) } - fastpathTV.DecMapInt8Int32V(rv2i(rv).(map[int8]int32), false, d) } func (f fastpathT) DecMapInt8Int32X(vp *map[int8]int32, d *Decoder) { - if v, changed := f.DecMapInt8Int32V(*vp, true, d); changed { + v, changed := f.DecMapInt8Int32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt8Int32V(v map[int8]int32, canChange bool, d *Decoder) (_ map[int8]int32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 5) @@ -29040,7 +30456,6 @@ func (_ fastpathT) DecMapInt8Int32V(v map[int8]int32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int8 var mv int32 hasLen := containerLen > 0 @@ -29048,19 +30463,20 @@ func (_ fastpathT) DecMapInt8Int32V(v map[int8]int32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int8(dd.DecodeInt(8)) + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int32(dd.DecodeInt(32)) + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } @@ -29072,22 +30488,23 @@ func (_ fastpathT) DecMapInt8Int32V(v map[int8]int32, canChange bool, func (d *Decoder) fastpathDecMapInt8Int64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int8]int64) - if v, changed := fastpathTV.DecMapInt8Int64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt8Int64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt8Int64V(rv2i(rv).(map[int8]int64), false, d) } - fastpathTV.DecMapInt8Int64V(rv2i(rv).(map[int8]int64), false, d) } func (f fastpathT) DecMapInt8Int64X(vp *map[int8]int64, d *Decoder) { - if v, changed := f.DecMapInt8Int64V(*vp, true, d); changed { + v, changed := f.DecMapInt8Int64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt8Int64V(v map[int8]int64, canChange bool, d *Decoder) (_ map[int8]int64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -29098,7 +30515,6 @@ func (_ fastpathT) DecMapInt8Int64V(v map[int8]int64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int8 var mv int64 hasLen := containerLen > 0 @@ -29106,19 +30522,20 @@ func (_ fastpathT) DecMapInt8Int64V(v map[int8]int64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int8(dd.DecodeInt(8)) + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeInt(64) + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } @@ -29130,22 +30547,23 @@ func (_ fastpathT) DecMapInt8Int64V(v map[int8]int64, canChange bool, func (d *Decoder) fastpathDecMapInt8Float32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int8]float32) - if v, changed := fastpathTV.DecMapInt8Float32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt8Float32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt8Float32V(rv2i(rv).(map[int8]float32), false, d) } - fastpathTV.DecMapInt8Float32V(rv2i(rv).(map[int8]float32), false, d) } func (f fastpathT) DecMapInt8Float32X(vp *map[int8]float32, d *Decoder) { - if v, changed := f.DecMapInt8Float32V(*vp, true, d); changed { + v, changed := f.DecMapInt8Float32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt8Float32V(v map[int8]float32, canChange bool, d *Decoder) (_ map[int8]float32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 5) @@ -29156,7 +30574,6 @@ func (_ fastpathT) DecMapInt8Float32V(v map[int8]float32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int8 var mv float32 hasLen := containerLen > 0 @@ -29164,19 +30581,20 @@ func (_ fastpathT) DecMapInt8Float32V(v map[int8]float32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int8(dd.DecodeInt(8)) + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = float32(dd.DecodeFloat(true)) + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } @@ -29188,22 +30606,23 @@ func (_ fastpathT) DecMapInt8Float32V(v map[int8]float32, canChange bool, func (d *Decoder) fastpathDecMapInt8Float64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int8]float64) - if v, changed := fastpathTV.DecMapInt8Float64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt8Float64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt8Float64V(rv2i(rv).(map[int8]float64), false, d) } - fastpathTV.DecMapInt8Float64V(rv2i(rv).(map[int8]float64), false, d) } func (f fastpathT) DecMapInt8Float64X(vp *map[int8]float64, d *Decoder) { - if v, changed := f.DecMapInt8Float64V(*vp, true, d); changed { + v, changed := f.DecMapInt8Float64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt8Float64V(v map[int8]float64, canChange bool, d *Decoder) (_ map[int8]float64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -29214,7 +30633,6 @@ func (_ fastpathT) DecMapInt8Float64V(v map[int8]float64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int8 var mv float64 hasLen := containerLen > 0 @@ -29222,19 +30640,20 @@ func (_ fastpathT) DecMapInt8Float64V(v map[int8]float64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int8(dd.DecodeInt(8)) + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeFloat(false) + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } @@ -29246,22 +30665,23 @@ func (_ fastpathT) DecMapInt8Float64V(v map[int8]float64, canChange bool, func (d *Decoder) fastpathDecMapInt8BoolR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int8]bool) - if v, changed := fastpathTV.DecMapInt8BoolV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt8BoolV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt8BoolV(rv2i(rv).(map[int8]bool), false, d) } - fastpathTV.DecMapInt8BoolV(rv2i(rv).(map[int8]bool), false, d) } func (f fastpathT) DecMapInt8BoolX(vp *map[int8]bool, d *Decoder) { - if v, changed := f.DecMapInt8BoolV(*vp, true, d); changed { + v, changed := f.DecMapInt8BoolV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt8BoolV(v map[int8]bool, canChange bool, d *Decoder) (_ map[int8]bool, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 2) @@ -29272,7 +30692,6 @@ func (_ fastpathT) DecMapInt8BoolV(v map[int8]bool, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int8 var mv bool hasLen := containerLen > 0 @@ -29280,12 +30699,13 @@ func (_ fastpathT) DecMapInt8BoolV(v map[int8]bool, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int8(dd.DecodeInt(8)) + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = false @@ -29304,22 +30724,23 @@ func (_ fastpathT) DecMapInt8BoolV(v map[int8]bool, canChange bool, func (d *Decoder) fastpathDecMapInt16IntfR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int16]interface{}) - if v, changed := fastpathTV.DecMapInt16IntfV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt16IntfV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt16IntfV(rv2i(rv).(map[int16]interface{}), false, d) } - fastpathTV.DecMapInt16IntfV(rv2i(rv).(map[int16]interface{}), false, d) } func (f fastpathT) DecMapInt16IntfX(vp *map[int16]interface{}, d *Decoder) { - if v, changed := f.DecMapInt16IntfV(*vp, true, d); changed { + v, changed := f.DecMapInt16IntfV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt16IntfV(v map[int16]interface{}, canChange bool, d *Decoder) (_ map[int16]interface{}, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 18) @@ -29330,7 +30751,7 @@ func (_ fastpathT) DecMapInt16IntfV(v map[int16]interface{}, canChange bool, dd.ReadMapEnd() return v, changed } - mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset var mk int16 var mv interface{} hasLen := containerLen > 0 @@ -29338,12 +30759,13 @@ func (_ fastpathT) DecMapInt16IntfV(v map[int16]interface{}, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int16(dd.DecodeInt(16)) + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = nil @@ -29367,22 +30789,23 @@ func (_ fastpathT) DecMapInt16IntfV(v map[int16]interface{}, canChange bool, func (d *Decoder) fastpathDecMapInt16StringR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int16]string) - if v, changed := fastpathTV.DecMapInt16StringV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt16StringV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt16StringV(rv2i(rv).(map[int16]string), false, d) } - fastpathTV.DecMapInt16StringV(rv2i(rv).(map[int16]string), false, d) } func (f fastpathT) DecMapInt16StringX(vp *map[int16]string, d *Decoder) { - if v, changed := f.DecMapInt16StringV(*vp, true, d); changed { + v, changed := f.DecMapInt16StringV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt16StringV(v map[int16]string, canChange bool, d *Decoder) (_ map[int16]string, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 18) @@ -29393,7 +30816,6 @@ func (_ fastpathT) DecMapInt16StringV(v map[int16]string, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int16 var mv string hasLen := containerLen > 0 @@ -29401,12 +30823,13 @@ func (_ fastpathT) DecMapInt16StringV(v map[int16]string, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int16(dd.DecodeInt(16)) + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = "" @@ -29425,22 +30848,23 @@ func (_ fastpathT) DecMapInt16StringV(v map[int16]string, canChange bool, func (d *Decoder) fastpathDecMapInt16UintR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int16]uint) - if v, changed := fastpathTV.DecMapInt16UintV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt16UintV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt16UintV(rv2i(rv).(map[int16]uint), false, d) } - fastpathTV.DecMapInt16UintV(rv2i(rv).(map[int16]uint), false, d) } func (f fastpathT) DecMapInt16UintX(vp *map[int16]uint, d *Decoder) { - if v, changed := f.DecMapInt16UintV(*vp, true, d); changed { + v, changed := f.DecMapInt16UintV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt16UintV(v map[int16]uint, canChange bool, d *Decoder) (_ map[int16]uint, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -29451,7 +30875,6 @@ func (_ fastpathT) DecMapInt16UintV(v map[int16]uint, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int16 var mv uint hasLen := containerLen > 0 @@ -29459,19 +30882,20 @@ func (_ fastpathT) DecMapInt16UintV(v map[int16]uint, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int16(dd.DecodeInt(16)) + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint(dd.DecodeUint(uintBitsize)) + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -29483,22 +30907,23 @@ func (_ fastpathT) DecMapInt16UintV(v map[int16]uint, canChange bool, func (d *Decoder) fastpathDecMapInt16Uint8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int16]uint8) - if v, changed := fastpathTV.DecMapInt16Uint8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt16Uint8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt16Uint8V(rv2i(rv).(map[int16]uint8), false, d) } - fastpathTV.DecMapInt16Uint8V(rv2i(rv).(map[int16]uint8), false, d) } func (f fastpathT) DecMapInt16Uint8X(vp *map[int16]uint8, d *Decoder) { - if v, changed := f.DecMapInt16Uint8V(*vp, true, d); changed { + v, changed := f.DecMapInt16Uint8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt16Uint8V(v map[int16]uint8, canChange bool, d *Decoder) (_ map[int16]uint8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 3) @@ -29509,7 +30934,6 @@ func (_ fastpathT) DecMapInt16Uint8V(v map[int16]uint8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int16 var mv uint8 hasLen := containerLen > 0 @@ -29517,19 +30941,20 @@ func (_ fastpathT) DecMapInt16Uint8V(v map[int16]uint8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int16(dd.DecodeInt(16)) + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint8(dd.DecodeUint(8)) + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } @@ -29541,22 +30966,23 @@ func (_ fastpathT) DecMapInt16Uint8V(v map[int16]uint8, canChange bool, func (d *Decoder) fastpathDecMapInt16Uint16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int16]uint16) - if v, changed := fastpathTV.DecMapInt16Uint16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt16Uint16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt16Uint16V(rv2i(rv).(map[int16]uint16), false, d) } - fastpathTV.DecMapInt16Uint16V(rv2i(rv).(map[int16]uint16), false, d) } func (f fastpathT) DecMapInt16Uint16X(vp *map[int16]uint16, d *Decoder) { - if v, changed := f.DecMapInt16Uint16V(*vp, true, d); changed { + v, changed := f.DecMapInt16Uint16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt16Uint16V(v map[int16]uint16, canChange bool, d *Decoder) (_ map[int16]uint16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 4) @@ -29567,7 +30993,6 @@ func (_ fastpathT) DecMapInt16Uint16V(v map[int16]uint16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int16 var mv uint16 hasLen := containerLen > 0 @@ -29575,19 +31000,20 @@ func (_ fastpathT) DecMapInt16Uint16V(v map[int16]uint16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int16(dd.DecodeInt(16)) + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint16(dd.DecodeUint(16)) + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } @@ -29599,22 +31025,23 @@ func (_ fastpathT) DecMapInt16Uint16V(v map[int16]uint16, canChange bool, func (d *Decoder) fastpathDecMapInt16Uint32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int16]uint32) - if v, changed := fastpathTV.DecMapInt16Uint32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt16Uint32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt16Uint32V(rv2i(rv).(map[int16]uint32), false, d) } - fastpathTV.DecMapInt16Uint32V(rv2i(rv).(map[int16]uint32), false, d) } func (f fastpathT) DecMapInt16Uint32X(vp *map[int16]uint32, d *Decoder) { - if v, changed := f.DecMapInt16Uint32V(*vp, true, d); changed { + v, changed := f.DecMapInt16Uint32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt16Uint32V(v map[int16]uint32, canChange bool, d *Decoder) (_ map[int16]uint32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 6) @@ -29625,7 +31052,6 @@ func (_ fastpathT) DecMapInt16Uint32V(v map[int16]uint32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int16 var mv uint32 hasLen := containerLen > 0 @@ -29633,19 +31059,20 @@ func (_ fastpathT) DecMapInt16Uint32V(v map[int16]uint32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int16(dd.DecodeInt(16)) + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint32(dd.DecodeUint(32)) + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } @@ -29657,22 +31084,23 @@ func (_ fastpathT) DecMapInt16Uint32V(v map[int16]uint32, canChange bool, func (d *Decoder) fastpathDecMapInt16Uint64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int16]uint64) - if v, changed := fastpathTV.DecMapInt16Uint64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt16Uint64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt16Uint64V(rv2i(rv).(map[int16]uint64), false, d) } - fastpathTV.DecMapInt16Uint64V(rv2i(rv).(map[int16]uint64), false, d) } func (f fastpathT) DecMapInt16Uint64X(vp *map[int16]uint64, d *Decoder) { - if v, changed := f.DecMapInt16Uint64V(*vp, true, d); changed { + v, changed := f.DecMapInt16Uint64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt16Uint64V(v map[int16]uint64, canChange bool, d *Decoder) (_ map[int16]uint64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -29683,7 +31111,6 @@ func (_ fastpathT) DecMapInt16Uint64V(v map[int16]uint64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int16 var mv uint64 hasLen := containerLen > 0 @@ -29691,19 +31118,20 @@ func (_ fastpathT) DecMapInt16Uint64V(v map[int16]uint64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int16(dd.DecodeInt(16)) + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeUint(64) + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } @@ -29715,22 +31143,23 @@ func (_ fastpathT) DecMapInt16Uint64V(v map[int16]uint64, canChange bool, func (d *Decoder) fastpathDecMapInt16UintptrR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int16]uintptr) - if v, changed := fastpathTV.DecMapInt16UintptrV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt16UintptrV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt16UintptrV(rv2i(rv).(map[int16]uintptr), false, d) } - fastpathTV.DecMapInt16UintptrV(rv2i(rv).(map[int16]uintptr), false, d) } func (f fastpathT) DecMapInt16UintptrX(vp *map[int16]uintptr, d *Decoder) { - if v, changed := f.DecMapInt16UintptrV(*vp, true, d); changed { + v, changed := f.DecMapInt16UintptrV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt16UintptrV(v map[int16]uintptr, canChange bool, d *Decoder) (_ map[int16]uintptr, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -29741,7 +31170,6 @@ func (_ fastpathT) DecMapInt16UintptrV(v map[int16]uintptr, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int16 var mv uintptr hasLen := containerLen > 0 @@ -29749,19 +31177,20 @@ func (_ fastpathT) DecMapInt16UintptrV(v map[int16]uintptr, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int16(dd.DecodeInt(16)) + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uintptr(dd.DecodeUint(uintBitsize)) + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -29773,22 +31202,23 @@ func (_ fastpathT) DecMapInt16UintptrV(v map[int16]uintptr, canChange bool, func (d *Decoder) fastpathDecMapInt16IntR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int16]int) - if v, changed := fastpathTV.DecMapInt16IntV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt16IntV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt16IntV(rv2i(rv).(map[int16]int), false, d) } - fastpathTV.DecMapInt16IntV(rv2i(rv).(map[int16]int), false, d) } func (f fastpathT) DecMapInt16IntX(vp *map[int16]int, d *Decoder) { - if v, changed := f.DecMapInt16IntV(*vp, true, d); changed { + v, changed := f.DecMapInt16IntV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt16IntV(v map[int16]int, canChange bool, d *Decoder) (_ map[int16]int, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -29799,7 +31229,6 @@ func (_ fastpathT) DecMapInt16IntV(v map[int16]int, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int16 var mv int hasLen := containerLen > 0 @@ -29807,19 +31236,20 @@ func (_ fastpathT) DecMapInt16IntV(v map[int16]int, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int16(dd.DecodeInt(16)) + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int(dd.DecodeInt(intBitsize)) + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } @@ -29831,22 +31261,23 @@ func (_ fastpathT) DecMapInt16IntV(v map[int16]int, canChange bool, func (d *Decoder) fastpathDecMapInt16Int8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int16]int8) - if v, changed := fastpathTV.DecMapInt16Int8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt16Int8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt16Int8V(rv2i(rv).(map[int16]int8), false, d) } - fastpathTV.DecMapInt16Int8V(rv2i(rv).(map[int16]int8), false, d) } func (f fastpathT) DecMapInt16Int8X(vp *map[int16]int8, d *Decoder) { - if v, changed := f.DecMapInt16Int8V(*vp, true, d); changed { + v, changed := f.DecMapInt16Int8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt16Int8V(v map[int16]int8, canChange bool, d *Decoder) (_ map[int16]int8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 3) @@ -29857,7 +31288,6 @@ func (_ fastpathT) DecMapInt16Int8V(v map[int16]int8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int16 var mv int8 hasLen := containerLen > 0 @@ -29865,19 +31295,20 @@ func (_ fastpathT) DecMapInt16Int8V(v map[int16]int8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int16(dd.DecodeInt(16)) + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int8(dd.DecodeInt(8)) + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } @@ -29889,22 +31320,23 @@ func (_ fastpathT) DecMapInt16Int8V(v map[int16]int8, canChange bool, func (d *Decoder) fastpathDecMapInt16Int16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int16]int16) - if v, changed := fastpathTV.DecMapInt16Int16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt16Int16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt16Int16V(rv2i(rv).(map[int16]int16), false, d) } - fastpathTV.DecMapInt16Int16V(rv2i(rv).(map[int16]int16), false, d) } func (f fastpathT) DecMapInt16Int16X(vp *map[int16]int16, d *Decoder) { - if v, changed := f.DecMapInt16Int16V(*vp, true, d); changed { + v, changed := f.DecMapInt16Int16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt16Int16V(v map[int16]int16, canChange bool, d *Decoder) (_ map[int16]int16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 4) @@ -29915,7 +31347,6 @@ func (_ fastpathT) DecMapInt16Int16V(v map[int16]int16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int16 var mv int16 hasLen := containerLen > 0 @@ -29923,19 +31354,20 @@ func (_ fastpathT) DecMapInt16Int16V(v map[int16]int16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int16(dd.DecodeInt(16)) + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int16(dd.DecodeInt(16)) + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } @@ -29947,22 +31379,23 @@ func (_ fastpathT) DecMapInt16Int16V(v map[int16]int16, canChange bool, func (d *Decoder) fastpathDecMapInt16Int32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int16]int32) - if v, changed := fastpathTV.DecMapInt16Int32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt16Int32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt16Int32V(rv2i(rv).(map[int16]int32), false, d) } - fastpathTV.DecMapInt16Int32V(rv2i(rv).(map[int16]int32), false, d) } func (f fastpathT) DecMapInt16Int32X(vp *map[int16]int32, d *Decoder) { - if v, changed := f.DecMapInt16Int32V(*vp, true, d); changed { + v, changed := f.DecMapInt16Int32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt16Int32V(v map[int16]int32, canChange bool, d *Decoder) (_ map[int16]int32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 6) @@ -29973,7 +31406,6 @@ func (_ fastpathT) DecMapInt16Int32V(v map[int16]int32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int16 var mv int32 hasLen := containerLen > 0 @@ -29981,19 +31413,20 @@ func (_ fastpathT) DecMapInt16Int32V(v map[int16]int32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int16(dd.DecodeInt(16)) + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int32(dd.DecodeInt(32)) + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } @@ -30005,22 +31438,23 @@ func (_ fastpathT) DecMapInt16Int32V(v map[int16]int32, canChange bool, func (d *Decoder) fastpathDecMapInt16Int64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int16]int64) - if v, changed := fastpathTV.DecMapInt16Int64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt16Int64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt16Int64V(rv2i(rv).(map[int16]int64), false, d) } - fastpathTV.DecMapInt16Int64V(rv2i(rv).(map[int16]int64), false, d) } func (f fastpathT) DecMapInt16Int64X(vp *map[int16]int64, d *Decoder) { - if v, changed := f.DecMapInt16Int64V(*vp, true, d); changed { + v, changed := f.DecMapInt16Int64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt16Int64V(v map[int16]int64, canChange bool, d *Decoder) (_ map[int16]int64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -30031,7 +31465,6 @@ func (_ fastpathT) DecMapInt16Int64V(v map[int16]int64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int16 var mv int64 hasLen := containerLen > 0 @@ -30039,19 +31472,20 @@ func (_ fastpathT) DecMapInt16Int64V(v map[int16]int64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int16(dd.DecodeInt(16)) + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeInt(64) + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } @@ -30063,22 +31497,23 @@ func (_ fastpathT) DecMapInt16Int64V(v map[int16]int64, canChange bool, func (d *Decoder) fastpathDecMapInt16Float32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int16]float32) - if v, changed := fastpathTV.DecMapInt16Float32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt16Float32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt16Float32V(rv2i(rv).(map[int16]float32), false, d) } - fastpathTV.DecMapInt16Float32V(rv2i(rv).(map[int16]float32), false, d) } func (f fastpathT) DecMapInt16Float32X(vp *map[int16]float32, d *Decoder) { - if v, changed := f.DecMapInt16Float32V(*vp, true, d); changed { + v, changed := f.DecMapInt16Float32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt16Float32V(v map[int16]float32, canChange bool, d *Decoder) (_ map[int16]float32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 6) @@ -30089,7 +31524,6 @@ func (_ fastpathT) DecMapInt16Float32V(v map[int16]float32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int16 var mv float32 hasLen := containerLen > 0 @@ -30097,19 +31531,20 @@ func (_ fastpathT) DecMapInt16Float32V(v map[int16]float32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int16(dd.DecodeInt(16)) + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = float32(dd.DecodeFloat(true)) + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } @@ -30121,22 +31556,23 @@ func (_ fastpathT) DecMapInt16Float32V(v map[int16]float32, canChange bool, func (d *Decoder) fastpathDecMapInt16Float64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int16]float64) - if v, changed := fastpathTV.DecMapInt16Float64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt16Float64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt16Float64V(rv2i(rv).(map[int16]float64), false, d) } - fastpathTV.DecMapInt16Float64V(rv2i(rv).(map[int16]float64), false, d) } func (f fastpathT) DecMapInt16Float64X(vp *map[int16]float64, d *Decoder) { - if v, changed := f.DecMapInt16Float64V(*vp, true, d); changed { + v, changed := f.DecMapInt16Float64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt16Float64V(v map[int16]float64, canChange bool, d *Decoder) (_ map[int16]float64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -30147,7 +31583,6 @@ func (_ fastpathT) DecMapInt16Float64V(v map[int16]float64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int16 var mv float64 hasLen := containerLen > 0 @@ -30155,19 +31590,20 @@ func (_ fastpathT) DecMapInt16Float64V(v map[int16]float64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int16(dd.DecodeInt(16)) + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeFloat(false) + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } @@ -30179,22 +31615,23 @@ func (_ fastpathT) DecMapInt16Float64V(v map[int16]float64, canChange bool, func (d *Decoder) fastpathDecMapInt16BoolR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int16]bool) - if v, changed := fastpathTV.DecMapInt16BoolV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt16BoolV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt16BoolV(rv2i(rv).(map[int16]bool), false, d) } - fastpathTV.DecMapInt16BoolV(rv2i(rv).(map[int16]bool), false, d) } func (f fastpathT) DecMapInt16BoolX(vp *map[int16]bool, d *Decoder) { - if v, changed := f.DecMapInt16BoolV(*vp, true, d); changed { + v, changed := f.DecMapInt16BoolV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt16BoolV(v map[int16]bool, canChange bool, d *Decoder) (_ map[int16]bool, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 3) @@ -30205,7 +31642,6 @@ func (_ fastpathT) DecMapInt16BoolV(v map[int16]bool, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int16 var mv bool hasLen := containerLen > 0 @@ -30213,12 +31649,13 @@ func (_ fastpathT) DecMapInt16BoolV(v map[int16]bool, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int16(dd.DecodeInt(16)) + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = false @@ -30237,22 +31674,23 @@ func (_ fastpathT) DecMapInt16BoolV(v map[int16]bool, canChange bool, func (d *Decoder) fastpathDecMapInt32IntfR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int32]interface{}) - if v, changed := fastpathTV.DecMapInt32IntfV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt32IntfV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt32IntfV(rv2i(rv).(map[int32]interface{}), false, d) } - fastpathTV.DecMapInt32IntfV(rv2i(rv).(map[int32]interface{}), false, d) } func (f fastpathT) DecMapInt32IntfX(vp *map[int32]interface{}, d *Decoder) { - if v, changed := f.DecMapInt32IntfV(*vp, true, d); changed { + v, changed := f.DecMapInt32IntfV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt32IntfV(v map[int32]interface{}, canChange bool, d *Decoder) (_ map[int32]interface{}, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 20) @@ -30263,7 +31701,7 @@ func (_ fastpathT) DecMapInt32IntfV(v map[int32]interface{}, canChange bool, dd.ReadMapEnd() return v, changed } - mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset var mk int32 var mv interface{} hasLen := containerLen > 0 @@ -30271,12 +31709,13 @@ func (_ fastpathT) DecMapInt32IntfV(v map[int32]interface{}, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int32(dd.DecodeInt(32)) + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = nil @@ -30300,22 +31739,23 @@ func (_ fastpathT) DecMapInt32IntfV(v map[int32]interface{}, canChange bool, func (d *Decoder) fastpathDecMapInt32StringR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int32]string) - if v, changed := fastpathTV.DecMapInt32StringV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt32StringV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt32StringV(rv2i(rv).(map[int32]string), false, d) } - fastpathTV.DecMapInt32StringV(rv2i(rv).(map[int32]string), false, d) } func (f fastpathT) DecMapInt32StringX(vp *map[int32]string, d *Decoder) { - if v, changed := f.DecMapInt32StringV(*vp, true, d); changed { + v, changed := f.DecMapInt32StringV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt32StringV(v map[int32]string, canChange bool, d *Decoder) (_ map[int32]string, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 20) @@ -30326,7 +31766,6 @@ func (_ fastpathT) DecMapInt32StringV(v map[int32]string, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int32 var mv string hasLen := containerLen > 0 @@ -30334,12 +31773,13 @@ func (_ fastpathT) DecMapInt32StringV(v map[int32]string, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int32(dd.DecodeInt(32)) + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = "" @@ -30358,22 +31798,23 @@ func (_ fastpathT) DecMapInt32StringV(v map[int32]string, canChange bool, func (d *Decoder) fastpathDecMapInt32UintR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int32]uint) - if v, changed := fastpathTV.DecMapInt32UintV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt32UintV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt32UintV(rv2i(rv).(map[int32]uint), false, d) } - fastpathTV.DecMapInt32UintV(rv2i(rv).(map[int32]uint), false, d) } func (f fastpathT) DecMapInt32UintX(vp *map[int32]uint, d *Decoder) { - if v, changed := f.DecMapInt32UintV(*vp, true, d); changed { + v, changed := f.DecMapInt32UintV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt32UintV(v map[int32]uint, canChange bool, d *Decoder) (_ map[int32]uint, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -30384,7 +31825,6 @@ func (_ fastpathT) DecMapInt32UintV(v map[int32]uint, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int32 var mv uint hasLen := containerLen > 0 @@ -30392,19 +31832,20 @@ func (_ fastpathT) DecMapInt32UintV(v map[int32]uint, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int32(dd.DecodeInt(32)) + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint(dd.DecodeUint(uintBitsize)) + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -30416,22 +31857,23 @@ func (_ fastpathT) DecMapInt32UintV(v map[int32]uint, canChange bool, func (d *Decoder) fastpathDecMapInt32Uint8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int32]uint8) - if v, changed := fastpathTV.DecMapInt32Uint8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt32Uint8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt32Uint8V(rv2i(rv).(map[int32]uint8), false, d) } - fastpathTV.DecMapInt32Uint8V(rv2i(rv).(map[int32]uint8), false, d) } func (f fastpathT) DecMapInt32Uint8X(vp *map[int32]uint8, d *Decoder) { - if v, changed := f.DecMapInt32Uint8V(*vp, true, d); changed { + v, changed := f.DecMapInt32Uint8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt32Uint8V(v map[int32]uint8, canChange bool, d *Decoder) (_ map[int32]uint8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 5) @@ -30442,7 +31884,6 @@ func (_ fastpathT) DecMapInt32Uint8V(v map[int32]uint8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int32 var mv uint8 hasLen := containerLen > 0 @@ -30450,19 +31891,20 @@ func (_ fastpathT) DecMapInt32Uint8V(v map[int32]uint8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int32(dd.DecodeInt(32)) + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint8(dd.DecodeUint(8)) + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } @@ -30474,22 +31916,23 @@ func (_ fastpathT) DecMapInt32Uint8V(v map[int32]uint8, canChange bool, func (d *Decoder) fastpathDecMapInt32Uint16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int32]uint16) - if v, changed := fastpathTV.DecMapInt32Uint16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt32Uint16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt32Uint16V(rv2i(rv).(map[int32]uint16), false, d) } - fastpathTV.DecMapInt32Uint16V(rv2i(rv).(map[int32]uint16), false, d) } func (f fastpathT) DecMapInt32Uint16X(vp *map[int32]uint16, d *Decoder) { - if v, changed := f.DecMapInt32Uint16V(*vp, true, d); changed { + v, changed := f.DecMapInt32Uint16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt32Uint16V(v map[int32]uint16, canChange bool, d *Decoder) (_ map[int32]uint16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 6) @@ -30500,7 +31943,6 @@ func (_ fastpathT) DecMapInt32Uint16V(v map[int32]uint16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int32 var mv uint16 hasLen := containerLen > 0 @@ -30508,19 +31950,20 @@ func (_ fastpathT) DecMapInt32Uint16V(v map[int32]uint16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int32(dd.DecodeInt(32)) + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint16(dd.DecodeUint(16)) + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } @@ -30532,22 +31975,23 @@ func (_ fastpathT) DecMapInt32Uint16V(v map[int32]uint16, canChange bool, func (d *Decoder) fastpathDecMapInt32Uint32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int32]uint32) - if v, changed := fastpathTV.DecMapInt32Uint32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt32Uint32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt32Uint32V(rv2i(rv).(map[int32]uint32), false, d) } - fastpathTV.DecMapInt32Uint32V(rv2i(rv).(map[int32]uint32), false, d) } func (f fastpathT) DecMapInt32Uint32X(vp *map[int32]uint32, d *Decoder) { - if v, changed := f.DecMapInt32Uint32V(*vp, true, d); changed { + v, changed := f.DecMapInt32Uint32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt32Uint32V(v map[int32]uint32, canChange bool, d *Decoder) (_ map[int32]uint32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 8) @@ -30558,7 +32002,6 @@ func (_ fastpathT) DecMapInt32Uint32V(v map[int32]uint32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int32 var mv uint32 hasLen := containerLen > 0 @@ -30566,19 +32009,20 @@ func (_ fastpathT) DecMapInt32Uint32V(v map[int32]uint32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int32(dd.DecodeInt(32)) + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint32(dd.DecodeUint(32)) + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } @@ -30590,22 +32034,23 @@ func (_ fastpathT) DecMapInt32Uint32V(v map[int32]uint32, canChange bool, func (d *Decoder) fastpathDecMapInt32Uint64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int32]uint64) - if v, changed := fastpathTV.DecMapInt32Uint64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt32Uint64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt32Uint64V(rv2i(rv).(map[int32]uint64), false, d) } - fastpathTV.DecMapInt32Uint64V(rv2i(rv).(map[int32]uint64), false, d) } func (f fastpathT) DecMapInt32Uint64X(vp *map[int32]uint64, d *Decoder) { - if v, changed := f.DecMapInt32Uint64V(*vp, true, d); changed { + v, changed := f.DecMapInt32Uint64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt32Uint64V(v map[int32]uint64, canChange bool, d *Decoder) (_ map[int32]uint64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -30616,7 +32061,6 @@ func (_ fastpathT) DecMapInt32Uint64V(v map[int32]uint64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int32 var mv uint64 hasLen := containerLen > 0 @@ -30624,19 +32068,20 @@ func (_ fastpathT) DecMapInt32Uint64V(v map[int32]uint64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int32(dd.DecodeInt(32)) + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeUint(64) + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } @@ -30648,22 +32093,23 @@ func (_ fastpathT) DecMapInt32Uint64V(v map[int32]uint64, canChange bool, func (d *Decoder) fastpathDecMapInt32UintptrR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int32]uintptr) - if v, changed := fastpathTV.DecMapInt32UintptrV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt32UintptrV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt32UintptrV(rv2i(rv).(map[int32]uintptr), false, d) } - fastpathTV.DecMapInt32UintptrV(rv2i(rv).(map[int32]uintptr), false, d) } func (f fastpathT) DecMapInt32UintptrX(vp *map[int32]uintptr, d *Decoder) { - if v, changed := f.DecMapInt32UintptrV(*vp, true, d); changed { + v, changed := f.DecMapInt32UintptrV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt32UintptrV(v map[int32]uintptr, canChange bool, d *Decoder) (_ map[int32]uintptr, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -30674,7 +32120,6 @@ func (_ fastpathT) DecMapInt32UintptrV(v map[int32]uintptr, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int32 var mv uintptr hasLen := containerLen > 0 @@ -30682,19 +32127,20 @@ func (_ fastpathT) DecMapInt32UintptrV(v map[int32]uintptr, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int32(dd.DecodeInt(32)) + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uintptr(dd.DecodeUint(uintBitsize)) + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -30706,22 +32152,23 @@ func (_ fastpathT) DecMapInt32UintptrV(v map[int32]uintptr, canChange bool, func (d *Decoder) fastpathDecMapInt32IntR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int32]int) - if v, changed := fastpathTV.DecMapInt32IntV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt32IntV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt32IntV(rv2i(rv).(map[int32]int), false, d) } - fastpathTV.DecMapInt32IntV(rv2i(rv).(map[int32]int), false, d) } func (f fastpathT) DecMapInt32IntX(vp *map[int32]int, d *Decoder) { - if v, changed := f.DecMapInt32IntV(*vp, true, d); changed { + v, changed := f.DecMapInt32IntV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt32IntV(v map[int32]int, canChange bool, d *Decoder) (_ map[int32]int, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -30732,7 +32179,6 @@ func (_ fastpathT) DecMapInt32IntV(v map[int32]int, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int32 var mv int hasLen := containerLen > 0 @@ -30740,19 +32186,20 @@ func (_ fastpathT) DecMapInt32IntV(v map[int32]int, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int32(dd.DecodeInt(32)) + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int(dd.DecodeInt(intBitsize)) + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } @@ -30764,22 +32211,23 @@ func (_ fastpathT) DecMapInt32IntV(v map[int32]int, canChange bool, func (d *Decoder) fastpathDecMapInt32Int8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int32]int8) - if v, changed := fastpathTV.DecMapInt32Int8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt32Int8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt32Int8V(rv2i(rv).(map[int32]int8), false, d) } - fastpathTV.DecMapInt32Int8V(rv2i(rv).(map[int32]int8), false, d) } func (f fastpathT) DecMapInt32Int8X(vp *map[int32]int8, d *Decoder) { - if v, changed := f.DecMapInt32Int8V(*vp, true, d); changed { + v, changed := f.DecMapInt32Int8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt32Int8V(v map[int32]int8, canChange bool, d *Decoder) (_ map[int32]int8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 5) @@ -30790,7 +32238,6 @@ func (_ fastpathT) DecMapInt32Int8V(v map[int32]int8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int32 var mv int8 hasLen := containerLen > 0 @@ -30798,19 +32245,20 @@ func (_ fastpathT) DecMapInt32Int8V(v map[int32]int8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int32(dd.DecodeInt(32)) + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int8(dd.DecodeInt(8)) + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } @@ -30822,22 +32270,23 @@ func (_ fastpathT) DecMapInt32Int8V(v map[int32]int8, canChange bool, func (d *Decoder) fastpathDecMapInt32Int16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int32]int16) - if v, changed := fastpathTV.DecMapInt32Int16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt32Int16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt32Int16V(rv2i(rv).(map[int32]int16), false, d) } - fastpathTV.DecMapInt32Int16V(rv2i(rv).(map[int32]int16), false, d) } func (f fastpathT) DecMapInt32Int16X(vp *map[int32]int16, d *Decoder) { - if v, changed := f.DecMapInt32Int16V(*vp, true, d); changed { + v, changed := f.DecMapInt32Int16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt32Int16V(v map[int32]int16, canChange bool, d *Decoder) (_ map[int32]int16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 6) @@ -30848,7 +32297,6 @@ func (_ fastpathT) DecMapInt32Int16V(v map[int32]int16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int32 var mv int16 hasLen := containerLen > 0 @@ -30856,19 +32304,20 @@ func (_ fastpathT) DecMapInt32Int16V(v map[int32]int16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int32(dd.DecodeInt(32)) + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int16(dd.DecodeInt(16)) + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } @@ -30880,22 +32329,23 @@ func (_ fastpathT) DecMapInt32Int16V(v map[int32]int16, canChange bool, func (d *Decoder) fastpathDecMapInt32Int32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int32]int32) - if v, changed := fastpathTV.DecMapInt32Int32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt32Int32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt32Int32V(rv2i(rv).(map[int32]int32), false, d) } - fastpathTV.DecMapInt32Int32V(rv2i(rv).(map[int32]int32), false, d) } func (f fastpathT) DecMapInt32Int32X(vp *map[int32]int32, d *Decoder) { - if v, changed := f.DecMapInt32Int32V(*vp, true, d); changed { + v, changed := f.DecMapInt32Int32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt32Int32V(v map[int32]int32, canChange bool, d *Decoder) (_ map[int32]int32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 8) @@ -30906,7 +32356,6 @@ func (_ fastpathT) DecMapInt32Int32V(v map[int32]int32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int32 var mv int32 hasLen := containerLen > 0 @@ -30914,19 +32363,20 @@ func (_ fastpathT) DecMapInt32Int32V(v map[int32]int32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int32(dd.DecodeInt(32)) + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int32(dd.DecodeInt(32)) + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } @@ -30938,22 +32388,23 @@ func (_ fastpathT) DecMapInt32Int32V(v map[int32]int32, canChange bool, func (d *Decoder) fastpathDecMapInt32Int64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int32]int64) - if v, changed := fastpathTV.DecMapInt32Int64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt32Int64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt32Int64V(rv2i(rv).(map[int32]int64), false, d) } - fastpathTV.DecMapInt32Int64V(rv2i(rv).(map[int32]int64), false, d) } func (f fastpathT) DecMapInt32Int64X(vp *map[int32]int64, d *Decoder) { - if v, changed := f.DecMapInt32Int64V(*vp, true, d); changed { + v, changed := f.DecMapInt32Int64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt32Int64V(v map[int32]int64, canChange bool, d *Decoder) (_ map[int32]int64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -30964,7 +32415,6 @@ func (_ fastpathT) DecMapInt32Int64V(v map[int32]int64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int32 var mv int64 hasLen := containerLen > 0 @@ -30972,19 +32422,20 @@ func (_ fastpathT) DecMapInt32Int64V(v map[int32]int64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int32(dd.DecodeInt(32)) + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeInt(64) + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } @@ -30996,22 +32447,23 @@ func (_ fastpathT) DecMapInt32Int64V(v map[int32]int64, canChange bool, func (d *Decoder) fastpathDecMapInt32Float32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int32]float32) - if v, changed := fastpathTV.DecMapInt32Float32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt32Float32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt32Float32V(rv2i(rv).(map[int32]float32), false, d) } - fastpathTV.DecMapInt32Float32V(rv2i(rv).(map[int32]float32), false, d) } func (f fastpathT) DecMapInt32Float32X(vp *map[int32]float32, d *Decoder) { - if v, changed := f.DecMapInt32Float32V(*vp, true, d); changed { + v, changed := f.DecMapInt32Float32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt32Float32V(v map[int32]float32, canChange bool, d *Decoder) (_ map[int32]float32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 8) @@ -31022,7 +32474,6 @@ func (_ fastpathT) DecMapInt32Float32V(v map[int32]float32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int32 var mv float32 hasLen := containerLen > 0 @@ -31030,19 +32481,20 @@ func (_ fastpathT) DecMapInt32Float32V(v map[int32]float32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int32(dd.DecodeInt(32)) + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = float32(dd.DecodeFloat(true)) + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } @@ -31054,22 +32506,23 @@ func (_ fastpathT) DecMapInt32Float32V(v map[int32]float32, canChange bool, func (d *Decoder) fastpathDecMapInt32Float64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int32]float64) - if v, changed := fastpathTV.DecMapInt32Float64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt32Float64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt32Float64V(rv2i(rv).(map[int32]float64), false, d) } - fastpathTV.DecMapInt32Float64V(rv2i(rv).(map[int32]float64), false, d) } func (f fastpathT) DecMapInt32Float64X(vp *map[int32]float64, d *Decoder) { - if v, changed := f.DecMapInt32Float64V(*vp, true, d); changed { + v, changed := f.DecMapInt32Float64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt32Float64V(v map[int32]float64, canChange bool, d *Decoder) (_ map[int32]float64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -31080,7 +32533,6 @@ func (_ fastpathT) DecMapInt32Float64V(v map[int32]float64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int32 var mv float64 hasLen := containerLen > 0 @@ -31088,19 +32540,20 @@ func (_ fastpathT) DecMapInt32Float64V(v map[int32]float64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int32(dd.DecodeInt(32)) + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeFloat(false) + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } @@ -31112,22 +32565,23 @@ func (_ fastpathT) DecMapInt32Float64V(v map[int32]float64, canChange bool, func (d *Decoder) fastpathDecMapInt32BoolR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int32]bool) - if v, changed := fastpathTV.DecMapInt32BoolV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt32BoolV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt32BoolV(rv2i(rv).(map[int32]bool), false, d) } - fastpathTV.DecMapInt32BoolV(rv2i(rv).(map[int32]bool), false, d) } func (f fastpathT) DecMapInt32BoolX(vp *map[int32]bool, d *Decoder) { - if v, changed := f.DecMapInt32BoolV(*vp, true, d); changed { + v, changed := f.DecMapInt32BoolV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt32BoolV(v map[int32]bool, canChange bool, d *Decoder) (_ map[int32]bool, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 5) @@ -31138,7 +32592,6 @@ func (_ fastpathT) DecMapInt32BoolV(v map[int32]bool, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int32 var mv bool hasLen := containerLen > 0 @@ -31146,12 +32599,13 @@ func (_ fastpathT) DecMapInt32BoolV(v map[int32]bool, canChange bool, if esep { dd.ReadMapElemKey() } - mk = int32(dd.DecodeInt(32)) + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = false @@ -31170,22 +32624,23 @@ func (_ fastpathT) DecMapInt32BoolV(v map[int32]bool, canChange bool, func (d *Decoder) fastpathDecMapInt64IntfR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int64]interface{}) - if v, changed := fastpathTV.DecMapInt64IntfV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt64IntfV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt64IntfV(rv2i(rv).(map[int64]interface{}), false, d) } - fastpathTV.DecMapInt64IntfV(rv2i(rv).(map[int64]interface{}), false, d) } func (f fastpathT) DecMapInt64IntfX(vp *map[int64]interface{}, d *Decoder) { - if v, changed := f.DecMapInt64IntfV(*vp, true, d); changed { + v, changed := f.DecMapInt64IntfV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt64IntfV(v map[int64]interface{}, canChange bool, d *Decoder) (_ map[int64]interface{}, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -31196,7 +32651,7 @@ func (_ fastpathT) DecMapInt64IntfV(v map[int64]interface{}, canChange bool, dd.ReadMapEnd() return v, changed } - mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset var mk int64 var mv interface{} hasLen := containerLen > 0 @@ -31204,12 +32659,13 @@ func (_ fastpathT) DecMapInt64IntfV(v map[int64]interface{}, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeInt(64) + mk = dd.DecodeInt64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = nil @@ -31233,22 +32689,23 @@ func (_ fastpathT) DecMapInt64IntfV(v map[int64]interface{}, canChange bool, func (d *Decoder) fastpathDecMapInt64StringR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int64]string) - if v, changed := fastpathTV.DecMapInt64StringV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt64StringV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt64StringV(rv2i(rv).(map[int64]string), false, d) } - fastpathTV.DecMapInt64StringV(rv2i(rv).(map[int64]string), false, d) } func (f fastpathT) DecMapInt64StringX(vp *map[int64]string, d *Decoder) { - if v, changed := f.DecMapInt64StringV(*vp, true, d); changed { + v, changed := f.DecMapInt64StringV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt64StringV(v map[int64]string, canChange bool, d *Decoder) (_ map[int64]string, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 24) @@ -31259,7 +32716,6 @@ func (_ fastpathT) DecMapInt64StringV(v map[int64]string, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int64 var mv string hasLen := containerLen > 0 @@ -31267,12 +32723,13 @@ func (_ fastpathT) DecMapInt64StringV(v map[int64]string, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeInt(64) + mk = dd.DecodeInt64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = "" @@ -31291,22 +32748,23 @@ func (_ fastpathT) DecMapInt64StringV(v map[int64]string, canChange bool, func (d *Decoder) fastpathDecMapInt64UintR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int64]uint) - if v, changed := fastpathTV.DecMapInt64UintV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt64UintV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt64UintV(rv2i(rv).(map[int64]uint), false, d) } - fastpathTV.DecMapInt64UintV(rv2i(rv).(map[int64]uint), false, d) } func (f fastpathT) DecMapInt64UintX(vp *map[int64]uint, d *Decoder) { - if v, changed := f.DecMapInt64UintV(*vp, true, d); changed { + v, changed := f.DecMapInt64UintV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt64UintV(v map[int64]uint, canChange bool, d *Decoder) (_ map[int64]uint, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -31317,7 +32775,6 @@ func (_ fastpathT) DecMapInt64UintV(v map[int64]uint, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int64 var mv uint hasLen := containerLen > 0 @@ -31325,19 +32782,20 @@ func (_ fastpathT) DecMapInt64UintV(v map[int64]uint, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeInt(64) + mk = dd.DecodeInt64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint(dd.DecodeUint(uintBitsize)) + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -31349,22 +32807,23 @@ func (_ fastpathT) DecMapInt64UintV(v map[int64]uint, canChange bool, func (d *Decoder) fastpathDecMapInt64Uint8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int64]uint8) - if v, changed := fastpathTV.DecMapInt64Uint8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt64Uint8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt64Uint8V(rv2i(rv).(map[int64]uint8), false, d) } - fastpathTV.DecMapInt64Uint8V(rv2i(rv).(map[int64]uint8), false, d) } func (f fastpathT) DecMapInt64Uint8X(vp *map[int64]uint8, d *Decoder) { - if v, changed := f.DecMapInt64Uint8V(*vp, true, d); changed { + v, changed := f.DecMapInt64Uint8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt64Uint8V(v map[int64]uint8, canChange bool, d *Decoder) (_ map[int64]uint8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -31375,7 +32834,6 @@ func (_ fastpathT) DecMapInt64Uint8V(v map[int64]uint8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int64 var mv uint8 hasLen := containerLen > 0 @@ -31383,19 +32841,20 @@ func (_ fastpathT) DecMapInt64Uint8V(v map[int64]uint8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeInt(64) + mk = dd.DecodeInt64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint8(dd.DecodeUint(8)) + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } @@ -31407,22 +32866,23 @@ func (_ fastpathT) DecMapInt64Uint8V(v map[int64]uint8, canChange bool, func (d *Decoder) fastpathDecMapInt64Uint16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int64]uint16) - if v, changed := fastpathTV.DecMapInt64Uint16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt64Uint16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt64Uint16V(rv2i(rv).(map[int64]uint16), false, d) } - fastpathTV.DecMapInt64Uint16V(rv2i(rv).(map[int64]uint16), false, d) } func (f fastpathT) DecMapInt64Uint16X(vp *map[int64]uint16, d *Decoder) { - if v, changed := f.DecMapInt64Uint16V(*vp, true, d); changed { + v, changed := f.DecMapInt64Uint16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt64Uint16V(v map[int64]uint16, canChange bool, d *Decoder) (_ map[int64]uint16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -31433,7 +32893,6 @@ func (_ fastpathT) DecMapInt64Uint16V(v map[int64]uint16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int64 var mv uint16 hasLen := containerLen > 0 @@ -31441,19 +32900,20 @@ func (_ fastpathT) DecMapInt64Uint16V(v map[int64]uint16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeInt(64) + mk = dd.DecodeInt64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint16(dd.DecodeUint(16)) + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } @@ -31465,22 +32925,23 @@ func (_ fastpathT) DecMapInt64Uint16V(v map[int64]uint16, canChange bool, func (d *Decoder) fastpathDecMapInt64Uint32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int64]uint32) - if v, changed := fastpathTV.DecMapInt64Uint32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt64Uint32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt64Uint32V(rv2i(rv).(map[int64]uint32), false, d) } - fastpathTV.DecMapInt64Uint32V(rv2i(rv).(map[int64]uint32), false, d) } func (f fastpathT) DecMapInt64Uint32X(vp *map[int64]uint32, d *Decoder) { - if v, changed := f.DecMapInt64Uint32V(*vp, true, d); changed { + v, changed := f.DecMapInt64Uint32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt64Uint32V(v map[int64]uint32, canChange bool, d *Decoder) (_ map[int64]uint32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -31491,7 +32952,6 @@ func (_ fastpathT) DecMapInt64Uint32V(v map[int64]uint32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int64 var mv uint32 hasLen := containerLen > 0 @@ -31499,19 +32959,20 @@ func (_ fastpathT) DecMapInt64Uint32V(v map[int64]uint32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeInt(64) + mk = dd.DecodeInt64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint32(dd.DecodeUint(32)) + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } @@ -31523,22 +32984,23 @@ func (_ fastpathT) DecMapInt64Uint32V(v map[int64]uint32, canChange bool, func (d *Decoder) fastpathDecMapInt64Uint64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int64]uint64) - if v, changed := fastpathTV.DecMapInt64Uint64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt64Uint64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt64Uint64V(rv2i(rv).(map[int64]uint64), false, d) } - fastpathTV.DecMapInt64Uint64V(rv2i(rv).(map[int64]uint64), false, d) } func (f fastpathT) DecMapInt64Uint64X(vp *map[int64]uint64, d *Decoder) { - if v, changed := f.DecMapInt64Uint64V(*vp, true, d); changed { + v, changed := f.DecMapInt64Uint64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt64Uint64V(v map[int64]uint64, canChange bool, d *Decoder) (_ map[int64]uint64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -31549,7 +33011,6 @@ func (_ fastpathT) DecMapInt64Uint64V(v map[int64]uint64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int64 var mv uint64 hasLen := containerLen > 0 @@ -31557,19 +33018,20 @@ func (_ fastpathT) DecMapInt64Uint64V(v map[int64]uint64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeInt(64) + mk = dd.DecodeInt64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeUint(64) + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } @@ -31581,22 +33043,23 @@ func (_ fastpathT) DecMapInt64Uint64V(v map[int64]uint64, canChange bool, func (d *Decoder) fastpathDecMapInt64UintptrR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int64]uintptr) - if v, changed := fastpathTV.DecMapInt64UintptrV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt64UintptrV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt64UintptrV(rv2i(rv).(map[int64]uintptr), false, d) } - fastpathTV.DecMapInt64UintptrV(rv2i(rv).(map[int64]uintptr), false, d) } func (f fastpathT) DecMapInt64UintptrX(vp *map[int64]uintptr, d *Decoder) { - if v, changed := f.DecMapInt64UintptrV(*vp, true, d); changed { + v, changed := f.DecMapInt64UintptrV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt64UintptrV(v map[int64]uintptr, canChange bool, d *Decoder) (_ map[int64]uintptr, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -31607,7 +33070,6 @@ func (_ fastpathT) DecMapInt64UintptrV(v map[int64]uintptr, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int64 var mv uintptr hasLen := containerLen > 0 @@ -31615,19 +33077,20 @@ func (_ fastpathT) DecMapInt64UintptrV(v map[int64]uintptr, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeInt(64) + mk = dd.DecodeInt64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uintptr(dd.DecodeUint(uintBitsize)) + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -31639,22 +33102,23 @@ func (_ fastpathT) DecMapInt64UintptrV(v map[int64]uintptr, canChange bool, func (d *Decoder) fastpathDecMapInt64IntR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int64]int) - if v, changed := fastpathTV.DecMapInt64IntV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt64IntV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt64IntV(rv2i(rv).(map[int64]int), false, d) } - fastpathTV.DecMapInt64IntV(rv2i(rv).(map[int64]int), false, d) } func (f fastpathT) DecMapInt64IntX(vp *map[int64]int, d *Decoder) { - if v, changed := f.DecMapInt64IntV(*vp, true, d); changed { + v, changed := f.DecMapInt64IntV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt64IntV(v map[int64]int, canChange bool, d *Decoder) (_ map[int64]int, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -31665,7 +33129,6 @@ func (_ fastpathT) DecMapInt64IntV(v map[int64]int, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int64 var mv int hasLen := containerLen > 0 @@ -31673,19 +33136,20 @@ func (_ fastpathT) DecMapInt64IntV(v map[int64]int, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeInt(64) + mk = dd.DecodeInt64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int(dd.DecodeInt(intBitsize)) + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } @@ -31697,22 +33161,23 @@ func (_ fastpathT) DecMapInt64IntV(v map[int64]int, canChange bool, func (d *Decoder) fastpathDecMapInt64Int8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int64]int8) - if v, changed := fastpathTV.DecMapInt64Int8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt64Int8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt64Int8V(rv2i(rv).(map[int64]int8), false, d) } - fastpathTV.DecMapInt64Int8V(rv2i(rv).(map[int64]int8), false, d) } func (f fastpathT) DecMapInt64Int8X(vp *map[int64]int8, d *Decoder) { - if v, changed := f.DecMapInt64Int8V(*vp, true, d); changed { + v, changed := f.DecMapInt64Int8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt64Int8V(v map[int64]int8, canChange bool, d *Decoder) (_ map[int64]int8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -31723,7 +33188,6 @@ func (_ fastpathT) DecMapInt64Int8V(v map[int64]int8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int64 var mv int8 hasLen := containerLen > 0 @@ -31731,19 +33195,20 @@ func (_ fastpathT) DecMapInt64Int8V(v map[int64]int8, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeInt(64) + mk = dd.DecodeInt64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int8(dd.DecodeInt(8)) + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } @@ -31755,22 +33220,23 @@ func (_ fastpathT) DecMapInt64Int8V(v map[int64]int8, canChange bool, func (d *Decoder) fastpathDecMapInt64Int16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int64]int16) - if v, changed := fastpathTV.DecMapInt64Int16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt64Int16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt64Int16V(rv2i(rv).(map[int64]int16), false, d) } - fastpathTV.DecMapInt64Int16V(rv2i(rv).(map[int64]int16), false, d) } func (f fastpathT) DecMapInt64Int16X(vp *map[int64]int16, d *Decoder) { - if v, changed := f.DecMapInt64Int16V(*vp, true, d); changed { + v, changed := f.DecMapInt64Int16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt64Int16V(v map[int64]int16, canChange bool, d *Decoder) (_ map[int64]int16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 10) @@ -31781,7 +33247,6 @@ func (_ fastpathT) DecMapInt64Int16V(v map[int64]int16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int64 var mv int16 hasLen := containerLen > 0 @@ -31789,19 +33254,20 @@ func (_ fastpathT) DecMapInt64Int16V(v map[int64]int16, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeInt(64) + mk = dd.DecodeInt64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int16(dd.DecodeInt(16)) + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } @@ -31813,22 +33279,23 @@ func (_ fastpathT) DecMapInt64Int16V(v map[int64]int16, canChange bool, func (d *Decoder) fastpathDecMapInt64Int32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int64]int32) - if v, changed := fastpathTV.DecMapInt64Int32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt64Int32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt64Int32V(rv2i(rv).(map[int64]int32), false, d) } - fastpathTV.DecMapInt64Int32V(rv2i(rv).(map[int64]int32), false, d) } func (f fastpathT) DecMapInt64Int32X(vp *map[int64]int32, d *Decoder) { - if v, changed := f.DecMapInt64Int32V(*vp, true, d); changed { + v, changed := f.DecMapInt64Int32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt64Int32V(v map[int64]int32, canChange bool, d *Decoder) (_ map[int64]int32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -31839,7 +33306,6 @@ func (_ fastpathT) DecMapInt64Int32V(v map[int64]int32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int64 var mv int32 hasLen := containerLen > 0 @@ -31847,19 +33313,20 @@ func (_ fastpathT) DecMapInt64Int32V(v map[int64]int32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeInt(64) + mk = dd.DecodeInt64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int32(dd.DecodeInt(32)) + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } @@ -31871,22 +33338,23 @@ func (_ fastpathT) DecMapInt64Int32V(v map[int64]int32, canChange bool, func (d *Decoder) fastpathDecMapInt64Int64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int64]int64) - if v, changed := fastpathTV.DecMapInt64Int64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt64Int64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt64Int64V(rv2i(rv).(map[int64]int64), false, d) } - fastpathTV.DecMapInt64Int64V(rv2i(rv).(map[int64]int64), false, d) } func (f fastpathT) DecMapInt64Int64X(vp *map[int64]int64, d *Decoder) { - if v, changed := f.DecMapInt64Int64V(*vp, true, d); changed { + v, changed := f.DecMapInt64Int64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt64Int64V(v map[int64]int64, canChange bool, d *Decoder) (_ map[int64]int64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -31897,7 +33365,6 @@ func (_ fastpathT) DecMapInt64Int64V(v map[int64]int64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int64 var mv int64 hasLen := containerLen > 0 @@ -31905,19 +33372,20 @@ func (_ fastpathT) DecMapInt64Int64V(v map[int64]int64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeInt(64) + mk = dd.DecodeInt64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeInt(64) + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } @@ -31929,22 +33397,23 @@ func (_ fastpathT) DecMapInt64Int64V(v map[int64]int64, canChange bool, func (d *Decoder) fastpathDecMapInt64Float32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int64]float32) - if v, changed := fastpathTV.DecMapInt64Float32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt64Float32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt64Float32V(rv2i(rv).(map[int64]float32), false, d) } - fastpathTV.DecMapInt64Float32V(rv2i(rv).(map[int64]float32), false, d) } func (f fastpathT) DecMapInt64Float32X(vp *map[int64]float32, d *Decoder) { - if v, changed := f.DecMapInt64Float32V(*vp, true, d); changed { + v, changed := f.DecMapInt64Float32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt64Float32V(v map[int64]float32, canChange bool, d *Decoder) (_ map[int64]float32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 12) @@ -31955,7 +33424,6 @@ func (_ fastpathT) DecMapInt64Float32V(v map[int64]float32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int64 var mv float32 hasLen := containerLen > 0 @@ -31963,19 +33431,20 @@ func (_ fastpathT) DecMapInt64Float32V(v map[int64]float32, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeInt(64) + mk = dd.DecodeInt64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = float32(dd.DecodeFloat(true)) + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } @@ -31987,22 +33456,23 @@ func (_ fastpathT) DecMapInt64Float32V(v map[int64]float32, canChange bool, func (d *Decoder) fastpathDecMapInt64Float64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int64]float64) - if v, changed := fastpathTV.DecMapInt64Float64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt64Float64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt64Float64V(rv2i(rv).(map[int64]float64), false, d) } - fastpathTV.DecMapInt64Float64V(rv2i(rv).(map[int64]float64), false, d) } func (f fastpathT) DecMapInt64Float64X(vp *map[int64]float64, d *Decoder) { - if v, changed := f.DecMapInt64Float64V(*vp, true, d); changed { + v, changed := f.DecMapInt64Float64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt64Float64V(v map[int64]float64, canChange bool, d *Decoder) (_ map[int64]float64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 16) @@ -32013,7 +33483,6 @@ func (_ fastpathT) DecMapInt64Float64V(v map[int64]float64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int64 var mv float64 hasLen := containerLen > 0 @@ -32021,19 +33490,20 @@ func (_ fastpathT) DecMapInt64Float64V(v map[int64]float64, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeInt(64) + mk = dd.DecodeInt64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeFloat(false) + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } @@ -32045,22 +33515,23 @@ func (_ fastpathT) DecMapInt64Float64V(v map[int64]float64, canChange bool, func (d *Decoder) fastpathDecMapInt64BoolR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[int64]bool) - if v, changed := fastpathTV.DecMapInt64BoolV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapInt64BoolV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapInt64BoolV(rv2i(rv).(map[int64]bool), false, d) } - fastpathTV.DecMapInt64BoolV(rv2i(rv).(map[int64]bool), false, d) } func (f fastpathT) DecMapInt64BoolX(vp *map[int64]bool, d *Decoder) { - if v, changed := f.DecMapInt64BoolV(*vp, true, d); changed { + v, changed := f.DecMapInt64BoolV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapInt64BoolV(v map[int64]bool, canChange bool, d *Decoder) (_ map[int64]bool, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -32071,7 +33542,6 @@ func (_ fastpathT) DecMapInt64BoolV(v map[int64]bool, canChange bool, dd.ReadMapEnd() return v, changed } - var mk int64 var mv bool hasLen := containerLen > 0 @@ -32079,12 +33549,13 @@ func (_ fastpathT) DecMapInt64BoolV(v map[int64]bool, canChange bool, if esep { dd.ReadMapElemKey() } - mk = dd.DecodeInt(64) + mk = dd.DecodeInt64() if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = false @@ -32103,22 +33574,23 @@ func (_ fastpathT) DecMapInt64BoolV(v map[int64]bool, canChange bool, func (d *Decoder) fastpathDecMapBoolIntfR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[bool]interface{}) - if v, changed := fastpathTV.DecMapBoolIntfV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapBoolIntfV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapBoolIntfV(rv2i(rv).(map[bool]interface{}), false, d) } - fastpathTV.DecMapBoolIntfV(rv2i(rv).(map[bool]interface{}), false, d) } func (f fastpathT) DecMapBoolIntfX(vp *map[bool]interface{}, d *Decoder) { - if v, changed := f.DecMapBoolIntfV(*vp, true, d); changed { + v, changed := f.DecMapBoolIntfV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapBoolIntfV(v map[bool]interface{}, canChange bool, d *Decoder) (_ map[bool]interface{}, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 17) @@ -32129,7 +33601,7 @@ func (_ fastpathT) DecMapBoolIntfV(v map[bool]interface{}, canChange bool, dd.ReadMapEnd() return v, changed } - mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset var mk bool var mv interface{} hasLen := containerLen > 0 @@ -32142,7 +33614,8 @@ func (_ fastpathT) DecMapBoolIntfV(v map[bool]interface{}, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = nil @@ -32166,22 +33639,23 @@ func (_ fastpathT) DecMapBoolIntfV(v map[bool]interface{}, canChange bool, func (d *Decoder) fastpathDecMapBoolStringR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[bool]string) - if v, changed := fastpathTV.DecMapBoolStringV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapBoolStringV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapBoolStringV(rv2i(rv).(map[bool]string), false, d) } - fastpathTV.DecMapBoolStringV(rv2i(rv).(map[bool]string), false, d) } func (f fastpathT) DecMapBoolStringX(vp *map[bool]string, d *Decoder) { - if v, changed := f.DecMapBoolStringV(*vp, true, d); changed { + v, changed := f.DecMapBoolStringV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapBoolStringV(v map[bool]string, canChange bool, d *Decoder) (_ map[bool]string, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 17) @@ -32192,7 +33666,6 @@ func (_ fastpathT) DecMapBoolStringV(v map[bool]string, canChange bool, dd.ReadMapEnd() return v, changed } - var mk bool var mv string hasLen := containerLen > 0 @@ -32205,7 +33678,8 @@ func (_ fastpathT) DecMapBoolStringV(v map[bool]string, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = "" @@ -32224,22 +33698,23 @@ func (_ fastpathT) DecMapBoolStringV(v map[bool]string, canChange bool, func (d *Decoder) fastpathDecMapBoolUintR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[bool]uint) - if v, changed := fastpathTV.DecMapBoolUintV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapBoolUintV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapBoolUintV(rv2i(rv).(map[bool]uint), false, d) } - fastpathTV.DecMapBoolUintV(rv2i(rv).(map[bool]uint), false, d) } func (f fastpathT) DecMapBoolUintX(vp *map[bool]uint, d *Decoder) { - if v, changed := f.DecMapBoolUintV(*vp, true, d); changed { + v, changed := f.DecMapBoolUintV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapBoolUintV(v map[bool]uint, canChange bool, d *Decoder) (_ map[bool]uint, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -32250,7 +33725,6 @@ func (_ fastpathT) DecMapBoolUintV(v map[bool]uint, canChange bool, dd.ReadMapEnd() return v, changed } - var mk bool var mv uint hasLen := containerLen > 0 @@ -32263,14 +33737,15 @@ func (_ fastpathT) DecMapBoolUintV(v map[bool]uint, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint(dd.DecodeUint(uintBitsize)) + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -32282,22 +33757,23 @@ func (_ fastpathT) DecMapBoolUintV(v map[bool]uint, canChange bool, func (d *Decoder) fastpathDecMapBoolUint8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[bool]uint8) - if v, changed := fastpathTV.DecMapBoolUint8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapBoolUint8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapBoolUint8V(rv2i(rv).(map[bool]uint8), false, d) } - fastpathTV.DecMapBoolUint8V(rv2i(rv).(map[bool]uint8), false, d) } func (f fastpathT) DecMapBoolUint8X(vp *map[bool]uint8, d *Decoder) { - if v, changed := f.DecMapBoolUint8V(*vp, true, d); changed { + v, changed := f.DecMapBoolUint8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapBoolUint8V(v map[bool]uint8, canChange bool, d *Decoder) (_ map[bool]uint8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 2) @@ -32308,7 +33784,6 @@ func (_ fastpathT) DecMapBoolUint8V(v map[bool]uint8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk bool var mv uint8 hasLen := containerLen > 0 @@ -32321,14 +33796,15 @@ func (_ fastpathT) DecMapBoolUint8V(v map[bool]uint8, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint8(dd.DecodeUint(8)) + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } @@ -32340,22 +33816,23 @@ func (_ fastpathT) DecMapBoolUint8V(v map[bool]uint8, canChange bool, func (d *Decoder) fastpathDecMapBoolUint16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[bool]uint16) - if v, changed := fastpathTV.DecMapBoolUint16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapBoolUint16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapBoolUint16V(rv2i(rv).(map[bool]uint16), false, d) } - fastpathTV.DecMapBoolUint16V(rv2i(rv).(map[bool]uint16), false, d) } func (f fastpathT) DecMapBoolUint16X(vp *map[bool]uint16, d *Decoder) { - if v, changed := f.DecMapBoolUint16V(*vp, true, d); changed { + v, changed := f.DecMapBoolUint16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapBoolUint16V(v map[bool]uint16, canChange bool, d *Decoder) (_ map[bool]uint16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 3) @@ -32366,7 +33843,6 @@ func (_ fastpathT) DecMapBoolUint16V(v map[bool]uint16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk bool var mv uint16 hasLen := containerLen > 0 @@ -32379,14 +33855,15 @@ func (_ fastpathT) DecMapBoolUint16V(v map[bool]uint16, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint16(dd.DecodeUint(16)) + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } @@ -32398,22 +33875,23 @@ func (_ fastpathT) DecMapBoolUint16V(v map[bool]uint16, canChange bool, func (d *Decoder) fastpathDecMapBoolUint32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[bool]uint32) - if v, changed := fastpathTV.DecMapBoolUint32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapBoolUint32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapBoolUint32V(rv2i(rv).(map[bool]uint32), false, d) } - fastpathTV.DecMapBoolUint32V(rv2i(rv).(map[bool]uint32), false, d) } func (f fastpathT) DecMapBoolUint32X(vp *map[bool]uint32, d *Decoder) { - if v, changed := f.DecMapBoolUint32V(*vp, true, d); changed { + v, changed := f.DecMapBoolUint32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapBoolUint32V(v map[bool]uint32, canChange bool, d *Decoder) (_ map[bool]uint32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 5) @@ -32424,7 +33902,6 @@ func (_ fastpathT) DecMapBoolUint32V(v map[bool]uint32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk bool var mv uint32 hasLen := containerLen > 0 @@ -32437,14 +33914,15 @@ func (_ fastpathT) DecMapBoolUint32V(v map[bool]uint32, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uint32(dd.DecodeUint(32)) + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } @@ -32456,22 +33934,23 @@ func (_ fastpathT) DecMapBoolUint32V(v map[bool]uint32, canChange bool, func (d *Decoder) fastpathDecMapBoolUint64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[bool]uint64) - if v, changed := fastpathTV.DecMapBoolUint64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapBoolUint64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapBoolUint64V(rv2i(rv).(map[bool]uint64), false, d) } - fastpathTV.DecMapBoolUint64V(rv2i(rv).(map[bool]uint64), false, d) } func (f fastpathT) DecMapBoolUint64X(vp *map[bool]uint64, d *Decoder) { - if v, changed := f.DecMapBoolUint64V(*vp, true, d); changed { + v, changed := f.DecMapBoolUint64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapBoolUint64V(v map[bool]uint64, canChange bool, d *Decoder) (_ map[bool]uint64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -32482,7 +33961,6 @@ func (_ fastpathT) DecMapBoolUint64V(v map[bool]uint64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk bool var mv uint64 hasLen := containerLen > 0 @@ -32495,14 +33973,15 @@ func (_ fastpathT) DecMapBoolUint64V(v map[bool]uint64, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeUint(64) + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } @@ -32514,22 +33993,23 @@ func (_ fastpathT) DecMapBoolUint64V(v map[bool]uint64, canChange bool, func (d *Decoder) fastpathDecMapBoolUintptrR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[bool]uintptr) - if v, changed := fastpathTV.DecMapBoolUintptrV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapBoolUintptrV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapBoolUintptrV(rv2i(rv).(map[bool]uintptr), false, d) } - fastpathTV.DecMapBoolUintptrV(rv2i(rv).(map[bool]uintptr), false, d) } func (f fastpathT) DecMapBoolUintptrX(vp *map[bool]uintptr, d *Decoder) { - if v, changed := f.DecMapBoolUintptrV(*vp, true, d); changed { + v, changed := f.DecMapBoolUintptrV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapBoolUintptrV(v map[bool]uintptr, canChange bool, d *Decoder) (_ map[bool]uintptr, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -32540,7 +34020,6 @@ func (_ fastpathT) DecMapBoolUintptrV(v map[bool]uintptr, canChange bool, dd.ReadMapEnd() return v, changed } - var mk bool var mv uintptr hasLen := containerLen > 0 @@ -32553,14 +34032,15 @@ func (_ fastpathT) DecMapBoolUintptrV(v map[bool]uintptr, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = uintptr(dd.DecodeUint(uintBitsize)) + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } @@ -32572,22 +34052,23 @@ func (_ fastpathT) DecMapBoolUintptrV(v map[bool]uintptr, canChange bool, func (d *Decoder) fastpathDecMapBoolIntR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[bool]int) - if v, changed := fastpathTV.DecMapBoolIntV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapBoolIntV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapBoolIntV(rv2i(rv).(map[bool]int), false, d) } - fastpathTV.DecMapBoolIntV(rv2i(rv).(map[bool]int), false, d) } func (f fastpathT) DecMapBoolIntX(vp *map[bool]int, d *Decoder) { - if v, changed := f.DecMapBoolIntV(*vp, true, d); changed { + v, changed := f.DecMapBoolIntV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapBoolIntV(v map[bool]int, canChange bool, d *Decoder) (_ map[bool]int, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -32598,7 +34079,6 @@ func (_ fastpathT) DecMapBoolIntV(v map[bool]int, canChange bool, dd.ReadMapEnd() return v, changed } - var mk bool var mv int hasLen := containerLen > 0 @@ -32611,14 +34091,15 @@ func (_ fastpathT) DecMapBoolIntV(v map[bool]int, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int(dd.DecodeInt(intBitsize)) + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } @@ -32630,22 +34111,23 @@ func (_ fastpathT) DecMapBoolIntV(v map[bool]int, canChange bool, func (d *Decoder) fastpathDecMapBoolInt8R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[bool]int8) - if v, changed := fastpathTV.DecMapBoolInt8V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapBoolInt8V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapBoolInt8V(rv2i(rv).(map[bool]int8), false, d) } - fastpathTV.DecMapBoolInt8V(rv2i(rv).(map[bool]int8), false, d) } func (f fastpathT) DecMapBoolInt8X(vp *map[bool]int8, d *Decoder) { - if v, changed := f.DecMapBoolInt8V(*vp, true, d); changed { + v, changed := f.DecMapBoolInt8V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapBoolInt8V(v map[bool]int8, canChange bool, d *Decoder) (_ map[bool]int8, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 2) @@ -32656,7 +34138,6 @@ func (_ fastpathT) DecMapBoolInt8V(v map[bool]int8, canChange bool, dd.ReadMapEnd() return v, changed } - var mk bool var mv int8 hasLen := containerLen > 0 @@ -32669,14 +34150,15 @@ func (_ fastpathT) DecMapBoolInt8V(v map[bool]int8, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int8(dd.DecodeInt(8)) + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } @@ -32688,22 +34170,23 @@ func (_ fastpathT) DecMapBoolInt8V(v map[bool]int8, canChange bool, func (d *Decoder) fastpathDecMapBoolInt16R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[bool]int16) - if v, changed := fastpathTV.DecMapBoolInt16V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapBoolInt16V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapBoolInt16V(rv2i(rv).(map[bool]int16), false, d) } - fastpathTV.DecMapBoolInt16V(rv2i(rv).(map[bool]int16), false, d) } func (f fastpathT) DecMapBoolInt16X(vp *map[bool]int16, d *Decoder) { - if v, changed := f.DecMapBoolInt16V(*vp, true, d); changed { + v, changed := f.DecMapBoolInt16V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapBoolInt16V(v map[bool]int16, canChange bool, d *Decoder) (_ map[bool]int16, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 3) @@ -32714,7 +34197,6 @@ func (_ fastpathT) DecMapBoolInt16V(v map[bool]int16, canChange bool, dd.ReadMapEnd() return v, changed } - var mk bool var mv int16 hasLen := containerLen > 0 @@ -32727,14 +34209,15 @@ func (_ fastpathT) DecMapBoolInt16V(v map[bool]int16, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int16(dd.DecodeInt(16)) + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } @@ -32746,22 +34229,23 @@ func (_ fastpathT) DecMapBoolInt16V(v map[bool]int16, canChange bool, func (d *Decoder) fastpathDecMapBoolInt32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[bool]int32) - if v, changed := fastpathTV.DecMapBoolInt32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapBoolInt32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapBoolInt32V(rv2i(rv).(map[bool]int32), false, d) } - fastpathTV.DecMapBoolInt32V(rv2i(rv).(map[bool]int32), false, d) } func (f fastpathT) DecMapBoolInt32X(vp *map[bool]int32, d *Decoder) { - if v, changed := f.DecMapBoolInt32V(*vp, true, d); changed { + v, changed := f.DecMapBoolInt32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapBoolInt32V(v map[bool]int32, canChange bool, d *Decoder) (_ map[bool]int32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 5) @@ -32772,7 +34256,6 @@ func (_ fastpathT) DecMapBoolInt32V(v map[bool]int32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk bool var mv int32 hasLen := containerLen > 0 @@ -32785,14 +34268,15 @@ func (_ fastpathT) DecMapBoolInt32V(v map[bool]int32, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = int32(dd.DecodeInt(32)) + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } @@ -32804,22 +34288,23 @@ func (_ fastpathT) DecMapBoolInt32V(v map[bool]int32, canChange bool, func (d *Decoder) fastpathDecMapBoolInt64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[bool]int64) - if v, changed := fastpathTV.DecMapBoolInt64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapBoolInt64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapBoolInt64V(rv2i(rv).(map[bool]int64), false, d) } - fastpathTV.DecMapBoolInt64V(rv2i(rv).(map[bool]int64), false, d) } func (f fastpathT) DecMapBoolInt64X(vp *map[bool]int64, d *Decoder) { - if v, changed := f.DecMapBoolInt64V(*vp, true, d); changed { + v, changed := f.DecMapBoolInt64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapBoolInt64V(v map[bool]int64, canChange bool, d *Decoder) (_ map[bool]int64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -32830,7 +34315,6 @@ func (_ fastpathT) DecMapBoolInt64V(v map[bool]int64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk bool var mv int64 hasLen := containerLen > 0 @@ -32843,14 +34327,15 @@ func (_ fastpathT) DecMapBoolInt64V(v map[bool]int64, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeInt(64) + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } @@ -32862,22 +34347,23 @@ func (_ fastpathT) DecMapBoolInt64V(v map[bool]int64, canChange bool, func (d *Decoder) fastpathDecMapBoolFloat32R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[bool]float32) - if v, changed := fastpathTV.DecMapBoolFloat32V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapBoolFloat32V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapBoolFloat32V(rv2i(rv).(map[bool]float32), false, d) } - fastpathTV.DecMapBoolFloat32V(rv2i(rv).(map[bool]float32), false, d) } func (f fastpathT) DecMapBoolFloat32X(vp *map[bool]float32, d *Decoder) { - if v, changed := f.DecMapBoolFloat32V(*vp, true, d); changed { + v, changed := f.DecMapBoolFloat32V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapBoolFloat32V(v map[bool]float32, canChange bool, d *Decoder) (_ map[bool]float32, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 5) @@ -32888,7 +34374,6 @@ func (_ fastpathT) DecMapBoolFloat32V(v map[bool]float32, canChange bool, dd.ReadMapEnd() return v, changed } - var mk bool var mv float32 hasLen := containerLen > 0 @@ -32901,14 +34386,15 @@ func (_ fastpathT) DecMapBoolFloat32V(v map[bool]float32, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = float32(dd.DecodeFloat(true)) + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } @@ -32920,22 +34406,23 @@ func (_ fastpathT) DecMapBoolFloat32V(v map[bool]float32, canChange bool, func (d *Decoder) fastpathDecMapBoolFloat64R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[bool]float64) - if v, changed := fastpathTV.DecMapBoolFloat64V(*vp, true, d); changed { + v, changed := fastpathTV.DecMapBoolFloat64V(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapBoolFloat64V(rv2i(rv).(map[bool]float64), false, d) } - fastpathTV.DecMapBoolFloat64V(rv2i(rv).(map[bool]float64), false, d) } func (f fastpathT) DecMapBoolFloat64X(vp *map[bool]float64, d *Decoder) { - if v, changed := f.DecMapBoolFloat64V(*vp, true, d); changed { + v, changed := f.DecMapBoolFloat64V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapBoolFloat64V(v map[bool]float64, canChange bool, d *Decoder) (_ map[bool]float64, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 9) @@ -32946,7 +34433,6 @@ func (_ fastpathT) DecMapBoolFloat64V(v map[bool]float64, canChange bool, dd.ReadMapEnd() return v, changed } - var mk bool var mv float64 hasLen := containerLen > 0 @@ -32959,14 +34445,15 @@ func (_ fastpathT) DecMapBoolFloat64V(v map[bool]float64, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = 0 } continue } - mv = dd.DecodeFloat(false) + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } @@ -32978,22 +34465,23 @@ func (_ fastpathT) DecMapBoolFloat64V(v map[bool]float64, canChange bool, func (d *Decoder) fastpathDecMapBoolBoolR(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[bool]bool) - if v, changed := fastpathTV.DecMapBoolBoolV(*vp, true, d); changed { + v, changed := fastpathTV.DecMapBoolBoolV(*vp, true, d) + if changed { *vp = v } - return + } else { + fastpathTV.DecMapBoolBoolV(rv2i(rv).(map[bool]bool), false, d) } - fastpathTV.DecMapBoolBoolV(rv2i(rv).(map[bool]bool), false, d) } func (f fastpathT) DecMapBoolBoolX(vp *map[bool]bool, d *Decoder) { - if v, changed := f.DecMapBoolBoolV(*vp, true, d); changed { + v, changed := f.DecMapBoolBoolV(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) DecMapBoolBoolV(v map[bool]bool, canChange bool, d *Decoder) (_ map[bool]bool, changed bool) { dd, esep := d.d, d.hh.hasElemSeparators() - containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, 2) @@ -33004,7 +34492,6 @@ func (_ fastpathT) DecMapBoolBoolV(v map[bool]bool, canChange bool, dd.ReadMapEnd() return v, changed } - var mk bool var mv bool hasLen := containerLen > 0 @@ -33017,7 +34504,8 @@ func (_ fastpathT) DecMapBoolBoolV(v map[bool]bool, canChange bool, dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { + if v == nil { + } else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = false diff --git a/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl b/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl index eebc31b38..2023e05d3 100644 --- a/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl +++ b/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl @@ -3,10 +3,7 @@ // Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. -// ************************************************************ -// DO NOT EDIT. -// THIS FILE IS AUTO-GENERATED from fast-path.go.tmpl -// ************************************************************ +// Code generated from fast-path.go.tmpl - DO NOT EDIT. package codec @@ -18,19 +15,19 @@ package codec // This file can be omitted without causing a build failure. // // The advantage of fast paths is: -// - Many calls bypass reflection altogether +// - Many calls bypass reflection altogether // // Currently support -// - slice of all builtin types, -// - map of all builtin types to string or interface value -// - symmetrical maps of all builtin types (e.g. str-str, uint8-uint8) +// - slice of all builtin types, +// - map of all builtin types to string or interface value +// - symmetrical maps of all builtin types (e.g. str-str, uint8-uint8) // This should provide adequate "typical" implementations. // // Note that fast track decode functions must handle values for which an address cannot be obtained. // For example: -// m2 := map[string]int{} -// p2 := []interface{}{m2} -// // decoding into p2 will bomb if fast track functions do not treat like unaddressable. +// m2 := map[string]int{} +// p2 := []interface{}{m2} +// // decoding into p2 will bomb if fast track functions do not treat like unaddressable. // import ( @@ -86,17 +83,13 @@ func init() { fd func(*Decoder, *codecFnInfo, reflect.Value)) (f fastpathE) { xrt := reflect.TypeOf(v) xptr := rt2id(xrt) - if useLookupRecognizedTypes { - recognizedRtids = append(recognizedRtids, xptr) - recognizedRtidPtrs = append(recognizedRtidPtrs, rt2id(reflect.PtrTo(xrt))) - } fastpathAV[i] = fastpathE{xptr, xrt, fe, fd} i++ return } - - {{range .Values}}{{if not .Primitive}}{{if not .MapKey }} - fn([]{{ .Elem }}(nil), (*Encoder).{{ .MethodNamePfx "fastpathEnc" false }}R, (*Decoder).{{ .MethodNamePfx "fastpathDec" false }}R){{end}}{{end}}{{end}} + {{/* do not register []uint8 in fast-path */}} + {{range .Values}}{{if not .Primitive}}{{if not .MapKey }}{{if ne .Elem "uint8"}} + fn([]{{ .Elem }}(nil), (*Encoder).{{ .MethodNamePfx "fastpathEnc" false }}R, (*Decoder).{{ .MethodNamePfx "fastpathDec" false }}R){{end}}{{end}}{{end}}{{end}} {{range .Values}}{{if not .Primitive}}{{if .MapKey }} fn(map[{{ .MapKey }}]{{ .Elem }}(nil), (*Encoder).{{ .MethodNamePfx "fastpathEnc" false }}R, (*Decoder).{{ .MethodNamePfx "fastpathDec" false }}R){{end}}{{end}}{{end}} @@ -109,21 +102,37 @@ func init() { // -- -- fast path type switch func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { switch v := iv.(type) { -{{range .Values}}{{if not .Primitive}}{{if not .MapKey }} - case []{{ .Elem }}:{{else}} - case map[{{ .MapKey }}]{{ .Elem }}:{{end}} - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, e){{if not .MapKey }} - case *[]{{ .Elem }}:{{else}} - case *map[{{ .MapKey }}]{{ .Elem }}:{{end}} - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e) -{{end}}{{end}} + +{{range .Values}}{{if not .Primitive}}{{if not .MapKey }}{{if ne .Elem "uint8"}} + case []{{ .Elem }}: + fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, e) + case *[]{{ .Elem }}: + fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e){{/* +*/}}{{end}}{{end}}{{end}}{{end}} + +{{range .Values}}{{if not .Primitive}}{{if .MapKey }} + case map[{{ .MapKey }}]{{ .Elem }}: + fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, e) + case *map[{{ .MapKey }}]{{ .Elem }}: + fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e){{/* +*/}}{{end}}{{end}}{{end}} + default: - _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) + _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 return false } return true } +{{/* +**** removing this block, as they are never called directly **** + + + +**** removing this block, as they are never called directly **** + + + func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { switch v := iv.(type) { {{range .Values}}{{if not .Primitive}}{{if not .MapKey }} @@ -133,7 +142,7 @@ func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e) {{end}}{{end}}{{end}} default: - _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) + _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 return false } return true @@ -148,15 +157,23 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e) {{end}}{{end}}{{end}} default: - _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) + _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 return false } return true } + + +**** removing this block, as they are never called directly **** + + + +**** removing this block, as they are never called directly **** +*/}} + // -- -- fast path functions {{range .Values}}{{if not .Primitive}}{{if not .MapKey }} - func (e *Encoder) {{ .MethodNamePfx "fastpathEnc" false }}R(f *codecFnInfo, rv reflect.Value) { if f.ti.mbs { fastpathTV.{{ .MethodNamePfx "EncAsMap" false }}V(rv2i(rv).([]{{ .Elem }}), e) @@ -165,15 +182,25 @@ func (e *Encoder) {{ .MethodNamePfx "fastpathEnc" false }}R(f *codecFnInfo, rv r } } func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v []{{ .Elem }}, e *Encoder) { + if v == nil { e.e.EncodeNil(); return } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteArrayStart(len(v)) + if esep { + for _, v2 := range v { + ee.WriteArrayElem() + {{ encmd .Elem "v2"}} + } + } else { + for _, v2 := range v { + {{ encmd .Elem "v2"}} + } + } {{/* for _, v2 := range v { if esep { ee.WriteArrayElem() } {{ encmd .Elem "v2"}} - } + } */}} ee.WriteArrayEnd() } - func (_ fastpathT) {{ .MethodNamePfx "EncAsMap" false }}V(v []{{ .Elem }}, e *Encoder) { ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { @@ -181,6 +208,20 @@ func (_ fastpathT) {{ .MethodNamePfx "EncAsMap" false }}V(v []{{ .Elem }}, e *En return } ee.WriteMapStart(len(v) / 2) + if esep { + for j, v2 := range v { + if j%2 == 0 { + ee.WriteMapElemKey() + } else { + ee.WriteMapElemValue() + } + {{ encmd .Elem "v2"}} + } + } else { + for _, v2 := range v { + {{ encmd .Elem "v2"}} + } + } {{/* for j, v2 := range v { if esep { if j%2 == 0 { @@ -190,22 +231,20 @@ func (_ fastpathT) {{ .MethodNamePfx "EncAsMap" false }}V(v []{{ .Elem }}, e *En } } {{ encmd .Elem "v2"}} - } + } */}} ee.WriteMapEnd() } - {{end}}{{end}}{{end}} {{range .Values}}{{if not .Primitive}}{{if .MapKey }} - func (e *Encoder) {{ .MethodNamePfx "fastpathEnc" false }}R(f *codecFnInfo, rv reflect.Value) { fastpathTV.{{ .MethodNamePfx "Enc" false }}V(rv2i(rv).(map[{{ .MapKey }}]{{ .Elem }}), e) } func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v map[{{ .MapKey }}]{{ .Elem }}, e *Encoder) { + if v == nil { e.e.EncodeNil(); return } ee, esep := e.e, e.hh.hasElemSeparators() ee.WriteMapStart(len(v)) - {{if eq .MapKey "string"}}asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 - {{end}}if e.h.Canonical { + if e.h.Canonical { {{if eq .MapKey "interface{}"}}{{/* out of band */}}var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding e2 := NewEncoderBytes(&mksv, e.hh) @@ -221,76 +260,126 @@ func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v map[{{ .MapKey }}]{{ .Ele i++ } sort.Sort(bytesISlice(v2)) + if esep { + for j := range v2 { + ee.WriteMapElemKey() + e.asis(v2[j].v) + ee.WriteMapElemValue() + e.encode(v[v2[j].i]) + } + } else { + for j := range v2 { + e.asis(v2[j].v) + e.encode(v[v2[j].i]) + } + } {{/* for j := range v2 { if esep { ee.WriteMapElemKey() } e.asis(v2[j].v) if esep { ee.WriteMapElemValue() } e.encode(v[v2[j].i]) - } {{else}}{{ $x := sorttype .MapKey true}}v2 := make([]{{ $x }}, len(v)) + } */}} {{else}}{{ $x := sorttype .MapKey true}}v2 := make([]{{ $x }}, len(v)) var i int for k, _ := range v { v2[i] = {{ $x }}(k) i++ } sort.Sort({{ sorttype .MapKey false}}(v2)) + if esep { + for _, k2 := range v2 { + ee.WriteMapElemKey() + {{if eq .MapKey "string"}}ee.EncodeString(cUTF8, k2){{else}}{{ $y := printf "%s(k2)" .MapKey }}{{ encmd .MapKey $y }}{{end}} + ee.WriteMapElemValue() + {{ $y := printf "v[%s(k2)]" .MapKey }}{{ encmd .Elem $y }} + } + } else { + for _, k2 := range v2 { + {{if eq .MapKey "string"}}ee.EncodeString(cUTF8, k2){{else}}{{ $y := printf "%s(k2)" .MapKey }}{{ encmd .MapKey $y }}{{end}} + {{ $y := printf "v[%s(k2)]" .MapKey }}{{ encmd .Elem $y }} + } + } {{/* for _, k2 := range v2 { if esep { ee.WriteMapElemKey() } - {{if eq .MapKey "string"}}if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - }{{else}}{{ $y := printf "%s(k2)" .MapKey }}{{ encmd .MapKey $y }}{{end}} + {{if eq .MapKey "string"}}ee.EncodeString(cUTF8, k2){{else}}{{ $y := printf "%s(k2)" .MapKey }}{{ encmd .MapKey $y }}{{end}} if esep { ee.WriteMapElemValue() } {{ $y := printf "v[%s(k2)]" .MapKey }}{{ encmd .Elem $y }} - } {{end}} + } */}} {{end}} } else { + if esep { + for k2, v2 := range v { + ee.WriteMapElemKey() + {{if eq .MapKey "string"}}ee.EncodeString(cUTF8, k2){{else}}{{ encmd .MapKey "k2"}}{{end}} + ee.WriteMapElemValue() + {{ encmd .Elem "v2"}} + } + } else { + for k2, v2 := range v { + {{if eq .MapKey "string"}}ee.EncodeString(cUTF8, k2){{else}}{{ encmd .MapKey "k2"}}{{end}} + {{ encmd .Elem "v2"}} + } + } {{/* for k2, v2 := range v { if esep { ee.WriteMapElemKey() } - {{if eq .MapKey "string"}}if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - }{{else}}{{ encmd .MapKey "k2"}}{{end}} + {{if eq .MapKey "string"}}ee.EncodeString(cUTF8, k2){{else}}{{ encmd .MapKey "k2"}}{{end}} if esep { ee.WriteMapElemValue() } {{ encmd .Elem "v2"}} - } + } */}} } ee.WriteMapEnd() } - {{end}}{{end}}{{end}} // -- decode // -- -- fast path type switch func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { + var changed bool switch v := iv.(type) { -{{range .Values}}{{if not .Primitive}}{{if not .MapKey }} - case []{{ .Elem }}:{{else}} - case map[{{ .MapKey }}]{{ .Elem }}:{{end}} - fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, false, d){{if not .MapKey }} - case *[]{{ .Elem }}: {{else}} - case *map[{{ .MapKey }}]{{ .Elem }}: {{end}} - if v2, changed2 := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*v, true, d); changed2 { - *v = v2 +{{range .Values}}{{if not .Primitive}}{{if not .MapKey }}{{if ne .Elem "uint8"}} + case []{{ .Elem }}: + var v2 []{{ .Elem }} + v2, changed = fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, false, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) } -{{end}}{{end}} + case *[]{{ .Elem }}: + var v2 []{{ .Elem }} + v2, changed = fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*v, true, d) + if changed { + *v = v2 + }{{/* +*/}}{{end}}{{end}}{{end}}{{end}} +{{range .Values}}{{if not .Primitive}}{{if .MapKey }}{{/* +// maps only change if nil, and in that case, there's no point copying +*/}} + case map[{{ .MapKey }}]{{ .Elem }}: + fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, false, d) + case *map[{{ .MapKey }}]{{ .Elem }}: + var v2 map[{{ .MapKey }}]{{ .Elem }} + v2, changed = fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*v, true, d) + if changed { + *v = v2 + }{{/* +*/}}{{end}}{{end}}{{end}} default: - _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) + _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 return false } return true } -func fastpathDecodeSetZeroTypeSwitch(iv interface{}, d *Decoder) bool { +func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool { switch v := iv.(type) { {{range .Values}}{{if not .Primitive}}{{if not .MapKey }} - case *[]{{ .Elem }}: {{else}} - case *map[{{ .MapKey }}]{{ .Elem }}: {{end}} - *v = nil -{{end}}{{end}} + case *[]{{ .Elem }}: + *v = nil {{/* +*/}}{{end}}{{end}}{{end}} +{{range .Values}}{{if not .Primitive}}{{if .MapKey }} + case *map[{{ .MapKey }}]{{ .Elem }}: + *v = nil {{/* +*/}}{{end}}{{end}}{{end}} default: - _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) + _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 return false } return true @@ -304,39 +393,36 @@ Slices can change if they - are addressable (from a ptr) - are settable (e.g. contained in an interface{}) */}} -func (d *Decoder) {{ .MethodNamePfx "fastpathDec" false }}R(f *codecFnInfo, rv reflect.Value) { +func (d *Decoder) {{ .MethodNamePfx "fastpathDec" false }}R(f *codecFnInfo, rv reflect.Value) { if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { - var vp = rv2i(rv).(*[]{{ .Elem }}) - if v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*vp, !array, d); changed { - *vp = v - } + vp := rv2i(rv).(*[]{{ .Elem }}) + v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*vp, !array, d) + if changed { *vp = v } } else { - fastpathTV.{{ .MethodNamePfx "Dec" false }}V(rv2i(rv).([]{{ .Elem }}), !array, d) + v := rv2i(rv).([]{{ .Elem }}) + v2, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, !array, d) + if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) { + copy(v, v2) + } } } - func (f fastpathT) {{ .MethodNamePfx "Dec" false }}X(vp *[]{{ .Elem }}, d *Decoder) { - if v, changed := f.{{ .MethodNamePfx "Dec" false }}V(*vp, true, d); changed { - *vp = v - } + v, changed := f.{{ .MethodNamePfx "Dec" false }}V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v []{{ .Elem }}, canChange bool, d *Decoder) (_ []{{ .Elem }}, changed bool) { - dd := d.d - {{/* // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() */}} + dd := d.d{{/* + // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() + */}} slh, containerLenS := d.decSliceHelperStart() if containerLenS == 0 { if canChange { - if v == nil { - v = []{{ .Elem }}{} - } else if len(v) != 0 { - v = v[:0] - } + if v == nil { v = []{{ .Elem }}{} } else if len(v) != 0 { v = v[:0] } changed = true } slh.End() return v, changed } - hasLen := containerLenS > 0 var xlen int if hasLen && canChange { @@ -355,7 +441,7 @@ func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v []{{ .Elem }}, canChange } j := 0 for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { - if j == 0 && len(v) == 0 { + if j == 0 && len(v) == 0 && canChange { if hasLen { xlen = decInferLen(containerLenS, d.h.MaxInitLen, {{ .Size }}) } else { @@ -374,10 +460,12 @@ func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v []{{ .Elem }}, canChange d.arrayCannotExpand(len(v), j+1) decodeIntoBlank = true } - } + } slh.ElemContainerState(j) if decodeIntoBlank { d.swallow() + } else if dd.TryDecodeAsNil() { + v[j] = {{ zerocmd .Elem }} } else { {{ if eq .Elem "interface{}" }}d.decode(&v[j]){{ else }}v[j] = {{ decmd .Elem }}{{ end }} } @@ -394,10 +482,8 @@ func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v []{{ .Elem }}, canChange slh.End() return v, changed } - {{end}}{{end}}{{end}} - {{range .Values}}{{if not .Primitive}}{{if .MapKey }} {{/* Maps can change if they are @@ -407,22 +493,21 @@ Maps can change if they are func (d *Decoder) {{ .MethodNamePfx "fastpathDec" false }}R(f *codecFnInfo, rv reflect.Value) { if rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*map[{{ .MapKey }}]{{ .Elem }}) - if v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*vp, true, d); changed { - *vp = v - } - return - } - fastpathTV.{{ .MethodNamePfx "Dec" false }}V(rv2i(rv).(map[{{ .MapKey }}]{{ .Elem }}), false, d) + v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*vp, true, d); + if changed { *vp = v } + } else { + fastpathTV.{{ .MethodNamePfx "Dec" false }}V(rv2i(rv).(map[{{ .MapKey }}]{{ .Elem }}), false, d) + } } func (f fastpathT) {{ .MethodNamePfx "Dec" false }}X(vp *map[{{ .MapKey }}]{{ .Elem }}, d *Decoder) { - if v, changed := f.{{ .MethodNamePfx "Dec" false }}V(*vp, true, d); changed { - *vp = v - } + v, changed := f.{{ .MethodNamePfx "Dec" false }}V(*vp, true, d) + if changed { *vp = v } } func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v map[{{ .MapKey }}]{{ .Elem }}, canChange bool, d *Decoder) (_ map[{{ .MapKey }}]{{ .Elem }}, changed bool) { - dd, esep := d.d, d.hh.hasElemSeparators() - {{/* // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() */}} + dd, esep := d.d, d.hh.hasElemSeparators(){{/* + // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + */}} containerLen := dd.ReadMapStart() if canChange && v == nil { xlen := decInferLen(containerLen, d.h.MaxInitLen, {{ .Size }}) @@ -433,8 +518,8 @@ func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v map[{{ .MapKey }}]{{ .Ele dd.ReadMapEnd() return v, changed } - {{ if eq .Elem "interface{}" }}mapGet := !d.h.MapValueReset && !d.h.InterfaceReset{{end}} - var mk {{ .MapKey }} + {{ if eq .Elem "interface{}" }}mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset + {{end}}var mk {{ .MapKey }} var mv {{ .Elem }} hasLen := containerLen > 0 for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { @@ -446,17 +531,14 @@ func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v map[{{ .MapKey }}]{{ .Ele }{{ else }}mk = {{ decmd .MapKey }}{{ end }} if esep { dd.ReadMapElemValue() } if dd.TryDecodeAsNil() { - if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = {{ zerocmd .Elem }} } + if v == nil {} else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = {{ zerocmd .Elem }} } continue } {{ if eq .Elem "interface{}" }}if mapGet { mv = v[mk] } else { mv = nil } d.decode(&mv){{ else }}mv = {{ decmd .Elem }}{{ end }} - if v != nil { - v[mk] = mv - } + if v != nil { v[mk] = mv } } dd.ReadMapEnd() return v, changed } - {{end}}{{end}}{{end}} diff --git a/vendor/github.com/ugorji/go/codec/fast-path.not.go b/vendor/github.com/ugorji/go/codec/fast-path.not.go index 9573d64ab..f11b4674f 100644 --- a/vendor/github.com/ugorji/go/codec/fast-path.not.go +++ b/vendor/github.com/ugorji/go/codec/fast-path.not.go @@ -1,3 +1,6 @@ +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. +// Use of this source code is governed by a MIT license found in the LICENSE file. + // +build notfastpath package codec @@ -14,11 +17,11 @@ const fastpathEnabled = false // This tag disables fastpath during build, allowing for faster build, test execution, // short-program runs, etc. -func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { return false } -func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { return false } -func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { return false } -func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { return false } -func fastpathDecodeSetZeroTypeSwitch(iv interface{}, d *Decoder) bool { return false } +func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { return false } +func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { return false } +func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { return false } +func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { return false } +func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool { return false } type fastpathT struct{} type fastpathE struct { @@ -31,5 +34,14 @@ type fastpathA [0]fastpathE func (x fastpathA) index(rtid uintptr) int { return -1 } +func (_ fastpathT) DecSliceUint8V(v []uint8, canChange bool, d *Decoder) (_ []uint8, changed bool) { + fn := d.cfer().get(uint8SliceTyp, true, true) + d.kSlice(&fn.i, reflect.ValueOf(&v).Elem()) + return v, true +} + var fastpathAV fastpathA var fastpathTV fastpathT + +// ---- +type TestMammoth2Wrapper struct{} // to allow testMammoth work in notfastpath mode diff --git a/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl b/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl index d9940c0ad..fbe802ed9 100644 --- a/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl +++ b/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl @@ -43,7 +43,7 @@ if {{var "l"}} == 0 { {{var "c"}} = true }{{end}} {{var "h"}}.ElemContainerState({{var "j"}}) - // {{var "dn"}} = r.TryDecodeAsNil() + {{/* {{var "dn"}} = r.TryDecodeAsNil() */}} {{if isChan}}{{ $x := printf "%[1]vv%[2]v" .TempVar .Rand }}var {{var $x}} {{ .Typ }} {{ decLineVar $x }} {{var "v"}} <- {{ $x }} diff --git a/vendor/github.com/ugorji/go/codec/gen-helper.generated.go b/vendor/github.com/ugorji/go/codec/gen-helper.generated.go index 9293463de..917d28283 100644 --- a/vendor/github.com/ugorji/go/codec/gen-helper.generated.go +++ b/vendor/github.com/ugorji/go/codec/gen-helper.generated.go @@ -3,10 +3,7 @@ // Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. -// ************************************************************ -// DO NOT EDIT. -// THIS FILE IS AUTO-GENERATED from gen-helper.go.tmpl -// ************************************************************ +// Code generated from gen-helper.go.tmpl - DO NOT EDIT. package codec @@ -31,30 +28,73 @@ const GenVersion = 8 // GenHelperEncoder is exported so that it can be used externally by codecgen. // // Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE. -func GenHelperEncoder(e *Encoder) (genHelperEncoder, encDriver) { - return genHelperEncoder{e: e}, e.e +func GenHelperEncoder(e *Encoder) (ge genHelperEncoder, ee genHelperEncDriver) { + ge = genHelperEncoder{e: e} + ee = genHelperEncDriver{encDriver: e.e} + return } // GenHelperDecoder is exported so that it can be used externally by codecgen. // // Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE. -func GenHelperDecoder(d *Decoder) (genHelperDecoder, decDriver) { - return genHelperDecoder{d: d}, d.d +func GenHelperDecoder(d *Decoder) (gd genHelperDecoder, dd genHelperDecDriver) { + gd = genHelperDecoder{d: d} + dd = genHelperDecDriver{decDriver: d.d} + return } -// Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE. -func BasicHandleDoNotUse(h Handle) *BasicHandle { - return h.getBasicHandle() +type genHelperEncDriver struct { + encDriver +} + +func (x genHelperEncDriver) EncodeBuiltin(rt uintptr, v interface{}) {} +func (x genHelperEncDriver) EncStructFieldKey(keyType valueType, s string) { + encStructFieldKey(x.encDriver, keyType, s) +} +func (x genHelperEncDriver) EncodeSymbol(s string) { + x.encDriver.EncodeString(cUTF8, s) +} + +type genHelperDecDriver struct { + decDriver + C checkOverflow +} + +func (x genHelperDecDriver) DecodeBuiltin(rt uintptr, v interface{}) {} +func (x genHelperDecDriver) DecStructFieldKey(keyType valueType, buf *[decScratchByteArrayLen]byte) []byte { + return decStructFieldKey(x.decDriver, keyType, buf) +} +func (x genHelperDecDriver) DecodeInt(bitsize uint8) (i int64) { + return x.C.IntV(x.decDriver.DecodeInt64(), bitsize) +} +func (x genHelperDecDriver) DecodeUint(bitsize uint8) (ui uint64) { + return x.C.UintV(x.decDriver.DecodeUint64(), bitsize) +} +func (x genHelperDecDriver) DecodeFloat(chkOverflow32 bool) (f float64) { + f = x.DecodeFloat64() + if chkOverflow32 && chkOvf.Float32(f) { + panicv.errorf("float32 overflow: %v", f) + } + return +} +func (x genHelperDecDriver) DecodeFloat32As64() (f float64) { + f = x.DecodeFloat64() + if chkOvf.Float32(f) { + panicv.errorf("float32 overflow: %v", f) + } + return } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* type genHelperEncoder struct { + M must e *Encoder F fastpathT } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* type genHelperDecoder struct { + C checkOverflow d *Decoder F fastpathT } @@ -66,7 +106,12 @@ func (f genHelperEncoder) EncBasicHandle() *BasicHandle { // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) EncBinary() bool { - return f.e.cf.be // f.e.hh.isBinaryEncoding() + return f.e.be // f.e.hh.isBinaryEncoding() +} + +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperEncoder) IsJSONHandle() bool { + return f.e.js } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* @@ -79,52 +124,65 @@ func (f genHelperEncoder) EncFallback(iv interface{}) { // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) EncTextMarshal(iv encoding.TextMarshaler) { bs, fnerr := iv.MarshalText() - f.e.marshal(bs, fnerr, false, c_UTF8) + f.e.marshal(bs, fnerr, false, cUTF8) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) EncJSONMarshal(iv jsonMarshaler) { bs, fnerr := iv.MarshalJSON() - f.e.marshal(bs, fnerr, true, c_UTF8) + f.e.marshal(bs, fnerr, true, cUTF8) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) { bs, fnerr := iv.MarshalBinary() - f.e.marshal(bs, fnerr, false, c_RAW) + f.e.marshal(bs, fnerr, false, cRAW) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncRaw(iv Raw) { - f.e.rawBytes(iv) +func (f genHelperEncoder) EncRaw(iv Raw) { f.e.rawBytes(iv) } + +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +// +// Deprecated: builtin no longer supported - so we make this method a no-op, +// but leave in-place so that old generated files continue to work without regeneration. +func (f genHelperEncoder) TimeRtidIfBinc() (v uintptr) { return } + +// func (f genHelperEncoder) TimeRtidIfBinc() uintptr { +// if _, ok := f.e.hh.(*BincHandle); ok { +// return timeTypId +// } +// } + +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperEncoder) I2Rtid(v interface{}) uintptr { + return i2rtid(v) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) TimeRtidIfBinc() uintptr { - if _, ok := f.e.hh.(*BincHandle); ok { - return timeTypId - } - return 0 +func (f genHelperEncoder) Extension(rtid uintptr) (xfn *extTypeTagFn) { + return f.e.h.getExt(rtid) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) IsJSONHandle() bool { - return f.e.cf.js +func (f genHelperEncoder) EncExtension(v interface{}, xfFn *extTypeTagFn) { + f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext, f.e) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +// +// Deprecated: No longer used, +// but leave in-place so that old generated files continue to work without regeneration. func (f genHelperEncoder) HasExtensions() bool { return len(f.e.h.extHandle) != 0 } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +// +// Deprecated: No longer used, +// but leave in-place so that old generated files continue to work without regeneration. func (f genHelperEncoder) EncExt(v interface{}) (r bool) { - rt := reflect.TypeOf(v) - if rt.Kind() == reflect.Ptr { - rt = rt.Elem() - } - rtid := rt2id(rt) - if xfFn := f.e.h.getExt(rtid); xfFn != nil { + if xfFn := f.e.h.getExt(i2rtid(v)); xfFn != nil { f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext, f.e) return true } @@ -144,15 +202,18 @@ func (f genHelperDecoder) DecBinary() bool { } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecSwallow() { - f.d.swallow() -} +func (f genHelperDecoder) DecSwallow() { f.d.swallow() } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecScratchBuffer() []byte { return f.d.b[:] } +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperDecoder) DecScratchArrayBuffer() *[decScratchByteArrayLen]byte { + return &f.d.b +} + // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecFallback(iv interface{}, chkPtr bool) { // println(">>>>>>>>> DecFallback") @@ -160,7 +221,7 @@ func (f genHelperDecoder) DecFallback(iv interface{}, chkPtr bool) { if chkPtr { rv = f.d.ensureDecodeable(rv) } - f.d.decodeValue(rv, nil, false, false) + f.d.decodeValue(rv, nil, false) // f.d.decodeValueFallback(rv) } @@ -206,17 +267,21 @@ func (f genHelperDecoder) DecBinaryUnmarshal(bm encoding.BinaryUnmarshaler) { } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecRaw() []byte { - return f.d.rawBytes() -} +func (f genHelperDecoder) DecRaw() []byte { return f.d.rawBytes() } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) TimeRtidIfBinc() uintptr { - if _, ok := f.d.hh.(*BincHandle); ok { - return timeTypId - } - return 0 -} +// +// Deprecated: builtin no longer supported - so we make this method a no-op, +// but leave in-place so that old generated files continue to work without regeneration. +func (f genHelperDecoder) TimeRtidIfBinc() (v uintptr) { return } + +// func (f genHelperDecoder) TimeRtidIfBinc() uintptr { +// // Note: builtin is no longer supported - so make this a no-op +// if _, ok := f.d.hh.(*BincHandle); ok { +// return timeTypId +// } +// return 0 +// } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) IsJSONHandle() bool { @@ -224,15 +289,34 @@ func (f genHelperDecoder) IsJSONHandle() bool { } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperDecoder) I2Rtid(v interface{}) uintptr { + return i2rtid(v) +} + +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperDecoder) Extension(rtid uintptr) (xfn *extTypeTagFn) { + return f.d.h.getExt(rtid) +} + +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperDecoder) DecExtension(v interface{}, xfFn *extTypeTagFn) { + f.d.d.DecodeExt(v, xfFn.tag, xfFn.ext) +} + +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +// +// Deprecated: No longer used, +// but leave in-place so that old generated files continue to work without regeneration. func (f genHelperDecoder) HasExtensions() bool { return len(f.d.h.extHandle) != 0 } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +// +// Deprecated: No longer used, +// but leave in-place so that old generated files continue to work without regeneration. func (f genHelperDecoder) DecExt(v interface{}) (r bool) { - rt := reflect.TypeOf(v).Elem() - rtid := rt2id(rt) - if xfFn := f.d.h.getExt(rtid); xfFn != nil { + if xfFn := f.d.h.getExt(i2rtid(v)); xfFn != nil { f.d.d.DecodeExt(v, xfFn.tag, xfFn.ext) return true } @@ -245,6 +329,7 @@ func (f genHelperDecoder) DecInferLen(clen, maxlen, unit int) (rvlen int) { } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) StringView(v []byte) string { - return stringView(v) -} +// +// Deprecated: no longer used, +// but leave in-place so that old generated files continue to work without regeneration. +func (f genHelperDecoder) StringView(v []byte) string { return stringView(v) } diff --git a/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl b/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl index dfa1def20..6aeb85650 100644 --- a/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl +++ b/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl @@ -3,10 +3,7 @@ // Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. -// ************************************************************ -// DO NOT EDIT. -// THIS FILE IS AUTO-GENERATED from gen-helper.go.tmpl -// ************************************************************ +// Code generated from gen-helper.go.tmpl - DO NOT EDIT. package codec @@ -21,40 +18,83 @@ const GenVersion = {{ .Version }} // This file is used to generate helper code for codecgen. // The values here i.e. genHelper(En|De)coder are not to be used directly by // library users. They WILL change continuously and without notice. -// +// // To help enforce this, we create an unexported type with exported members. // The only way to get the type is via the one exported type that we control (somewhat). -// +// // When static codecs are created for types, they will use this value // to perform encoding or decoding of primitives or known slice or map types. // GenHelperEncoder is exported so that it can be used externally by codecgen. -// +// // Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE. -func GenHelperEncoder(e *Encoder) (genHelperEncoder, encDriver) { - return genHelperEncoder{e:e}, e.e +func GenHelperEncoder(e *Encoder) (ge genHelperEncoder, ee genHelperEncDriver) { + ge = genHelperEncoder{e: e} + ee = genHelperEncDriver{encDriver: e.e} + return } // GenHelperDecoder is exported so that it can be used externally by codecgen. -// +// // Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE. -func GenHelperDecoder(d *Decoder) (genHelperDecoder, decDriver) { - return genHelperDecoder{d:d}, d.d +func GenHelperDecoder(d *Decoder) (gd genHelperDecoder, dd genHelperDecDriver) { + gd = genHelperDecoder{d: d} + dd = genHelperDecDriver{decDriver: d.d} + return } -// Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE. -func BasicHandleDoNotUse(h Handle) *BasicHandle { - return h.getBasicHandle() +type genHelperEncDriver struct { + encDriver +} + +func (x genHelperEncDriver) EncodeBuiltin(rt uintptr, v interface{}) {} +func (x genHelperEncDriver) EncStructFieldKey(keyType valueType, s string) { + encStructFieldKey(x.encDriver, keyType, s) +} +func (x genHelperEncDriver) EncodeSymbol(s string) { + x.encDriver.EncodeString(cUTF8, s) +} + +type genHelperDecDriver struct { + decDriver + C checkOverflow +} + +func (x genHelperDecDriver) DecodeBuiltin(rt uintptr, v interface{}) {} +func (x genHelperDecDriver) DecStructFieldKey(keyType valueType, buf *[decScratchByteArrayLen]byte) []byte { + return decStructFieldKey(x.decDriver, keyType, buf) +} +func (x genHelperDecDriver) DecodeInt(bitsize uint8) (i int64) { + return x.C.IntV(x.decDriver.DecodeInt64(), bitsize) +} +func (x genHelperDecDriver) DecodeUint(bitsize uint8) (ui uint64) { + return x.C.UintV(x.decDriver.DecodeUint64(), bitsize) +} +func (x genHelperDecDriver) DecodeFloat(chkOverflow32 bool) (f float64) { + f = x.DecodeFloat64() + if chkOverflow32 && chkOvf.Float32(f) { + panicv.errorf("float32 overflow: %v", f) + } + return +} +func (x genHelperDecDriver) DecodeFloat32As64() (f float64) { + f = x.DecodeFloat64() + if chkOvf.Float32(f) { + panicv.errorf("float32 overflow: %v", f) + } + return } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* type genHelperEncoder struct { + M must e *Encoder F fastpathT } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* type genHelperDecoder struct { + C checkOverflow d *Decoder F fastpathT } @@ -63,10 +103,13 @@ type genHelperDecoder struct { func (f genHelperEncoder) EncBasicHandle() *BasicHandle { return f.e.h } - // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) EncBinary() bool { - return f.e.cf.be // f.e.hh.isBinaryEncoding() + return f.e.be // f.e.hh.isBinaryEncoding() +} +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperEncoder) IsJSONHandle() bool { + return f.e.js } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) EncFallback(iv interface{}) { @@ -77,58 +120,61 @@ func (f genHelperEncoder) EncFallback(iv interface{}) { // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) EncTextMarshal(iv encoding.TextMarshaler) { bs, fnerr := iv.MarshalText() - f.e.marshal(bs, fnerr, false, c_UTF8) + f.e.marshal(bs, fnerr, false, cUTF8) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) EncJSONMarshal(iv jsonMarshaler) { bs, fnerr := iv.MarshalJSON() - f.e.marshal(bs, fnerr, true, c_UTF8) + f.e.marshal(bs, fnerr, true, cUTF8) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) { bs, fnerr := iv.MarshalBinary() - f.e.marshal(bs, fnerr, false, c_RAW) + f.e.marshal(bs, fnerr, false, cRAW) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncRaw(iv Raw) { - f.e.rawBytes(iv) +func (f genHelperEncoder) EncRaw(iv Raw) { f.e.rawBytes(iv) } +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +// +// Deprecated: builtin no longer supported - so we make this method a no-op, +// but leave in-place so that old generated files continue to work without regeneration. +func (f genHelperEncoder) TimeRtidIfBinc() (v uintptr) { return } +// func (f genHelperEncoder) TimeRtidIfBinc() uintptr { +// if _, ok := f.e.hh.(*BincHandle); ok { +// return timeTypId +// } +// } + +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperEncoder) I2Rtid(v interface{}) uintptr { + return i2rtid(v) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) TimeRtidIfBinc() uintptr { - if _, ok := f.e.hh.(*BincHandle); ok { - return timeTypId - } - return 0 +func (f genHelperEncoder) Extension(rtid uintptr) (xfn *extTypeTagFn) { + return f.e.h.getExt(rtid) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) IsJSONHandle() bool { - return f.e.cf.js +func (f genHelperEncoder) EncExtension(v interface{}, xfFn *extTypeTagFn) { + f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext, f.e) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +// +// Deprecated: No longer used, +// but leave in-place so that old generated files continue to work without regeneration. func (f genHelperEncoder) HasExtensions() bool { return len(f.e.h.extHandle) != 0 } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +// +// Deprecated: No longer used, +// but leave in-place so that old generated files continue to work without regeneration. func (f genHelperEncoder) EncExt(v interface{}) (r bool) { - rt := reflect.TypeOf(v) - if rt.Kind() == reflect.Ptr { - rt = rt.Elem() - } - rtid := rt2id(rt) - if xfFn := f.e.h.getExt(rtid); xfFn != nil { + if xfFn := f.e.h.getExt(i2rtid(v)); xfFn != nil { f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext, f.e) return true } return false } -{{/* -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncSendContainerState(c containerState) { - if f.e.cr != nil { - f.e.cr.sendContainerState(c) - } -} -*/}} // ---------------- DECODER FOLLOWS ----------------- @@ -141,21 +187,23 @@ func (f genHelperDecoder) DecBinary() bool { return f.d.be // f.d.hh.isBinaryEncoding() } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecSwallow() { - f.d.swallow() -} +func (f genHelperDecoder) DecSwallow() { f.d.swallow() } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecScratchBuffer() []byte { return f.d.b[:] } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperDecoder) DecScratchArrayBuffer() *[decScratchByteArrayLen]byte { + return &f.d.b +} +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecFallback(iv interface{}, chkPtr bool) { // println(">>>>>>>>> DecFallback") rv := reflect.ValueOf(iv) if chkPtr { rv = f.d.ensureDecodeable(rv) } - f.d.decodeValue(rv, nil, false, false) + f.d.decodeValue(rv, nil, false) // f.d.decodeValueFallback(rv) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* @@ -194,29 +242,49 @@ func (f genHelperDecoder) DecBinaryUnmarshal(bm encoding.BinaryUnmarshaler) { } } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecRaw() []byte { - return f.d.rawBytes() -} +func (f genHelperDecoder) DecRaw() []byte { return f.d.rawBytes() } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) TimeRtidIfBinc() uintptr { - if _, ok := f.d.hh.(*BincHandle); ok { - return timeTypId - } - return 0 -} +// +// Deprecated: builtin no longer supported - so we make this method a no-op, +// but leave in-place so that old generated files continue to work without regeneration. +func (f genHelperDecoder) TimeRtidIfBinc() (v uintptr) { return } +// func (f genHelperDecoder) TimeRtidIfBinc() uintptr { +// // Note: builtin is no longer supported - so make this a no-op +// if _, ok := f.d.hh.(*BincHandle); ok { +// return timeTypId +// } +// return 0 +// } + // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) IsJSONHandle() bool { return f.d.js } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperDecoder) I2Rtid(v interface{}) uintptr { + return i2rtid(v) +} +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperDecoder) Extension(rtid uintptr) (xfn *extTypeTagFn) { + return f.d.h.getExt(rtid) +} +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperDecoder) DecExtension(v interface{}, xfFn *extTypeTagFn) { + f.d.d.DecodeExt(v, xfFn.tag, xfFn.ext) +} +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +// +// Deprecated: No longer used, +// but leave in-place so that old generated files continue to work without regeneration. func (f genHelperDecoder) HasExtensions() bool { return len(f.d.h.extHandle) != 0 } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +// +// Deprecated: No longer used, +// but leave in-place so that old generated files continue to work without regeneration. func (f genHelperDecoder) DecExt(v interface{}) (r bool) { - rt := reflect.TypeOf(v).Elem() - rtid := rt2id(rt) - if xfFn := f.d.h.getExt(rtid); xfFn != nil { + if xfFn := f.d.h.getExt(i2rtid(v)); xfFn != nil { f.d.d.DecodeExt(v, xfFn.tag, xfFn.ext) return true } @@ -227,170 +295,8 @@ func (f genHelperDecoder) DecInferLen(clen, maxlen, unit int) (rvlen int) { return decInferLen(clen, maxlen, unit) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) StringView(v []byte) string { - return stringView(v) -} -{{/* -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecSendContainerState(c containerState) { - if f.d.cr != nil { - f.d.cr.sendContainerState(c) - } -} -*/}} - -{{/* - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncDriver() encDriver { - return f.e.e -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecDriver() decDriver { - return f.d.d -} +// +// Deprecated: no longer used, +// but leave in-place so that old generated files continue to work without regeneration. +func (f genHelperDecoder) StringView(v []byte) string { return stringView(v) } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncNil() { - f.e.e.EncodeNil() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncBytes(v []byte) { - f.e.e.EncodeStringBytes(c_RAW, v) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncArrayStart(length int) { - f.e.e.EncodeArrayStart(length) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncArrayEnd() { - f.e.e.EncodeArrayEnd() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncArrayEntrySeparator() { - f.e.e.EncodeArrayEntrySeparator() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncMapStart(length int) { - f.e.e.EncodeMapStart(length) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncMapEnd() { - f.e.e.EncodeMapEnd() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncMapEntrySeparator() { - f.e.e.EncodeMapEntrySeparator() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncMapKVSeparator() { - f.e.e.EncodeMapKVSeparator() -} - -// --------- - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecBytes(v *[]byte) { - *v = f.d.d.DecodeBytes(*v) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecTryNil() bool { - return f.d.d.TryDecodeAsNil() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecContainerIsNil() (b bool) { - return f.d.d.IsContainerType(valueTypeNil) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecContainerIsMap() (b bool) { - return f.d.d.IsContainerType(valueTypeMap) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecContainerIsArray() (b bool) { - return f.d.d.IsContainerType(valueTypeArray) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecCheckBreak() bool { - return f.d.d.CheckBreak() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecMapStart() int { - return f.d.d.ReadMapStart() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecArrayStart() int { - return f.d.d.ReadArrayStart() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecMapEnd() { - f.d.d.ReadMapEnd() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecArrayEnd() { - f.d.d.ReadArrayEnd() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecArrayEntrySeparator() { - f.d.d.ReadArrayEntrySeparator() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecMapEntrySeparator() { - f.d.d.ReadMapEntrySeparator() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecMapKVSeparator() { - f.d.d.ReadMapKVSeparator() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) ReadStringAsBytes(bs []byte) []byte { - return f.d.d.DecodeStringAsBytes(bs) -} - - -// -- encode calls (primitives) -{{range .Values}}{{if .Primitive }}{{if ne .Primitive "interface{}" }} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) {{ .MethodNamePfx "Enc" true }}(v {{ .Primitive }}) { - ee := f.e.e - {{ encmd .Primitive "v" }} -} -{{ end }}{{ end }}{{ end }} - -// -- decode calls (primitives) -{{range .Values}}{{if .Primitive }}{{if ne .Primitive "interface{}" }} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) {{ .MethodNamePfx "Dec" true }}(vp *{{ .Primitive }}) { - dd := f.d.d - *vp = {{ decmd .Primitive }} -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) {{ .MethodNamePfx "Read" true }}() (v {{ .Primitive }}) { - dd := f.d.d - v = {{ decmd .Primitive }} - return -} -{{ end }}{{ end }}{{ end }} - - -// -- encode calls (slices/maps) -{{range .Values}}{{if not .Primitive }}{{if .Slice }} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) {{ .MethodNamePfx "Enc" false }}(v []{{ .Elem }}) { {{ else }} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) {{ .MethodNamePfx "Enc" false }}(v map[{{ .MapKey }}]{{ .Elem }}) { {{end}} - f.F.{{ .MethodNamePfx "Enc" false }}V(v, false, f.e) -} -{{ end }}{{ end }} - -// -- decode calls (slices/maps) -{{range .Values}}{{if not .Primitive }} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -{{if .Slice }}func (f genHelperDecoder) {{ .MethodNamePfx "Dec" false }}(vp *[]{{ .Elem }}) { -{{else}}func (f genHelperDecoder) {{ .MethodNamePfx "Dec" false }}(vp *map[{{ .MapKey }}]{{ .Elem }}) { {{end}} - v, changed := f.F.{{ .MethodNamePfx "Dec" false }}V(*vp, false, true, f.d) - if changed { - *vp = v - } -} -{{ end }}{{ end }} -*/}} diff --git a/vendor/github.com/ugorji/go/codec/gen.generated.go b/vendor/github.com/ugorji/go/codec/gen.generated.go index b50a6024d..799bc76e8 100644 --- a/vendor/github.com/ugorji/go/codec/gen.generated.go +++ b/vendor/github.com/ugorji/go/codec/gen.generated.go @@ -1,3 +1,5 @@ +// +build codecgen.exec + // Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. @@ -96,7 +98,7 @@ if {{var "l"}} == 0 { {{var "c"}} = true }{{end}} {{var "h"}}.ElemContainerState({{var "j"}}) - // {{var "dn"}} = r.TryDecodeAsNil() + {{/* {{var "dn"}} = r.TryDecodeAsNil() */}} {{if isChan}}{{ $x := printf "%[1]vv%[2]v" .TempVar .Rand }}var {{var $x}} {{ .Typ }} {{ decLineVar $x }} {{var "v"}} <- {{ $x }} @@ -129,4 +131,3 @@ if {{var "l"}} == 0 { }{{end}} ` - diff --git a/vendor/github.com/ugorji/go/codec/gen.go b/vendor/github.com/ugorji/go/codec/gen.go index 043f10d80..5794452d3 100644 --- a/vendor/github.com/ugorji/go/codec/gen.go +++ b/vendor/github.com/ugorji/go/codec/gen.go @@ -1,6 +1,6 @@ // +build codecgen.exec -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. package codec @@ -30,7 +30,6 @@ import ( // codecgen supports the full cycle of reflection-based codec: // - RawExt // - Raw -// - Builtins // - Extensions // - (Binary|Text|JSON)(Unm|M)arshal // - generic by-kind @@ -101,6 +100,8 @@ import ( // v4: Removed separator support from (en|de)cDriver, and refactored codec(gen) // v5: changes to support faster json decoding. Let encoder/decoder maintain state of collections. // v6: removed unsafe from gen, and now uses codecgen.exec tag +// v7: +// v8: current - we now maintain compatibility with old generated code. const genVersion = 8 const ( @@ -129,12 +130,27 @@ const ( ) var ( - genAllTypesSamePkgErr = errors.New("All types must be in the same package") - genExpectArrayOrMapErr = errors.New("unexpected type. Expecting array/map/slice") - genBase64enc = base64.NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789__") - genQNameRegex = regexp.MustCompile(`[A-Za-z_.]+`) + errGenAllTypesSamePkg = errors.New("All types must be in the same package") + errGenExpectArrayOrMap = errors.New("unexpected type. Expecting array/map/slice") + + genBase64enc = base64.NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789__") + genQNameRegex = regexp.MustCompile(`[A-Za-z_.]+`) ) +type genBuf struct { + buf []byte +} + +func (x *genBuf) s(s string) *genBuf { x.buf = append(x.buf, s...); return x } +func (x *genBuf) b(s []byte) *genBuf { x.buf = append(x.buf, s...); return x } +func (x *genBuf) v() string { return string(x.buf) } +func (x *genBuf) f(s string, args ...interface{}) { x.s(fmt.Sprintf(s, args...)) } +func (x *genBuf) reset() { + if x.buf != nil { + x.buf = x.buf[:0] + } +} + // genRunner holds some state used during a Gen run. type genRunner struct { w io.Writer // output @@ -170,7 +186,7 @@ type genRunner struct { // Gen will write a complete go file containing Selfer implementations for each // type passed. All the types must be in the same package. // -// Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE. +// Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINUOUSLY WITHOUT NOTICE. func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool, ti *TypeInfos, typ ...reflect.Type) { // All types passed to this method do not have a codec.Selfer method implemented directly. @@ -209,7 +225,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool, for _, t := range typ { // fmt.Printf("###########: PkgPath: '%v', Name: '%s'\n", genImportPath(t), t.Name()) if genImportPath(t) != x.bp { - panic(genAllTypesSamePkgErr) + panic(errGenAllTypesSamePkg) } x.genRefPkgs(t) } @@ -219,10 +235,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool, } x.line(` -// ************************************************************ -// DO NOT EDIT. -// THIS FILE IS AUTO-GENERATED BY codecgen. -// ************************************************************ +// Code generated by codecgen - DO NOT EDIT. `) x.line("package " + pkgName) @@ -234,15 +247,19 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool, } // use a sorted set of im keys, so that we can get consistent output imKeys := make([]string, 0, len(x.im)) - for k, _ := range x.im { + for k := range x.im { imKeys = append(imKeys, k) } sort.Strings(imKeys) for _, k := range imKeys { // for k, _ := range x.im { - x.linef("%s \"%s\"", x.imn[k], k) + if k == x.imn[k] { + x.linef("\"%s\"", k) + } else { + x.linef("%s \"%s\"", x.imn[k], k) + } } // add required packages - for _, k := range [...]string{"reflect", "runtime", "fmt", "errors"} { + for _, k := range [...]string{"runtime", "errors", "strconv"} { // "reflect", "fmt" if _, ok := x.im[k]; !ok { x.line("\"" + k + "\"") } @@ -252,21 +269,19 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool, x.line("const (") x.linef("// ----- content types ----") - x.linef("codecSelferC_UTF8%s = %v", x.xs, int64(c_UTF8)) - x.linef("codecSelferC_RAW%s = %v", x.xs, int64(c_RAW)) + x.linef("codecSelferCcUTF8%s = %v", x.xs, int64(cUTF8)) + x.linef("codecSelferCcRAW%s = %v", x.xs, int64(cRAW)) x.linef("// ----- value types used ----") - x.linef("codecSelferValueTypeArray%s = %v", x.xs, int64(valueTypeArray)) - x.linef("codecSelferValueTypeMap%s = %v", x.xs, int64(valueTypeMap)) - x.linef("// ----- containerStateValues ----") - x.linef("codecSelfer_containerMapKey%s = %v", x.xs, int64(containerMapKey)) - x.linef("codecSelfer_containerMapValue%s = %v", x.xs, int64(containerMapValue)) - x.linef("codecSelfer_containerMapEnd%s = %v", x.xs, int64(containerMapEnd)) - x.linef("codecSelfer_containerArrayElem%s = %v", x.xs, int64(containerArrayElem)) - x.linef("codecSelfer_containerArrayEnd%s = %v", x.xs, int64(containerArrayEnd)) + for _, vt := range [...]valueType{ + valueTypeArray, valueTypeMap, valueTypeString, + valueTypeInt, valueTypeUint, valueTypeFloat} { + x.linef("codecSelferValueType%s%s = %v", vt.String(), x.xs, int64(vt)) + } + + x.linef("codecSelferBitsize%s = uint8(strconv.IntSize) // uint8(32 << (^uint(0) >> 63))", x.xs) x.line(")") x.line("var (") - x.line("codecSelferBitsize" + x.xs + " = uint8(reflect.TypeOf(uint(0)).Bits())") - x.line("codecSelferOnlyMapOrArrayEncodeToStructErr" + x.xs + " = errors.New(`only encoded map or array can be decoded into a struct`)") + x.line("errCodecSelferOnlyMapOrArrayEncodeToStruct" + x.xs + " = errors.New(`only encoded map or array can be decoded into a struct`)") x.line(")") x.line("") @@ -278,11 +293,12 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool, x.line("func init() {") x.linef("if %sGenVersion != %v {", x.cpfx, genVersion) x.line("_, file, _, _ := runtime.Caller(0)") - x.line(`err := fmt.Errorf("codecgen version mismatch: current: %v, need %v. Re-generate file: %v", `) - x.linef(`%v, %sGenVersion, file)`, genVersion, x.cpfx) - x.line("panic(err)") + x.outf(`panic("codecgen version mismatch: current: %v, need " + strconv.FormatInt(int64(%sGenVersion), 10) + ". Re-generate file: " + file)`, genVersion, x.cpfx) + // x.out(`panic(fmt.Errorf("codecgen version mismatch: current: %v, need %v. Re-generate file: %v", `) + // x.linef(`%v, %sGenVersion, file))`, genVersion, x.cpfx) x.linef("}") x.line("if false { // reference the types, but skip this branch at build/run time") + // x.line("_ = strconv.ParseInt") var n int // for k, t := range x.im { for _, k := range imKeys { @@ -323,7 +339,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool, case reflect.Map: x.encMapFallback("v", t) default: - panic(genExpectArrayOrMapErr) + panic(errGenExpectArrayOrMap) } x.line("}") x.line("") @@ -338,7 +354,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool, case reflect.Map: x.decMapFallback("v", rtid, t) default: - panic(genExpectArrayOrMapErr) + panic(errGenExpectArrayOrMap) } x.line("}") x.line("") @@ -374,7 +390,6 @@ func (x *genRunner) genRefPkgs(t reflect.Type) { if _, ok := x.is[t]; ok { return } - // fmt.Printf(">>>>>>: PkgPath: '%v', Name: '%s'\n", genImportPath(t), t.Name()) x.is[t] = struct{}{} tpkg, tname := genImportPath(t), t.Name() if tpkg != "" && tpkg != x.bp && tpkg != x.cp && tname != "" && tname[0] >= 'A' && tname[0] <= 'Z' { @@ -403,13 +418,6 @@ func (x *genRunner) genRefPkgs(t reflect.Type) { } } -func (x *genRunner) line(s string) { - x.out(s) - if len(s) == 0 || s[len(s)-1] != '\n' { - x.out("\n") - } -} - func (x *genRunner) varsfx() string { x.c++ return strconv.FormatUint(x.c, 10) @@ -420,17 +428,31 @@ func (x *genRunner) varsfxreset() { } func (x *genRunner) out(s string) { - if _, err := io.WriteString(x.w, s); err != nil { + _, err := io.WriteString(x.w, s) + if err != nil { panic(err) } } -func (x *genRunner) linef(s string, params ...interface{}) { - x.line(fmt.Sprintf(s, params...)) +func (x *genRunner) outf(s string, params ...interface{}) { + _, err := fmt.Fprintf(x.w, s, params...) + if err != nil { + panic(err) + } } -func (x *genRunner) outf(s string, params ...interface{}) { - x.out(fmt.Sprintf(s, params...)) +func (x *genRunner) line(s string) { + x.out(s) + if len(s) == 0 || s[len(s)-1] != '\n' { + x.out("\n") + } +} + +func (x *genRunner) linef(s string, params ...interface{}) { + x.outf(s, params...) + if len(s) == 0 || s[len(s)-1] != '\n' { + x.out("\n") + } } func (x *genRunner) genTypeName(t reflect.Type) (n string) { @@ -503,16 +525,17 @@ func (x *genRunner) selfer(encode bool) { t := x.tc t0 := t // always make decode use a pointer receiver, - // and structs always use a ptr receiver (encode|decode) - isptr := !encode || t.Kind() == reflect.Struct + // and structs/arrays always use a ptr receiver (encode|decode) + isptr := !encode || t.Kind() == reflect.Array || (t.Kind() == reflect.Struct && t != timeTyp) x.varsfxreset() - fnSigPfx := "func (x " + + fnSigPfx := "func (" + genTopLevelVarName + " " if isptr { fnSigPfx += "*" } fnSigPfx += x.genTypeName(t) - x.out(fnSigPfx) + if isptr { t = reflect.PtrTo(t) } @@ -528,7 +551,7 @@ func (x *genRunner) selfer(encode bool) { // or way to elegantly handle that, and also setting it to a // non-nil value doesn't affect the pointer passed. // x.decVar(genTopLevelVarName, t, false) - x.dec(genTopLevelVarName, t0) + x.dec(genTopLevelVarName, t0, true) } x.line("}") x.line("") @@ -572,11 +595,17 @@ func (x *genRunner) selfer(encode bool) { } // used for chan, array, slice, map -func (x *genRunner) xtraSM(varname string, encode bool, t reflect.Type) { +func (x *genRunner) xtraSM(varname string, t reflect.Type, encode, isptr bool) { + var ptrPfx, addrPfx string + if isptr { + ptrPfx = "*" + } else { + addrPfx = "&" + } if encode { - x.linef("h.enc%s((%s%s)(%s), e)", x.genMethodNameT(t), x.arr2str(t, "*"), x.genTypeName(t), varname) + x.linef("h.enc%s((%s%s)(%s), e)", x.genMethodNameT(t), ptrPfx, x.genTypeName(t), varname) } else { - x.linef("h.dec%s((*%s)(%s), d)", x.genMethodNameT(t), x.genTypeName(t), varname) + x.linef("h.dec%s((*%s)(%s%s), d)", x.genMethodNameT(t), x.genTypeName(t), addrPfx, varname) } x.registerXtraT(t) } @@ -615,17 +644,23 @@ func (x *genRunner) encVar(varname string, t reflect.Type) { if checkNil { x.linef("if %s == nil { r.EncodeNil() } else { ", varname) } + switch t.Kind() { case reflect.Ptr: - switch t.Elem().Kind() { - case reflect.Struct, reflect.Array: + telem := t.Elem() + tek := telem.Kind() + if tek == reflect.Array || (tek == reflect.Struct && t != timeTyp) { x.enc(varname, genNonPtr(t)) - default: - i := x.varsfx() - x.line(genTempVarPfx + i + " := *" + varname) - x.enc(genTempVarPfx+i, genNonPtr(t)) + break } + i := x.varsfx() + x.line(genTempVarPfx + i + " := *" + varname) + x.enc(genTempVarPfx+i, genNonPtr(t)) case reflect.Struct, reflect.Array: + if t == timeTyp { + x.enc(varname, t) + break + } i := x.varsfx() x.line(genTempVarPfx + i + " := &" + varname) x.enc(genTempVarPfx+i, t) @@ -639,29 +674,33 @@ func (x *genRunner) encVar(varname string, t reflect.Type) { } -// enc will encode a variable (varname) of type t, -// except t is of kind reflect.Struct or reflect.Array, wherein varname is of type ptrTo(T) (to prevent copying) +// enc will encode a variable (varname) of type t, where t represents T. +// if t is !time.Time and t is of kind reflect.Struct or reflect.Array, varname is of type *T +// (to prevent copying), +// else t is of type T func (x *genRunner) enc(varname string, t reflect.Type) { rtid := rt2id(t) + ti2 := x.ti.get(rtid, t) // We call CodecEncodeSelf if one of the following are honored: // - the type already implements Selfer, call that // - the type has a Selfer implementation just created, use that // - the type is in the list of the ones we will generate for, but it is not currently being generated mi := x.varsfx() - tptr := reflect.PtrTo(t) + // tptr := reflect.PtrTo(t) tk := t.Kind() if x.checkForSelfer(t, varname) { - if tk == reflect.Array || tk == reflect.Struct { // varname is of type *T - if tptr.Implements(selferTyp) || t.Implements(selferTyp) { + if tk == reflect.Array || (tk == reflect.Struct && rtid != timeTypId) { // varname is of type *T + // if tptr.Implements(selferTyp) || t.Implements(selferTyp) { + if ti2.isFlag(typeInfoFlagIsZeroerPtr) || ti2.isFlag(typeInfoFlagIsZeroer) { x.line(varname + ".CodecEncodeSelf(e)") return } } else { // varname is of type T - if t.Implements(selferTyp) { + if ti2.cs { // t.Implements(selferTyp) { x.line(varname + ".CodecEncodeSelf(e)") return - } else if tptr.Implements(selferTyp) { + } else if ti2.csp { // tptr.Implements(selferTyp) { x.linef("%ssf%s := &%s", genTempVarPfx, mi, varname) x.linef("%ssf%s.CodecEncodeSelf(e)", genTempVarPfx, mi) return @@ -693,57 +732,53 @@ func (x *genRunner) enc(varname string, t reflect.Type) { } // check if - // - type is RawExt, Raw + // - type is time.Time, RawExt, Raw // - the type implements (Text|JSON|Binary)(Unm|M)arshal - x.linef("%sm%s := z.EncBinary()", genTempVarPfx, mi) - x.linef("_ = %sm%s", genTempVarPfx, mi) + x.line("if false {") //start if block defer func() { x.line("}") }() //end if block + if t == timeTyp { + x.linef("} else { r.EncodeTime(%s)", varname) + return + } if t == rawTyp { - x.linef("} else { z.EncRaw(%v)", varname) + x.linef("} else { z.EncRaw(%s)", varname) return } if t == rawExtTyp { - x.linef("} else { r.EncodeRawExt(%v, e)", varname) + x.linef("} else { r.EncodeRawExt(%s, e)", varname) return } - // HACK: Support for Builtins. - // Currently, only Binc supports builtins, and the only builtin type is time.Time. - // Have a method that returns the rtid for time.Time if Handle is Binc. - if t == timeTyp { - vrtid := genTempVarPfx + "m" + x.varsfx() - x.linef("} else if %s := z.TimeRtidIfBinc(); %s != 0 { ", vrtid, vrtid) - x.linef("r.EncodeBuiltin(%s, %s)", vrtid, varname) - } // only check for extensions if the type is named, and has a packagePath. + var arrayOrStruct = tk == reflect.Array || tk == reflect.Struct // meaning varname if of type *T if !x.nx && genImportPath(t) != "" && t.Name() != "" { - // first check if extensions are configued, before doing the interface conversion - x.linef("} else if z.HasExtensions() && z.EncExt(%s) {", varname) + yy := fmt.Sprintf("%sxt%s", genTempVarPfx, mi) + x.linef("} else if %s := z.Extension(z.I2Rtid(%s)); %s != nil { z.EncExtension(%s, %s) ", yy, varname, yy, varname, yy) } - if tk == reflect.Array || tk == reflect.Struct { // varname is of type *T - if t.Implements(binaryMarshalerTyp) || tptr.Implements(binaryMarshalerTyp) { - x.linef("} else if %sm%s { z.EncBinaryMarshal(%v) ", genTempVarPfx, mi, varname) + if arrayOrStruct { // varname is of type *T + if ti2.bm || ti2.bmp { // t.Implements(binaryMarshalerTyp) || tptr.Implements(binaryMarshalerTyp) { + x.linef("} else if z.EncBinary() { z.EncBinaryMarshal(%v) ", varname) } - if t.Implements(jsonMarshalerTyp) || tptr.Implements(jsonMarshalerTyp) { - x.linef("} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", genTempVarPfx, mi, varname) - } else if t.Implements(textMarshalerTyp) || tptr.Implements(textMarshalerTyp) { - x.linef("} else if !%sm%s { z.EncTextMarshal(%v) ", genTempVarPfx, mi, varname) + if ti2.jm || ti2.jmp { // t.Implements(jsonMarshalerTyp) || tptr.Implements(jsonMarshalerTyp) { + x.linef("} else if !z.EncBinary() && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", varname) + } else if ti2.tm || ti2.tmp { // t.Implements(textMarshalerTyp) || tptr.Implements(textMarshalerTyp) { + x.linef("} else if !z.EncBinary() { z.EncTextMarshal(%v) ", varname) } } else { // varname is of type T - if t.Implements(binaryMarshalerTyp) { - x.linef("} else if %sm%s { z.EncBinaryMarshal(%v) ", genTempVarPfx, mi, varname) - } else if tptr.Implements(binaryMarshalerTyp) { - x.linef("} else if %sm%s { z.EncBinaryMarshal(&%v) ", genTempVarPfx, mi, varname) + if ti2.bm { // t.Implements(binaryMarshalerTyp) { + x.linef("} else if z.EncBinary() { z.EncBinaryMarshal(%v) ", varname) + } else if ti2.bmp { // tptr.Implements(binaryMarshalerTyp) { + x.linef("} else if z.EncBinary() { z.EncBinaryMarshal(&%v) ", varname) } - if t.Implements(jsonMarshalerTyp) { - x.linef("} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", genTempVarPfx, mi, varname) - } else if tptr.Implements(jsonMarshalerTyp) { - x.linef("} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(&%v) ", genTempVarPfx, mi, varname) - } else if t.Implements(textMarshalerTyp) { - x.linef("} else if !%sm%s { z.EncTextMarshal(%v) ", genTempVarPfx, mi, varname) - } else if tptr.Implements(textMarshalerTyp) { - x.linef("} else if !%sm%s { z.EncTextMarshal(&%v) ", genTempVarPfx, mi, varname) + if ti2.jm { // t.Implements(jsonMarshalerTyp) { + x.linef("} else if !z.EncBinary() && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", varname) + } else if ti2.jmp { // tptr.Implements(jsonMarshalerTyp) { + x.linef("} else if !z.EncBinary() && z.IsJSONHandle() { z.EncJSONMarshal(&%v) ", varname) + } else if ti2.tm { // t.Implements(textMarshalerTyp) { + x.linef("} else if !z.EncBinary() { z.EncTextMarshal(%v) ", varname) + } else if ti2.tmp { // tptr.Implements(textMarshalerTyp) { + x.linef("} else if !z.EncBinary() { z.EncTextMarshal(&%v) ", varname) } } x.line("} else {") @@ -760,12 +795,12 @@ func (x *genRunner) enc(varname string, t reflect.Type) { case reflect.Bool: x.line("r.EncodeBool(bool(" + varname + "))") case reflect.String: - x.line("r.EncodeString(codecSelferC_UTF8" + x.xs + ", string(" + varname + "))") + x.line("r.EncodeString(codecSelferCcUTF8" + x.xs + ", string(" + varname + "))") case reflect.Chan: - x.xtraSM(varname, true, t) + x.xtraSM(varname, t, true, false) // x.encListFallback(varname, rtid, t) case reflect.Array: - x.xtraSM(varname, true, t) + x.xtraSM(varname, t, true, true) case reflect.Slice: // if nil, call dedicated function // if a []uint8, call dedicated function @@ -774,12 +809,12 @@ func (x *genRunner) enc(varname string, t reflect.Type) { // - if elements are primitives or Selfers, call dedicated function on each member. // - else call Encoder.encode(XXX) on it. if rtid == uint8SliceTypId { - x.line("r.EncodeStringBytes(codecSelferC_RAW" + x.xs + ", []byte(" + varname + "))") + x.line("r.EncodeStringBytes(codecSelferCcRAW" + x.xs + ", []byte(" + varname + "))") } else if fastpathAV.index(rtid) != -1 { g := x.newGenV(t) x.line("z.F." + g.MethodNamePfx("Enc", false) + "V(" + varname + ", e)") } else { - x.xtraSM(varname, true, t) + x.xtraSM(varname, t, true, false) // x.encListFallback(varname, rtid, t) } case reflect.Map: @@ -793,7 +828,7 @@ func (x *genRunner) enc(varname string, t reflect.Type) { g := x.newGenV(t) x.line("z.F." + g.MethodNamePfx("Enc", false) + "V(" + varname + ", e)") } else { - x.xtraSM(varname, true, t) + x.xtraSM(varname, t, true, false) // x.encMapFallback(varname, rtid, t) } case reflect.Struct: @@ -824,12 +859,53 @@ func (x *genRunner) encZero(t reflect.Type) { case reflect.Bool: x.line("r.EncodeBool(false)") case reflect.String: - x.line("r.EncodeString(codecSelferC_UTF8" + x.xs + `, "")`) + x.line("r.EncodeString(codecSelferCcUTF8" + x.xs + `, "")`) default: x.line("r.EncodeNil()") } } +func (x *genRunner) encOmitEmptyLine(t2 reflect.StructField, varname string, buf *genBuf) { + // smartly check omitEmpty on a struct type, as it may contain uncomparable map/slice/etc. + // also, for maps/slices/arrays, check if len ! 0 (not if == zero value) + varname2 := varname + "." + t2.Name + switch t2.Type.Kind() { + case reflect.Struct: + rtid2 := rt2id(t2.Type) + ti2 := x.ti.get(rtid2, t2.Type) + // fmt.Printf(">>>> structfield: omitempty: type: %s, field: %s\n", t2.Type.Name(), t2.Name) + if ti2.rtid == timeTypId { + buf.s("!(").s(varname2).s(".IsZero())") + break + } + if ti2.isFlag(typeInfoFlagIsZeroerPtr) || ti2.isFlag(typeInfoFlagIsZeroer) { + buf.s("!(").s(varname2).s(".IsZero())") + break + } + if ti2.isFlag(typeInfoFlagComparable) { + buf.s(varname2).s(" != ").s(x.genZeroValueR(t2.Type)) + break + } + // buf.s("(") + buf.s("false") + for i, n := 0, t2.Type.NumField(); i < n; i++ { + f := t2.Type.Field(i) + if f.PkgPath != "" { // unexported + continue + } + buf.s(" || ") + x.encOmitEmptyLine(f, varname2, buf) + } + //buf.s(")") + case reflect.Bool: + buf.s(varname2) + case reflect.Map, reflect.Slice, reflect.Array, reflect.Chan: + buf.s("len(").s(varname2).s(") != 0") + default: + buf.s(varname2).s(" != ").s(x.genZeroValueR(t2.Type)) + } +} + func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) { // Use knowledge from structfieldinfo (mbs, encodable fields. Ignore omitempty. ) // replicate code in kStruct i.e. for each field, deref type to non-pointer, and call x.enc on it @@ -844,29 +920,34 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) { x.line(sepVarname + " := !z.EncBinary()") x.linef("%s := z.EncBasicHandle().StructToArray", struct2arrvar) - tisfi := ti.sfip // always use sequence from file. decStruct expects same thing. + x.linef("_, _ = %s, %s", sepVarname, struct2arrvar) + x.linef("const %s bool = %v // struct tag has 'toArray'", ti2arrayvar, ti.toArray) + + tisfi := ti.sfiSrc // always use sequence from file. decStruct expects same thing. + + // var nn int // due to omitEmpty, we need to calculate the // number of non-empty things we write out first. // This is required as we need to pre-determine the size of the container, // to support length-prefixing. if ti.anyOmitEmpty { - x.linef("var %s [%v]bool", numfieldsvar, len(tisfi)) - x.linef("_ = %s", numfieldsvar) - } - x.linef("_, _ = %s, %s", sepVarname, struct2arrvar) - x.linef("const %s bool = %v", ti2arrayvar, ti.toArray) - var nn int - if ti.anyOmitEmpty { + x.linef("var %s = [%v]bool{ // should field at this index be written?", numfieldsvar, len(tisfi)) + for j, si := range tisfi { - if !si.omitEmpty { - nn++ + _ = j + if !si.omitEmpty() { + // x.linef("%s[%v] = true // %s", numfieldsvar, j, si.fieldName) + x.linef("true, // %s", si.fieldName) + // nn++ continue } var t2 reflect.StructField - var omitline string + var omitline genBuf { t2typ := t varname3 := varname + // go through the loop, record the t2 field explicitly, + // and gather the omit line if embedded in pointers. for ij, ix := range si.is { if uint8(ij) == si.nis { break @@ -877,30 +958,27 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) { t2 = t2typ.Field(int(ix)) t2typ = t2.Type varname3 = varname3 + "." + t2.Name - if t2typ.Kind() == reflect.Ptr { - omitline += varname3 + " != nil && " + // do not include actual field in the omit line. + // that is done subsequently (right after - below). + if uint8(ij+1) < si.nis && t2typ.Kind() == reflect.Ptr { + omitline.s(varname3).s(" != nil && ") } } } - // never check omitEmpty on a struct type, as it may contain uncomparable map/slice/etc. - // also, for maps/slices/arrays, check if len ! 0 (not if == zero value) - switch t2.Type.Kind() { - case reflect.Struct: - omitline += " true" - case reflect.Map, reflect.Slice, reflect.Array, reflect.Chan: - omitline += "len(" + varname + "." + t2.Name + ") != 0" - default: - omitline += varname + "." + t2.Name + " != " + x.genZeroValueR(t2.Type) - } - x.linef("%s[%v] = %s", numfieldsvar, j, omitline) + x.encOmitEmptyLine(t2, varname, &omitline) + x.linef("%s, // %s", omitline.v(), si.fieldName) } + x.line("}") + x.linef("_ = %s", numfieldsvar) } // x.linef("var %snn%s int", genTempVarPfx, i) x.linef("if %s || %s {", ti2arrayvar, struct2arrvar) // if ti.toArray { x.linef("r.WriteArrayStart(%d)", len(tisfi)) x.linef("} else {") // if not ti.toArray if ti.anyOmitEmpty { - x.linef("var %snn%s = %v", genTempVarPfx, i, nn) + // nn = 0 + // x.linef("var %snn%s = %v", genTempVarPfx, i, nn) + x.linef("var %snn%s int", genTempVarPfx, i) x.linef("for _, b := range %s { if b { %snn%s++ } }", numfieldsvar, genTempVarPfx, i) x.linef("r.WriteMapStart(%snn%s)", genTempVarPfx, i) x.linef("%snn%s = %v", genTempVarPfx, i, 0) @@ -921,7 +999,6 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) { if uint8(ij) == si.nis { break } - // fmt.Printf("%%%% %v, ix: %v\n", t2typ, ix) for t2typ.Kind() == reflect.Ptr { t2typ = t2typ.Elem() } @@ -949,14 +1026,13 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) { x.linef("if %s || %s {", ti2arrayvar, struct2arrvar) // if ti.toArray if labelUsed { x.linef("if %s { r.WriteArrayElem(); r.EncodeNil() } else { ", isNilVarName) - // x.linef("if %s { z.EncSendContainerState(codecSelfer_containerArrayElem%s); r.EncodeNil() } else { ", isNilVarName, x.xs) } - x.line("r.WriteArrayElem()") // x.linef("z.EncSendContainerState(codecSelfer_containerArrayElem%s)", x.xs) - if si.omitEmpty { + x.line("r.WriteArrayElem()") + if si.omitEmpty() { x.linef("if %s[%v] {", numfieldsvar, j) } x.encVar(varname+"."+t2.Name, t2.Type) - if si.omitEmpty { + if si.omitEmpty() { x.linef("} else {") x.encZero(t2.Type) x.linef("}") @@ -967,12 +1043,25 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) { x.linef("} else {") // if not ti.toArray - if si.omitEmpty { + if si.omitEmpty() { x.linef("if %s[%v] {", numfieldsvar, j) } - x.line("r.WriteMapElemKey()") // x.linef("z.EncSendContainerState(codecSelfer_containerMapKey%s)", x.xs) - x.line("r.EncodeString(codecSelferC_UTF8" + x.xs + ", string(\"" + si.encName + "\"))") - x.line("r.WriteMapElemValue()") // x.linef("z.EncSendContainerState(codecSelfer_containerMapValue%s)", x.xs) + x.line("r.WriteMapElemKey()") + + // x.line("r.EncodeString(codecSelferCcUTF8" + x.xs + ", `" + si.encName + "`)") + // emulate EncStructFieldKey + switch ti.keyType { + case valueTypeInt: + x.linef("r.EncodeInt(z.M.Int(strconv.ParseInt(`%s`, 10, 64)))", si.encName) + case valueTypeUint: + x.linef("r.EncodeUint(z.M.Uint(strconv.ParseUint(`%s`, 10, 64)))", si.encName) + case valueTypeFloat: + x.linef("r.EncodeFloat64(z.M.Float(strconv.ParseFloat(`%s`, 64)))", si.encName) + default: // string + x.linef("r.EncodeString(codecSelferCcUTF8%s, `%s`)", x.xs, si.encName) + } + // x.linef("r.EncStructFieldKey(codecSelferValueType%s%s, `%s`)", ti.keyType.String(), x.xs, si.encName) + x.line("r.WriteMapElemValue()") if labelUsed { x.line("if " + isNilVarName + " { r.EncodeNil() } else { ") x.encVar(varname+"."+t2.Name, t2.Type) @@ -980,26 +1069,26 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) { } else { x.encVar(varname+"."+t2.Name, t2.Type) } - if si.omitEmpty { + if si.omitEmpty() { x.line("}") } x.linef("} ") // end if/else ti.toArray } x.linef("if %s || %s {", ti2arrayvar, struct2arrvar) // if ti.toArray { - x.line("r.WriteArrayEnd()") // x.linef("z.EncSendContainerState(codecSelfer_containerArrayEnd%s)", x.xs) + x.line("r.WriteArrayEnd()") x.line("} else {") - x.line("r.WriteMapEnd()") // x.linef("z.EncSendContainerState(codecSelfer_containerMapEnd%s)", x.xs) + x.line("r.WriteMapEnd()") x.line("}") } func (x *genRunner) encListFallback(varname string, t reflect.Type) { if t.AssignableTo(uint8SliceTyp) { - x.linef("r.EncodeStringBytes(codecSelferC_RAW%s, []byte(%s))", x.xs, varname) + x.linef("r.EncodeStringBytes(codecSelferCcRAW%s, []byte(%s))", x.xs, varname) return } if t.Kind() == reflect.Array && t.Elem().Kind() == reflect.Uint8 { - x.linef("r.EncodeStringBytes(codecSelferC_RAW%s, ([%v]byte(%s))[:])", x.xs, t.Len(), varname) + x.linef("r.EncodeStringBytes(codecSelferCcRAW%s, ((*[%d]byte)(%s))[:])", x.xs, t.Len(), varname) return } i := x.varsfx() @@ -1007,16 +1096,15 @@ func (x *genRunner) encListFallback(varname string, t reflect.Type) { x.line("r.WriteArrayStart(len(" + varname + "))") if t.Kind() == reflect.Chan { x.linef("for %si%s, %si2%s := 0, len(%s); %si%s < %si2%s; %si%s++ {", g, i, g, i, varname, g, i, g, i, g, i) - x.line("r.WriteArrayElem()") // x.linef("z.EncSendContainerState(codecSelfer_containerArrayElem%s)", x.xs) + x.line("r.WriteArrayElem()") x.linef("%sv%s := <-%s", g, i, varname) } else { - // x.linef("for %si%s, %sv%s := range %s {", genTempVarPfx, i, genTempVarPfx, i, varname) x.linef("for _, %sv%s := range %s {", genTempVarPfx, i, varname) - x.line("r.WriteArrayElem()") // x.linef("z.EncSendContainerState(codecSelfer_containerArrayElem%s)", x.xs) + x.line("r.WriteArrayElem()") } x.encVar(genTempVarPfx+"v"+i, t.Elem()) x.line("}") - x.line("r.WriteArrayEnd()") // x.linef("z.EncSendContainerState(codecSelfer_containerArrayEnd%s)", x.xs) + x.line("r.WriteArrayEnd()") } func (x *genRunner) encMapFallback(varname string, t reflect.Type) { @@ -1024,94 +1112,154 @@ func (x *genRunner) encMapFallback(varname string, t reflect.Type) { i := x.varsfx() x.line("r.WriteMapStart(len(" + varname + "))") x.linef("for %sk%s, %sv%s := range %s {", genTempVarPfx, i, genTempVarPfx, i, varname) - // x.line("for " + genTempVarPfx + "k" + i + ", " + genTempVarPfx + "v" + i + " := range " + varname + " {") - x.line("r.WriteMapElemKey()") // f("z.EncSendContainerState(codecSelfer_containerMapKey%s)", x.xs) + x.line("r.WriteMapElemKey()") x.encVar(genTempVarPfx+"k"+i, t.Key()) - x.line("r.WriteMapElemValue()") // f("z.EncSendContainerState(codecSelfer_containerMapValue%s)", x.xs) + x.line("r.WriteMapElemValue()") x.encVar(genTempVarPfx+"v"+i, t.Elem()) x.line("}") - x.line("r.WriteMapEnd()") // f("z.EncSendContainerState(codecSelfer_containerMapEnd%s)", x.xs) + x.line("r.WriteMapEnd()") } -func (x *genRunner) decVar(varname, decodedNilVarname string, t reflect.Type, canBeNil bool) { - // We only encode as nil if a nillable value. - // This removes some of the wasted checks for TryDecodeAsNil. - // We need to think about this more, to see what happens if omitempty, etc - // cause a nil value to be stored when something is expected. - // This could happen when decoding from a struct encoded as an array. - // For that, decVar should be called with canNil=true, to force true as its value. - i := x.varsfx() - if !canBeNil { - canBeNil = genAnythingCanBeNil || !genIsImmutable(t) +func (x *genRunner) decVarInitPtr(varname, nilvar string, t reflect.Type, si *structFieldInfo, + newbuf, nilbuf *genBuf) (t2 reflect.StructField) { + //we must accommodate anonymous fields, where the embedded field is a nil pointer in the value. + // t2 = t.FieldByIndex(si.is) + t2typ := t + varname3 := varname + t2kind := t2typ.Kind() + var nilbufed bool + if si != nil { + for ij, ix := range si.is { + if uint8(ij) == si.nis { + break + } + for t2typ.Kind() == reflect.Ptr { + t2typ = t2typ.Elem() + } + t2 = t2typ.Field(int(ix)) + t2typ = t2.Type + varname3 = varname3 + "." + t2.Name + t2kind = t2typ.Kind() + if t2kind != reflect.Ptr { + continue + } + if newbuf != nil { + newbuf.f("if %s == nil { %s = new(%s) }\n", varname3, varname3, x.genTypeName(t2typ.Elem())) + } + if nilbuf != nil { + if !nilbufed { + nilbuf.s("if true") + nilbufed = true + } + nilbuf.s(" && ").s(varname3).s(" != nil") + } + } } - if canBeNil { - x.line("if r.TryDecodeAsNil() {") - if decodedNilVarname != "" { - x.line(decodedNilVarname + " = true") - } else if t.Kind() == reflect.Ptr { - x.line("if " + varname + " != nil { ") - - // if varname is a field of a struct (has a dot in it), - // then just set it to nil - if strings.IndexByte(varname, '.') != -1 { - x.line(varname + " = nil") + // if t2typ.Kind() == reflect.Ptr { + // varname3 = varname3 + t2.Name + // } + if nilbuf != nil { + if nilbufed { + nilbuf.s(" { ") + } + if nilvar != "" { + nilbuf.s(nilvar).s(" = true") + } else if tk := t2typ.Kind(); tk == reflect.Ptr { + if strings.IndexByte(varname3, '.') != -1 || strings.IndexByte(varname3, '[') != -1 { + nilbuf.s(varname3).s(" = nil") } else { - x.line("*" + varname + " = " + x.genZeroValueR(t.Elem())) + nilbuf.s("*").s(varname3).s(" = ").s(x.genZeroValueR(t2typ.Elem())) } - x.line("}") } else { - x.line(varname + " = " + x.genZeroValueR(t)) + nilbuf.s(varname3).s(" = ").s(x.genZeroValueR(t2typ)) + } + if nilbufed { + nilbuf.s("}") } - x.line("} else {") - } else { - x.line("// cannot be nil") } + return t2 +} + +// decVar takes a variable called varname, of type t +func (x *genRunner) decVarMain(varname, rand string, t reflect.Type, checkNotNil bool) { + // We only encode as nil if a nillable value. + // This removes some of the wasted checks for TryDecodeAsNil. + // We need to think about this more, to see what happens if omitempty, etc + // cause a nil value to be stored when something is expected. + // This could happen when decoding from a struct encoded as an array. + // For that, decVar should be called with canNil=true, to force true as its value. + var varname2 string if t.Kind() != reflect.Ptr { - if x.decTryAssignPrimitive(varname, t) { - x.line(genTempVarPfx + "v" + i + " := &" + varname) - x.dec(genTempVarPfx+"v"+i, t) + if t.PkgPath() != "" || !x.decTryAssignPrimitive(varname, t, false) { + x.dec(varname, t, false) } } else { - x.linef("if %s == nil { %s = new(%s) }", varname, varname, x.genTypeName(t.Elem())) + if checkNotNil { + x.linef("if %s == nil { %s = new(%s) }", varname, varname, x.genTypeName(t.Elem())) + } // Ensure we set underlying ptr to a non-nil value (so we can deref to it later). // There's a chance of a **T in here which is nil. var ptrPfx string for t = t.Elem(); t.Kind() == reflect.Ptr; t = t.Elem() { ptrPfx += "*" - x.linef("if %s%s == nil { %s%s = new(%s)}", - ptrPfx, varname, ptrPfx, varname, x.genTypeName(t)) - } - // if varname has [ in it, then create temp variable for this ptr thingie - if strings.Index(varname, "[") >= 0 { - varname2 := genTempVarPfx + "w" + i - x.line(varname2 + " := " + varname) - varname = varname2 + if checkNotNil { + x.linef("if %s%s == nil { %s%s = new(%s)}", + ptrPfx, varname, ptrPfx, varname, x.genTypeName(t)) + } } + // Should we create temp var if a slice/map indexing? No. dec(...) can now handle it. if ptrPfx == "" { - x.dec(varname, t) + x.dec(varname, t, true) } else { - x.line(genTempVarPfx + "z" + i + " := " + ptrPfx + varname) - x.dec(genTempVarPfx+"z"+i, t) + varname2 = genTempVarPfx + "z" + rand + x.line(varname2 + " := " + ptrPfx + varname) + x.dec(varname2, t, true) } + } +} + +// decVar takes a variable called varname, of type t +func (x *genRunner) decVar(varname, nilvar string, t reflect.Type, canBeNil, checkNotNil bool) { + i := x.varsfx() + + // We only encode as nil if a nillable value. + // This removes some of the wasted checks for TryDecodeAsNil. + // We need to think about this more, to see what happens if omitempty, etc + // cause a nil value to be stored when something is expected. + // This could happen when decoding from a struct encoded as an array. + // For that, decVar should be called with canNil=true, to force true as its value. + + if !canBeNil { + canBeNil = genAnythingCanBeNil || !genIsImmutable(t) + } + if canBeNil { + var buf genBuf + x.decVarInitPtr(varname, nilvar, t, nil, nil, &buf) + x.linef("if r.TryDecodeAsNil() { %s } else {", buf.buf) + } else { + x.line("// cannot be nil") } + x.decVarMain(varname, i, t, checkNotNil) + if canBeNil { x.line("} ") } } -// dec will decode a variable (varname) of type ptrTo(t). +// dec will decode a variable (varname) of type t or ptrTo(t) if isptr==true. // t is always a basetype (i.e. not of kind reflect.Ptr). -func (x *genRunner) dec(varname string, t reflect.Type) { +func (x *genRunner) dec(varname string, t reflect.Type, isptr bool) { // assumptions: // - the varname is to a pointer already. No need to take address of it // - t is always a baseType T (not a *T, etc). rtid := rt2id(t) - tptr := reflect.PtrTo(t) + ti2 := x.ti.get(rtid, t) + // tptr := reflect.PtrTo(t) if x.checkForSelfer(t, varname) { - if t.Implements(selferTyp) || tptr.Implements(selferTyp) { + if ti2.cs || ti2.csp { // t.Implements(selferTyp) || tptr.Implements(selferTyp) { x.line(varname + ".CodecDecodeSelf(d)") return } @@ -1140,100 +1288,61 @@ func (x *genRunner) dec(varname string, t reflect.Type) { } // check if - // - type is Raw, RawExt + // - type is time.Time, Raw, RawExt // - the type implements (Text|JSON|Binary)(Unm|M)arshal + mi := x.varsfx() - x.linef("%sm%s := z.DecBinary()", genTempVarPfx, mi) - x.linef("_ = %sm%s", genTempVarPfx, mi) + // x.linef("%sm%s := z.DecBinary()", genTempVarPfx, mi) + // x.linef("_ = %sm%s", genTempVarPfx, mi) x.line("if false {") //start if block defer func() { x.line("}") }() //end if block + var ptrPfx, addrPfx string + if isptr { + ptrPfx = "*" + } else { + addrPfx = "&" + } + if t == timeTyp { + x.linef("} else { %s%v = r.DecodeTime()", ptrPfx, varname) + return + } if t == rawTyp { - x.linef("} else { *%v = z.DecRaw()", varname) + x.linef("} else { %s%v = z.DecRaw()", ptrPfx, varname) return } + if t == rawExtTyp { - x.linef("} else { r.DecodeExt(%v, 0, nil)", varname) + x.linef("} else { r.DecodeExt(%s%v, 0, nil)", addrPfx, varname) return } - // HACK: Support for Builtins. - // Currently, only Binc supports builtins, and the only builtin type is time.Time. - // Have a method that returns the rtid for time.Time if Handle is Binc. - if t == timeTyp { - vrtid := genTempVarPfx + "m" + x.varsfx() - x.linef("} else if %s := z.TimeRtidIfBinc(); %s != 0 { ", vrtid, vrtid) - x.linef("r.DecodeBuiltin(%s, %s)", vrtid, varname) - } // only check for extensions if the type is named, and has a packagePath. if !x.nx && genImportPath(t) != "" && t.Name() != "" { // first check if extensions are configued, before doing the interface conversion - x.linef("} else if z.HasExtensions() && z.DecExt(%s) {", varname) + // x.linef("} else if z.HasExtensions() && z.DecExt(%s) {", varname) + yy := fmt.Sprintf("%sxt%s", genTempVarPfx, mi) + x.linef("} else if %s := z.Extension(z.I2Rtid(%s)); %s != nil { z.DecExtension(%s, %s) ", yy, varname, yy, varname, yy) } - if t.Implements(binaryUnmarshalerTyp) || tptr.Implements(binaryUnmarshalerTyp) { - x.linef("} else if %sm%s { z.DecBinaryUnmarshal(%v) ", genTempVarPfx, mi, varname) + if ti2.bu || ti2.bup { // t.Implements(binaryUnmarshalerTyp) || tptr.Implements(binaryUnmarshalerTyp) { + x.linef("} else if z.DecBinary() { z.DecBinaryUnmarshal(%s%v) ", addrPfx, varname) } - if t.Implements(jsonUnmarshalerTyp) || tptr.Implements(jsonUnmarshalerTyp) { - x.linef("} else if !%sm%s && z.IsJSONHandle() { z.DecJSONUnmarshal(%v)", genTempVarPfx, mi, varname) - } else if t.Implements(textUnmarshalerTyp) || tptr.Implements(textUnmarshalerTyp) { - x.linef("} else if !%sm%s { z.DecTextUnmarshal(%v)", genTempVarPfx, mi, varname) + if ti2.ju || ti2.jup { // t.Implements(jsonUnmarshalerTyp) || tptr.Implements(jsonUnmarshalerTyp) { + x.linef("} else if !z.DecBinary() && z.IsJSONHandle() { z.DecJSONUnmarshal(%s%v)", addrPfx, varname) + } else if ti2.tu || ti2.tup { // t.Implements(textUnmarshalerTyp) || tptr.Implements(textUnmarshalerTyp) { + x.linef("} else if !z.DecBinary() { z.DecTextUnmarshal(%s%v)", addrPfx, varname) } x.line("} else {") - // Since these are pointers, we cannot share, and have to use them one by one - switch t.Kind() { - case reflect.Int: - x.line("*((*int)(" + varname + ")) = int(r.DecodeInt(codecSelferBitsize" + x.xs + "))") - // x.line("z.DecInt((*int)(" + varname + "))") - case reflect.Int8: - x.line("*((*int8)(" + varname + ")) = int8(r.DecodeInt(8))") - // x.line("z.DecInt8((*int8)(" + varname + "))") - case reflect.Int16: - x.line("*((*int16)(" + varname + ")) = int16(r.DecodeInt(16))") - // x.line("z.DecInt16((*int16)(" + varname + "))") - case reflect.Int32: - x.line("*((*int32)(" + varname + ")) = int32(r.DecodeInt(32))") - // x.line("z.DecInt32((*int32)(" + varname + "))") - case reflect.Int64: - x.line("*((*int64)(" + varname + ")) = int64(r.DecodeInt(64))") - // x.line("z.DecInt64((*int64)(" + varname + "))") - - case reflect.Uint: - x.line("*((*uint)(" + varname + ")) = uint(r.DecodeUint(codecSelferBitsize" + x.xs + "))") - // x.line("z.DecUint((*uint)(" + varname + "))") - case reflect.Uint8: - x.line("*((*uint8)(" + varname + ")) = uint8(r.DecodeUint(8))") - // x.line("z.DecUint8((*uint8)(" + varname + "))") - case reflect.Uint16: - x.line("*((*uint16)(" + varname + ")) = uint16(r.DecodeUint(16))") - //x.line("z.DecUint16((*uint16)(" + varname + "))") - case reflect.Uint32: - x.line("*((*uint32)(" + varname + ")) = uint32(r.DecodeUint(32))") - //x.line("z.DecUint32((*uint32)(" + varname + "))") - case reflect.Uint64: - x.line("*((*uint64)(" + varname + ")) = uint64(r.DecodeUint(64))") - //x.line("z.DecUint64((*uint64)(" + varname + "))") - case reflect.Uintptr: - x.line("*((*uintptr)(" + varname + ")) = uintptr(r.DecodeUint(codecSelferBitsize" + x.xs + "))") - - case reflect.Float32: - x.line("*((*float32)(" + varname + ")) = float32(r.DecodeFloat(true))") - //x.line("z.DecFloat32((*float32)(" + varname + "))") - case reflect.Float64: - x.line("*((*float64)(" + varname + ")) = float64(r.DecodeFloat(false))") - // x.line("z.DecFloat64((*float64)(" + varname + "))") + if x.decTryAssignPrimitive(varname, t, isptr) { + return + } - case reflect.Bool: - x.line("*((*bool)(" + varname + ")) = r.DecodeBool()") - // x.line("z.DecBool((*bool)(" + varname + "))") - case reflect.String: - x.line("*((*string)(" + varname + ")) = r.DecodeString()") - // x.line("z.DecString((*string)(" + varname + "))") + switch t.Kind() { case reflect.Array, reflect.Chan: - x.xtraSM(varname, false, t) - // x.decListFallback(varname, rtid, true, t) + x.xtraSM(varname, t, false, isptr) case reflect.Slice: // if a []uint8, call dedicated function // if a known fastpath slice, call dedicated function @@ -1241,12 +1350,13 @@ func (x *genRunner) dec(varname string, t reflect.Type) { // - if elements are primitives or Selfers, call dedicated function on each member. // - else call Encoder.encode(XXX) on it. if rtid == uint8SliceTypId { - x.line("*" + varname + " = r.DecodeBytes(*(*[]byte)(" + varname + "), false)") + x.linef("%s%s = r.DecodeBytes(%s(%s[]byte)(%s), false)", + ptrPfx, varname, ptrPfx, ptrPfx, varname) } else if fastpathAV.index(rtid) != -1 { g := x.newGenV(t) - x.line("z.F." + g.MethodNamePfx("Dec", false) + "X(" + varname + ", d)") + x.linef("z.F.%sX(%s%s, d)", g.MethodNamePfx("Dec", false), addrPfx, varname) } else { - x.xtraSM(varname, false, t) + x.xtraSM(varname, t, false, isptr) // x.decListFallback(varname, rtid, false, t) } case reflect.Map: @@ -1256,74 +1366,80 @@ func (x *genRunner) dec(varname string, t reflect.Type) { // - else call Encoder.encode(XXX) on it. if fastpathAV.index(rtid) != -1 { g := x.newGenV(t) - x.line("z.F." + g.MethodNamePfx("Dec", false) + "X(" + varname + ", d)") + x.linef("z.F.%sX(%s%s, d)", g.MethodNamePfx("Dec", false), addrPfx, varname) } else { - x.xtraSM(varname, false, t) + x.xtraSM(varname, t, false, isptr) // x.decMapFallback(varname, rtid, t) } case reflect.Struct: if inlist { - x.decStruct(varname, rtid, t) + // no need to create temp variable if isptr, or x.F or x[F] + if isptr || strings.IndexByte(varname, '.') != -1 || strings.IndexByte(varname, '[') != -1 { + x.decStruct(varname, rtid, t) + } else { + varname2 := genTempVarPfx + "j" + mi + x.line(varname2 + " := &" + varname) + x.decStruct(varname2, rtid, t) + } } else { // delete(x.td, rtid) - x.line("z.DecFallback(" + varname + ", false)") + x.line("z.DecFallback(" + addrPfx + varname + ", false)") } default: if rtidAdded { delete(x.te, rtid) } - x.line("z.DecFallback(" + varname + ", true)") + x.line("z.DecFallback(" + addrPfx + varname + ", true)") } } -func (x *genRunner) decTryAssignPrimitive(varname string, t reflect.Type) (tryAsPtr bool) { +func (x *genRunner) decTryAssignPrimitive(varname string, t reflect.Type, isptr bool) (done bool) { // This should only be used for exact primitives (ie un-named types). // Named types may be implementations of Selfer, Unmarshaler, etc. // They should be handled by dec(...) - if t.Name() != "" { - tryAsPtr = true - return + var ptr string + if isptr { + ptr = "*" } - switch t.Kind() { case reflect.Int: - x.linef("%s = r.DecodeInt(codecSelferBitsize%s)", varname, x.xs) + x.linef("%s%s = (%s)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize%s))", ptr, varname, x.genTypeName(t), x.xs) case reflect.Int8: - x.linef("%s = r.DecodeInt(8)", varname) + x.linef("%s%s = (%s)(z.C.IntV(r.DecodeInt64(), 8))", ptr, varname, x.genTypeName(t)) case reflect.Int16: - x.linef("%s = r.DecodeInt(16)", varname) + x.linef("%s%s = (%s)(z.C.IntV(r.DecodeInt64(), 16))", ptr, varname, x.genTypeName(t)) case reflect.Int32: - x.linef("%s = r.DecodeInt(32)", varname) + x.linef("%s%s = (%s)(z.C.IntV(r.DecodeInt64(), 32))", ptr, varname, x.genTypeName(t)) case reflect.Int64: - x.linef("%s = r.DecodeInt(64)", varname) + x.linef("%s%s = (%s)(r.DecodeInt64())", ptr, varname, x.genTypeName(t)) case reflect.Uint: - x.linef("%s = r.DecodeUint(codecSelferBitsize%s)", varname, x.xs) + x.linef("%s%s = (%s)(z.C.UintV(r.DecodeUint64(), codecSelferBitsize%s))", ptr, varname, x.genTypeName(t), x.xs) case reflect.Uint8: - x.linef("%s = r.DecodeUint(8)", varname) + x.linef("%s%s = (%s)(z.C.UintV(r.DecodeUint64(), 8))", ptr, varname, x.genTypeName(t)) case reflect.Uint16: - x.linef("%s = r.DecodeUint(16)", varname) + x.linef("%s%s = (%s)(z.C.UintV(r.DecodeUint64(), 16))", ptr, varname, x.genTypeName(t)) case reflect.Uint32: - x.linef("%s = r.DecodeUint(32)", varname) + x.linef("%s%s = (%s)(z.C.UintV(r.DecodeUint64(), 32))", ptr, varname, x.genTypeName(t)) case reflect.Uint64: - x.linef("%s = r.DecodeUint(64)", varname) + x.linef("%s%s = (%s)(r.DecodeUint64())", ptr, varname, x.genTypeName(t)) case reflect.Uintptr: - x.linef("%s = r.DecodeUint(codecSelferBitsize%s)", varname, x.xs) + x.linef("%s%s = (%s)(z.C.UintV(r.DecodeUint64(), codecSelferBitsize%s))", ptr, varname, x.genTypeName(t), x.xs) case reflect.Float32: - x.linef("%s = r.DecodeFloat(true)", varname) + x.linef("%s%s = (%s)(r.DecodeFloat32As64())", ptr, varname, x.genTypeName(t)) case reflect.Float64: - x.linef("%s = r.DecodeFloat(false)", varname) + x.linef("%s%s = (%s)(r.DecodeFloat64())", ptr, varname, x.genTypeName(t)) case reflect.Bool: - x.linef("%s = r.DecodeBool()", varname) + x.linef("%s%s = (%s)(r.DecodeBool())", ptr, varname, x.genTypeName(t)) case reflect.String: - x.linef("%s = r.DecodeString()", varname) + x.linef("%s%s = (%s)(r.DecodeString())", ptr, varname, x.genTypeName(t)) default: - tryAsPtr = true + return false } - return + return true } func (x *genRunner) decListFallback(varname string, rtid uintptr, t reflect.Type) { @@ -1332,7 +1448,7 @@ func (x *genRunner) decListFallback(varname string, rtid uintptr, t reflect.Type return } if t.Kind() == reflect.Array && t.Elem().Kind() == reflect.Uint8 { - x.linef("r.DecodeBytes( ((*[%s]byte)(%s))[:], true)", t.Len(), varname) + x.linef("r.DecodeBytes( ((*[%d]byte)(%s))[:], true)", t.Len(), varname) return } type tstruc struct { @@ -1350,13 +1466,9 @@ func (x *genRunner) decListFallback(varname string, rtid uintptr, t reflect.Type funcs := make(template.FuncMap) funcs["decLineVar"] = func(varname string) string { - x.decVar(varname, "", telem, false) + x.decVar(varname, "", telem, false, true) return "" } - // funcs["decLine"] = func(pfx string) string { - // x.decVar(ts.TempVar+pfx+ts.Rand, "", reflect.PtrTo(telem), false) - // return "" - // } funcs["var"] = func(s string) string { return ts.TempVar + s + ts.Rand } @@ -1412,21 +1524,13 @@ func (x *genRunner) decMapFallback(varname string, rtid uintptr, t reflect.Type) return telem.Kind() == reflect.Interface } funcs["decLineVarK"] = func(varname string) string { - x.decVar(varname, "", tkey, false) + x.decVar(varname, "", tkey, false, true) return "" } funcs["decLineVar"] = func(varname, decodedNilVarname string) string { - x.decVar(varname, decodedNilVarname, telem, false) + x.decVar(varname, decodedNilVarname, telem, false, true) return "" } - // funcs["decLineK"] = func(pfx string) string { - // x.decVar(ts.TempVar+pfx+ts.Rand, reflect.PtrTo(tkey), false) - // return "" - // } - // funcs["decLine"] = func(pfx string) string { - // x.decVar(ts.TempVar+pfx+ts.Rand, reflect.PtrTo(telem), false) - // return "" - // } funcs["var"] = func(s string) string { return ts.TempVar + s + ts.Rand } @@ -1442,32 +1546,17 @@ func (x *genRunner) decMapFallback(varname string, rtid uintptr, t reflect.Type) func (x *genRunner) decStructMapSwitch(kName string, varname string, rtid uintptr, t reflect.Type) { ti := x.ti.get(rtid, t) - tisfi := ti.sfip // always use sequence from file. decStruct expects same thing. + tisfi := ti.sfiSrc // always use sequence from file. decStruct expects same thing. x.line("switch (" + kName + ") {") + var newbuf, nilbuf genBuf for _, si := range tisfi { x.line("case \"" + si.encName + "\":") - var t2 reflect.StructField - { - //we must accommodate anonymous fields, where the embedded field is a nil pointer in the value. - // t2 = t.FieldByIndex(si.is) - t2typ := t - varname3 := varname - for ij, ix := range si.is { - if uint8(ij) == si.nis { - break - } - for t2typ.Kind() == reflect.Ptr { - t2typ = t2typ.Elem() - } - t2 = t2typ.Field(int(ix)) - t2typ = t2.Type - varname3 = varname3 + "." + t2.Name - if t2typ.Kind() == reflect.Ptr { - x.linef("if %s == nil { %s = new(%s) }", varname3, varname3, x.genTypeName(t2typ.Elem())) - } - } - } - x.decVar(varname+"."+t2.Name, "", t2.Type, false) + newbuf.reset() + nilbuf.reset() + t2 := x.decVarInitPtr(varname, "", t, si, &newbuf, &nilbuf) + x.linef("if r.TryDecodeAsNil() { %s } else { %s", nilbuf.buf, newbuf.buf) + x.decVarMain(varname+"."+t2.Name, x.varsfx(), t2.Type, false) + x.line("}") } x.line("default:") // pass the slice here, so that the string will not escape, and maybe save allocation @@ -1477,16 +1566,10 @@ func (x *genRunner) decStructMapSwitch(kName string, varname string, rtid uintpt func (x *genRunner) decStructMap(varname, lenvarname string, rtid uintptr, t reflect.Type, style genStructMapStyle) { tpfx := genTempVarPfx + ti := x.ti.get(rtid, t) i := x.varsfx() kName := tpfx + "s" + i - // x.line("var " + kName + "Arr = [32]byte{} // default string to decode into") - // x.line("var " + kName + "Slc = " + kName + "Arr[:] // default slice to decode into") - // use the scratch buffer to avoid allocation (most field names are < 32). - - x.line("var " + kName + "Slc = z.DecScratchBuffer() // default slice to decode into") - - x.line("_ = " + kName + "Slc") switch style { case genStructMapStyleLenPrefix: x.linef("for %sj%s := 0; %sj%s < %s; %sj%s++ {", tpfx, i, tpfx, i, lenvarname, tpfx, i) @@ -1498,55 +1581,49 @@ func (x *genRunner) decStructMap(varname, lenvarname string, rtid uintptr, t ref x.linef("if %shl%s { if %sj%s >= %s { break }", tpfx, i, tpfx, i, lenvarname) x.line("} else { if r.CheckBreak() { break }; }") } - x.line("r.ReadMapElemKey()") // f("z.DecSendContainerState(codecSelfer_containerMapKey%s)", x.xs) - x.line(kName + "Slc = r.DecodeStringAsBytes()") - // let string be scoped to this loop alone, so it doesn't escape. - x.line(kName + " := string(" + kName + "Slc)") - x.line("r.ReadMapElemValue()") // f("z.DecSendContainerState(codecSelfer_containerMapValue%s)", x.xs) + x.line("r.ReadMapElemKey()") + + // emulate decstructfieldkey + switch ti.keyType { + case valueTypeInt: + x.linef("%s := z.StringView(strconv.AppendInt(z.DecScratchArrayBuffer()[:0], r.DecodeInt64(), 10))", kName) + case valueTypeUint: + x.linef("%s := z.StringView(strconv.AppendUint(z.DecScratchArrayBuffer()[:0], r.DecodeUint64(), 10))", kName) + case valueTypeFloat: + x.linef("%s := z.StringView(strconv.AppendFloat(z.DecScratchArrayBuffer()[:0], r.DecodeFloat64(), 'f', -1, 64))", kName) + default: // string + x.linef("%s := z.StringView(r.DecodeStringAsBytes())", kName) + } + // x.linef("%s := z.StringView(r.DecStructFieldKey(codecSelferValueType%s%s, z.DecScratchArrayBuffer()))", kName, ti.keyType.String(), x.xs) + + x.line("r.ReadMapElemValue()") x.decStructMapSwitch(kName, varname, rtid, t) x.line("} // end for " + tpfx + "j" + i) - x.line("r.ReadMapEnd()") // f("z.DecSendContainerState(codecSelfer_containerMapEnd%s)", x.xs) + x.line("r.ReadMapEnd()") } func (x *genRunner) decStructArray(varname, lenvarname, breakString string, rtid uintptr, t reflect.Type) { tpfx := genTempVarPfx i := x.varsfx() ti := x.ti.get(rtid, t) - tisfi := ti.sfip // always use sequence from file. decStruct expects same thing. + tisfi := ti.sfiSrc // always use sequence from file. decStruct expects same thing. x.linef("var %sj%s int", tpfx, i) x.linef("var %sb%s bool", tpfx, i) // break x.linef("var %shl%s bool = %s >= 0", tpfx, i, lenvarname) // has length + var newbuf, nilbuf genBuf for _, si := range tisfi { - var t2 reflect.StructField - { - //we must accommodate anonymous fields, where the embedded field is a nil pointer in the value. - // t2 = t.FieldByIndex(si.is) - t2typ := t - varname3 := varname - for ij, ix := range si.is { - if uint8(ij) == si.nis { - break - } - for t2typ.Kind() == reflect.Ptr { - t2typ = t2typ.Elem() - } - t2 = t2typ.Field(int(ix)) - t2typ = t2.Type - varname3 = varname3 + "." + t2.Name - if t2typ.Kind() == reflect.Ptr { - x.linef("if %s == nil { %s = new(%s) }", varname3, varname3, x.genTypeName(t2typ.Elem())) - } - } - } - x.linef("%sj%s++; if %shl%s { %sb%s = %sj%s > %s } else { %sb%s = r.CheckBreak() }", tpfx, i, tpfx, i, tpfx, i, tpfx, i, lenvarname, tpfx, i) x.linef("if %sb%s { r.ReadArrayEnd(); %s }", tpfx, i, breakString) - // x.linef("if %sb%s { z.DecSendContainerState(codecSelfer_containerArrayEnd%s); %s }", tpfx, i, x.xs, breakString) - x.line("r.ReadArrayElem()") // f("z.DecSendContainerState(codecSelfer_containerArrayElem%s)", x.xs) - x.decVar(varname+"."+t2.Name, "", t2.Type, true) + x.line("r.ReadArrayElem()") + newbuf.reset() + nilbuf.reset() + t2 := x.decVarInitPtr(varname, "", t, si, &newbuf, &nilbuf) + x.linef("if r.TryDecodeAsNil() { %s } else { %s", nilbuf.buf, newbuf.buf) + x.decVarMain(varname+"."+t2.Name, x.varsfx(), t2.Type, false) + x.line("}") } // read remaining values and throw away. x.line("for {") @@ -1554,28 +1631,28 @@ func (x *genRunner) decStructArray(varname, lenvarname, breakString string, rtid tpfx, i, tpfx, i, tpfx, i, tpfx, i, lenvarname, tpfx, i) x.linef("if %sb%s { break }", tpfx, i) - x.line("r.ReadArrayElem()") // f("z.DecSendContainerState(codecSelfer_containerArrayElem%s)", x.xs) + x.line("r.ReadArrayElem()") x.linef(`z.DecStructFieldNotFound(%sj%s - 1, "")`, tpfx, i) x.line("}") - x.line("r.ReadArrayEnd()") // f("z.DecSendContainerState(codecSelfer_containerArrayEnd%s)", x.xs) + x.line("r.ReadArrayEnd()") } func (x *genRunner) decStruct(varname string, rtid uintptr, t reflect.Type) { - // if container is map + // varname MUST be a ptr, or a struct field or a slice element. i := x.varsfx() x.linef("%sct%s := r.ContainerType()", genTempVarPfx, i) x.linef("if %sct%s == codecSelferValueTypeMap%s {", genTempVarPfx, i, x.xs) x.line(genTempVarPfx + "l" + i + " := r.ReadMapStart()") x.linef("if %sl%s == 0 {", genTempVarPfx, i) - x.line("r.ReadMapEnd()") // f("z.DecSendContainerState(codecSelfer_containerMapEnd%s)", x.xs) + x.line("r.ReadMapEnd()") if genUseOneFunctionForDecStructMap { x.line("} else { ") - x.linef("x.codecDecodeSelfFromMap(%sl%s, d)", genTempVarPfx, i) + x.linef("%s.codecDecodeSelfFromMap(%sl%s, d)", varname, genTempVarPfx, i) } else { x.line("} else if " + genTempVarPfx + "l" + i + " > 0 { ") - x.line("x.codecDecodeSelfFromMapLenPrefix(" + genTempVarPfx + "l" + i + ", d)") + x.line(varname + ".codecDecodeSelfFromMapLenPrefix(" + genTempVarPfx + "l" + i + ", d)") x.line("} else {") - x.line("x.codecDecodeSelfFromMapCheckBreak(" + genTempVarPfx + "l" + i + ", d)") + x.line(varname + ".codecDecodeSelfFromMapCheckBreak(" + genTempVarPfx + "l" + i + ", d)") } x.line("}") @@ -1583,13 +1660,13 @@ func (x *genRunner) decStruct(varname string, rtid uintptr, t reflect.Type) { x.linef("} else if %sct%s == codecSelferValueTypeArray%s {", genTempVarPfx, i, x.xs) x.line(genTempVarPfx + "l" + i + " := r.ReadArrayStart()") x.linef("if %sl%s == 0 {", genTempVarPfx, i) - x.line("r.ReadArrayEnd()") // f("z.DecSendContainerState(codecSelfer_containerArrayEnd%s)", x.xs) + x.line("r.ReadArrayEnd()") x.line("} else { ") - x.linef("x.codecDecodeSelfFromArray(%sl%s, d)", genTempVarPfx, i) + x.linef("%s.codecDecodeSelfFromArray(%sl%s, d)", varname, genTempVarPfx, i) x.line("}") // else panic x.line("} else { ") - x.line("panic(codecSelferOnlyMapOrArrayEncodeToStructErr" + x.xs + ")") + x.line("panic(errCodecSelferOnlyMapOrArrayEncodeToStruct" + x.xs + ")") x.line("} ") } @@ -1649,7 +1726,7 @@ func genImportPath(t reflect.Type) (s string) { s = t.PkgPath() if genCheckVendor { // HACK: always handle vendoring. It should be typically on in go 1.6, 1.7 - s = stripVendor(s) + s = genStripVendor(s) } return } @@ -1777,7 +1854,7 @@ type genInternal struct { func (x genInternal) FastpathLen() (l int) { for _, v := range x.Values { - if v.Primitive == "" { + if v.Primitive == "" && !(v.MapKey == "" && v.Elem == "uint8") { l++ } } @@ -1797,6 +1874,32 @@ func genInternalZeroValue(s string) string { } } +var genInternalNonZeroValueIdx [5]uint64 +var genInternalNonZeroValueStrs = [2][5]string{ + {`"string-is-an-interface"`, "true", `"some-string"`, "11.1", "33"}, + {`"string-is-an-interface-2"`, "true", `"some-string-2"`, "22.2", "44"}, +} + +func genInternalNonZeroValue(s string) string { + switch s { + case "interface{}", "interface {}": + genInternalNonZeroValueIdx[0]++ + return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[0]%2][0] // return string, to remove ambiguity + case "bool": + genInternalNonZeroValueIdx[1]++ + return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[1]%2][1] + case "string": + genInternalNonZeroValueIdx[2]++ + return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[2]%2][2] + case "float32", "float64", "float", "double": + genInternalNonZeroValueIdx[3]++ + return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[3]%2][3] + default: + genInternalNonZeroValueIdx[4]++ + return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[4]%2][4] + } +} + func genInternalEncCommandAsString(s string, vname string) string { switch s { case "uint", "uint8", "uint16", "uint32", "uint64": @@ -1804,15 +1907,15 @@ func genInternalEncCommandAsString(s string, vname string) string { case "int", "int8", "int16", "int32", "int64": return "ee.EncodeInt(int64(" + vname + "))" case "string": - return "ee.EncodeString(c_UTF8, " + vname + ")" + return "ee.EncodeString(cUTF8, " + vname + ")" case "float32": return "ee.EncodeFloat32(" + vname + ")" case "float64": return "ee.EncodeFloat64(" + vname + ")" case "bool": return "ee.EncodeBool(" + vname + ")" - case "symbol": - return "ee.EncodeSymbol(" + vname + ")" + // case "symbol": + // return "ee.EncodeSymbol(" + vname + ")" default: return "e.encode(" + vname + ")" } @@ -1821,34 +1924,34 @@ func genInternalEncCommandAsString(s string, vname string) string { func genInternalDecCommandAsString(s string) string { switch s { case "uint": - return "uint(dd.DecodeUint(uintBitsize))" + return "uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))" case "uint8": - return "uint8(dd.DecodeUint(8))" + return "uint8(chkOvf.UintV(dd.DecodeUint64(), 8))" case "uint16": - return "uint16(dd.DecodeUint(16))" + return "uint16(chkOvf.UintV(dd.DecodeUint64(), 16))" case "uint32": - return "uint32(dd.DecodeUint(32))" + return "uint32(chkOvf.UintV(dd.DecodeUint64(), 32))" case "uint64": - return "dd.DecodeUint(64)" + return "dd.DecodeUint64()" case "uintptr": - return "uintptr(dd.DecodeUint(uintBitsize))" + return "uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))" case "int": - return "int(dd.DecodeInt(intBitsize))" + return "int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))" case "int8": - return "int8(dd.DecodeInt(8))" + return "int8(chkOvf.IntV(dd.DecodeInt64(), 8))" case "int16": - return "int16(dd.DecodeInt(16))" + return "int16(chkOvf.IntV(dd.DecodeInt64(), 16))" case "int32": - return "int32(dd.DecodeInt(32))" + return "int32(chkOvf.IntV(dd.DecodeInt64(), 32))" case "int64": - return "dd.DecodeInt(64)" + return "dd.DecodeInt64()" case "string": return "dd.DecodeString()" case "float32": - return "float32(dd.DecodeFloat(true))" + return "float32(chkOvf.Float32V(dd.DecodeFloat64()))" case "float64": - return "dd.DecodeFloat(false)" + return "dd.DecodeFloat64()" case "bool": return "dd.DecodeBool()" default: @@ -1872,7 +1975,7 @@ func genInternalSortType(s string, elem bool) string { panic("sorttype: unexpected type: " + s) } -func stripVendor(s string) string { +func genStripVendor(s string) string { // HACK: Misbehaviour occurs in go 1.5. May have to re-visit this later. // if s contains /vendor/ OR startsWith vendor/, then return everything after it. const vendorStart = "vendor/" @@ -1954,9 +2057,10 @@ func genInternalInit() { // For each slice or map type, there must be a (symmetrical) Encode and Decode fast-path function for _, s := range types { gt.Values = append(gt.Values, genV{Primitive: s, Size: mapvaltypes2[s]}) - if s != "uint8" { // do not generate fast path for slice of bytes. Treat specially already. - gt.Values = append(gt.Values, genV{Elem: s, Size: mapvaltypes2[s]}) - } + // if s != "uint8" { // do not generate fast path for slice of bytes. Treat specially already. + // gt.Values = append(gt.Values, genV{Elem: s, Size: mapvaltypes2[s]}) + // } + gt.Values = append(gt.Values, genV{Elem: s, Size: mapvaltypes2[s]}) if _, ok := mapvaltypes2[s]; !ok { gt.Values = append(gt.Values, genV{MapKey: s, Elem: s, Size: 2 * mapvaltypes2[s]}) } @@ -1970,6 +2074,7 @@ func genInternalInit() { funcs["encmd"] = genInternalEncCommandAsString funcs["decmd"] = genInternalDecCommandAsString funcs["zerocmd"] = genInternalZeroValue + funcs["nonzerocmd"] = genInternalNonZeroValue funcs["hasprefix"] = strings.HasPrefix funcs["sorttype"] = genInternalSortType diff --git a/vendor/github.com/ugorji/go/codec/goversion_arrayof_gte_go15.go b/vendor/github.com/ugorji/go/codec/goversion_arrayof_gte_go15.go index 7567e2c07..9ddbe2059 100644 --- a/vendor/github.com/ugorji/go/codec/goversion_arrayof_gte_go15.go +++ b/vendor/github.com/ugorji/go/codec/goversion_arrayof_gte_go15.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. // +build go1.5 diff --git a/vendor/github.com/ugorji/go/codec/goversion_arrayof_lt_go15.go b/vendor/github.com/ugorji/go/codec/goversion_arrayof_lt_go15.go index ec94bd0c0..c5fcd6697 100644 --- a/vendor/github.com/ugorji/go/codec/goversion_arrayof_lt_go15.go +++ b/vendor/github.com/ugorji/go/codec/goversion_arrayof_lt_go15.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. // +build !go1.5 diff --git a/vendor/github.com/ugorji/go/codec/goversion_makemap_gte_go19.go b/vendor/github.com/ugorji/go/codec/goversion_makemap_gte_go19.go index 51fe40e5b..bc39d6b71 100644 --- a/vendor/github.com/ugorji/go/codec/goversion_makemap_gte_go19.go +++ b/vendor/github.com/ugorji/go/codec/goversion_makemap_gte_go19.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. // +build go1.9 diff --git a/vendor/github.com/ugorji/go/codec/goversion_makemap_lt_go19.go b/vendor/github.com/ugorji/go/codec/goversion_makemap_lt_go19.go index d4b9c2c8d..cde4cd372 100644 --- a/vendor/github.com/ugorji/go/codec/goversion_makemap_lt_go19.go +++ b/vendor/github.com/ugorji/go/codec/goversion_makemap_lt_go19.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. // +build !go1.9 diff --git a/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_gte_go110.go b/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_gte_go110.go new file mode 100644 index 000000000..794133a3c --- /dev/null +++ b/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_gte_go110.go @@ -0,0 +1,8 @@ +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. +// Use of this source code is governed by a MIT license found in the LICENSE file. + +// +build go1.10 + +package codec + +const allowSetUnexportedEmbeddedPtr = false diff --git a/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_lt_go110.go b/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_lt_go110.go new file mode 100644 index 000000000..fd92ede35 --- /dev/null +++ b/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_lt_go110.go @@ -0,0 +1,8 @@ +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. +// Use of this source code is governed by a MIT license found in the LICENSE file. + +// +build !go1.10 + +package codec + +const allowSetUnexportedEmbeddedPtr = true diff --git a/vendor/github.com/ugorji/go/codec/goversion_unsupported_lt_go14.go b/vendor/github.com/ugorji/go/codec/goversion_unsupported_lt_go14.go index dcd8c3d11..8debfa613 100644 --- a/vendor/github.com/ugorji/go/codec/goversion_unsupported_lt_go14.go +++ b/vendor/github.com/ugorji/go/codec/goversion_unsupported_lt_go14.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. // +build !go1.4 diff --git a/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go15.go b/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go15.go index 68626e1ce..0f1bb01e5 100644 --- a/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go15.go +++ b/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go15.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. // +build go1.5,!go1.6 diff --git a/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go16.go b/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go16.go index 344f5967b..2fb4b057d 100644 --- a/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go16.go +++ b/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go16.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. // +build go1.6,!go1.7 diff --git a/vendor/github.com/ugorji/go/codec/goversion_vendor_gte_go17.go b/vendor/github.com/ugorji/go/codec/goversion_vendor_gte_go17.go index de91d2940..c5b815505 100644 --- a/vendor/github.com/ugorji/go/codec/goversion_vendor_gte_go17.go +++ b/vendor/github.com/ugorji/go/codec/goversion_vendor_gte_go17.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. // +build go1.7 diff --git a/vendor/github.com/ugorji/go/codec/goversion_vendor_lt_go15.go b/vendor/github.com/ugorji/go/codec/goversion_vendor_lt_go15.go index 9d007bfed..837cf240b 100644 --- a/vendor/github.com/ugorji/go/codec/goversion_vendor_lt_go15.go +++ b/vendor/github.com/ugorji/go/codec/goversion_vendor_lt_go15.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. // +build !go1.5 diff --git a/vendor/github.com/ugorji/go/codec/helper.go b/vendor/github.com/ugorji/go/codec/helper.go index b846df0d8..35f71d645 100644 --- a/vendor/github.com/ugorji/go/codec/helper.go +++ b/vendor/github.com/ugorji/go/codec/helper.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. package codec @@ -102,8 +102,8 @@ import ( "encoding/binary" "errors" "fmt" + "io" "math" - "os" "reflect" "sort" "strconv" @@ -128,42 +128,14 @@ const ( // allowing zero-alloc initialization. arrayCacheLen = 8 - // We tried an optimization, where we detect if a type is one of the known types - // we optimized for (e.g. int, []uint64, etc). - // - // However, we notice some worse performance when using this optimization. - // So we hide it behind a flag, to turn on if needed. - useLookupRecognizedTypes = false + // size of the cacheline: defaulting to value for archs: amd64, arm64, 386 + // should use "runtime/internal/sys".CacheLineSize, but that is not exposed. + cacheLineSize = 64 - // using recognized allows us to do d.decode(interface{}) instead of d.decodeValue(reflect.Value) - // when we can infer that the kind of the interface{} is one of the ones hard-coded in the - // type switch for known types or the ones defined by fast-path. - // - // However, it seems we get better performance when we don't recognize, and just let - // reflection handle it. - // - // Reasoning is as below: - // typeswitch is a binary search with a branch to a code-point. - // getdecfn is a binary search with a call to a function pointer. - // - // both are about the same. - // - // so: why prefer typeswitch? - // - // is recognized does the following: - // - lookup rtid - // - check if in sorted list - // - calls decode(type switch) - // - 1 or 2 binary search to a point in code - // - branch there - // - // vs getdecfn - // - lookup rtid - // - check in sorted list for a function pointer - // - calls it to decode using reflection (optimized) + wordSizeBits = strconv.IntSize + wordSize = wordSizeBits / 8 - // always set xDebug = false before releasing software - xDebug = true + maxLevelsEmbedding = 15 // use this, so structFieldInfo fits into 8 bytes ) var ( @@ -171,29 +143,28 @@ var ( zeroByteSlice = oneByteArr[:0:0] ) +var refBitset bitset32 var pool pooler +var panicv panicHdl func init() { pool.init() -} - -// type findCodecFnMode uint8 -// const ( -// findCodecFnModeMap findCodecFnMode = iota -// findCodecFnModeBinarySearch -// findCodecFnModeLinearSearch -// ) + refBitset.set(byte(reflect.Map)) + refBitset.set(byte(reflect.Ptr)) + refBitset.set(byte(reflect.Func)) + refBitset.set(byte(reflect.Chan)) +} type charEncoding uint8 const ( - c_RAW charEncoding = iota - c_UTF8 - c_UTF16LE - c_UTF16BE - c_UTF32LE - c_UTF32BE + cRAW charEncoding = iota + cUTF8 + cUTF16LE + cUTF16BE + cUTF32LE + cUTF32BE ) // valueType is the stream type @@ -211,38 +182,31 @@ const ( valueTypeBytes valueTypeMap valueTypeArray - valueTypeTimestamp + valueTypeTime valueTypeExt // valueTypeInvalid = 0xff ) +var valueTypeStrings = [...]string{ + "Unset", + "Nil", + "Int", + "Uint", + "Float", + "Bool", + "String", + "Symbol", + "Bytes", + "Map", + "Array", + "Timestamp", + "Ext", +} + func (x valueType) String() string { - switch x { - case valueTypeNil: - return "Nil" - case valueTypeInt: - return "Int" - case valueTypeUint: - return "Uint" - case valueTypeFloat: - return "Float" - case valueTypeBool: - return "Bool" - case valueTypeString: - return "String" - case valueTypeSymbol: - return "Symbol" - case valueTypeBytes: - return "Bytes" - case valueTypeMap: - return "Map" - case valueTypeArray: - return "Array" - case valueTypeTimestamp: - return "Timestamp" - case valueTypeExt: - return "Ext" + if int(x) < len(valueTypeStrings) { + return valueTypeStrings[x] } return strconv.FormatInt(int64(x), 10) } @@ -272,11 +236,11 @@ const ( containerArrayEnd ) -// sfiIdx used for tracking where a (field/enc)Name is seen in a []*structFieldInfo -type sfiIdx struct { - name string - index int -} +// // sfiIdx used for tracking where a (field/enc)Name is seen in a []*structFieldInfo +// type sfiIdx struct { +// name string +// index int +// } // do not recurse if a containing type refers to an embedded type // which refers back to its containing type (via a pointer). @@ -285,30 +249,39 @@ type sfiIdx struct { const rgetMaxRecursion = 2 // Anecdotally, we believe most types have <= 12 fields. -// Java's PMD rules set TooManyFields threshold to 15. -const typeInfoLoadArrayLen = 12 +// - even Java's PMD rules set TooManyFields threshold to 15. +// However, go has embedded fields, which should be regarded as +// top level, allowing structs to possibly double or triple. +// In addition, we don't want to keep creating transient arrays, +// especially for the sfi index tracking, and the evtypes tracking. +// +// So - try to keep typeInfoLoadArray within 2K bytes +const ( + typeInfoLoadArraySfisLen = 16 + typeInfoLoadArraySfiidxLen = 8 * 112 + typeInfoLoadArrayEtypesLen = 12 + typeInfoLoadArrayBLen = 8 * 4 +) type typeInfoLoad struct { - fNames []string - encNames []string - etypes []uintptr - sfis []*structFieldInfo + // fNames []string + // encNames []string + etypes []uintptr + sfis []structFieldInfo } type typeInfoLoadArray struct { - fNames [typeInfoLoadArrayLen]string - encNames [typeInfoLoadArrayLen]string - etypes [typeInfoLoadArrayLen]uintptr - sfis [typeInfoLoadArrayLen]*structFieldInfo - sfiidx [typeInfoLoadArrayLen]sfiIdx + // fNames [typeInfoLoadArrayLen]string + // encNames [typeInfoLoadArrayLen]string + sfis [typeInfoLoadArraySfisLen]structFieldInfo + sfiidx [typeInfoLoadArraySfiidxLen]byte + etypes [typeInfoLoadArrayEtypesLen]uintptr + b [typeInfoLoadArrayBLen]byte // scratch - used for struct field names } -// type containerStateRecv interface { -// sendContainerState(containerState) -// } - // mirror json.Marshaler and json.Unmarshaler here, // so we don't import the encoding/json package + type jsonMarshaler interface { MarshalJSON() ([]byte, error) } @@ -316,6 +289,10 @@ type jsonUnmarshaler interface { UnmarshalJSON([]byte) error } +type isZeroer interface { + IsZero() bool +} + // type byteAccepter func(byte) bool var ( @@ -327,11 +304,17 @@ var ( intfSliceTyp = reflect.TypeOf([]interface{}(nil)) intfTyp = intfSliceTyp.Elem() + reflectValTyp = reflect.TypeOf((*reflect.Value)(nil)).Elem() + stringTyp = reflect.TypeOf("") timeTyp = reflect.TypeOf(time.Time{}) rawExtTyp = reflect.TypeOf(RawExt{}) rawTyp = reflect.TypeOf(Raw{}) + uintptrTyp = reflect.TypeOf(uintptr(0)) + uint8Typ = reflect.TypeOf(uint8(0)) uint8SliceTyp = reflect.TypeOf([]uint8(nil)) + uintTyp = reflect.TypeOf(uint(0)) + intTyp = reflect.TypeOf(int(0)) mapBySliceTyp = reflect.TypeOf((*MapBySlice)(nil)).Elem() @@ -345,7 +328,9 @@ var ( jsonUnmarshalerTyp = reflect.TypeOf((*jsonUnmarshaler)(nil)).Elem() selferTyp = reflect.TypeOf((*Selfer)(nil)).Elem() + iszeroTyp = reflect.TypeOf((*isZeroer)(nil)).Elem() + uint8TypId = rt2id(uint8Typ) uint8SliceTypId = rt2id(uint8SliceTyp) rawExtTypId = rt2id(rawExtTyp) rawTypId = rt2id(rawTyp) @@ -358,15 +343,15 @@ var ( intfSliceTypId = rt2id(intfSliceTyp) // mapBySliceTypId = rt2id(mapBySliceTyp) - intBitsize uint8 = uint8(reflect.TypeOf(int(0)).Bits()) - uintBitsize uint8 = uint8(reflect.TypeOf(uint(0)).Bits()) + intBitsize = uint8(intTyp.Bits()) + uintBitsize = uint8(uintTyp.Bits()) bsAll0x00 = []byte{0, 0, 0, 0, 0, 0, 0, 0} bsAll0xff = []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} chkOvf checkOverflow - noFieldNameToStructFieldInfoErr = errors.New("no field name passed to parseStructFieldInfo") + errNoFieldNameToStructFieldInfo = errors.New("no field name passed to parseStructFieldInfo") ) var defTypeInfos = NewTypeInfos([]string{"codec", "json"}) @@ -401,69 +386,6 @@ var immutableKindsSet = [32]bool{ // reflect.UnsafePointer } -var recognizedRtids []uintptr -var recognizedRtidPtrs []uintptr -var recognizedRtidOrPtrs []uintptr - -func init() { - if !useLookupRecognizedTypes { - return - } - for _, v := range [...]interface{}{ - float32(0), - float64(0), - uintptr(0), - uint(0), - uint8(0), - uint16(0), - uint32(0), - uint64(0), - uintptr(0), - int(0), - int8(0), - int16(0), - int32(0), - int64(0), - bool(false), - string(""), - Raw{}, - []byte(nil), - } { - rt := reflect.TypeOf(v) - recognizedRtids = append(recognizedRtids, rt2id(rt)) - recognizedRtidPtrs = append(recognizedRtidPtrs, rt2id(reflect.PtrTo(rt))) - } -} - -func containsU(s []uintptr, v uintptr) bool { - // return false // TODO: REMOVE - h, i, j := 0, 0, len(s) - for i < j { - h = i + (j-i)/2 - if s[h] < v { - i = h + 1 - } else { - j = h - } - } - if i < len(s) && s[i] == v { - return true - } - return false -} - -func isRecognizedRtid(rtid uintptr) bool { - return containsU(recognizedRtids, rtid) -} - -func isRecognizedRtidPtr(rtid uintptr) bool { - return containsU(recognizedRtidPtrs, rtid) -} - -func isRecognizedRtidOrPtr(rtid uintptr) bool { - return containsU(recognizedRtidOrPtrs, rtid) -} - // Selfer defines methods by which a value can encode or decode itself. // // Any type which implements Selfer will be able to encode or decode itself. @@ -474,30 +396,55 @@ type Selfer interface { CodecDecodeSelf(*Decoder) } -// MapBySlice represents a slice which should be encoded as a map in the stream. +// MapBySlice is a tag interface that denotes wrapped slice should encode as a map in the stream. // The slice contains a sequence of key-value pairs. // This affords storing a map in a specific sequence in the stream. // +// Example usage: +// type T1 []string // or []int or []Point or any other "slice" type +// func (_ T1) MapBySlice{} // T1 now implements MapBySlice, and will be encoded as a map +// type T2 struct { KeyValues T1 } +// +// var kvs = []string{"one", "1", "two", "2", "three", "3"} +// var v2 = T2{ KeyValues: T1(kvs) } +// // v2 will be encoded like the map: {"KeyValues": {"one": "1", "two": "2", "three": "3"} } +// // The support of MapBySlice affords the following: // - A slice type which implements MapBySlice will be encoded as a map // - A slice can be decoded from a map in the stream +// - It MUST be a slice type (not a pointer receiver) that implements MapBySlice type MapBySlice interface { MapBySlice() } -// WARNING: DO NOT USE DIRECTLY. EXPORTED FOR GODOC BENEFIT. WILL BE REMOVED. -// // BasicHandle encapsulates the common options and extension functions. +// +// Deprecated: DO NOT USE DIRECTLY. EXPORTED FOR GODOC BENEFIT. WILL BE REMOVED. type BasicHandle struct { + // BasicHandle is always a part of a different type. + // It doesn't have to fit into it own cache lines. + // TypeInfos is used to get the type info for any type. // // If not configured, the default TypeInfos is used, which uses struct tag keys: codec, json TypeInfos *TypeInfos + // Note: BasicHandle is not comparable, due to these slices here (extHandle, intf2impls). + // If *[]T is used instead, this becomes comparable, at the cost of extra indirection. + // Thses slices are used all the time, so keep as slices (not pointers). + extHandle - EncodeOptions + + intf2impls + + RPCOptions + + // ---- cache line DecodeOptions - noBuiltInTypeChecker + + // ---- cache line + EncodeOptions + // noBuiltInTypeChecker } func (x *BasicHandle) getBasicHandle() *BasicHandle { @@ -517,30 +464,36 @@ func (x *BasicHandle) getTypeInfo(rtid uintptr, rt reflect.Type) (pti *typeInfo) // and not modified while in use. Such a pre-configured Handle // is safe for concurrent access. type Handle interface { + Name() string getBasicHandle() *BasicHandle + recreateEncDriver(encDriver) bool newEncDriver(w *Encoder) encDriver newDecDriver(r *Decoder) decDriver isBinary() bool hasElemSeparators() bool - IsBuiltinType(rtid uintptr) bool + // IsBuiltinType(rtid uintptr) bool } // Raw represents raw formatted bytes. -// We "blindly" store it during encode and store the raw bytes during decode. -// Note: it is dangerous during encode, so we may gate the behaviour behind an Encode flag which must be explicitly set. +// We "blindly" store it during encode and retrieve the raw bytes during decode. +// Note: it is dangerous during encode, so we may gate the behaviour +// behind an Encode flag which must be explicitly set. type Raw []byte // RawExt represents raw unprocessed extension data. -// Some codecs will decode extension data as a *RawExt if there is no registered extension for the tag. +// Some codecs will decode extension data as a *RawExt +// if there is no registered extension for the tag. // -// Only one of Data or Value is nil. If Data is nil, then the content of the RawExt is in the Value. +// Only one of Data or Value is nil. +// If Data is nil, then the content of the RawExt is in the Value. type RawExt struct { Tag uint64 - // Data is the []byte which represents the raw ext. If Data is nil, ext is exposed in Value. - // Data is used by codecs (e.g. binc, msgpack, simple) which do custom serialization of the types + // Data is the []byte which represents the raw ext. If nil, ext is exposed in Value. + // Data is used by codecs (e.g. binc, msgpack, simple) which do custom serialization of types Data []byte // Value represents the extension, if Data is nil. - // Value is used by codecs (e.g. cbor, json) which use the format to do custom serialization of the types. + // Value is used by codecs (e.g. cbor, json) which leverage the format to do + // custom serialization of the types. Value interface{} } @@ -549,24 +502,30 @@ type RawExt struct { type BytesExt interface { // WriteExt converts a value to a []byte. // - // Note: v *may* be a pointer to the extension type, if the extension type was a struct or array. + // Note: v is a pointer iff the registered extension type is a struct or array kind. WriteExt(v interface{}) []byte // ReadExt updates a value from a []byte. + // + // Note: dst is always a pointer kind to the registered extension type. ReadExt(dst interface{}, src []byte) } // InterfaceExt handles custom (de)serialization of types to/from another interface{} value. // The Encoder or Decoder will then handle the further (de)serialization of that known type. // -// It is used by codecs (e.g. cbor, json) which use the format to do custom serialization of the types. +// It is used by codecs (e.g. cbor, json) which use the format to do custom serialization of types. type InterfaceExt interface { - // ConvertExt converts a value into a simpler interface for easy encoding e.g. convert time.Time to int64. + // ConvertExt converts a value into a simpler interface for easy encoding + // e.g. convert time.Time to int64. // - // Note: v *may* be a pointer to the extension type, if the extension type was a struct or array. + // Note: v is a pointer iff the registered extension type is a struct or array kind. ConvertExt(v interface{}) interface{} - // UpdateExt updates a value from a simpler interface for easy decoding e.g. convert int64 to time.Time. + // UpdateExt updates a value from a simpler interface for easy decoding + // e.g. convert int64 to time.Time. + // + // Note: dst is always a pointer kind to the registered extension type. UpdateExt(dst interface{}, src interface{}) } @@ -604,69 +563,59 @@ func (x addExtWrapper) UpdateExt(dest interface{}, v interface{}) { x.ReadExt(dest, v.([]byte)) } -type setExtWrapper struct { - b BytesExt - i InterfaceExt -} - -func (x *setExtWrapper) WriteExt(v interface{}) []byte { - if x.b == nil { - panic("BytesExt.WriteExt is not supported") - } - return x.b.WriteExt(v) +type extWrapper struct { + BytesExt + InterfaceExt } -func (x *setExtWrapper) ReadExt(v interface{}, bs []byte) { - if x.b == nil { - panic("BytesExt.WriteExt is not supported") +type bytesExtFailer struct{} - } - x.b.ReadExt(v, bs) +func (bytesExtFailer) WriteExt(v interface{}) []byte { + panicv.errorstr("BytesExt.WriteExt is not supported") + return nil } - -func (x *setExtWrapper) ConvertExt(v interface{}) interface{} { - if x.i == nil { - panic("InterfaceExt.ConvertExt is not supported") - - } - return x.i.ConvertExt(v) +func (bytesExtFailer) ReadExt(v interface{}, bs []byte) { + panicv.errorstr("BytesExt.ReadExt is not supported") } -func (x *setExtWrapper) UpdateExt(dest interface{}, v interface{}) { - if x.i == nil { - panic("InterfaceExxt.UpdateExt is not supported") +type interfaceExtFailer struct{} - } - x.i.UpdateExt(dest, v) +func (interfaceExtFailer) ConvertExt(v interface{}) interface{} { + panicv.errorstr("InterfaceExt.ConvertExt is not supported") + return nil +} +func (interfaceExtFailer) UpdateExt(dest interface{}, v interface{}) { + panicv.errorstr("InterfaceExt.UpdateExt is not supported") } type binaryEncodingType struct{} -func (_ binaryEncodingType) isBinary() bool { return true } +func (binaryEncodingType) isBinary() bool { return true } type textEncodingType struct{} -func (_ textEncodingType) isBinary() bool { return false } +func (textEncodingType) isBinary() bool { return false } // noBuiltInTypes is embedded into many types which do not support builtins // e.g. msgpack, simple, cbor. -type noBuiltInTypeChecker struct{} - -func (_ noBuiltInTypeChecker) IsBuiltinType(rt uintptr) bool { return false } +// type noBuiltInTypeChecker struct{} +// func (noBuiltInTypeChecker) IsBuiltinType(rt uintptr) bool { return false } +// type noBuiltInTypes struct{ noBuiltInTypeChecker } -type noBuiltInTypes struct{ noBuiltInTypeChecker } +type noBuiltInTypes struct{} -func (_ noBuiltInTypes) EncodeBuiltin(rt uintptr, v interface{}) {} -func (_ noBuiltInTypes) DecodeBuiltin(rt uintptr, v interface{}) {} +func (noBuiltInTypes) EncodeBuiltin(rt uintptr, v interface{}) {} +func (noBuiltInTypes) DecodeBuiltin(rt uintptr, v interface{}) {} // type noStreamingCodec struct{} -// func (_ noStreamingCodec) CheckBreak() bool { return false } -// func (_ noStreamingCodec) hasElemSeparators() bool { return false } +// func (noStreamingCodec) CheckBreak() bool { return false } +// func (noStreamingCodec) hasElemSeparators() bool { return false } type noElemSeparators struct{} -func (_ noElemSeparators) hasElemSeparators() (v bool) { return } +func (noElemSeparators) hasElemSeparators() (v bool) { return } +func (noElemSeparators) recreateEncDriver(e encDriver) (v bool) { return } // bigenHelper. // Users must already slice the x completely, because we will not reslice. @@ -691,90 +640,174 @@ func (z bigenHelper) writeUint64(v uint64) { } type extTypeTagFn struct { - rtid uintptr - rt reflect.Type - tag uint64 - ext Ext + rtid uintptr + rtidptr uintptr + rt reflect.Type + tag uint64 + ext Ext + _ [1]uint64 // padding } type extHandle []extTypeTagFn -// DEPRECATED: Use SetBytesExt or SetInterfaceExt on the Handle instead. -// // AddExt registes an encode and decode function for a reflect.Type. -// AddExt internally calls SetExt. // To deregister an Ext, call AddExt with nil encfn and/or nil decfn. -func (o *extHandle) AddExt( - rt reflect.Type, tag byte, - encfn func(reflect.Value) ([]byte, error), decfn func(reflect.Value, []byte) error, -) (err error) { +// +// Deprecated: Use SetBytesExt or SetInterfaceExt on the Handle instead. +func (o *extHandle) AddExt(rt reflect.Type, tag byte, + encfn func(reflect.Value) ([]byte, error), + decfn func(reflect.Value, []byte) error) (err error) { if encfn == nil || decfn == nil { return o.SetExt(rt, uint64(tag), nil) } return o.SetExt(rt, uint64(tag), addExtWrapper{encfn, decfn}) } -// DEPRECATED: Use SetBytesExt or SetInterfaceExt on the Handle instead. +// SetExt will set the extension for a tag and reflect.Type. +// Note that the type must be a named type, and specifically not a pointer or Interface. +// An error is returned if that is not honored. +// To Deregister an ext, call SetExt with nil Ext. // -// Note that the type must be a named type, and specifically not -// a pointer or Interface. An error is returned if that is not honored. -// -// To Deregister an ext, call SetExt with nil Ext +// Deprecated: Use SetBytesExt or SetInterfaceExt on the Handle instead. func (o *extHandle) SetExt(rt reflect.Type, tag uint64, ext Ext) (err error) { // o is a pointer, because we may need to initialize it - if rt.PkgPath() == "" || rt.Kind() == reflect.Interface { - err = fmt.Errorf("codec.Handle.AddExt: Takes named type, not a pointer or interface: %T", - reflect.Zero(rt).Interface()) - return + rk := rt.Kind() + for rk == reflect.Ptr { + rt = rt.Elem() + rk = rt.Kind() + } + + if rt.PkgPath() == "" || rk == reflect.Interface { // || rk == reflect.Ptr { + return fmt.Errorf("codec.Handle.SetExt: Takes named type, not a pointer or interface: %v", rt) } rtid := rt2id(rt) - for _, v := range *o { + switch rtid { + case timeTypId, rawTypId, rawExtTypId: + // all natively supported type, so cannot have an extension + return // TODO: should we silently ignore, or return an error??? + } + // if o == nil { + // return errors.New("codec.Handle.SetExt: extHandle not initialized") + // } + o2 := *o + // if o2 == nil { + // return errors.New("codec.Handle.SetExt: extHandle not initialized") + // } + for i := range o2 { + v := &o2[i] if v.rtid == rtid { v.tag, v.ext = tag, ext return } } - - if *o == nil { - *o = make([]extTypeTagFn, 0, 4) - } - *o = append(*o, extTypeTagFn{rtid, rt, tag, ext}) + rtidptr := rt2id(reflect.PtrTo(rt)) + *o = append(o2, extTypeTagFn{rtid, rtidptr, rt, tag, ext, [1]uint64{}}) return } -func (o extHandle) getExt(rtid uintptr) *extTypeTagFn { - var v *extTypeTagFn +func (o extHandle) getExt(rtid uintptr) (v *extTypeTagFn) { for i := range o { v = &o[i] - if v.rtid == rtid { - return v + if v.rtid == rtid || v.rtidptr == rtid { + return } } return nil } -func (o extHandle) getExtForTag(tag uint64) *extTypeTagFn { - var v *extTypeTagFn +func (o extHandle) getExtForTag(tag uint64) (v *extTypeTagFn) { for i := range o { v = &o[i] if v.tag == tag { - return v + return } } return nil } -const maxLevelsEmbedding = 16 +type intf2impl struct { + rtid uintptr // for intf + impl reflect.Type + // _ [1]uint64 // padding // not-needed, as *intf2impl is never returned. +} + +type intf2impls []intf2impl + +// Intf2Impl maps an interface to an implementing type. +// This allows us support infering the concrete type +// and populating it when passed an interface. +// e.g. var v io.Reader can be decoded as a bytes.Buffer, etc. +// +// Passing a nil impl will clear the mapping. +func (o *intf2impls) Intf2Impl(intf, impl reflect.Type) (err error) { + if impl != nil && !impl.Implements(intf) { + return fmt.Errorf("Intf2Impl: %v does not implement %v", impl, intf) + } + rtid := rt2id(intf) + o2 := *o + for i := range o2 { + v := &o2[i] + if v.rtid == rtid { + v.impl = impl + return + } + } + *o = append(o2, intf2impl{rtid, impl}) + return +} + +func (o intf2impls) intf2impl(rtid uintptr) (rv reflect.Value) { + for i := range o { + v := &o[i] + if v.rtid == rtid { + if v.impl == nil { + return + } + if v.impl.Kind() == reflect.Ptr { + return reflect.New(v.impl.Elem()) + } + return reflect.New(v.impl).Elem() + } + } + return +} + +type structFieldInfoFlag uint8 + +const ( + _ structFieldInfoFlag = 1 << iota + structFieldInfoFlagReady + structFieldInfoFlagOmitEmpty +) + +func (x *structFieldInfoFlag) flagSet(f structFieldInfoFlag) { + *x = *x | f +} + +func (x *structFieldInfoFlag) flagClr(f structFieldInfoFlag) { + *x = *x &^ f +} + +func (x structFieldInfoFlag) flagGet(f structFieldInfoFlag) bool { + return x&f != 0 +} + +func (x structFieldInfoFlag) omitEmpty() bool { + return x.flagGet(structFieldInfoFlagOmitEmpty) +} + +func (x structFieldInfoFlag) ready() bool { + return x.flagGet(structFieldInfoFlagReady) +} type structFieldInfo struct { encName string // encode name fieldName string // field name - is [maxLevelsEmbedding]uint16 // (recursive/embedded) field index in struct - nis uint8 // num levels of embedding. if 1, then it's not embedded. - omitEmpty bool - toArray bool // if field is _struct, is the toArray set? + is [maxLevelsEmbedding]uint16 // (recursive/embedded) field index in struct + nis uint8 // num levels of embedding. if 1, then it's not embedded. + structFieldInfoFlag } func (si *structFieldInfo) setToZeroValue(v reflect.Value) { @@ -800,36 +833,63 @@ func (si *structFieldInfo) field(v reflect.Value, update bool) (rv2 reflect.Valu return v, true } -func (si *structFieldInfo) fieldval(v reflect.Value, update bool) reflect.Value { - v, _ = si.field(v, update) - return v +// func (si *structFieldInfo) fieldval(v reflect.Value, update bool) reflect.Value { +// v, _ = si.field(v, update) +// return v +// } + +func parseStructInfo(stag string) (toArray, omitEmpty bool, keytype valueType) { + keytype = valueTypeString // default + if stag == "" { + return + } + for i, s := range strings.Split(stag, ",") { + if i == 0 { + } else { + switch s { + case "omitempty": + omitEmpty = true + case "toarray": + toArray = true + case "int": + keytype = valueTypeInt + case "uint": + keytype = valueTypeUint + case "float": + keytype = valueTypeFloat + // case "bool": + // keytype = valueTypeBool + case "string": + keytype = valueTypeString + } + } + } + return } -func parseStructFieldInfo(fname string, stag string) *structFieldInfo { +func (si *structFieldInfo) parseTag(stag string) { // if fname == "" { - // panic(noFieldNameToStructFieldInfoErr) + // panic(errNoFieldNameToStructFieldInfo) // } - si := structFieldInfo{ - encName: fname, - } - if stag != "" { - for i, s := range strings.Split(stag, ",") { - if i == 0 { - if s != "" { - si.encName = s - } - } else { - if s == "omitempty" { - si.omitEmpty = true - } else if s == "toarray" { - si.toArray = true - } + if stag == "" { + return + } + for i, s := range strings.Split(stag, ",") { + if i == 0 { + if s != "" { + si.encName = s + } + } else { + switch s { + case "omitempty": + si.flagSet(structFieldInfoFlagOmitEmpty) + // si.omitEmpty = true + // case "toarray": + // si.toArray = true } } } - // si.encNameBs = []byte(si.encName) - return &si } type sfiSortedByEncName []*structFieldInfo @@ -855,7 +915,6 @@ type structFieldNodeCache struct { } func (x *structFieldNodeCache) get(key uint32) (fv reflect.Value, valid bool) { - // defer func() { fmt.Printf(">>>> found in cache2? %v\n", valid) }() for i, k := range &x.idx { if uint8(i) == x.num { return // break @@ -937,7 +996,15 @@ func baseStructRv(v reflect.Value, update bool) (v2 reflect.Value, valid bool) { return v, true } -// typeInfo keeps information about each type referenced in the encode/decode sequence. +type typeInfoFlag uint8 + +const ( + typeInfoFlagComparable = 1 << iota + typeInfoFlagIsZeroer + typeInfoFlagIsZeroerPtr +) + +// typeInfo keeps information about each (non-ptr) type referenced in the encode/decode sequence. // // During an encode/decode sequence, we work as below: // - If base is a built in type, en/decode base value @@ -946,77 +1013,77 @@ func baseStructRv(v reflect.Value, update bool) (v2 reflect.Value, valid bool) { // - If type is text(M/Unm)arshaler, call Text(M/Unm)arshal method // - Else decode appropriately based on the reflect.Kind type typeInfo struct { - sfi []*structFieldInfo // sorted. Used when enc/dec struct to map. - sfip []*structFieldInfo // unsorted. Used when enc/dec struct to array. + rt reflect.Type + elem reflect.Type + pkgpath string - rt reflect.Type rtid uintptr // rv0 reflect.Value // saved zero value, used if immutableKind numMeth uint16 // number of methods + kind uint8 + chandir uint8 + + anyOmitEmpty bool // true if a struct, and any of the fields are tagged "omitempty" + toArray bool // whether this (struct) type should be encoded as an array + keyType valueType // if struct, how is the field name stored in a stream? default is string + mbs bool // base type (T or *T) is a MapBySlice - // baseId gives pointer to the base reflect.Type, after deferencing - // the pointers. E.g. base type of ***time.Time is time.Time. - base reflect.Type - baseId uintptr - baseIndir int8 // number of indirections to get to base + // ---- cpu cache line boundary? + sfiSort []*structFieldInfo // sorted. Used when enc/dec struct to map. + sfiSrc []*structFieldInfo // unsorted. Used when enc/dec struct to array. - anyOmitEmpty bool + key reflect.Type - mbs bool // base type (T or *T) is a MapBySlice + // ---- cpu cache line boundary? + // sfis []structFieldInfo // all sfi, in src order, as created. + sfiNamesSort []byte // all names, with indexes into the sfiSort - bm bool // base type (T or *T) is a binaryMarshaler - bunm bool // base type (T or *T) is a binaryUnmarshaler - bmIndir int8 // number of indirections to get to binaryMarshaler type - bunmIndir int8 // number of indirections to get to binaryUnmarshaler type + // format of marshal type fields below: [btj][mu]p? OR csp? - tm bool // base type (T or *T) is a textMarshaler - tunm bool // base type (T or *T) is a textUnmarshaler - tmIndir int8 // number of indirections to get to textMarshaler type - tunmIndir int8 // number of indirections to get to textUnmarshaler type + bm bool // T is a binaryMarshaler + bmp bool // *T is a binaryMarshaler + bu bool // T is a binaryUnmarshaler + bup bool // *T is a binaryUnmarshaler + tm bool // T is a textMarshaler + tmp bool // *T is a textMarshaler + tu bool // T is a textUnmarshaler + tup bool // *T is a textUnmarshaler - jm bool // base type (T or *T) is a jsonMarshaler - junm bool // base type (T or *T) is a jsonUnmarshaler - jmIndir int8 // number of indirections to get to jsonMarshaler type - junmIndir int8 // number of indirections to get to jsonUnmarshaler type + jm bool // T is a jsonMarshaler + jmp bool // *T is a jsonMarshaler + ju bool // T is a jsonUnmarshaler + jup bool // *T is a jsonUnmarshaler + cs bool // T is a Selfer + csp bool // *T is a Selfer - cs bool // base type (T or *T) is a Selfer - csIndir int8 // number of indirections to get to Selfer type + // other flags, with individual bits representing if set. + flags typeInfoFlag - toArray bool // whether this (struct) type should be encoded as an array + // _ [2]byte // padding + _ [3]uint64 // padding } -// define length beyond which we do a binary search instead of a linear search. -// From our testing, linear search seems faster than binary search up to 16-field structs. -// However, we set to 8 similar to what python does for hashtables. -const indexForEncNameBinarySearchThreshold = 8 +func (ti *typeInfo) isFlag(f typeInfoFlag) bool { + return ti.flags&f != 0 +} -func (ti *typeInfo) indexForEncName(name string) int { - // NOTE: name may be a stringView, so don't pass it to another function. - //tisfi := ti.sfi - sfilen := len(ti.sfi) - if sfilen < indexForEncNameBinarySearchThreshold { - for i, si := range ti.sfi { - if si.encName == name { - return i - } - } - return -1 - } - // binary search. adapted from sort/search.go. - h, i, j := 0, 0, sfilen - for i < j { - h = i + (j-i)/2 - if ti.sfi[h].encName < name { - i = h + 1 - } else { - j = h - } +func (ti *typeInfo) indexForEncName(name []byte) (index int16) { + var sn []byte + if len(name)+2 <= 32 { + var buf [32]byte // should not escape + sn = buf[:len(name)+2] + } else { + sn = make([]byte, len(name)+2) } - if i < sfilen && ti.sfi[i].encName == name { - return i + copy(sn[1:], name) + sn[0], sn[len(sn)-1] = tiSep2(name), 0xff + j := bytes.Index(ti.sfiNamesSort, sn) + if j < 0 { + return -1 } - return -1 + index = int16(uint16(ti.sfiNamesSort[j+len(sn)+1]) | uint16(ti.sfiNamesSort[j+len(sn)])<<8) + return } type rtid2ti struct { @@ -1029,9 +1096,11 @@ type rtid2ti struct { // It is configured with a set of tag keys, which are used to get // configuration for the type. type TypeInfos struct { - infos atomicTypeInfoSlice // formerly map[uintptr]*typeInfo, now *[]rtid2ti + // infos: formerly map[uintptr]*typeInfo, now *[]rtid2ti, 2 words expected + infos atomicTypeInfoSlice mu sync.Mutex tags []string + _ [2]uint64 // padding } // NewTypeInfos creates a TypeInfos given a set of struct tags keys. @@ -1054,12 +1123,12 @@ func (x *TypeInfos) structTag(t reflect.StructTag) (s string) { return } -func (x *TypeInfos) find(sp *[]rtid2ti, rtid uintptr) (idx int, ti *typeInfo) { +func (x *TypeInfos) find(s []rtid2ti, rtid uintptr) (idx int, ti *typeInfo) { // binary search. adapted from sort/search.go. // if sp == nil { // return -1, nil // } - s := *sp + // s := *sp h, i, j := 0, 0, len(s) for i < j { h = i + (j-i)/2 @@ -1079,94 +1148,89 @@ func (x *TypeInfos) get(rtid uintptr, rt reflect.Type) (pti *typeInfo) { sp := x.infos.load() var idx int if sp != nil { - idx, pti = x.find(sp, rtid) + idx, pti = x.find(*sp, rtid) if pti != nil { return } } + rk := rt.Kind() + + if rk == reflect.Ptr { // || (rk == reflect.Interface && rtid != intfTypId) { + panicv.errorf("invalid kind passed to TypeInfos.get: %v - %v", rk, rt) + } + // do not hold lock while computing this. // it may lead to duplication, but that's ok. - ti := typeInfo{rt: rt, rtid: rtid} + ti := typeInfo{rt: rt, rtid: rtid, kind: uint8(rk), pkgpath: rt.PkgPath()} // ti.rv0 = reflect.Zero(rt) + // ti.comparable = rt.Comparable() ti.numMeth = uint16(rt.NumMethod()) - var ok bool - var indir int8 - if ok, indir = implementsIntf(rt, binaryMarshalerTyp); ok { - ti.bm, ti.bmIndir = true, indir - } - if ok, indir = implementsIntf(rt, binaryUnmarshalerTyp); ok { - ti.bunm, ti.bunmIndir = true, indir - } - if ok, indir = implementsIntf(rt, textMarshalerTyp); ok { - ti.tm, ti.tmIndir = true, indir - } - if ok, indir = implementsIntf(rt, textUnmarshalerTyp); ok { - ti.tunm, ti.tunmIndir = true, indir - } - if ok, indir = implementsIntf(rt, jsonMarshalerTyp); ok { - ti.jm, ti.jmIndir = true, indir - } - if ok, indir = implementsIntf(rt, jsonUnmarshalerTyp); ok { - ti.junm, ti.junmIndir = true, indir - } - if ok, indir = implementsIntf(rt, selferTyp); ok { - ti.cs, ti.csIndir = true, indir - } - if ok, _ = implementsIntf(rt, mapBySliceTyp); ok { - ti.mbs = true - } - pt := rt - var ptIndir int8 - // for ; pt.Kind() == reflect.Ptr; pt, ptIndir = pt.Elem(), ptIndir+1 { } - for pt.Kind() == reflect.Ptr { - pt = pt.Elem() - ptIndir++ + ti.bm, ti.bmp = implIntf(rt, binaryMarshalerTyp) + ti.bu, ti.bup = implIntf(rt, binaryUnmarshalerTyp) + ti.tm, ti.tmp = implIntf(rt, textMarshalerTyp) + ti.tu, ti.tup = implIntf(rt, textUnmarshalerTyp) + ti.jm, ti.jmp = implIntf(rt, jsonMarshalerTyp) + ti.ju, ti.jup = implIntf(rt, jsonUnmarshalerTyp) + ti.cs, ti.csp = implIntf(rt, selferTyp) + + b1, b2 := implIntf(rt, iszeroTyp) + if b1 { + ti.flags |= typeInfoFlagIsZeroer } - if ptIndir == 0 { - ti.base = rt - ti.baseId = rtid - } else { - ti.base = pt - ti.baseId = rt2id(pt) - ti.baseIndir = ptIndir + if b2 { + ti.flags |= typeInfoFlagIsZeroerPtr + } + if rt.Comparable() { + ti.flags |= typeInfoFlagComparable } - if rt.Kind() == reflect.Struct { + switch rk { + case reflect.Struct: var omitEmpty bool if f, ok := rt.FieldByName(structInfoFieldName); ok { - siInfo := parseStructFieldInfo(structInfoFieldName, x.structTag(f.Tag)) - ti.toArray = siInfo.toArray - omitEmpty = siInfo.omitEmpty + ti.toArray, omitEmpty, ti.keyType = parseStructInfo(x.structTag(f.Tag)) + } else { + ti.keyType = valueTypeString } pp, pi := pool.tiLoad() pv := pi.(*typeInfoLoadArray) - pv.etypes[0] = ti.baseId - vv := typeInfoLoad{pv.fNames[:0], pv.encNames[:0], pv.etypes[:1], pv.sfis[:0]} + pv.etypes[0] = ti.rtid + // vv := typeInfoLoad{pv.fNames[:0], pv.encNames[:0], pv.etypes[:1], pv.sfis[:0]} + vv := typeInfoLoad{pv.etypes[:1], pv.sfis[:0]} x.rget(rt, rtid, omitEmpty, nil, &vv) - ti.sfip, ti.sfi, ti.anyOmitEmpty = rgetResolveSFI(vv.sfis, pv.sfiidx[:0]) + // ti.sfis = vv.sfis + ti.sfiSrc, ti.sfiSort, ti.sfiNamesSort, ti.anyOmitEmpty = rgetResolveSFI(rt, vv.sfis, pv) pp.Put(pi) - } - // sfi = sfip + case reflect.Map: + ti.elem = rt.Elem() + ti.key = rt.Key() + case reflect.Slice: + ti.mbs, _ = implIntf(rt, mapBySliceTyp) + ti.elem = rt.Elem() + case reflect.Chan: + ti.elem = rt.Elem() + ti.chandir = uint8(rt.ChanDir()) + case reflect.Array, reflect.Ptr: + ti.elem = rt.Elem() + } + // sfi = sfiSrc - var vs []rtid2ti x.mu.Lock() sp = x.infos.load() if sp == nil { pti = &ti - vs = []rtid2ti{{rtid, pti}} + vs := append(make([]rtid2ti, 0, 16), rtid2ti{rtid, pti}) x.infos.store(&vs) } else { - idx, pti = x.find(sp, rtid) + idx, pti = x.find(*sp, rtid) if pti == nil { - s := *sp pti = &ti - vs = make([]rtid2ti, len(s)+1) - copy(vs, s[:idx]) + vs := append(*sp, rtid2ti{}) + copy(vs[idx+1:], vs[idx:]) vs[idx] = rtid2ti{rtid, pti} - copy(vs[idx+1:], s[idx:]) x.infos.store(&vs) } } @@ -1175,8 +1239,7 @@ func (x *TypeInfos) get(rtid uintptr, rt reflect.Type) (pti *typeInfo) { } func (x *TypeInfos) rget(rt reflect.Type, rtid uintptr, omitEmpty bool, - indexstack []uint16, pv *typeInfoLoad, -) { + indexstack []uint16, pv *typeInfoLoad) { // Read up fields and store how to access the value. // // It uses go's rules for message selectors, @@ -1187,8 +1250,10 @@ func (x *TypeInfos) rget(rt reflect.Type, rtid uintptr, omitEmpty bool, // and iteration using equals is faster than maps there flen := rt.NumField() if flen > (1< %v fields are not supported - has %v fields", + (1< maxLevelsEmbedding-1 { - panic(fmt.Errorf("codec: only supports up to %v depth of embedding - type has %v depth", maxLevelsEmbedding-1, len(indexstack))) + panicv.errorf("codec: only supports up to %v depth of embedding - type has %v depth", + maxLevelsEmbedding-1, len(indexstack)) } si.nis = uint8(len(indexstack)) + 1 copy(si.is[:], indexstack) si.is[len(indexstack)] = j if omitEmpty { - si.omitEmpty = true + si.flagSet(structFieldInfoFlagOmitEmpty) } pv.sfis = append(pv.sfis, si) } } +func tiSep(name string) uint8 { + // (xn[0]%64) // (between 192-255 - outside ascii BMP) + // return 0xfe - (name[0] & 63) + // return 0xfe - (name[0] & 63) - uint8(len(name)) + // return 0xfe - (name[0] & 63) - uint8(len(name)&63) + // return ((0xfe - (name[0] & 63)) & 0xf8) | (uint8(len(name) & 0x07)) + return 0xfe - (name[0] & 63) - uint8(len(name)&63) +} + +func tiSep2(name []byte) uint8 { + return 0xfe - (name[0] & 63) - uint8(len(name)&63) +} + // resolves the struct field info got from a call to rget. // Returns a trimmed, unsorted and sorted []*structFieldInfo. -func rgetResolveSFI(x []*structFieldInfo, pv []sfiIdx) (y, z []*structFieldInfo, anyOmitEmpty bool) { - var n int - for i, v := range x { - xn := v.encName // TODO: fieldName or encName? use encName for now. - var found bool - for j, k := range pv { - if k.name == xn { - // one of them must be reset to nil, and the index updated appropriately to the other one - if v.nis == x[k.index].nis { - } else if v.nis < x[k.index].nis { - pv[j].index = i - if x[k.index] != nil { - x[k.index] = nil - n++ - } - } else { - if x[i] != nil { - x[i] = nil - n++ - } +func rgetResolveSFI(rt reflect.Type, x []structFieldInfo, pv *typeInfoLoadArray) ( + y, z []*structFieldInfo, ss []byte, anyOmitEmpty bool) { + sa := pv.sfiidx[:0] + sn := pv.b[:] + n := len(x) + + var xn string + var ui uint16 + var sep byte + + for i := range x { + ui = uint16(i) + xn = x[i].encName // fieldName or encName? use encName for now. + if len(xn)+2 > cap(pv.b) { + sn = make([]byte, len(xn)+2) + } else { + sn = sn[:len(xn)+2] + } + // use a custom sep, so that misses are less frequent, + // since the sep (first char in search) is as unique as first char in field name. + sep = tiSep(xn) + sn[0], sn[len(sn)-1] = sep, 0xff + copy(sn[1:], xn) + j := bytes.Index(sa, sn) + if j == -1 { + sa = append(sa, sep) + sa = append(sa, xn...) + sa = append(sa, 0xff, byte(ui>>8), byte(ui)) + } else { + index := uint16(sa[j+len(sn)+1]) | uint16(sa[j+len(sn)])<<8 + // one of them must be reset to nil, + // and the index updated appropriately to the other one + if x[i].nis == x[index].nis { + } else if x[i].nis < x[index].nis { + sa[j+len(sn)], sa[j+len(sn)+1] = byte(ui>>8), byte(ui) + if x[index].ready() { + x[index].flagClr(structFieldInfoFlagReady) + n-- + } + } else { + if x[i].ready() { + x[i].flagClr(structFieldInfoFlagReady) + n-- } - found = true - break } } - if !found { - pv = append(pv, sfiIdx{xn, i}) - } + + } + var w []structFieldInfo + sharingArray := len(x) <= typeInfoLoadArraySfisLen // sharing array with typeInfoLoadArray + if sharingArray { + w = make([]structFieldInfo, n) } - // remove all the nils - y = make([]*structFieldInfo, len(x)-n) + // remove all the nils (non-ready) + y = make([]*structFieldInfo, n) n = 0 - for _, v := range x { - if v == nil { + var sslen int + for i := range x { + if !x[i].ready() { continue } - if !anyOmitEmpty && v.omitEmpty { + if !anyOmitEmpty && x[i].omitEmpty() { anyOmitEmpty = true } - y[n] = v + if sharingArray { + w[n] = x[i] + y[n] = &w[n] + } else { + y[n] = &x[i] + } + sslen = sslen + len(x[i].encName) + 4 n++ } + if n != len(y) { + panicv.errorf("failure reading struct %v - expecting %d of %d valid fields, got %d", + rt, len(y), len(x), n) + } z = make([]*structFieldInfo, len(y)) copy(z, y) sort.Sort(sfiSortedByEncName(z)) + + sharingArray = len(sa) <= typeInfoLoadArraySfiidxLen + if sharingArray { + ss = make([]byte, 0, sslen) + } else { + ss = sa[:0] // reuse the newly made sa array if necessary + } + for i := range z { + xn = z[i].encName + sep = tiSep(xn) + ui = uint16(i) + ss = append(ss, sep) + ss = append(ss, xn...) + ss = append(ss, 0xff, byte(ui>>8), byte(ui)) + } return } -func xprintf(format string, a ...interface{}) { - if xDebug { - fmt.Fprintf(os.Stderr, format, a...) +func implIntf(rt, iTyp reflect.Type) (base bool, indir bool) { + return rt.Implements(iTyp), reflect.PtrTo(rt).Implements(iTyp) +} + +// isEmptyStruct is only called from isEmptyValue, and checks if a struct is empty: +// - does it implement IsZero() bool +// - is it comparable, and can i compare directly using == +// - if checkStruct, then walk through the encodable fields +// and check if they are empty or not. +func isEmptyStruct(v reflect.Value, tinfos *TypeInfos, deref, checkStruct bool) bool { + // v is a struct kind - no need to check again. + // We only check isZero on a struct kind, to reduce the amount of times + // that we lookup the rtid and typeInfo for each type as we walk the tree. + + vt := v.Type() + rtid := rt2id(vt) + if tinfos == nil { + tinfos = defTypeInfos + } + ti := tinfos.get(rtid, vt) + if ti.rtid == timeTypId { + return rv2i(v).(time.Time).IsZero() + } + if ti.isFlag(typeInfoFlagIsZeroerPtr) && v.CanAddr() { + return rv2i(v.Addr()).(isZeroer).IsZero() + } + if ti.isFlag(typeInfoFlagIsZeroer) { + return rv2i(v).(isZeroer).IsZero() + } + if ti.isFlag(typeInfoFlagComparable) { + return rv2i(v) == rv2i(reflect.Zero(vt)) } + if !checkStruct { + return false + } + // We only care about what we can encode/decode, + // so that is what we use to check omitEmpty. + for _, si := range ti.sfiSrc { + sfv, valid := si.field(v, false) + if valid && !isEmptyValue(sfv, tinfos, deref, checkStruct) { + return false + } + } + return true } -func panicToErr(err *error) { +// func roundFloat(x float64) float64 { +// t := math.Trunc(x) +// if math.Abs(x-t) >= 0.5 { +// return t + math.Copysign(1, x) +// } +// return t +// } + +func panicToErr(h errstrDecorator, err *error) { if recoverPanicToErr { if x := recover(); x != nil { - // if false && xDebug { - // fmt.Printf("panic'ing with: %v\n", x) - // debug.PrintStack() - // } - panicValToErr(x, err) + // fmt.Printf("panic'ing with: %v\n", x) + // debug.PrintStack() + panicValToErr(h, x, err) } } } -func panicToErrs2(err1, err2 *error) { +func panicToErrs2(h errstrDecorator, err1, err2 *error) { if recoverPanicToErr { if x := recover(); x != nil { - panicValToErr(x, err1) - panicValToErr(x, err2) + panicValToErr(h, x, err1) + panicValToErr(h, x, err2) } } } -// func doPanic(tag string, format string, params ...interface{}) { -// params2 := make([]interface{}, len(params)+1) -// params2[0] = tag -// copy(params2[1:], params) -// panic(fmt.Errorf("%s: "+format, params2...)) -// } +func panicValToErr(h errstrDecorator, v interface{}, err *error) { + switch xerr := v.(type) { + case nil: + case error: + switch xerr { + case nil: + case io.EOF, io.ErrUnexpectedEOF, errEncoderNotInitialized, errDecoderNotInitialized: + // treat as special (bubble up) + *err = xerr + default: + h.wrapErrstr(xerr.Error(), err) + } + case string: + if xerr != "" { + h.wrapErrstr(xerr, err) + } + case fmt.Stringer: + if xerr != nil { + h.wrapErrstr(xerr.String(), err) + } + default: + h.wrapErrstr(v, err) + } +} func isImmutableKind(k reflect.Kind) (v bool) { return immutableKindsSet[k] - // return false || - // k == reflect.Int || - // k == reflect.Int8 || - // k == reflect.Int16 || - // k == reflect.Int32 || - // k == reflect.Int64 || - // k == reflect.Uint || - // k == reflect.Uint8 || - // k == reflect.Uint16 || - // k == reflect.Uint32 || - // k == reflect.Uint64 || - // k == reflect.Uintptr || - // k == reflect.Float32 || - // k == reflect.Float64 || - // k == reflect.Bool || - // k == reflect.String } // ---- @@ -1402,7 +1593,10 @@ type codecFnInfo struct { xfFn Ext xfTag uint64 seq seqType - addr bool + addrD bool + addrF bool // if addrD, this says whether decode function can take a value or a ptr + addrE bool + ready bool // ready to use } // codecFn encapsulates the captured variables and the encode function. @@ -1413,113 +1607,139 @@ type codecFn struct { i codecFnInfo fe func(*Encoder, *codecFnInfo, reflect.Value) fd func(*Decoder, *codecFnInfo, reflect.Value) + _ [1]uint64 // padding } type codecRtidFn struct { rtid uintptr - fn codecFn + fn *codecFn } type codecFner struct { - hh Handle + // hh Handle h *BasicHandle - cs [arrayCacheLen]*[arrayCacheLen]codecRtidFn - s []*[arrayCacheLen]codecRtidFn - sn uint32 + s []codecRtidFn be bool js bool - cf [arrayCacheLen]codecRtidFn + _ [6]byte // padding + _ [3]uint64 // padding } func (c *codecFner) reset(hh Handle) { - c.hh = hh - c.h = hh.getBasicHandle() - _, c.js = hh.(*JsonHandle) - c.be = hh.isBinary() + bh := hh.getBasicHandle() + // only reset iff extensions changed or *TypeInfos changed + var hhSame = true && + c.h == bh && c.h.TypeInfos == bh.TypeInfos && + len(c.h.extHandle) == len(bh.extHandle) && + (len(c.h.extHandle) == 0 || &c.h.extHandle[0] == &bh.extHandle[0]) + if !hhSame { + // c.hh = hh + c.h, bh = bh, c.h // swap both + _, c.js = hh.(*JsonHandle) + c.be = hh.isBinary() + for i := range c.s { + c.s[i].fn.i.ready = false + } + } } func (c *codecFner) get(rt reflect.Type, checkFastpath, checkCodecSelfer bool) (fn *codecFn) { rtid := rt2id(rt) - var j uint32 - var sn uint32 = c.sn - if sn == 0 { - c.s = c.cs[:1] - c.s[0] = &c.cf - c.cf[0].rtid = rtid - fn = &(c.cf[0].fn) - c.sn = 1 - } else { - LOOP1: - for _, x := range c.s { - for i := range x { - if j == sn { - break LOOP1 - } - if x[i].rtid == rtid { - fn = &(x[i].fn) - return - } - j++ + + for _, x := range c.s { + if x.rtid == rtid { + // if rtid exists, then there's a *codenFn attached (non-nil) + fn = x.fn + if fn.i.ready { + return } + break } - sx, sy := sn/arrayCacheLen, sn%arrayCacheLen - if sy == 0 { - c.s = append(c.s, &[arrayCacheLen]codecRtidFn{}) + } + var ti *typeInfo + if fn == nil { + fn = new(codecFn) + if c.s == nil { + c.s = make([]codecRtidFn, 0, 8) } - c.s[sx][sy].rtid = rtid - fn = &(c.s[sx][sy].fn) - c.sn++ + c.s = append(c.s, codecRtidFn{rtid, fn}) + } else { + ti = fn.i.ti + *fn = codecFn{} + fn.i.ti = ti + // fn.fe, fn.fd = nil, nil } - - ti := c.h.getTypeInfo(rtid, rt) fi := &(fn.i) - fi.ti = ti + fi.ready = true + if ti == nil { + ti = c.h.getTypeInfo(rtid, rt) + fi.ti = ti + } + + rk := reflect.Kind(ti.kind) - if checkCodecSelfer && ti.cs { + if checkCodecSelfer && (ti.cs || ti.csp) { fn.fe = (*Encoder).selferMarshal fn.fd = (*Decoder).selferUnmarshal + fi.addrF = true + fi.addrD = ti.csp + fi.addrE = ti.csp + } else if rtid == timeTypId { + fn.fe = (*Encoder).kTime + fn.fd = (*Decoder).kTime } else if rtid == rawTypId { fn.fe = (*Encoder).raw fn.fd = (*Decoder).raw } else if rtid == rawExtTypId { fn.fe = (*Encoder).rawExt fn.fd = (*Decoder).rawExt - fn.i.addr = true - } else if c.hh.IsBuiltinType(rtid) { - fn.fe = (*Encoder).builtin - fn.fd = (*Decoder).builtin - fn.i.addr = true + fi.addrF = true + fi.addrD = true + fi.addrE = true } else if xfFn := c.h.getExt(rtid); xfFn != nil { fi.xfTag, fi.xfFn = xfFn.tag, xfFn.ext fn.fe = (*Encoder).ext fn.fd = (*Decoder).ext - fn.i.addr = true - } else if supportMarshalInterfaces && c.be && ti.bm { + fi.addrF = true + fi.addrD = true + if rk == reflect.Struct || rk == reflect.Array { + fi.addrE = true + } + } else if supportMarshalInterfaces && c.be && (ti.bm || ti.bmp) && (ti.bu || ti.bup) { fn.fe = (*Encoder).binaryMarshal fn.fd = (*Decoder).binaryUnmarshal - } else if supportMarshalInterfaces && !c.be && c.js && ti.jm { + fi.addrF = true + fi.addrD = ti.bup + fi.addrE = ti.bmp + } else if supportMarshalInterfaces && !c.be && c.js && (ti.jm || ti.jmp) && (ti.ju || ti.jup) { //If JSON, we should check JSONMarshal before textMarshal fn.fe = (*Encoder).jsonMarshal fn.fd = (*Decoder).jsonUnmarshal - } else if supportMarshalInterfaces && !c.be && ti.tm { + fi.addrF = true + fi.addrD = ti.jup + fi.addrE = ti.jmp + } else if supportMarshalInterfaces && !c.be && (ti.tm || ti.tmp) && (ti.tu || ti.tup) { fn.fe = (*Encoder).textMarshal fn.fd = (*Decoder).textUnmarshal + fi.addrF = true + fi.addrD = ti.tup + fi.addrE = ti.tmp } else { - rk := rt.Kind() if fastpathEnabled && checkFastpath && (rk == reflect.Map || rk == reflect.Slice) { - if rt.PkgPath() == "" { // un-named slice or map + if ti.pkgpath == "" { // un-named slice or map if idx := fastpathAV.index(rtid); idx != -1 { fn.fe = fastpathAV[idx].encfn fn.fd = fastpathAV[idx].decfn - fn.i.addr = true + fi.addrD = true + fi.addrF = false } } else { // use mapping for underlying type if there var rtu reflect.Type if rk == reflect.Map { - rtu = reflect.MapOf(rt.Key(), rt.Elem()) + rtu = reflect.MapOf(ti.key, ti.elem) } else { - rtu = reflect.SliceOf(rt.Elem()) + rtu = reflect.SliceOf(ti.elem) } rtuid := rt2id(rtu) if idx := fastpathAV.index(rtuid); idx != -1 { @@ -1528,10 +1748,15 @@ func (c *codecFner) get(rt reflect.Type, checkFastpath, checkCodecSelfer bool) ( fn.fe = func(e *Encoder, xf *codecFnInfo, xrv reflect.Value) { xfnf(e, xf, xrv.Convert(xrt)) } - fn.i.addr = true + fi.addrD = true + fi.addrF = false // meaning it can be an address(ptr) or a value xfnf2 := fastpathAV[idx].decfn fn.fd = func(d *Decoder, xf *codecFnInfo, xrv reflect.Value) { - xfnf2(d, xf, xrv.Convert(reflect.PtrTo(xrt))) + if xrv.Kind() == reflect.Ptr { + xfnf2(d, xf, xrv.Convert(reflect.PtrTo(xrt))) + } else { + xfnf2(d, xf, xrv.Convert(xrt)) + } } } } @@ -1548,36 +1773,34 @@ func (c *codecFner) get(rt reflect.Type, checkFastpath, checkCodecSelfer bool) ( fn.fd = (*Decoder).kInt fn.fe = (*Encoder).kInt case reflect.Int8: - fn.fe = (*Encoder).kInt + fn.fe = (*Encoder).kInt8 fn.fd = (*Decoder).kInt8 case reflect.Int16: - fn.fe = (*Encoder).kInt + fn.fe = (*Encoder).kInt16 fn.fd = (*Decoder).kInt16 case reflect.Int32: - fn.fe = (*Encoder).kInt + fn.fe = (*Encoder).kInt32 fn.fd = (*Decoder).kInt32 case reflect.Int64: - fn.fe = (*Encoder).kInt + fn.fe = (*Encoder).kInt64 fn.fd = (*Decoder).kInt64 case reflect.Uint: fn.fd = (*Decoder).kUint fn.fe = (*Encoder).kUint case reflect.Uint8: - fn.fe = (*Encoder).kUint + fn.fe = (*Encoder).kUint8 fn.fd = (*Decoder).kUint8 case reflect.Uint16: - fn.fe = (*Encoder).kUint + fn.fe = (*Encoder).kUint16 fn.fd = (*Decoder).kUint16 case reflect.Uint32: - fn.fe = (*Encoder).kUint + fn.fe = (*Encoder).kUint32 fn.fd = (*Decoder).kUint32 case reflect.Uint64: - fn.fe = (*Encoder).kUint + fn.fe = (*Encoder).kUint64 fn.fd = (*Decoder).kUint64 - // case reflect.Ptr: - // fn.fd = (*Decoder).kPtr case reflect.Uintptr: - fn.fe = (*Encoder).kUint + fn.fe = (*Encoder).kUintptr fn.fd = (*Decoder).kUintptr case reflect.Float32: fn.fe = (*Encoder).kFloat32 @@ -1587,6 +1810,7 @@ func (c *codecFner) get(rt reflect.Type, checkFastpath, checkCodecSelfer bool) ( fn.fd = (*Decoder).kFloat64 case reflect.Invalid: fn.fe = (*Encoder).kInvalid + fn.fd = (*Decoder).kErr case reflect.Chan: fi.seq = seqTypeChan fn.fe = (*Encoder).kSlice @@ -1598,12 +1822,11 @@ func (c *codecFner) get(rt reflect.Type, checkFastpath, checkCodecSelfer bool) ( case reflect.Array: fi.seq = seqTypeArray fn.fe = (*Encoder).kSlice - fi.addr = false - rt2 := reflect.SliceOf(rt.Elem()) + fi.addrF = false + fi.addrD = false + rt2 := reflect.SliceOf(ti.elem) fn.fd = func(d *Decoder, xf *codecFnInfo, xrv reflect.Value) { - // println(">>>>>> decoding an array ... ") - d.cf.get(rt2, true, false).fd(d, xf, xrv.Slice(0, xrv.Len())) - // println(">>>>>> decoding an array ... DONE") + d.cfer().get(rt2, true, false).fd(d, xf, xrv.Slice(0, xrv.Len())) } // fn.fd = (*Decoder).kArray case reflect.Struct: @@ -1613,40 +1836,70 @@ func (c *codecFner) get(rt reflect.Type, checkFastpath, checkCodecSelfer bool) ( fn.fe = (*Encoder).kStructNoOmitempty } fn.fd = (*Decoder).kStruct - // reflect.Ptr and reflect.Interface are handled already by preEncodeValue - // case reflect.Ptr: - // fn.fe = (*Encoder).kPtr - // case reflect.Interface: - // fn.fe = (*Encoder).kInterface case reflect.Map: fn.fe = (*Encoder).kMap fn.fd = (*Decoder).kMap case reflect.Interface: // encode: reflect.Interface are handled already by preEncodeValue fn.fd = (*Decoder).kInterface + fn.fe = (*Encoder).kErr default: + // reflect.Ptr and reflect.Interface are handled already by preEncodeValue fn.fe = (*Encoder).kErr fn.fd = (*Decoder).kErr } } } - return } +type codecFnPooler struct { + cf *codecFner + cfp *sync.Pool + hh Handle +} + +func (d *codecFnPooler) cfer() *codecFner { + if d.cf == nil { + var v interface{} + d.cfp, v = pool.codecFner() + d.cf = v.(*codecFner) + d.cf.reset(d.hh) + } + return d.cf +} + +func (d *codecFnPooler) alwaysAtEnd() { + if d.cf != nil { + d.cfp.Put(d.cf) + d.cf, d.cfp = nil, nil + } +} + // ---- -// these functions must be inlinable, and not call anybody +// these "checkOverflow" functions must be inlinable, and not call anybody. +// Overflow means that the value cannot be represented without wrapping/overflow. +// Overflow=false does not mean that the value can be represented without losing precision +// (especially for floating point). + type checkOverflow struct{} -func (_ checkOverflow) Float32(f float64) (overflow bool) { - if f < 0 { - f = -f +// func (checkOverflow) Float16(f float64) (overflow bool) { +// panicv.errorf("unimplemented") +// if f < 0 { +// f = -f +// } +// return math.MaxFloat32 < f && f <= math.MaxFloat64 +// } + +func (checkOverflow) Float32(v float64) (overflow bool) { + if v < 0 { + v = -v } - return math.MaxFloat32 < f && f <= math.MaxFloat64 + return math.MaxFloat32 < v && v <= math.MaxFloat64 } - -func (_ checkOverflow) Uint(v uint64, bitsize uint8) (overflow bool) { +func (checkOverflow) Uint(v uint64, bitsize uint8) (overflow bool) { if bitsize == 0 || bitsize >= 64 || v == 0 { return } @@ -1655,8 +1908,7 @@ func (_ checkOverflow) Uint(v uint64, bitsize uint8) (overflow bool) { } return } - -func (_ checkOverflow) Int(v int64, bitsize uint8) (overflow bool) { +func (checkOverflow) Int(v int64, bitsize uint8) (overflow bool) { if bitsize == 0 || bitsize >= 64 || v == 0 { return } @@ -1665,39 +1917,76 @@ func (_ checkOverflow) Int(v int64, bitsize uint8) (overflow bool) { } return } - -func (_ checkOverflow) SignedInt(v uint64) (i int64, overflow bool) { +func (checkOverflow) SignedInt(v uint64) (overflow bool) { //e.g. -127 to 128 for int8 pos := (v >> 63) == 0 ui2 := v & 0x7fffffffffffffff if pos { if ui2 > math.MaxInt64 { overflow = true - return } } else { if ui2 > math.MaxInt64-1 { overflow = true - return } } - i = int64(v) return } +func (x checkOverflow) Float32V(v float64) float64 { + if x.Float32(v) { + panicv.errorf("float32 overflow: %v", v) + } + return v +} +func (x checkOverflow) UintV(v uint64, bitsize uint8) uint64 { + if x.Uint(v, bitsize) { + panicv.errorf("uint64 overflow: %v", v) + } + return v +} +func (x checkOverflow) IntV(v int64, bitsize uint8) int64 { + if x.Int(v, bitsize) { + panicv.errorf("int64 overflow: %v", v) + } + return v +} +func (x checkOverflow) SignedIntV(v uint64) int64 { + if x.SignedInt(v) { + panicv.errorf("uint64 to int64 overflow: %v", v) + } + return int64(v) +} + // ------------------ SORT ----------------- func isNaN(f float64) bool { return f != f } // ----------------------- +type ioFlusher interface { + Flush() error +} + +type ioPeeker interface { + Peek(int) ([]byte, error) +} + +type ioBuffered interface { + Buffered() int +} + +// ----------------------- + type intSlice []int64 type uintSlice []uint64 -type uintptrSlice []uintptr + +// type uintptrSlice []uintptr type floatSlice []float64 type boolSlice []bool type stringSlice []string -type bytesSlice [][]byte + +// type bytesSlice [][]byte func (p intSlice) Len() int { return len(p) } func (p intSlice) Less(i, j int) bool { return p[i] < p[j] } @@ -1707,9 +1996,9 @@ func (p uintSlice) Len() int { return len(p) } func (p uintSlice) Less(i, j int) bool { return p[i] < p[j] } func (p uintSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } -func (p uintptrSlice) Len() int { return len(p) } -func (p uintptrSlice) Less(i, j int) bool { return p[i] < p[j] } -func (p uintptrSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } +// func (p uintptrSlice) Len() int { return len(p) } +// func (p uintptrSlice) Less(i, j int) bool { return p[i] < p[j] } +// func (p uintptrSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } func (p floatSlice) Len() int { return len(p) } func (p floatSlice) Less(i, j int) bool { @@ -1721,9 +2010,9 @@ func (p stringSlice) Len() int { return len(p) } func (p stringSlice) Less(i, j int) bool { return p[i] < p[j] } func (p stringSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } -func (p bytesSlice) Len() int { return len(p) } -func (p bytesSlice) Less(i, j int) bool { return bytes.Compare(p[i], p[j]) == -1 } -func (p bytesSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } +// func (p bytesSlice) Len() int { return len(p) } +// func (p bytesSlice) Less(i, j int) bool { return bytes.Compare(p[i], p[j]) == -1 } +// func (p bytesSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } func (p boolSlice) Len() int { return len(p) } func (p boolSlice) Less(i, j int) bool { return !p[i] && p[j] } @@ -1761,6 +2050,11 @@ type bytesRv struct { r reflect.Value } type bytesRvSlice []bytesRv +type timeRv struct { + v time.Time + r reflect.Value +} +type timeRvSlice []timeRv func (p intRvSlice) Len() int { return len(p) } func (p intRvSlice) Less(i, j int) bool { return p[i].v < p[j].v } @@ -1788,6 +2082,10 @@ func (p boolRvSlice) Len() int { return len(p) } func (p boolRvSlice) Less(i, j int) bool { return !p[i].v && p[j].v } func (p boolRvSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } +func (p timeRvSlice) Len() int { return len(p) } +func (p timeRvSlice) Less(i, j int) bool { return p[i].v.Before(p[j].v) } +func (p timeRvSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + // ----------------- type bytesI struct { @@ -1879,36 +2177,69 @@ func (s *set) remove(v uintptr) (exists bool) { type bitset256 [32]byte -func (x *bitset256) set(pos byte) { - x[pos>>3] |= (1 << (pos & 7)) -} -func (x *bitset256) unset(pos byte) { - x[pos>>3] &^= (1 << (pos & 7)) -} func (x *bitset256) isset(pos byte) bool { return x[pos>>3]&(1<<(pos&7)) != 0 } +func (x *bitset256) issetv(pos byte) byte { + return x[pos>>3] & (1 << (pos & 7)) +} +func (x *bitset256) set(pos byte) { + x[pos>>3] |= (1 << (pos & 7)) +} + +// func (x *bitset256) unset(pos byte) { +// x[pos>>3] &^= (1 << (pos & 7)) +// } type bitset128 [16]byte +func (x *bitset128) isset(pos byte) bool { + return x[pos>>3]&(1<<(pos&7)) != 0 +} func (x *bitset128) set(pos byte) { x[pos>>3] |= (1 << (pos & 7)) } -func (x *bitset128) unset(pos byte) { - x[pos>>3] &^= (1 << (pos & 7)) -} -func (x *bitset128) isset(pos byte) bool { + +// func (x *bitset128) unset(pos byte) { +// x[pos>>3] &^= (1 << (pos & 7)) +// } + +type bitset32 [4]byte + +func (x *bitset32) isset(pos byte) bool { return x[pos>>3]&(1<<(pos&7)) != 0 } +func (x *bitset32) set(pos byte) { + x[pos>>3] |= (1 << (pos & 7)) +} + +// func (x *bitset32) unset(pos byte) { +// x[pos>>3] &^= (1 << (pos & 7)) +// } + +// type bit2set256 [64]byte + +// func (x *bit2set256) set(pos byte, v1, v2 bool) { +// var pos2 uint8 = (pos & 3) << 1 // returning 0, 2, 4 or 6 +// if v1 { +// x[pos>>2] |= 1 << (pos2 + 1) +// } +// if v2 { +// x[pos>>2] |= 1 << pos2 +// } +// } +// func (x *bit2set256) get(pos byte) uint8 { +// var pos2 uint8 = (pos & 3) << 1 // returning 0, 2, 4 or 6 +// return x[pos>>2] << (6 - pos2) >> 6 // 11000000 -> 00000011 +// } // ------------ type pooler struct { - // for stringRV - strRv8, strRv16, strRv32, strRv64, strRv128 sync.Pool - // for the decNaked - dn sync.Pool - tiload sync.Pool + dn sync.Pool // for decNaked + cfn sync.Pool // for codecFner + tiload sync.Pool + strRv8, strRv16, strRv32, strRv64, strRv128 sync.Pool // for stringRV } func (p *pooler) init() { @@ -1919,6 +2250,7 @@ func (p *pooler) init() { p.strRv128.New = func() interface{} { return new([128]stringRv) } p.dn.New = func() interface{} { x := new(decNaked); x.init(); return x } p.tiload.New = func() interface{} { return new(typeInfoLoadArray) } + p.cfn.New = func() interface{} { return new(codecFner) } } func (p *pooler) stringRv8() (sp *sync.Pool, v interface{}) { @@ -1939,6 +2271,143 @@ func (p *pooler) stringRv128() (sp *sync.Pool, v interface{}) { func (p *pooler) decNaked() (sp *sync.Pool, v interface{}) { return &p.dn, p.dn.Get() } +func (p *pooler) codecFner() (sp *sync.Pool, v interface{}) { + return &p.cfn, p.cfn.Get() +} func (p *pooler) tiLoad() (sp *sync.Pool, v interface{}) { return &p.tiload, p.tiload.Get() } + +// func (p *pooler) decNaked() (v *decNaked, f func(*decNaked) ) { +// sp := &(p.dn) +// vv := sp.Get() +// return vv.(*decNaked), func(x *decNaked) { sp.Put(vv) } +// } +// func (p *pooler) decNakedGet() (v interface{}) { +// return p.dn.Get() +// } +// func (p *pooler) codecFnerGet() (v interface{}) { +// return p.cfn.Get() +// } +// func (p *pooler) tiLoadGet() (v interface{}) { +// return p.tiload.Get() +// } +// func (p *pooler) decNakedPut(v interface{}) { +// p.dn.Put(v) +// } +// func (p *pooler) codecFnerPut(v interface{}) { +// p.cfn.Put(v) +// } +// func (p *pooler) tiLoadPut(v interface{}) { +// p.tiload.Put(v) +// } + +type panicHdl struct{} + +func (panicHdl) errorv(err error) { + if err != nil { + panic(err) + } +} + +func (panicHdl) errorstr(message string) { + if message != "" { + panic(message) + } +} + +func (panicHdl) errorf(format string, params ...interface{}) { + if format != "" { + if len(params) == 0 { + panic(format) + } else { + panic(fmt.Sprintf(format, params...)) + } + } +} + +type errstrDecorator interface { + wrapErrstr(interface{}, *error) +} + +type errstrDecoratorDef struct{} + +func (errstrDecoratorDef) wrapErrstr(v interface{}, e *error) { *e = fmt.Errorf("%v", v) } + +type must struct{} + +func (must) String(s string, err error) string { + if err != nil { + panicv.errorv(err) + } + return s +} +func (must) Int(s int64, err error) int64 { + if err != nil { + panicv.errorv(err) + } + return s +} +func (must) Uint(s uint64, err error) uint64 { + if err != nil { + panicv.errorv(err) + } + return s +} +func (must) Float(s float64, err error) float64 { + if err != nil { + panicv.errorv(err) + } + return s +} + +// xdebugf prints the message in red on the terminal. +// Use it in place of fmt.Printf (which it calls internally) +func xdebugf(pattern string, args ...interface{}) { + var delim string + if len(pattern) > 0 && pattern[len(pattern)-1] != '\n' { + delim = "\n" + } + fmt.Printf("\033[1;31m"+pattern+delim+"\033[0m", args...) +} + +// func isImmutableKind(k reflect.Kind) (v bool) { +// return false || +// k == reflect.Int || +// k == reflect.Int8 || +// k == reflect.Int16 || +// k == reflect.Int32 || +// k == reflect.Int64 || +// k == reflect.Uint || +// k == reflect.Uint8 || +// k == reflect.Uint16 || +// k == reflect.Uint32 || +// k == reflect.Uint64 || +// k == reflect.Uintptr || +// k == reflect.Float32 || +// k == reflect.Float64 || +// k == reflect.Bool || +// k == reflect.String +// } + +// func timeLocUTCName(tzint int16) string { +// if tzint == 0 { +// return "UTC" +// } +// var tzname = []byte("UTC+00:00") +// //tzname := fmt.Sprintf("UTC%s%02d:%02d", tzsign, tz/60, tz%60) //perf issue using Sprintf. inline below. +// //tzhr, tzmin := tz/60, tz%60 //faster if u convert to int first +// var tzhr, tzmin int16 +// if tzint < 0 { +// tzname[3] = '-' // (TODO: verify. this works here) +// tzhr, tzmin = -tzint/60, (-tzint)%60 +// } else { +// tzhr, tzmin = tzint/60, tzint%60 +// } +// tzname[4] = timeDigits[tzhr/10] +// tzname[5] = timeDigits[tzhr%10] +// tzname[7] = timeDigits[tzmin/10] +// tzname[8] = timeDigits[tzmin%10] +// return string(tzname) +// //return time.FixedZone(string(tzname), int(tzint)*60) +// } diff --git a/vendor/github.com/ugorji/go/codec/helper_internal.go b/vendor/github.com/ugorji/go/codec/helper_internal.go index eb18e2cca..0cbd665e2 100644 --- a/vendor/github.com/ugorji/go/codec/helper_internal.go +++ b/vendor/github.com/ugorji/go/codec/helper_internal.go @@ -6,74 +6,6 @@ package codec // All non-std package dependencies live in this file, // so porting to different environment is easy (just update functions). -import ( - "errors" - "fmt" - "math" - "reflect" -) - -func panicValToErr(panicVal interface{}, err *error) { - if panicVal == nil { - return - } - // case nil - switch xerr := panicVal.(type) { - case error: - *err = xerr - case string: - *err = errors.New(xerr) - default: - *err = fmt.Errorf("%v", panicVal) - } - return -} - -func hIsEmptyValue(v reflect.Value, deref, checkStruct bool) bool { - switch v.Kind() { - case reflect.Invalid: - return true - case reflect.Array, reflect.Map, reflect.Slice, reflect.String: - return v.Len() == 0 - case reflect.Bool: - return !v.Bool() - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return v.Int() == 0 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return v.Uint() == 0 - case reflect.Float32, reflect.Float64: - return v.Float() == 0 - case reflect.Interface, reflect.Ptr: - if deref { - if v.IsNil() { - return true - } - return hIsEmptyValue(v.Elem(), deref, checkStruct) - } else { - return v.IsNil() - } - case reflect.Struct: - if !checkStruct { - return false - } - // return true if all fields are empty. else return false. - // we cannot use equality check, because some fields may be maps/slices/etc - // and consequently the structs are not comparable. - // return v.Interface() == reflect.Zero(v.Type()).Interface() - for i, n := 0, v.NumField(); i < n; i++ { - if !hIsEmptyValue(v.Field(i), deref, checkStruct) { - return false - } - } - return true - } - return false -} - -func isEmptyValue(v reflect.Value, deref, checkStruct bool) bool { - return hIsEmptyValue(v, deref, checkStruct) -} - func pruneSignExt(v []byte, pos bool) (n int) { if len(v) < 2 { } else if pos && v[0] == 0 { @@ -86,37 +18,6 @@ func pruneSignExt(v []byte, pos bool) (n int) { return } -func implementsIntf(typ, iTyp reflect.Type) (success bool, indir int8) { - if typ == nil { - return - } - rt := typ - // The type might be a pointer and we need to keep - // dereferencing to the base type until we find an implementation. - for { - if rt.Implements(iTyp) { - return true, indir - } - if p := rt; p.Kind() == reflect.Ptr { - indir++ - if indir >= math.MaxInt8 { // insane number of indirections - return false, 0 - } - rt = p.Elem() - continue - } - break - } - // No luck yet, but if this is a base type (non-pointer), the pointer might satisfy. - if typ.Kind() != reflect.Ptr { - // Not a pointer, but does the pointer work? - if reflect.PtrTo(typ).Implements(iTyp) { - return true, -1 - } - } - return false, 0 -} - // validate that this function is correct ... // culled from OGRE (Object-Oriented Graphics Rendering Engine) // function: halfToFloatI (http://stderr.org/doc/ogre-doc/api/OgreBitwise_8h-source.html) @@ -129,21 +30,20 @@ func halfFloatToFloatBits(yy uint16) (d uint32) { if e == 0 { if m == 0 { // plu or minus 0 return s << 31 - } else { // Denormalized number -- renormalize it - for (m & 0x00000400) == 0 { - m <<= 1 - e -= 1 - } - e += 1 - const zz uint32 = 0x0400 - m &= ^zz } + // Denormalized number -- renormalize it + for (m & 0x00000400) == 0 { + m <<= 1 + e -= 1 + } + e += 1 + const zz uint32 = 0x0400 + m &= ^zz } else if e == 31 { if m == 0 { // Inf return (s << 31) | 0x7f800000 - } else { // NaN - return (s << 31) | 0x7f800000 | (m << 13) } + return (s << 31) | 0x7f800000 | (m << 13) // NaN } e = e + (127 - 15) m = m << 13 diff --git a/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go b/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go index 9d9d048ea..0c5e1bfdb 100644 --- a/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go +++ b/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go @@ -1,6 +1,6 @@ // +build !go1.7 safe appengine -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. package codec @@ -8,8 +8,11 @@ package codec import ( "reflect" "sync/atomic" + "time" ) +const safeMode = true + // stringView returns a view of the []byte as a string. // In unsafe mode, it doesn't incur allocation and copying caused by conversion. // In regular safe mode, it is an allocation and copy. @@ -31,28 +34,11 @@ func bytesView(v string) []byte { } func definitelyNil(v interface{}) bool { + // this is a best-effort option. + // We just return false, so we don't unnecessarily incur the cost of reflection this early. return false - // rv := reflect.ValueOf(v) - // switch rv.Kind() { - // case reflect.Invalid: - // return true - // case reflect.Ptr, reflect.Interface, reflect.Chan, reflect.Slice, reflect.Map, reflect.Func: - // return rv.IsNil() - // default: - // return false - // } } -// // keepAlive4BytesView maintains a reference to the input parameter for bytesView. -// // -// // Usage: call this at point where done with the bytes view. -// func keepAlive4BytesView(v string) {} - -// // keepAlive4BytesView maintains a reference to the input parameter for stringView. -// // -// // Usage: call this at point where done with the string view. -// func keepAlive4StringView(v []byte) {} - func rv2i(rv reflect.Value) interface{} { return rv.Interface() } @@ -65,16 +51,50 @@ func rv2rtid(rv reflect.Value) uintptr { return reflect.ValueOf(rv.Type()).Pointer() } +func i2rtid(i interface{}) uintptr { + return reflect.ValueOf(reflect.TypeOf(i)).Pointer() +} + +// -------------------------- + +func isEmptyValue(v reflect.Value, tinfos *TypeInfos, deref, checkStruct bool) bool { + switch v.Kind() { + case reflect.Invalid: + return true + case reflect.Array, reflect.Map, reflect.Slice, reflect.String: + return v.Len() == 0 + case reflect.Bool: + return !v.Bool() + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return v.Int() == 0 + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return v.Uint() == 0 + case reflect.Float32, reflect.Float64: + return v.Float() == 0 + case reflect.Interface, reflect.Ptr: + if deref { + if v.IsNil() { + return true + } + return isEmptyValue(v.Elem(), tinfos, deref, checkStruct) + } + return v.IsNil() + case reflect.Struct: + return isEmptyStruct(v, tinfos, deref, checkStruct) + } + return false +} + // -------------------------- // type ptrToRvMap struct{} -// func (_ *ptrToRvMap) init() {} -// func (_ *ptrToRvMap) get(i interface{}) reflect.Value { +// func (*ptrToRvMap) init() {} +// func (*ptrToRvMap) get(i interface{}) reflect.Value { // return reflect.ValueOf(i).Elem() // } // -------------------------- -type atomicTypeInfoSlice struct { +type atomicTypeInfoSlice struct { // expected to be 2 words v atomic.Value } @@ -103,54 +123,150 @@ func (d *Decoder) kBool(f *codecFnInfo, rv reflect.Value) { rv.SetBool(d.d.DecodeBool()) } +func (d *Decoder) kTime(f *codecFnInfo, rv reflect.Value) { + rv.Set(reflect.ValueOf(d.d.DecodeTime())) +} + func (d *Decoder) kFloat32(f *codecFnInfo, rv reflect.Value) { - rv.SetFloat(d.d.DecodeFloat(true)) + fv := d.d.DecodeFloat64() + if chkOvf.Float32(fv) { + d.errorf("float32 overflow: %v", fv) + } + rv.SetFloat(fv) } func (d *Decoder) kFloat64(f *codecFnInfo, rv reflect.Value) { - rv.SetFloat(d.d.DecodeFloat(false)) + rv.SetFloat(d.d.DecodeFloat64()) } func (d *Decoder) kInt(f *codecFnInfo, rv reflect.Value) { - rv.SetInt(d.d.DecodeInt(intBitsize)) + rv.SetInt(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) } func (d *Decoder) kInt8(f *codecFnInfo, rv reflect.Value) { - rv.SetInt(d.d.DecodeInt(8)) + rv.SetInt(chkOvf.IntV(d.d.DecodeInt64(), 8)) } func (d *Decoder) kInt16(f *codecFnInfo, rv reflect.Value) { - rv.SetInt(d.d.DecodeInt(16)) + rv.SetInt(chkOvf.IntV(d.d.DecodeInt64(), 16)) } func (d *Decoder) kInt32(f *codecFnInfo, rv reflect.Value) { - rv.SetInt(d.d.DecodeInt(32)) + rv.SetInt(chkOvf.IntV(d.d.DecodeInt64(), 32)) } func (d *Decoder) kInt64(f *codecFnInfo, rv reflect.Value) { - rv.SetInt(d.d.DecodeInt(64)) + rv.SetInt(d.d.DecodeInt64()) } func (d *Decoder) kUint(f *codecFnInfo, rv reflect.Value) { - rv.SetUint(d.d.DecodeUint(uintBitsize)) + rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) } func (d *Decoder) kUintptr(f *codecFnInfo, rv reflect.Value) { - rv.SetUint(d.d.DecodeUint(uintBitsize)) + rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) } func (d *Decoder) kUint8(f *codecFnInfo, rv reflect.Value) { - rv.SetUint(d.d.DecodeUint(8)) + rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), 8)) } func (d *Decoder) kUint16(f *codecFnInfo, rv reflect.Value) { - rv.SetUint(d.d.DecodeUint(16)) + rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), 16)) } func (d *Decoder) kUint32(f *codecFnInfo, rv reflect.Value) { - rv.SetUint(d.d.DecodeUint(32)) + rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), 32)) } func (d *Decoder) kUint64(f *codecFnInfo, rv reflect.Value) { - rv.SetUint(d.d.DecodeUint(64)) + rv.SetUint(d.d.DecodeUint64()) } + +// ---------------- + +func (e *Encoder) kBool(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeBool(rv.Bool()) +} + +func (e *Encoder) kTime(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeTime(rv2i(rv).(time.Time)) +} + +func (e *Encoder) kString(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeString(cUTF8, rv.String()) +} + +func (e *Encoder) kFloat64(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeFloat64(rv.Float()) +} + +func (e *Encoder) kFloat32(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeFloat32(float32(rv.Float())) +} + +func (e *Encoder) kInt(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeInt(rv.Int()) +} + +func (e *Encoder) kInt8(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeInt(rv.Int()) +} + +func (e *Encoder) kInt16(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeInt(rv.Int()) +} + +func (e *Encoder) kInt32(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeInt(rv.Int()) +} + +func (e *Encoder) kInt64(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeInt(rv.Int()) +} + +func (e *Encoder) kUint(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeUint(rv.Uint()) +} + +func (e *Encoder) kUint8(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeUint(rv.Uint()) +} + +func (e *Encoder) kUint16(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeUint(rv.Uint()) +} + +func (e *Encoder) kUint32(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeUint(rv.Uint()) +} + +func (e *Encoder) kUint64(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeUint(rv.Uint()) +} + +func (e *Encoder) kUintptr(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeUint(rv.Uint()) +} + +// // keepAlive4BytesView maintains a reference to the input parameter for bytesView. +// // +// // Usage: call this at point where done with the bytes view. +// func keepAlive4BytesView(v string) {} + +// // keepAlive4BytesView maintains a reference to the input parameter for stringView. +// // +// // Usage: call this at point where done with the string view. +// func keepAlive4StringView(v []byte) {} + +// func definitelyNil(v interface{}) bool { +// rv := reflect.ValueOf(v) +// switch rv.Kind() { +// case reflect.Invalid: +// return true +// case reflect.Ptr, reflect.Interface, reflect.Chan, reflect.Slice, reflect.Map, reflect.Func: +// return rv.IsNil() +// default: +// return false +// } +// } diff --git a/vendor/github.com/ugorji/go/codec/helper_unsafe.go b/vendor/github.com/ugorji/go/codec/helper_unsafe.go index c7c01b811..5e9a33aea 100644 --- a/vendor/github.com/ugorji/go/codec/helper_unsafe.go +++ b/vendor/github.com/ugorji/go/codec/helper_unsafe.go @@ -2,7 +2,7 @@ // +build !appengine // +build go1.7 -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. package codec @@ -10,6 +10,7 @@ package codec import ( "reflect" "sync/atomic" + "time" "unsafe" ) @@ -18,6 +19,7 @@ import ( // var zeroRTv [4]uintptr +const safeMode = false const unsafeFlagIndir = 1 << 7 // keep in sync with GO_ROOT/src/reflect/value.go type unsafeString struct { @@ -46,50 +48,49 @@ func stringView(v []byte) string { if len(v) == 0 { return "" } - bx := (*unsafeSlice)(unsafe.Pointer(&v)) - sx := unsafeString{bx.Data, bx.Len} - return *(*string)(unsafe.Pointer(&sx)) + return *(*string)(unsafe.Pointer(&unsafeString{bx.Data, bx.Len})) } func bytesView(v string) []byte { if len(v) == 0 { return zeroByteSlice } - sx := (*unsafeString)(unsafe.Pointer(&v)) - bx := unsafeSlice{sx.Data, sx.Len, sx.Len} - return *(*[]byte)(unsafe.Pointer(&bx)) + return *(*[]byte)(unsafe.Pointer(&unsafeSlice{sx.Data, sx.Len, sx.Len})) } func definitelyNil(v interface{}) bool { - return (*unsafeIntf)(unsafe.Pointer(&v)).word == nil + // There is no global way of checking if an interface is nil. + // For true references (map, ptr, func, chan), you can just look + // at the word of the interface. However, for slices, you have to dereference + // the word, and get a pointer to the 3-word interface value. + // + // However, the following are cheap calls + // - TypeOf(interface): cheap 2-line call. + // - ValueOf(interface{}): expensive + // - type.Kind: cheap call through an interface + // - Value.Type(): cheap call + // except it's a method value (e.g. r.Read, which implies that it is a Func) + + return ((*unsafeIntf)(unsafe.Pointer(&v))).word == nil } -// func keepAlive4BytesView(v string) { -// runtime.KeepAlive(v) -// } - -// func keepAlive4StringView(v []byte) { -// runtime.KeepAlive(v) -// } - -// TODO: consider a more generally-known optimization for reflect.Value ==> Interface -// -// Currently, we use this fragile method that taps into implememtation details from -// the source go stdlib reflect/value.go, -// and trims the implementation. func rv2i(rv reflect.Value) interface{} { - if false { - return rv.Interface() - } + // TODO: consider a more generally-known optimization for reflect.Value ==> Interface + // + // Currently, we use this fragile method that taps into implememtation details from + // the source go stdlib reflect/value.go, and trims the implementation. + urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - // references that are single-words (map, ptr) may be double-referenced as flagIndir - kk := urv.flag & (1<<5 - 1) - if (kk == uintptr(reflect.Map) || kk == uintptr(reflect.Ptr)) && urv.flag&unsafeFlagIndir != 0 { - return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: *(*unsafe.Pointer)(urv.ptr), typ: urv.typ})) + // true references (map, func, chan, ptr - NOT slice) may be double-referenced as flagIndir + var ptr unsafe.Pointer + if refBitset.isset(byte(urv.flag&(1<<5-1))) && urv.flag&unsafeFlagIndir != 0 { + ptr = *(*unsafe.Pointer)(urv.ptr) + } else { + ptr = urv.ptr } - return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: urv.ptr, typ: urv.typ})) + return *(*interface{})(unsafe.Pointer(&unsafeIntf{typ: urv.typ, word: ptr})) } func rt2id(rt reflect.Type) uintptr { @@ -100,16 +101,83 @@ func rv2rtid(rv reflect.Value) uintptr { return uintptr((*unsafeReflectValue)(unsafe.Pointer(&rv)).typ) } -// func rv0t(rt reflect.Type) reflect.Value { -// ut := (*unsafeIntf)(unsafe.Pointer(&rt)) -// // we need to determine whether ifaceIndir, and then whether to just pass 0 as the ptr -// uv := unsafeReflectValue{ut.word, &zeroRTv, flag(rt.Kind())} -// return *(*reflect.Value)(unsafe.Pointer(&uv}) -// } +func i2rtid(i interface{}) uintptr { + return uintptr(((*unsafeIntf)(unsafe.Pointer(&i))).typ) +} + +// -------------------------- + +func isEmptyValue(v reflect.Value, tinfos *TypeInfos, deref, checkStruct bool) bool { + urv := (*unsafeReflectValue)(unsafe.Pointer(&v)) + if urv.flag == 0 { + return true + } + switch v.Kind() { + case reflect.Invalid: + return true + case reflect.String: + return (*unsafeString)(urv.ptr).Len == 0 + case reflect.Slice: + return (*unsafeSlice)(urv.ptr).Len == 0 + case reflect.Bool: + return !*(*bool)(urv.ptr) + case reflect.Int: + return *(*int)(urv.ptr) == 0 + case reflect.Int8: + return *(*int8)(urv.ptr) == 0 + case reflect.Int16: + return *(*int16)(urv.ptr) == 0 + case reflect.Int32: + return *(*int32)(urv.ptr) == 0 + case reflect.Int64: + return *(*int64)(urv.ptr) == 0 + case reflect.Uint: + return *(*uint)(urv.ptr) == 0 + case reflect.Uint8: + return *(*uint8)(urv.ptr) == 0 + case reflect.Uint16: + return *(*uint16)(urv.ptr) == 0 + case reflect.Uint32: + return *(*uint32)(urv.ptr) == 0 + case reflect.Uint64: + return *(*uint64)(urv.ptr) == 0 + case reflect.Uintptr: + return *(*uintptr)(urv.ptr) == 0 + case reflect.Float32: + return *(*float32)(urv.ptr) == 0 + case reflect.Float64: + return *(*float64)(urv.ptr) == 0 + case reflect.Interface: + isnil := urv.ptr == nil || *(*unsafe.Pointer)(urv.ptr) == nil + if deref { + if isnil { + return true + } + return isEmptyValue(v.Elem(), tinfos, deref, checkStruct) + } + return isnil + case reflect.Ptr: + isnil := urv.ptr == nil + if deref { + if isnil { + return true + } + return isEmptyValue(v.Elem(), tinfos, deref, checkStruct) + } + return isnil + case reflect.Struct: + return isEmptyStruct(v, tinfos, deref, checkStruct) + case reflect.Map, reflect.Array, reflect.Chan: + return v.Len() == 0 + } + return false +} // -------------------------- -type atomicTypeInfoSlice struct { + +type atomicTypeInfoSlice struct { // expected to be 2 words v unsafe.Pointer + _ [8]byte // padding } func (x *atomicTypeInfoSlice) load() *[]rtid2ti { @@ -123,9 +191,6 @@ func (x *atomicTypeInfoSlice) store(p *[]rtid2ti) { // -------------------------- func (d *Decoder) raw(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - // if urv.flag&unsafeFlagIndir != 0 { - // urv.ptr = *(*unsafe.Pointer)(urv.ptr) - // } *(*[]byte)(urv.ptr) = d.rawBytes() } @@ -139,73 +204,214 @@ func (d *Decoder) kBool(f *codecFnInfo, rv reflect.Value) { *(*bool)(urv.ptr) = d.d.DecodeBool() } +func (d *Decoder) kTime(f *codecFnInfo, rv reflect.Value) { + urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) + *(*time.Time)(urv.ptr) = d.d.DecodeTime() +} + func (d *Decoder) kFloat32(f *codecFnInfo, rv reflect.Value) { + fv := d.d.DecodeFloat64() + if chkOvf.Float32(fv) { + d.errorf("float32 overflow: %v", fv) + } urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*float32)(urv.ptr) = float32(d.d.DecodeFloat(true)) + *(*float32)(urv.ptr) = float32(fv) } func (d *Decoder) kFloat64(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*float64)(urv.ptr) = d.d.DecodeFloat(false) + *(*float64)(urv.ptr) = d.d.DecodeFloat64() } func (d *Decoder) kInt(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*int)(urv.ptr) = int(d.d.DecodeInt(intBitsize)) + *(*int)(urv.ptr) = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) } func (d *Decoder) kInt8(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*int8)(urv.ptr) = int8(d.d.DecodeInt(8)) + *(*int8)(urv.ptr) = int8(chkOvf.IntV(d.d.DecodeInt64(), 8)) } func (d *Decoder) kInt16(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*int16)(urv.ptr) = int16(d.d.DecodeInt(16)) + *(*int16)(urv.ptr) = int16(chkOvf.IntV(d.d.DecodeInt64(), 16)) } func (d *Decoder) kInt32(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*int32)(urv.ptr) = int32(d.d.DecodeInt(32)) + *(*int32)(urv.ptr) = int32(chkOvf.IntV(d.d.DecodeInt64(), 32)) } func (d *Decoder) kInt64(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*int64)(urv.ptr) = d.d.DecodeInt(64) + *(*int64)(urv.ptr) = d.d.DecodeInt64() } func (d *Decoder) kUint(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*uint)(urv.ptr) = uint(d.d.DecodeUint(uintBitsize)) + *(*uint)(urv.ptr) = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) } func (d *Decoder) kUintptr(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*uintptr)(urv.ptr) = uintptr(d.d.DecodeUint(uintBitsize)) + *(*uintptr)(urv.ptr) = uintptr(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) } func (d *Decoder) kUint8(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*uint8)(urv.ptr) = uint8(d.d.DecodeUint(8)) + *(*uint8)(urv.ptr) = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) } func (d *Decoder) kUint16(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*uint16)(urv.ptr) = uint16(d.d.DecodeUint(16)) + *(*uint16)(urv.ptr) = uint16(chkOvf.UintV(d.d.DecodeUint64(), 16)) } func (d *Decoder) kUint32(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*uint32)(urv.ptr) = uint32(d.d.DecodeUint(32)) + *(*uint32)(urv.ptr) = uint32(chkOvf.UintV(d.d.DecodeUint64(), 32)) } func (d *Decoder) kUint64(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*uint64)(urv.ptr) = d.d.DecodeUint(64) + *(*uint64)(urv.ptr) = d.d.DecodeUint64() +} + +// ------------ + +func (e *Encoder) kBool(f *codecFnInfo, rv reflect.Value) { + v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) + e.e.EncodeBool(*(*bool)(v.ptr)) +} + +func (e *Encoder) kTime(f *codecFnInfo, rv reflect.Value) { + v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) + e.e.EncodeTime(*(*time.Time)(v.ptr)) +} + +func (e *Encoder) kString(f *codecFnInfo, rv reflect.Value) { + v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) + e.e.EncodeString(cUTF8, *(*string)(v.ptr)) +} + +func (e *Encoder) kFloat64(f *codecFnInfo, rv reflect.Value) { + v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) + e.e.EncodeFloat64(*(*float64)(v.ptr)) +} + +func (e *Encoder) kFloat32(f *codecFnInfo, rv reflect.Value) { + v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) + e.e.EncodeFloat32(*(*float32)(v.ptr)) +} + +func (e *Encoder) kInt(f *codecFnInfo, rv reflect.Value) { + v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) + e.e.EncodeInt(int64(*(*int)(v.ptr))) +} + +func (e *Encoder) kInt8(f *codecFnInfo, rv reflect.Value) { + v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) + e.e.EncodeInt(int64(*(*int8)(v.ptr))) +} + +func (e *Encoder) kInt16(f *codecFnInfo, rv reflect.Value) { + v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) + e.e.EncodeInt(int64(*(*int16)(v.ptr))) +} + +func (e *Encoder) kInt32(f *codecFnInfo, rv reflect.Value) { + v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) + e.e.EncodeInt(int64(*(*int32)(v.ptr))) +} + +func (e *Encoder) kInt64(f *codecFnInfo, rv reflect.Value) { + v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) + e.e.EncodeInt(int64(*(*int64)(v.ptr))) +} + +func (e *Encoder) kUint(f *codecFnInfo, rv reflect.Value) { + v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) + e.e.EncodeUint(uint64(*(*uint)(v.ptr))) +} + +func (e *Encoder) kUint8(f *codecFnInfo, rv reflect.Value) { + v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) + e.e.EncodeUint(uint64(*(*uint8)(v.ptr))) +} + +func (e *Encoder) kUint16(f *codecFnInfo, rv reflect.Value) { + v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) + e.e.EncodeUint(uint64(*(*uint16)(v.ptr))) +} + +func (e *Encoder) kUint32(f *codecFnInfo, rv reflect.Value) { + v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) + e.e.EncodeUint(uint64(*(*uint32)(v.ptr))) +} + +func (e *Encoder) kUint64(f *codecFnInfo, rv reflect.Value) { + v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) + e.e.EncodeUint(uint64(*(*uint64)(v.ptr))) +} + +func (e *Encoder) kUintptr(f *codecFnInfo, rv reflect.Value) { + v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) + e.e.EncodeUint(uint64(*(*uintptr)(v.ptr))) } // ------------ +// func (d *Decoder) raw(f *codecFnInfo, rv reflect.Value) { +// urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) +// // if urv.flag&unsafeFlagIndir != 0 { +// // urv.ptr = *(*unsafe.Pointer)(urv.ptr) +// // } +// *(*[]byte)(urv.ptr) = d.rawBytes() +// } + +// func rv0t(rt reflect.Type) reflect.Value { +// ut := (*unsafeIntf)(unsafe.Pointer(&rt)) +// // we need to determine whether ifaceIndir, and then whether to just pass 0 as the ptr +// uv := unsafeReflectValue{ut.word, &zeroRTv, flag(rt.Kind())} +// return *(*reflect.Value)(unsafe.Pointer(&uv}) +// } + +// func rv2i(rv reflect.Value) interface{} { +// urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) +// // true references (map, func, chan, ptr - NOT slice) may be double-referenced as flagIndir +// var ptr unsafe.Pointer +// // kk := reflect.Kind(urv.flag & (1<<5 - 1)) +// // if (kk == reflect.Map || kk == reflect.Ptr || kk == reflect.Chan || kk == reflect.Func) && urv.flag&unsafeFlagIndir != 0 { +// if refBitset.isset(byte(urv.flag&(1<<5-1))) && urv.flag&unsafeFlagIndir != 0 { +// ptr = *(*unsafe.Pointer)(urv.ptr) +// } else { +// ptr = urv.ptr +// } +// return *(*interface{})(unsafe.Pointer(&unsafeIntf{typ: urv.typ, word: ptr})) +// // return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: *(*unsafe.Pointer)(urv.ptr), typ: urv.typ})) +// // return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: urv.ptr, typ: urv.typ})) +// } + +// func definitelyNil(v interface{}) bool { +// var ui *unsafeIntf = (*unsafeIntf)(unsafe.Pointer(&v)) +// if ui.word == nil { +// return true +// } +// var tk = reflect.TypeOf(v).Kind() +// return (tk == reflect.Interface || tk == reflect.Slice) && *(*unsafe.Pointer)(ui.word) == nil +// fmt.Printf(">>>> definitely nil: isnil: %v, TYPE: \t%T, word: %v, *word: %v, type: %v, nil: %v\n", +// v == nil, v, word, *((*unsafe.Pointer)(word)), ui.typ, nil) +// } + +// func keepAlive4BytesView(v string) { +// runtime.KeepAlive(v) +// } + +// func keepAlive4StringView(v []byte) { +// runtime.KeepAlive(v) +// } + // func rt2id(rt reflect.Type) uintptr { // return uintptr(((*unsafeIntf)(unsafe.Pointer(&rt))).word) // // var i interface{} = rt diff --git a/vendor/github.com/ugorji/go/codec/json.go b/vendor/github.com/ugorji/go/codec/json.go index a6af2c809..ec7b0d656 100644 --- a/vendor/github.com/ugorji/go/codec/json.go +++ b/vendor/github.com/ugorji/go/codec/json.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. package codec @@ -17,16 +17,6 @@ package codec // Note: // - we cannot use strconv.Quote and strconv.Unquote because json quotes/unquotes differently. // We implement it here. -// - Also, strconv.ParseXXX for floats and integers -// - only works on strings resulting in unnecessary allocation and []byte-string conversion. -// - it does a lot of redundant checks, because json numbers are simpler that what it supports. -// - We parse numbers (floats and integers) directly here. -// We only delegate parsing floats if it is a hairy float which could cause a loss of precision. -// In that case, we delegate to strconv.ParseFloat. -// -// Note: -// - encode does not beautify. There is no whitespace when encoding. -// - rpc calls which take single integer arguments or write single numeric arguments will need care. // Top-level methods of json(End|Dec)Driver (which are implementations of (en|de)cDriver // MUST not call one-another. @@ -34,49 +24,41 @@ package codec import ( "bytes" "encoding/base64" + "math" "reflect" "strconv" + "time" + "unicode" "unicode/utf16" "unicode/utf8" ) //-------------------------------- -var ( - // jsonLiterals = [...]byte{'t', 'r', 'u', 'e', 'f', 'a', 'l', 's', 'e', 'n', 'u', 'l', 'l'} - - // jsonFloat64Pow10 = [...]float64{ - // 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, - // 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, - // 1e20, 1e21, 1e22, - // } - - // jsonUint64Pow10 = [...]uint64{ - // 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, - // 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, - // } +var jsonLiterals = [...]byte{ + '"', 't', 'r', 'u', 'e', '"', + '"', 'f', 'a', 'l', 's', 'e', '"', + '"', 'n', 'u', 'l', 'l', '"', +} - // jsonTabs and jsonSpaces are used as caches for indents - jsonTabs, jsonSpaces string +const ( + jsonLitTrueQ = 0 + jsonLitTrue = 1 + jsonLitFalseQ = 6 + jsonLitFalse = 7 + jsonLitNullQ = 13 + jsonLitNull = 14 +) - jsonCharHtmlSafeSet bitset128 - jsonCharSafeSet bitset128 - jsonCharWhitespaceSet bitset256 - jsonNumSet bitset256 - // jsonIsFloatSet bitset256 +const ( + jsonU4Chk2 = '0' + jsonU4Chk1 = 'a' - 10 + jsonU4Chk0 = 'A' - 10 - jsonU4Set [256]byte + jsonScratchArrayLen = 64 ) const ( - // jsonUnreadAfterDecNum controls whether we unread after decoding a number. - // - // instead of unreading, just update d.tok (iff it's not a whitespace char) - // However, doing this means that we may HOLD onto some data which belongs to another stream. - // Thus, it is safest to unread the data when done. - // keep behind a constant flag for now. - jsonUnreadAfterDecNum = true - // If !jsonValidateSymbols, decoding will be faster, by skipping some checks: // - If we see first character of null, false or true, // do not validate subsequent characters. @@ -87,20 +69,24 @@ const ( jsonSpacesOrTabsLen = 128 - jsonU4SetErrVal = 128 + jsonAlwaysReturnInternString = false ) -func init() { - var bs [jsonSpacesOrTabsLen]byte - for i := 0; i < jsonSpacesOrTabsLen; i++ { - bs[i] = ' ' - } - jsonSpaces = string(bs[:]) +var ( + // jsonTabs and jsonSpaces are used as caches for indents + jsonTabs, jsonSpaces [jsonSpacesOrTabsLen]byte + + jsonCharHtmlSafeSet bitset128 + jsonCharSafeSet bitset128 + jsonCharWhitespaceSet bitset256 + jsonNumSet bitset256 +) +func init() { for i := 0; i < jsonSpacesOrTabsLen; i++ { - bs[i] = '\t' + jsonSpaces[i] = ' ' + jsonTabs[i] = '\t' } - jsonTabs = string(bs[:]) // populate the safe values as true: note: ASCII control characters are (0-31) // jsonCharSafeSet: all true except (0-31) " \ @@ -124,38 +110,113 @@ func init() { jsonNumSet.set(i) } } - for j := range jsonU4Set { - switch i = byte(j); i { - case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - jsonU4Set[i] = i - '0' - case 'a', 'b', 'c', 'd', 'e', 'f': - jsonU4Set[i] = i - 'a' + 10 - case 'A', 'B', 'C', 'D', 'E', 'F': - jsonU4Set[i] = i - 'A' + 10 - default: - jsonU4Set[i] = jsonU4SetErrVal - } - // switch i = byte(j); i { - // case 'e', 'E', '.': - // jsonIsFloatSet.set(i) - // } - } - // jsonU4Set[255] = jsonU4SetErrVal } -type jsonEncDriver struct { - e *Encoder - w encWriter - h *JsonHandle - b [64]byte // scratch - bs []byte // scratch - se setExtWrapper - ds string // indent string - dl uint16 // indent level - dt bool // indent using tabs - d bool // indent +// ---------------- + +type jsonEncDriverTypical struct { + w encWriter + // w *encWriterSwitch + b *[jsonScratchArrayLen]byte + tw bool // term white space c containerState - noBuiltInTypes +} + +func (e *jsonEncDriverTypical) typical() {} + +func (e *jsonEncDriverTypical) reset(ee *jsonEncDriver) { + e.w = ee.ew + // e.w = &ee.e.encWriterSwitch + e.b = &ee.b + e.tw = ee.h.TermWhitespace + e.c = 0 +} + +func (e *jsonEncDriverTypical) WriteArrayStart(length int) { + e.w.writen1('[') + e.c = containerArrayStart +} + +func (e *jsonEncDriverTypical) WriteArrayElem() { + if e.c != containerArrayStart { + e.w.writen1(',') + } + e.c = containerArrayElem +} + +func (e *jsonEncDriverTypical) WriteArrayEnd() { + e.w.writen1(']') + e.c = containerArrayEnd +} + +func (e *jsonEncDriverTypical) WriteMapStart(length int) { + e.w.writen1('{') + e.c = containerMapStart +} + +func (e *jsonEncDriverTypical) WriteMapElemKey() { + if e.c != containerMapStart { + e.w.writen1(',') + } + e.c = containerMapKey +} + +func (e *jsonEncDriverTypical) WriteMapElemValue() { + e.w.writen1(':') + e.c = containerMapValue +} + +func (e *jsonEncDriverTypical) WriteMapEnd() { + e.w.writen1('}') + e.c = containerMapEnd +} + +func (e *jsonEncDriverTypical) EncodeBool(b bool) { + if b { + e.w.writeb(jsonLiterals[jsonLitTrue : jsonLitTrue+4]) + } else { + e.w.writeb(jsonLiterals[jsonLitFalse : jsonLitFalse+5]) + } +} + +func (e *jsonEncDriverTypical) EncodeFloat64(f float64) { + fmt, prec := jsonFloatStrconvFmtPrec(f) + e.w.writeb(strconv.AppendFloat(e.b[:0], f, fmt, prec, 64)) +} + +func (e *jsonEncDriverTypical) EncodeInt(v int64) { + e.w.writeb(strconv.AppendInt(e.b[:0], v, 10)) +} + +func (e *jsonEncDriverTypical) EncodeUint(v uint64) { + e.w.writeb(strconv.AppendUint(e.b[:0], v, 10)) +} + +func (e *jsonEncDriverTypical) EncodeFloat32(f float32) { + e.EncodeFloat64(float64(f)) +} + +func (e *jsonEncDriverTypical) atEndOfEncode() { + if e.tw { + e.w.writen1(' ') + } +} + +// ---------------- + +type jsonEncDriverGeneric struct { + w encWriter // encWriter // *encWriterSwitch + b *[jsonScratchArrayLen]byte + c containerState + // ds string // indent string + di int8 // indent per + d bool // indenting? + dt bool // indent using tabs + dl uint16 // indent level + ks bool // map key as string + is byte // integer as string + tw bool // term white space + _ [7]byte // padding } // indent is done as below: @@ -163,7 +224,26 @@ type jsonEncDriver struct { // - newline and indent are added before each ending, // except there was no entry (so we can have {} or []) -func (e *jsonEncDriver) WriteArrayStart(length int) { +func (e *jsonEncDriverGeneric) reset(ee *jsonEncDriver) { + e.w = ee.ew + e.b = &ee.b + e.tw = ee.h.TermWhitespace + e.c = 0 + e.d, e.dt, e.dl, e.di = false, false, 0, 0 + h := ee.h + if h.Indent > 0 { + e.d = true + e.di = int8(h.Indent) + } else if h.Indent < 0 { + e.d = true + e.dt = true + e.di = int8(-h.Indent) + } + e.ks = h.MapKeyAsString + e.is = h.IntegerAsString +} + +func (e *jsonEncDriverGeneric) WriteArrayStart(length int) { if e.d { e.dl++ } @@ -171,7 +251,7 @@ func (e *jsonEncDriver) WriteArrayStart(length int) { e.c = containerArrayStart } -func (e *jsonEncDriver) WriteArrayElem() { +func (e *jsonEncDriverGeneric) WriteArrayElem() { if e.c != containerArrayStart { e.w.writen1(',') } @@ -181,7 +261,7 @@ func (e *jsonEncDriver) WriteArrayElem() { e.c = containerArrayElem } -func (e *jsonEncDriver) WriteArrayEnd() { +func (e *jsonEncDriverGeneric) WriteArrayEnd() { if e.d { e.dl-- if e.c != containerArrayStart { @@ -192,7 +272,7 @@ func (e *jsonEncDriver) WriteArrayEnd() { e.c = containerArrayEnd } -func (e *jsonEncDriver) WriteMapStart(length int) { +func (e *jsonEncDriverGeneric) WriteMapStart(length int) { if e.d { e.dl++ } @@ -200,7 +280,7 @@ func (e *jsonEncDriver) WriteMapStart(length int) { e.c = containerMapStart } -func (e *jsonEncDriver) WriteMapElemKey() { +func (e *jsonEncDriverGeneric) WriteMapElemKey() { if e.c != containerMapStart { e.w.writen1(',') } @@ -210,7 +290,7 @@ func (e *jsonEncDriver) WriteMapElemKey() { e.c = containerMapKey } -func (e *jsonEncDriver) WriteMapElemValue() { +func (e *jsonEncDriverGeneric) WriteMapElemValue() { if e.d { e.w.writen2(':', ' ') } else { @@ -219,7 +299,7 @@ func (e *jsonEncDriver) WriteMapElemValue() { e.c = containerMapValue } -func (e *jsonEncDriver) WriteMapEnd() { +func (e *jsonEncDriverGeneric) WriteMapEnd() { if e.d { e.dl-- if e.c != containerMapStart { @@ -230,116 +310,141 @@ func (e *jsonEncDriver) WriteMapEnd() { e.c = containerMapEnd } -// func (e *jsonEncDriver) sendContainerState(c containerState) { -// // determine whether to output separators -// switch c { -// case containerMapKey: -// if e.c != containerMapStart { -// e.w.writen1(',') -// } -// if e.d { -// e.writeIndent() -// } -// case containerMapValue: -// if e.d { -// e.w.writen2(':', ' ') -// } else { -// e.w.writen1(':') -// } -// case containerMapEnd: -// if e.d { -// e.dl-- -// if e.c != containerMapStart { -// e.writeIndent() -// } -// } -// e.w.writen1('}') -// case containerArrayElem: -// if e.c != containerArrayStart { -// e.w.writen1(',') -// } -// if e.d { -// e.writeIndent() -// } -// case containerArrayEnd: -// if e.d { -// e.dl-- -// if e.c != containerArrayStart { -// e.writeIndent() -// } -// } -// e.w.writen1(']') -// } -// e.c = c -// } - -func (e *jsonEncDriver) writeIndent() { +func (e *jsonEncDriverGeneric) writeIndent() { e.w.writen1('\n') - if x := len(e.ds) * int(e.dl); x <= jsonSpacesOrTabsLen { - if e.dt { - e.w.writestr(jsonTabs[:x]) - } else { - e.w.writestr(jsonSpaces[:x]) + x := int(e.di) * int(e.dl) + if e.dt { + for x > jsonSpacesOrTabsLen { + e.w.writeb(jsonTabs[:]) + x -= jsonSpacesOrTabsLen } + e.w.writeb(jsonTabs[:x]) } else { - for i := uint16(0); i < e.dl; i++ { - e.w.writestr(e.ds) + for x > jsonSpacesOrTabsLen { + e.w.writeb(jsonSpaces[:]) + x -= jsonSpacesOrTabsLen } + e.w.writeb(jsonSpaces[:x]) } } -func (e *jsonEncDriver) EncodeNil() { - e.w.writen4('n', 'u', 'l', 'l') // e.w.writeb(jsonLiterals[9:13]) // null -} - -func (e *jsonEncDriver) EncodeBool(b bool) { - if b { - e.w.writen4('t', 'r', 'u', 'e') // e.w.writeb(jsonLiterals[0:4]) // true +func (e *jsonEncDriverGeneric) EncodeBool(b bool) { + if e.ks && e.c == containerMapKey { + if b { + e.w.writeb(jsonLiterals[jsonLitTrueQ : jsonLitTrueQ+6]) + } else { + e.w.writeb(jsonLiterals[jsonLitFalseQ : jsonLitFalseQ+7]) + } } else { - e.w.writen5('f', 'a', 'l', 's', 'e') // e.w.writeb(jsonLiterals[4:9]) // false + if b { + e.w.writeb(jsonLiterals[jsonLitTrue : jsonLitTrue+4]) + } else { + e.w.writeb(jsonLiterals[jsonLitFalse : jsonLitFalse+5]) + } } } -func (e *jsonEncDriver) EncodeFloat32(f float32) { - e.encodeFloat(float64(f), 32) -} - -func (e *jsonEncDriver) EncodeFloat64(f float64) { - e.encodeFloat(f, 64) -} +func (e *jsonEncDriverGeneric) EncodeFloat64(f float64) { + // instead of using 'g', specify whether to use 'e' or 'f' + fmt, prec := jsonFloatStrconvFmtPrec(f) -func (e *jsonEncDriver) encodeFloat(f float64, numbits int) { - x := strconv.AppendFloat(e.b[:0], f, 'G', -1, numbits) - // if bytes.IndexByte(x, 'E') == -1 && bytes.IndexByte(x, '.') == -1 { - if !jsonIsFloatBytesB2(x) { - x = append(x, '.', '0') + var blen int + if e.ks && e.c == containerMapKey { + blen = 2 + len(strconv.AppendFloat(e.b[1:1], f, fmt, prec, 64)) + e.b[0] = '"' + e.b[blen-1] = '"' + } else { + blen = len(strconv.AppendFloat(e.b[:0], f, fmt, prec, 64)) } - e.w.writeb(x) + e.w.writeb(e.b[:blen]) } -func (e *jsonEncDriver) EncodeInt(v int64) { - if x := e.h.IntegerAsString; x == 'A' || x == 'L' && (v > 1<<53 || v < -(1<<53)) { - e.w.writen1('"') - e.w.writeb(strconv.AppendInt(e.b[:0], v, 10)) - e.w.writen1('"') +func (e *jsonEncDriverGeneric) EncodeInt(v int64) { + x := e.is + if x == 'A' || x == 'L' && (v > 1<<53 || v < -(1<<53)) || (e.ks && e.c == containerMapKey) { + blen := 2 + len(strconv.AppendInt(e.b[1:1], v, 10)) + e.b[0] = '"' + e.b[blen-1] = '"' + e.w.writeb(e.b[:blen]) return } e.w.writeb(strconv.AppendInt(e.b[:0], v, 10)) } -func (e *jsonEncDriver) EncodeUint(v uint64) { - if x := e.h.IntegerAsString; x == 'A' || x == 'L' && v > 1<<53 { - e.w.writen1('"') - e.w.writeb(strconv.AppendUint(e.b[:0], v, 10)) - e.w.writen1('"') +func (e *jsonEncDriverGeneric) EncodeUint(v uint64) { + x := e.is + if x == 'A' || x == 'L' && v > 1<<53 || (e.ks && e.c == containerMapKey) { + blen := 2 + len(strconv.AppendUint(e.b[1:1], v, 10)) + e.b[0] = '"' + e.b[blen-1] = '"' + e.w.writeb(e.b[:blen]) return } e.w.writeb(strconv.AppendUint(e.b[:0], v, 10)) } +func (e *jsonEncDriverGeneric) EncodeFloat32(f float32) { + // e.encodeFloat(float64(f), 32) + // always encode all floats as IEEE 64-bit floating point. + // It also ensures that we can decode in full precision even if into a float32, + // as what is written is always to float64 precision. + e.EncodeFloat64(float64(f)) +} + +func (e *jsonEncDriverGeneric) atEndOfEncode() { + if e.tw { + if e.d { + e.w.writen1('\n') + } else { + e.w.writen1(' ') + } + } +} + +// -------------------- + +type jsonEncDriver struct { + noBuiltInTypes + e *Encoder + h *JsonHandle + ew encWriter // encWriter // *encWriterSwitch + se extWrapper + // ---- cpu cache line boundary? + bs []byte // scratch + // ---- cpu cache line boundary? + b [jsonScratchArrayLen]byte // scratch (encode time, +} + +func (e *jsonEncDriver) EncodeNil() { + // We always encode nil as just null (never in quotes) + // This allows us to easily decode if a nil in the json stream + // ie if initial token is n. + e.ew.writeb(jsonLiterals[jsonLitNull : jsonLitNull+4]) + + // if e.h.MapKeyAsString && e.c == containerMapKey { + // e.ew.writeb(jsonLiterals[jsonLitNullQ : jsonLitNullQ+6]) + // } else { + // e.ew.writeb(jsonLiterals[jsonLitNull : jsonLitNull+4]) + // } +} + +func (e *jsonEncDriver) EncodeTime(t time.Time) { + // Do NOT use MarshalJSON, as it allocates internally. + // instead, we call AppendFormat directly, using our scratch buffer (e.b) + if t.IsZero() { + e.EncodeNil() + } else { + e.b[0] = '"' + b := t.AppendFormat(e.b[1:1], time.RFC3339Nano) + e.b[len(b)+1] = '"' + e.ew.writeb(e.b[:len(b)+2]) + } + // v, err := t.MarshalJSON(); if err != nil { e.e.error(err) } e.ew.writeb(v) +} + func (e *jsonEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext, en *Encoder) { if v := ext.ConvertExt(rv); v == nil { - e.w.writen4('n', 'u', 'l', 'l') // e.w.writeb(jsonLiterals[9:13]) // null // e.EncodeNil() + e.EncodeNil() } else { en.encode(v) } @@ -348,7 +453,7 @@ func (e *jsonEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext, en *Enco func (e *jsonEncDriver) EncodeRawExt(re *RawExt, en *Encoder) { // only encodes re.Value (never re.Data) if re.Value == nil { - e.w.writen4('n', 'u', 'l', 'l') // e.w.writeb(jsonLiterals[9:13]) // null // e.EncodeNil() + e.EncodeNil() } else { en.encode(re.Value) } @@ -358,40 +463,42 @@ func (e *jsonEncDriver) EncodeString(c charEncoding, v string) { e.quoteStr(v) } -func (e *jsonEncDriver) EncodeSymbol(v string) { - e.quoteStr(v) -} - func (e *jsonEncDriver) EncodeStringBytes(c charEncoding, v []byte) { // if encoding raw bytes and RawBytesExt is configured, use it to encode - if c == c_RAW && e.se.i != nil { - e.EncodeExt(v, 0, &e.se, e.e) + if v == nil { + e.EncodeNil() return } - if c == c_RAW { + if c == cRAW { + if e.se.InterfaceExt != nil { + e.EncodeExt(v, 0, &e.se, e.e) + return + } + slen := base64.StdEncoding.EncodedLen(len(v)) - if cap(e.bs) >= slen { - e.bs = e.bs[:slen] + if cap(e.bs) >= slen+2 { + e.bs = e.bs[:slen+2] } else { - e.bs = make([]byte, slen) + e.bs = make([]byte, slen+2) } - base64.StdEncoding.Encode(e.bs, v) - e.w.writen1('"') - e.w.writeb(e.bs) - e.w.writen1('"') + e.bs[0] = '"' + base64.StdEncoding.Encode(e.bs[1:], v) + e.bs[slen+1] = '"' + e.ew.writeb(e.bs) } else { e.quoteStr(stringView(v)) } } func (e *jsonEncDriver) EncodeAsis(v []byte) { - e.w.writeb(v) + e.ew.writeb(v) } func (e *jsonEncDriver) quoteStr(s string) { // adapted from std pkg encoding/json const hex = "0123456789abcdef" - w := e.w + w := e.ew + htmlasis := e.h.HTMLCharsAsIs w.writen1('"') var start int for i, slen := 0, len(s); i < slen; { @@ -399,7 +506,8 @@ func (e *jsonEncDriver) quoteStr(s string) { // also encode < > & to prevent security holes when served to some browsers. if b := s[i]; b < utf8.RuneSelf { // if 0x20 <= b && b != '\\' && b != '"' && b != '<' && b != '>' && b != '&' { - if jsonCharHtmlSafeSet.isset(b) || (e.h.HTMLCharsAsIs && jsonCharSafeSet.isset(b)) { + // if (htmlasis && jsonCharSafeSet.isset(b)) || jsonCharHtmlSafeSet.isset(b) { + if jsonCharHtmlSafeSet.isset(b) || (htmlasis && jsonCharSafeSet.isset(b)) { i++ continue } @@ -457,42 +565,33 @@ func (e *jsonEncDriver) quoteStr(s string) { w.writen1('"') } -func (e *jsonEncDriver) atEndOfEncode() { - if e.h.TermWhitespace { - if e.d { - e.w.writen1('\n') - } else { - e.w.writen1(' ') - } - } -} - type jsonDecDriver struct { noBuiltInTypes - d *Decoder - h *JsonHandle - r decReader + d *Decoder + h *JsonHandle + r decReader // *decReaderSwitch // decReader + se extWrapper + + // ---- writable fields during execution --- *try* to keep in sep cache line c containerState // tok is used to store the token read right after skipWhiteSpace. - tok uint8 - - fnull bool // found null from appendStringAsBytes - - bstr [8]byte // scratch used for string \UXXX parsing - b [64]byte // scratch, used for parsing strings or numbers - b2 [64]byte // scratch, used only for decodeBytes (after base64) - bs []byte // scratch. Initialized from b. Used for parsing strings or numbers. - - se setExtWrapper - + tok uint8 + fnull bool // found null from appendStringAsBytes + bs []byte // scratch. Initialized from b. Used for parsing strings or numbers. + bstr [8]byte // scratch used for string \UXXX parsing + // ---- cpu cache line boundary? + b [jsonScratchArrayLen]byte // scratch 1, used for parsing strings or numbers or time.Time + b2 [jsonScratchArrayLen]byte // scratch 2, used only for readUntil, decNumBytes + + _ [3]uint64 // padding // n jsonNum } -func jsonIsWS(b byte) bool { - // return b == ' ' || b == '\t' || b == '\r' || b == '\n' - return jsonCharWhitespaceSet.isset(b) -} +// func jsonIsWS(b byte) bool { +// // return b == ' ' || b == '\t' || b == '\r' || b == '\n' +// return jsonCharWhitespaceSet.isset(b) +// } func (d *jsonDecDriver) uncacheRead() { if d.tok != 0 { @@ -505,8 +604,9 @@ func (d *jsonDecDriver) ReadMapStart() int { if d.tok == 0 { d.tok = d.r.skip(&jsonCharWhitespaceSet) } - if d.tok != '{' { - d.d.errorf("json: expect char '%c' but got char '%c'", '{', d.tok) + const xc uint8 = '{' + if d.tok != xc { + d.d.errorf("expect char '%c' but got char '%c'", xc, d.tok) } d.tok = 0 d.c = containerMapStart @@ -517,8 +617,9 @@ func (d *jsonDecDriver) ReadArrayStart() int { if d.tok == 0 { d.tok = d.r.skip(&jsonCharWhitespaceSet) } - if d.tok != '[' { - d.d.errorf("json: expect char '%c' but got char '%c'", '[', d.tok) + const xc uint8 = '[' + if d.tok != xc { + d.d.errorf("expect char '%c' but got char '%c'", xc, d.tok) } d.tok = 0 d.c = containerArrayStart @@ -532,14 +633,23 @@ func (d *jsonDecDriver) CheckBreak() bool { return d.tok == '}' || d.tok == ']' } +// For the ReadXXX methods below, we could just delegate to helper functions +// readContainerState(c containerState, xc uint8, check bool) +// - ReadArrayElem would become: +// readContainerState(containerArrayElem, ',', d.c != containerArrayStart) +// +// However, until mid-stack inlining (go 1.10?) comes, supporting inlining of +// oneliners, we explicitly write them all 5 out to elide the extra func call. +// TODO: For Go 1.10, if inlined, consider consolidating these. + func (d *jsonDecDriver) ReadArrayElem() { + const xc uint8 = ',' if d.tok == 0 { d.tok = d.r.skip(&jsonCharWhitespaceSet) } if d.c != containerArrayStart { - const xc uint8 = ',' if d.tok != xc { - d.d.errorf("json: expect char '%c' but got char '%c'", xc, d.tok) + d.d.errorf("expect char '%c' but got char '%c'", xc, d.tok) } d.tok = 0 } @@ -547,25 +657,25 @@ func (d *jsonDecDriver) ReadArrayElem() { } func (d *jsonDecDriver) ReadArrayEnd() { + const xc uint8 = ']' if d.tok == 0 { d.tok = d.r.skip(&jsonCharWhitespaceSet) } - const xc uint8 = ']' if d.tok != xc { - d.d.errorf("json: expect char '%c' but got char '%c'", xc, d.tok) + d.d.errorf("expect char '%c' but got char '%c'", xc, d.tok) } d.tok = 0 d.c = containerArrayEnd } func (d *jsonDecDriver) ReadMapElemKey() { + const xc uint8 = ',' if d.tok == 0 { d.tok = d.r.skip(&jsonCharWhitespaceSet) } if d.c != containerMapStart { - const xc uint8 = ',' if d.tok != xc { - d.d.errorf("json: expect char '%c' but got char '%c'", xc, d.tok) + d.d.errorf("expect char '%c' but got char '%c'", xc, d.tok) } d.tok = 0 } @@ -573,95 +683,34 @@ func (d *jsonDecDriver) ReadMapElemKey() { } func (d *jsonDecDriver) ReadMapElemValue() { + const xc uint8 = ':' if d.tok == 0 { d.tok = d.r.skip(&jsonCharWhitespaceSet) } - const xc uint8 = ':' if d.tok != xc { - d.d.errorf("json: expect char '%c' but got char '%c'", xc, d.tok) + d.d.errorf("expect char '%c' but got char '%c'", xc, d.tok) } d.tok = 0 d.c = containerMapValue } func (d *jsonDecDriver) ReadMapEnd() { + const xc uint8 = '}' if d.tok == 0 { d.tok = d.r.skip(&jsonCharWhitespaceSet) } - const xc uint8 = '}' if d.tok != xc { - d.d.errorf("json: expect char '%c' but got char '%c'", xc, d.tok) + d.d.errorf("expect char '%c' but got char '%c'", xc, d.tok) } d.tok = 0 d.c = containerMapEnd } -// func (d *jsonDecDriver) readContainerState(c containerState, xc uint8, check bool) { -// if d.tok == 0 { -// d.tok = d.r.skip(&jsonCharWhitespaceSet) -// } -// if check { -// if d.tok != xc { -// d.d.errorf("json: expect char '%c' but got char '%c'", xc, d.tok) -// } -// d.tok = 0 -// } -// d.c = c -// } - -// func (d *jsonDecDriver) sendContainerState(c containerState) { -// if d.tok == 0 { -// d.tok = d.r.skip(&jsonCharWhitespaceSet) -// } -// var xc uint8 // char expected -// switch c { -// case containerMapKey: -// if d.c != containerMapStart { -// xc = ',' -// } -// case containerMapValue: -// xc = ':' -// case containerMapEnd: -// xc = '}' -// case containerArrayElem: -// if d.c != containerArrayStart { -// xc = ',' -// } -// case containerArrayEnd: -// xc = ']' -// } -// if xc != 0 { -// if d.tok != xc { -// d.d.errorf("json: expect char '%c' but got char '%c'", xc, d.tok) -// } -// d.tok = 0 -// } -// d.c = c -// } - -// func (d *jsonDecDriver) readLiteralIdx(fromIdx, toIdx uint8) { -// bs := d.r.readx(int(toIdx - fromIdx)) -// d.tok = 0 -// if jsonValidateSymbols && !bytes.Equal(bs, jsonLiterals[fromIdx:toIdx]) { -// d.d.errorf("json: expecting %s: got %s", jsonLiterals[fromIdx:toIdx], bs) -// return -// } -// } - -func (d *jsonDecDriver) readSymbol3(v1, v2, v3 uint8) { - b1, b2, b3 := d.r.readn3() - d.tok = 0 - if jsonValidateSymbols && (b1 != v1 || b2 != v2 || b3 != v3) { - d.d.errorf("json: expecting %c, %c, %c: got %c, %c, %c", b1, b2, b3, v1, v2, v3) - return - } -} - -func (d *jsonDecDriver) readSymbol4(v1, v2, v3, v4 uint8) { - b1, b2, b3, b4 := d.r.readn4() +func (d *jsonDecDriver) readLit(length, fromIdx uint8) { + bs := d.r.readx(int(length)) d.tok = 0 - if jsonValidateSymbols && (b1 != v1 || b2 != v2 || b3 != v3 || b4 != v4) { - d.d.errorf("json: expecting %c, %c, %c, %c: got %c, %c, %c, %c", b1, b2, b3, b4, v1, v2, v3, v4) + if jsonValidateSymbols && !bytes.Equal(bs, jsonLiterals[fromIdx:fromIdx+length]) { + d.d.errorf("expecting %s: got %s", jsonLiterals[fromIdx:fromIdx+length], bs) return } } @@ -670,27 +719,51 @@ func (d *jsonDecDriver) TryDecodeAsNil() bool { if d.tok == 0 { d.tok = d.r.skip(&jsonCharWhitespaceSet) } + // we shouldn't try to see if "null" was here, right? + // only the plain string: `null` denotes a nil (ie not quotes) if d.tok == 'n' { - d.readSymbol3('u', 'l', 'l') // d.readLiteralIdx(10, 13) // ull + d.readLit(3, jsonLitNull+1) // (n)ull return true } return false } -func (d *jsonDecDriver) DecodeBool() bool { +func (d *jsonDecDriver) DecodeBool() (v bool) { if d.tok == 0 { d.tok = d.r.skip(&jsonCharWhitespaceSet) } - if d.tok == 'f' { - d.readSymbol4('a', 'l', 's', 'e') // d.readLiteralIdx(5, 9) // alse - return false + fquot := d.c == containerMapKey && d.tok == '"' + if fquot { + d.tok = d.r.readn1() } - if d.tok == 't' { - d.readSymbol3('r', 'u', 'e') // d.readLiteralIdx(1, 4) // rue - return true + switch d.tok { + case 'f': + d.readLit(4, jsonLitFalse+1) // (f)alse + // v = false + case 't': + d.readLit(3, jsonLitTrue+1) // (t)rue + v = true + default: + d.d.errorf("decode bool: got first char %c", d.tok) + // v = false // "unreachable" } - d.d.errorf("json: decode bool: got first char %c", d.tok) - return false // "unreachable" + if fquot { + d.r.readn1() + } + return +} + +func (d *jsonDecDriver) DecodeTime() (t time.Time) { + // read string, and pass the string into json.unmarshal + d.appendStringAsBytes() + if d.fnull { + return + } + t, err := time.Parse(time.RFC3339, stringView(d.bs)) + if err != nil { + d.d.errorv(err) + } + return } func (d *jsonDecDriver) ContainerType() (vt valueType) { @@ -698,6 +771,12 @@ func (d *jsonDecDriver) ContainerType() (vt valueType) { if d.tok == 0 { d.tok = d.r.skip(&jsonCharWhitespaceSet) } + + // optimize this, so we don't do 4 checks but do one computation. + // return jsonContainerSet[d.tok] + + // ContainerType is mostly called for Map and Array, + // so this conditional is good enough (max 2 checks typically) if b := d.tok; b == '{' { return valueTypeMap } else if b == '[' { @@ -708,8 +787,6 @@ func (d *jsonDecDriver) ContainerType() (vt valueType) { return valueTypeString } return valueTypeUnset - // d.d.errorf("isContainerType: unsupported parameter: %v", vt) - // return false // "unreachable" } func (d *jsonDecDriver) decNumBytes() (bs []byte) { @@ -728,36 +805,69 @@ func (d *jsonDecDriver) decNumBytes() (bs []byte) { return bs } -func (d *jsonDecDriver) DecodeUint(bitsize uint8) (u uint64) { +func (d *jsonDecDriver) DecodeUint64() (u uint64) { bs := d.decNumBytes() - u, err := strconv.ParseUint(stringView(bs), 10, int(bitsize)) - if err != nil { - d.d.errorf("json: decode uint from %s: %v", bs, err) - return + n, neg, badsyntax, overflow := jsonParseInteger(bs) + if overflow { + d.d.errorf("overflow parsing unsigned integer: %s", bs) + } else if neg { + d.d.errorf("minus found parsing unsigned integer: %s", bs) + } else if badsyntax { + // fallback: try to decode as float, and cast + n = d.decUint64ViaFloat(stringView(bs)) + } + return n +} + +func (d *jsonDecDriver) DecodeInt64() (i int64) { + const cutoff = uint64(1 << uint(64-1)) + bs := d.decNumBytes() + n, neg, badsyntax, overflow := jsonParseInteger(bs) + if overflow { + d.d.errorf("overflow parsing integer: %s", bs) + } else if badsyntax { + // d.d.errorf("invalid syntax for integer: %s", bs) + // fallback: try to decode as float, and cast + if neg { + n = d.decUint64ViaFloat(stringView(bs[1:])) + } else { + n = d.decUint64ViaFloat(stringView(bs)) + } + } + if neg { + if n > cutoff { + d.d.errorf("overflow parsing integer: %s", bs) + } + i = -(int64(n)) + } else { + if n >= cutoff { + d.d.errorf("overflow parsing integer: %s", bs) + } + i = int64(n) } return } -func (d *jsonDecDriver) DecodeInt(bitsize uint8) (i int64) { - bs := d.decNumBytes() - i, err := strconv.ParseInt(stringView(bs), 10, int(bitsize)) +func (d *jsonDecDriver) decUint64ViaFloat(s string) (u uint64) { + f, err := strconv.ParseFloat(s, 64) if err != nil { - d.d.errorf("json: decode int from %s: %v", bs, err) - return + d.d.errorf("invalid syntax for integer: %s", s) + // d.d.errorv(err) } - return + fi, ff := math.Modf(f) + if ff > 0 { + d.d.errorf("fractional part found parsing integer: %s", s) + } else if fi > float64(math.MaxUint64) { + d.d.errorf("overflow parsing integer: %s", s) + } + return uint64(fi) } -func (d *jsonDecDriver) DecodeFloat(chkOverflow32 bool) (f float64) { +func (d *jsonDecDriver) DecodeFloat64() (f float64) { bs := d.decNumBytes() - bitsize := 64 - if chkOverflow32 { - bitsize = 32 - } - f, err := strconv.ParseFloat(stringView(bs), bitsize) + f, err := strconv.ParseFloat(stringView(bs), 64) if err != nil { - d.d.errorf("json: decode float from %s: %v", bs, err) - return + d.d.errorv(err) } return } @@ -777,11 +887,19 @@ func (d *jsonDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxta func (d *jsonDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { // if decoding into raw bytes, and the RawBytesExt is configured, use it to decode. - if d.se.i != nil { + if d.se.InterfaceExt != nil { bsOut = bs d.DecodeExt(&bsOut, 0, &d.se) return } + if d.tok == 0 { + d.tok = d.r.skip(&jsonCharWhitespaceSet) + } + // check if an "array" of uint8's (see ContainerType for how to infer if an array) + if d.tok == '[' { + bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d) + return + } d.appendStringAsBytes() // base64 encodes []byte{} as "", and we encode nil []byte as null. // Consequently, base64 should decode null as a nil []byte, and "" as an empty []byte{}. @@ -804,7 +922,7 @@ func (d *jsonDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { } slen2, err := base64.StdEncoding.Decode(bsOut, bs0) if err != nil { - d.d.errorf("json: error decoding base64 binary '%s': %v", bs0, err) + d.d.errorf("error decoding base64 binary '%s': %v", bs0, err) return nil } if slen != slen2 { @@ -813,15 +931,9 @@ func (d *jsonDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { return } -const jsonAlwaysReturnInternString = false - func (d *jsonDecDriver) DecodeString() (s string) { d.appendStringAsBytes() - // if x := d.s.sc; x != nil && x.so && x.st == '}' { // map key - if jsonAlwaysReturnInternString || d.c == containerMapKey { - return d.d.string(d.bs) - } - return string(d.bs) + return d.bsToString() } func (d *jsonDecDriver) DecodeStringAsBytes() (s []byte) { @@ -836,25 +948,29 @@ func (d *jsonDecDriver) appendStringAsBytes() { d.fnull = false if d.tok != '"' { - // d.d.errorf("json: expect char '%c' but got char '%c'", '"', d.tok) + // d.d.errorf("expect char '%c' but got char '%c'", '"', d.tok) // handle non-string scalar: null, true, false or a number switch d.tok { case 'n': - d.readSymbol3('u', 'l', 'l') // d.readLiteralIdx(10, 13) // ull + d.readLit(3, jsonLitNull+1) // (n)ull d.bs = d.bs[:0] d.fnull = true case 'f': - d.readSymbol4('a', 'l', 's', 'e') // d.readLiteralIdx(5, 9) // alse + d.readLit(4, jsonLitFalse+1) // (f)alse d.bs = d.bs[:5] copy(d.bs, "false") case 't': - d.readSymbol3('r', 'u', 'e') // d.readLiteralIdx(1, 4) // rue + d.readLit(3, jsonLitTrue+1) // (t)rue d.bs = d.bs[:4] copy(d.bs, "true") default: // try to parse a valid number bs := d.decNumBytes() - d.bs = d.bs[:len(bs)] + if len(bs) <= cap(d.bs) { + d.bs = d.bs[:len(bs)] + } else { + d.bs = make([]byte, len(bs)) + } copy(d.bs, bs) } return @@ -907,38 +1023,59 @@ func (d *jsonDecDriver) appendStringAsBytes() { case 'u': var r rune var rr uint32 - c = cs[i+4] // may help reduce bounds-checking + if len(cs) < i+4 { // may help reduce bounds-checking + d.d.errorf("need at least 4 more bytes for unicode sequence") + } + // c = cs[i+4] // may help reduce bounds-checking for j := 1; j < 5; j++ { - c = jsonU4Set[cs[i+j]] - if c == jsonU4SetErrVal { - d.d.errorf(`json: unquoteStr: invalid hex char in \u unicode sequence: %q`, c) + // best to use explicit if-else + // - not a table, etc which involve memory loads, array lookup with bounds checks, etc + c = cs[i+j] + if c >= '0' && c <= '9' { + rr = rr*16 + uint32(c-jsonU4Chk2) + } else if c >= 'a' && c <= 'f' { + rr = rr*16 + uint32(c-jsonU4Chk1) + } else if c >= 'A' && c <= 'F' { + rr = rr*16 + uint32(c-jsonU4Chk0) + } else { + r = unicode.ReplacementChar + i += 4 + goto encode_rune } - rr = rr*16 + uint32(c) } r = rune(rr) i += 4 if utf16.IsSurrogate(r) { - if !(cs[i+2] == 'u' && cs[i+i] == '\\') { - d.d.errorf(`json: unquoteStr: invalid unicode sequence. Expecting \u`) - return - } - i += 2 - c = cs[i+4] // may help reduce bounds-checking - var rr1 uint32 - for j := 1; j < 5; j++ { - c = jsonU4Set[cs[i+j]] - if c == jsonU4SetErrVal { - d.d.errorf(`json: unquoteStr: invalid hex char in \u unicode sequence: %q`, c) + if len(cs) >= i+6 && cs[i+2] == 'u' && cs[i+1] == '\\' { + i += 2 + // c = cs[i+4] // may help reduce bounds-checking + var rr1 uint32 + for j := 1; j < 5; j++ { + c = cs[i+j] + if c >= '0' && c <= '9' { + rr = rr*16 + uint32(c-jsonU4Chk2) + } else if c >= 'a' && c <= 'f' { + rr = rr*16 + uint32(c-jsonU4Chk1) + } else if c >= 'A' && c <= 'F' { + rr = rr*16 + uint32(c-jsonU4Chk0) + } else { + r = unicode.ReplacementChar + i += 4 + goto encode_rune + } } - rr1 = rr1*16 + uint32(c) + r = utf16.DecodeRune(r, rune(rr1)) + i += 4 + } else { + r = unicode.ReplacementChar + goto encode_rune } - r = utf16.DecodeRune(r, rune(rr1)) - i += 4 } + encode_rune: w2 := utf8.EncodeRune(d.bstr[:], r) v = append(v, d.bstr[:w2]...) default: - d.d.errorf("json: unsupported escaped value: %c", c) + d.d.errorf("unsupported escaped value: %c", c) } i++ cursor = i @@ -946,24 +1083,48 @@ func (d *jsonDecDriver) appendStringAsBytes() { d.bs = v } -// func (d *jsonDecDriver) jsonU4Arr(bs [4]byte) (r rune) { -// // u, _ := strconv.ParseUint(string(d.bstr[:4]), 16, 64) -// var u uint32 -// for _, v := range bs { -// if '0' <= v && v <= '9' { -// v = v - '0' -// } else if 'a' <= v && v <= 'f' { -// v = v - 'a' + 10 -// } else if 'A' <= v && v <= 'f' { -// v = v - 'A' + 10 -// } else { -// // d.d.errorf(`json: unquoteStr: invalid hex char in \u unicode sequence: %q`, v) -// return utf8.RuneError -// } -// u = u*16 + uint32(v) -// } -// return rune(u) -// } +func (d *jsonDecDriver) nakedNum(z *decNaked, bs []byte) (err error) { + const cutoff = uint64(1 << uint(64-1)) + var n uint64 + var neg, badsyntax, overflow bool + + if d.h.PreferFloat { + goto F + } + n, neg, badsyntax, overflow = jsonParseInteger(bs) + if badsyntax || overflow { + goto F + } + if neg { + if n > cutoff { + goto F + } + z.v = valueTypeInt + z.i = -(int64(n)) + } else if d.h.SignedInteger { + if n >= cutoff { + goto F + } + z.v = valueTypeInt + z.i = int64(n) + } else { + z.v = valueTypeUint + z.u = n + } + return +F: + z.v = valueTypeFloat + z.f, err = strconv.ParseFloat(stringView(bs), 64) + return +} + +func (d *jsonDecDriver) bsToString() string { + // if x := d.s.sc; x != nil && x.so && x.st == '}' { // map key + if jsonAlwaysReturnInternString || d.c == containerMapKey { + return d.d.string(d.bs) + } + return string(d.bs) +} func (d *jsonDecDriver) DecodeNaked() { z := d.d.n @@ -974,14 +1135,14 @@ func (d *jsonDecDriver) DecodeNaked() { } switch d.tok { case 'n': - d.readSymbol3('u', 'l', 'l') // d.readLiteralIdx(10, 13) // ull + d.readLit(3, jsonLitNull+1) // (n)ull z.v = valueTypeNil case 'f': - d.readSymbol4('a', 'l', 's', 'e') // d.readLiteralIdx(5, 9) // alse + d.readLit(4, jsonLitFalse+1) // (f)alse z.v = valueTypeBool z.b = false case 't': - d.readSymbol3('r', 'u', 'e') // d.readLiteralIdx(1, 4) // rue + d.readLit(3, jsonLitTrue+1) // (t)rue z.v = valueTypeBool z.b = true case '{': @@ -989,36 +1150,38 @@ func (d *jsonDecDriver) DecodeNaked() { case '[': z.v = valueTypeArray // don't consume. kInterfaceNaked will call ReadArrayStart case '"': - z.v = valueTypeString - z.s = d.DecodeString() + // if a string, and MapKeyAsString, then try to decode it as a nil, bool or number first + d.appendStringAsBytes() + if len(d.bs) > 0 && d.c == containerMapKey && d.h.MapKeyAsString { + switch stringView(d.bs) { + case "null": + z.v = valueTypeNil + case "true": + z.v = valueTypeBool + z.b = true + case "false": + z.v = valueTypeBool + z.b = false + default: + // check if a number: float, int or uint + if err := d.nakedNum(z, d.bs); err != nil { + z.v = valueTypeString + z.s = d.bsToString() + } + } + } else { + z.v = valueTypeString + z.s = d.bsToString() + } default: // number bs := d.decNumBytes() - var err error if len(bs) == 0 { - d.d.errorf("json: decode number from empty string") + d.d.errorf("decode number from empty string") return - } else if d.h.PreferFloat || jsonIsFloatBytesB3(bs) { // bytes.IndexByte(bs, '.') != -1 ||... - // } else if d.h.PreferFloat || bytes.ContainsAny(bs, ".eE") { - z.v = valueTypeFloat - z.f, err = strconv.ParseFloat(stringView(bs), 64) - } else if d.h.SignedInteger || bs[0] == '-' { - z.v = valueTypeInt - z.i, err = strconv.ParseInt(stringView(bs), 10, 64) - } else { - z.v = valueTypeUint - z.u, err = strconv.ParseUint(stringView(bs), 10, 64) } - if err != nil { - if z.v == valueTypeInt || z.v == valueTypeUint { - if v, ok := err.(*strconv.NumError); ok && (v.Err == strconv.ErrRange || v.Err == strconv.ErrSyntax) { - z.v = valueTypeFloat - z.f, err = strconv.ParseFloat(stringView(bs), 64) - } - } - if err != nil { - d.d.errorf("json: decode number from %s: %v", bs, err) - return - } + if err := d.nakedNum(z, bs); err != nil { + d.d.errorf("decode number from %s: %v", bs, err) + return } } // if decodeFurther { @@ -1033,26 +1196,27 @@ func (d *jsonDecDriver) DecodeNaked() { // // Json is comprehensively supported: // - decodes numbers into interface{} as int, uint or float64 +// based on how the number looks and some config parameters e.g. PreferFloat, SignedInt, etc. +// - decode integers from float formatted numbers e.g. 1.27e+8 +// - decode any json value (numbers, bool, etc) from quoted strings // - configurable way to encode/decode []byte . // by default, encodes and decodes []byte using base64 Std Encoding // - UTF-8 support for encoding and decoding // // It has better performance than the json library in the standard library, -// by leveraging the performance improvements of the codec library and -// minimizing allocations. +// by leveraging the performance improvements of the codec library. // // In addition, it doesn't read more bytes than necessary during a decode, which allows // reading multiple values from a stream containing json and non-json content. // For example, a user can read a json value, then a cbor value, then a msgpack value, // all from the same stream in sequence. +// +// Note that, when decoding quoted strings, invalid UTF-8 or invalid UTF-16 surrogate pairs are +// not treated as an error. Instead, they are replaced by the Unicode replacement character U+FFFD. type JsonHandle struct { textEncodingType BasicHandle - // RawBytesExt, if configured, is used to encode and decode raw bytes in a custom way. - // If not configured, raw bytes are encoded to/from base64 text. - RawBytesExt InterfaceExt - // Indent indicates how a value is encoded. // - If positive, indent by that number of spaces. // - If negative, indent by that number of tabs. @@ -1069,7 +1233,7 @@ type JsonHandle struct { // - if 'A', then encode all integers as a json string // containing the exact integer representation as a decimal. // - else encode all integers as a json number (default) - IntegerAsString uint8 + IntegerAsString byte // HTMLCharsAsIs controls how to encode some special characters to html: < > & // @@ -1088,52 +1252,103 @@ type JsonHandle struct { // The whitespace is important, especially if using numbers in a context // where multiple items are written to a stream. TermWhitespace bool + + // MapKeyAsString says to encode all map keys as strings. + // + // Use this to enforce strict json output. + // The only caveat is that nil value is ALWAYS written as null (never as "null") + MapKeyAsString bool + + // _ [2]byte // padding + + // Note: below, we store hardly-used items e.g. RawBytesExt is cached in the (en|de)cDriver. + + // RawBytesExt, if configured, is used to encode and decode raw bytes in a custom way. + // If not configured, raw bytes are encoded to/from base64 text. + RawBytesExt InterfaceExt + + _ [3]uint64 // padding } +// Name returns the name of the handle: json +func (h *JsonHandle) Name() string { return "json" } func (h *JsonHandle) hasElemSeparators() bool { return true } +func (h *JsonHandle) typical() bool { + return h.Indent == 0 && !h.MapKeyAsString && h.IntegerAsString != 'A' && h.IntegerAsString != 'L' +} + +type jsonTypical interface { + typical() +} + +func (h *JsonHandle) recreateEncDriver(ed encDriver) (v bool) { + _, v = ed.(jsonTypical) + return v != h.typical() +} +// SetInterfaceExt sets an extension func (h *JsonHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) { - return h.SetExt(rt, tag, &setExtWrapper{i: ext}) + return h.SetExt(rt, tag, &extWrapper{bytesExtFailer{}, ext}) } -func (h *JsonHandle) newEncDriver(e *Encoder) encDriver { - hd := jsonEncDriver{e: e, h: h} - hd.bs = hd.b[:0] +type jsonEncDriverTypicalImpl struct { + jsonEncDriver + jsonEncDriverTypical + _ [1]uint64 // padding +} - hd.reset() +func (x *jsonEncDriverTypicalImpl) reset() { + x.jsonEncDriver.reset() + x.jsonEncDriverTypical.reset(&x.jsonEncDriver) +} - return &hd +type jsonEncDriverGenericImpl struct { + jsonEncDriver + jsonEncDriverGeneric +} + +func (x *jsonEncDriverGenericImpl) reset() { + x.jsonEncDriver.reset() + x.jsonEncDriverGeneric.reset(&x.jsonEncDriver) +} + +func (h *JsonHandle) newEncDriver(e *Encoder) (ee encDriver) { + var hd *jsonEncDriver + if h.typical() { + var v jsonEncDriverTypicalImpl + ee = &v + hd = &v.jsonEncDriver + } else { + var v jsonEncDriverGenericImpl + ee = &v + hd = &v.jsonEncDriver + } + hd.e, hd.h, hd.bs = e, h, hd.b[:0] + hd.se.BytesExt = bytesExtFailer{} + ee.reset() + return } func (h *JsonHandle) newDecDriver(d *Decoder) decDriver { // d := jsonDecDriver{r: r.(*bytesDecReader), h: h} hd := jsonDecDriver{d: d, h: h} + hd.se.BytesExt = bytesExtFailer{} hd.bs = hd.b[:0] hd.reset() return &hd } func (e *jsonEncDriver) reset() { - e.w = e.e.w - e.se.i = e.h.RawBytesExt + e.ew = e.e.w // e.e.w // &e.e.encWriterSwitch + e.se.InterfaceExt = e.h.RawBytesExt if e.bs != nil { e.bs = e.bs[:0] } - e.d, e.dt, e.dl, e.ds = false, false, 0, "" - e.c = 0 - if e.h.Indent > 0 { - e.d = true - e.ds = jsonSpaces[:e.h.Indent] - } else if e.h.Indent < 0 { - e.d = true - e.dt = true - e.ds = jsonTabs[:-(e.h.Indent)] - } } func (d *jsonDecDriver) reset() { - d.r = d.d.r - d.se.i = d.h.RawBytesExt + d.r = d.d.r // &d.d.decReaderSwitch // d.d.r + d.se.InterfaceExt = d.h.RawBytesExt if d.bs != nil { d.bs = d.bs[:0] } @@ -1141,32 +1356,67 @@ func (d *jsonDecDriver) reset() { // d.n.reset() } -// func jsonIsFloatBytes(bs []byte) bool { -// for _, v := range bs { -// // if v == '.' || v == 'e' || v == 'E' { -// if jsonIsFloatSet.isset(v) { -// return true -// } -// } -// return false -// } - -func jsonIsFloatBytesB2(bs []byte) bool { - return bytes.IndexByte(bs, '.') != -1 || - bytes.IndexByte(bs, 'E') != -1 -} - -func jsonIsFloatBytesB3(bs []byte) bool { - return bytes.IndexByte(bs, '.') != -1 || - bytes.IndexByte(bs, 'E') != -1 || - bytes.IndexByte(bs, 'e') != -1 +func jsonFloatStrconvFmtPrec(f float64) (fmt byte, prec int) { + prec = -1 + var abs = math.Abs(f) + if abs != 0 && (abs < 1e-6 || abs >= 1e21) { + fmt = 'e' + } else { + fmt = 'f' + // set prec to 1 iff mod is 0. + // better than using jsonIsFloatBytesB2 to check if a . or E in the float bytes. + // this ensures that every float has an e or .0 in it. + if abs <= 1 { + if abs == 0 || abs == 1 { + prec = 1 + } + } else if _, mod := math.Modf(abs); mod == 0 { + prec = 1 + } + } + return } -// var jsonEncodeTerminate = []byte{' '} +// custom-fitted version of strconv.Parse(Ui|I)nt. +// Also ensures we don't have to search for .eE to determine if a float or not. +func jsonParseInteger(s []byte) (n uint64, neg, badSyntax, overflow bool) { + const maxUint64 = (1<<64 - 1) + const cutoff = maxUint64/10 + 1 -// func (h *JsonHandle) rpcEncodeTerminate() []byte { -// return jsonEncodeTerminate -// } + if len(s) == 0 { + badSyntax = true + return + } + switch s[0] { + case '+': + s = s[1:] + case '-': + s = s[1:] + neg = true + } + for _, c := range s { + if c < '0' || c > '9' { + badSyntax = true + return + } + // unsigned integers don't overflow well on multiplication, so check cutoff here + // e.g. (maxUint64-5)*10 doesn't overflow well ... + if n >= cutoff { + overflow = true + return + } + n *= 10 + n1 := n + uint64(c-'0') + if n1 < n || n1 > maxUint64 { + overflow = true + return + } + n = n1 + } + return +} var _ decDriver = (*jsonDecDriver)(nil) -var _ encDriver = (*jsonEncDriver)(nil) +var _ encDriver = (*jsonEncDriverGenericImpl)(nil) +var _ encDriver = (*jsonEncDriverTypicalImpl)(nil) +var _ jsonTypical = (*jsonEncDriverTypical)(nil) diff --git a/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl b/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl index 6d716972a..90d758ce4 100644 --- a/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl +++ b/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl @@ -1,18 +1,21 @@ // Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. -// ************************************************************ -// DO NOT EDIT. -// THIS FILE IS AUTO-GENERATED from mammoth-test.go.tmpl -// ************************************************************ +// Code generated from mammoth-test.go.tmpl - DO NOT EDIT. package codec +import "testing" +import "fmt" +import "reflect" + // TestMammoth has all the different paths optimized in fast-path // It has all the primitives, slices and maps. // // For each of those types, it has a pointer and a non-pointer field. +func init() { _ = fmt.Printf } // so we can include fmt as needed + type TestMammoth struct { {{range .Values }}{{if .Primitive }}{{/* @@ -31,3 +34,121 @@ type TestMammoth struct { {{end}}{{end}}{{end}} } + +{{range .Values }}{{if not .Primitive }}{{if not .MapKey }}{{/* +*/}} type {{ .MethodNamePfx "typMbs" false }} []{{ .Elem }} +func (_ {{ .MethodNamePfx "typMbs" false }}) MapBySlice() { } +{{end}}{{end}}{{end}} + +{{range .Values }}{{if not .Primitive }}{{if .MapKey }}{{/* +*/}} type {{ .MethodNamePfx "typMap" false }} map[{{ .MapKey }}]{{ .Elem }} +{{end}}{{end}}{{end}} + +func doTestMammothSlices(t *testing.T, h Handle) { +{{range $i, $e := .Values }}{{if not .Primitive }}{{if not .MapKey }}{{/* +*/}} + var v{{$i}}va [8]{{ .Elem }} + for _, v := range [][]{{ .Elem }}{ nil, {}, { {{ nonzerocmd .Elem }}, {{ zerocmd .Elem }}, {{ zerocmd .Elem }}, {{ nonzerocmd .Elem }} } } { {{/* + // fmt.Printf(">>>> running mammoth slice v{{$i}}: %v\n", v) + // - encode value to some []byte + // - decode into a length-wise-equal []byte + // - check if equal to initial slice + // - encode ptr to the value + // - check if encode bytes are same + // - decode into ptrs to: nil, then 1-elem slice, equal-length, then large len slice + // - decode into non-addressable slice of equal length, then larger len + // - for each decode, compare elem-by-elem to the original slice + // - + // - rinse and repeat for a MapBySlice version + // - + */}} + var v{{$i}}v1, v{{$i}}v2 []{{ .Elem }} + v{{$i}}v1 = v + bs{{$i}} := testMarshalErr(v{{$i}}v1, h, t, "enc-slice-v{{$i}}") + if v == nil { v{{$i}}v2 = nil } else { v{{$i}}v2 = make([]{{ .Elem }}, len(v)) } + testUnmarshalErr(v{{$i}}v2, bs{{$i}}, h, t, "dec-slice-v{{$i}}") + testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-slice-v{{$i}}") + if v == nil { v{{$i}}v2 = nil } else { v{{$i}}v2 = make([]{{ .Elem }}, len(v)) } + testUnmarshalErr(reflect.ValueOf(v{{$i}}v2), bs{{$i}}, h, t, "dec-slice-v{{$i}}-noaddr") // non-addressable value + testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-slice-v{{$i}}-noaddr") + // ... + bs{{$i}} = testMarshalErr(&v{{$i}}v1, h, t, "enc-slice-v{{$i}}-p") + v{{$i}}v2 = nil + testUnmarshalErr(&v{{$i}}v2, bs{{$i}}, h, t, "dec-slice-v{{$i}}-p") + testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-slice-v{{$i}}-p") + v{{$i}}va = [8]{{ .Elem }}{} // clear the array + v{{$i}}v2 = v{{$i}}va[:1:1] + testUnmarshalErr(&v{{$i}}v2, bs{{$i}}, h, t, "dec-slice-v{{$i}}-p-1") + testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-slice-v{{$i}}-p-1") + v{{$i}}va = [8]{{ .Elem }}{} // clear the array + v{{$i}}v2 = v{{$i}}va[:len(v{{$i}}v1):len(v{{$i}}v1)] + testUnmarshalErr(&v{{$i}}v2, bs{{$i}}, h, t, "dec-slice-v{{$i}}-p-len") + testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-slice-v{{$i}}-p-len") + v{{$i}}va = [8]{{ .Elem }}{} // clear the array + v{{$i}}v2 = v{{$i}}va[:] + testUnmarshalErr(&v{{$i}}v2, bs{{$i}}, h, t, "dec-slice-v{{$i}}-p-cap") + testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-slice-v{{$i}}-p-cap") + if len(v{{$i}}v1) > 1 { + v{{$i}}va = [8]{{ .Elem }}{} // clear the array + testUnmarshalErr((&v{{$i}}va)[:len(v{{$i}}v1)], bs{{$i}}, h, t, "dec-slice-v{{$i}}-p-len-noaddr") + testDeepEqualErr(v{{$i}}v1, v{{$i}}va[:len(v{{$i}}v1)], t, "equal-slice-v{{$i}}-p-len-noaddr") + v{{$i}}va = [8]{{ .Elem }}{} // clear the array + testUnmarshalErr((&v{{$i}}va)[:], bs{{$i}}, h, t, "dec-slice-v{{$i}}-p-cap-noaddr") + testDeepEqualErr(v{{$i}}v1, v{{$i}}va[:len(v{{$i}}v1)], t, "equal-slice-v{{$i}}-p-cap-noaddr") + } + // ... + var v{{$i}}v3, v{{$i}}v4 {{ .MethodNamePfx "typMbs" false }} + v{{$i}}v2 = nil + if v != nil { v{{$i}}v2 = make([]{{ .Elem }}, len(v)) } + v{{$i}}v3 = {{ .MethodNamePfx "typMbs" false }}(v{{$i}}v1) + v{{$i}}v4 = {{ .MethodNamePfx "typMbs" false }}(v{{$i}}v2) + bs{{$i}} = testMarshalErr(v{{$i}}v3, h, t, "enc-slice-v{{$i}}-custom") + testUnmarshalErr(v{{$i}}v4, bs{{$i}}, h, t, "dec-slice-v{{$i}}-custom") + testDeepEqualErr(v{{$i}}v3, v{{$i}}v4, t, "equal-slice-v{{$i}}-custom") + bs{{$i}} = testMarshalErr(&v{{$i}}v3, h, t, "enc-slice-v{{$i}}-custom-p") + v{{$i}}v2 = nil + v{{$i}}v4 = {{ .MethodNamePfx "typMbs" false }}(v{{$i}}v2) + testUnmarshalErr(&v{{$i}}v4, bs{{$i}}, h, t, "dec-slice-v{{$i}}-custom-p") + testDeepEqualErr(v{{$i}}v3, v{{$i}}v4, t, "equal-slice-v{{$i}}-custom-p") + } +{{end}}{{end}}{{end}} +} + +func doTestMammothMaps(t *testing.T, h Handle) { +{{range $i, $e := .Values }}{{if not .Primitive }}{{if .MapKey }}{{/* +*/}} + for _, v := range []map[{{ .MapKey }}]{{ .Elem }}{ nil, {}, { {{ nonzerocmd .MapKey }}:{{ zerocmd .Elem }} {{if ne "bool" .MapKey}}, {{ nonzerocmd .MapKey }}:{{ nonzerocmd .Elem }} {{end}} } } { + // fmt.Printf(">>>> running mammoth map v{{$i}}: %v\n", v) + var v{{$i}}v1, v{{$i}}v2 map[{{ .MapKey }}]{{ .Elem }} + v{{$i}}v1 = v + bs{{$i}} := testMarshalErr(v{{$i}}v1, h, t, "enc-map-v{{$i}}") + if v == nil { v{{$i}}v2 = nil } else { v{{$i}}v2 = make(map[{{ .MapKey }}]{{ .Elem }}, len(v)) } // reset map + testUnmarshalErr(v{{$i}}v2, bs{{$i}}, h, t, "dec-map-v{{$i}}") + testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-map-v{{$i}}") + if v == nil { v{{$i}}v2 = nil } else { v{{$i}}v2 = make(map[{{ .MapKey }}]{{ .Elem }}, len(v)) } // reset map + testUnmarshalErr(reflect.ValueOf(v{{$i}}v2), bs{{$i}}, h, t, "dec-map-v{{$i}}-noaddr") // decode into non-addressable map value + testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-map-v{{$i}}-noaddr") + if v == nil { v{{$i}}v2 = nil } else { v{{$i}}v2 = make(map[{{ .MapKey }}]{{ .Elem }}, len(v)) } // reset map + testUnmarshalErr(&v{{$i}}v2, bs{{$i}}, h, t, "dec-map-v{{$i}}-p-len") + testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-map-v{{$i}}-p-len") + bs{{$i}} = testMarshalErr(&v{{$i}}v1, h, t, "enc-map-v{{$i}}-p") + v{{$i}}v2 = nil + testUnmarshalErr(&v{{$i}}v2, bs{{$i}}, h, t, "dec-map-v{{$i}}-p-nil") + testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-map-v{{$i}}-p-nil") + // ... + if v == nil { v{{$i}}v2 = nil } else { v{{$i}}v2 = make(map[{{ .MapKey }}]{{ .Elem }}, len(v)) } // reset map + var v{{$i}}v3, v{{$i}}v4 {{ .MethodNamePfx "typMap" false }} + v{{$i}}v3 = {{ .MethodNamePfx "typMap" false }}(v{{$i}}v1) + v{{$i}}v4 = {{ .MethodNamePfx "typMap" false }}(v{{$i}}v2) + bs{{$i}} = testMarshalErr(v{{$i}}v3, h, t, "enc-map-v{{$i}}-custom") + testUnmarshalErr(v{{$i}}v4, bs{{$i}}, h, t, "dec-map-v{{$i}}-p-len") + testDeepEqualErr(v{{$i}}v3, v{{$i}}v4, t, "equal-map-v{{$i}}-p-len") + } +{{end}}{{end}}{{end}} + +} + +func doTestMammothMapsAndSlices(t *testing.T, h Handle) { + doTestMammothSlices(t, h) + doTestMammothMaps(t, h) +} diff --git a/vendor/github.com/ugorji/go/codec/mammoth2-test.go.tmpl b/vendor/github.com/ugorji/go/codec/mammoth2-test.go.tmpl new file mode 100644 index 000000000..7cdf8f5d7 --- /dev/null +++ b/vendor/github.com/ugorji/go/codec/mammoth2-test.go.tmpl @@ -0,0 +1,94 @@ +// +build !notfastpath + +// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Use of this source code is governed by a MIT license found in the LICENSE file. + +// Code generated from mammoth2-test.go.tmpl - DO NOT EDIT. + +package codec + +// Increase codecoverage by covering all the codecgen paths, in fast-path and gen-helper.go.... +// +// Add: +// - test file for creating a mammoth generated file as _mammoth_generated.go +// - generate a second mammoth files in a different file: mammoth2_generated_test.go +// - mammoth-test.go.tmpl will do this +// - run codecgen on it, into mammoth2_codecgen_generated_test.go (no build tags) +// - as part of TestMammoth, run it also +// - this will cover all the codecgen, gen-helper, etc in one full run +// - check in mammoth* files into github also +// - then +// +// Now, add some types: +// - some that implement BinaryMarshal, TextMarshal, JSONMarshal, and one that implements none of it +// - create a wrapper type that includes TestMammoth2, with it in slices, and maps, and the custom types +// - this wrapper object is what we work encode/decode (so that the codecgen methods are called) + + +// import "encoding/binary" +import "fmt" + +type TestMammoth2 struct { + +{{range .Values }}{{if .Primitive }}{{/* +*/}}{{ .MethodNamePfx "F" true }} {{ .Primitive }} +{{ .MethodNamePfx "Fptr" true }} *{{ .Primitive }} +{{end}}{{end}} + +{{range .Values }}{{if not .Primitive }}{{if not .MapKey }}{{/* +*/}}{{ .MethodNamePfx "F" false }} []{{ .Elem }} +{{ .MethodNamePfx "Fptr" false }} *[]{{ .Elem }} +{{end}}{{end}}{{end}} + +{{range .Values }}{{if not .Primitive }}{{if .MapKey }}{{/* +*/}}{{ .MethodNamePfx "F" false }} map[{{ .MapKey }}]{{ .Elem }} +{{ .MethodNamePfx "Fptr" false }} *map[{{ .MapKey }}]{{ .Elem }} +{{end}}{{end}}{{end}} + +} + +// ----------- + +type testMammoth2Binary uint64 +func (x testMammoth2Binary) MarshalBinary() (data []byte, err error) { +data = make([]byte, 8) +bigen.PutUint64(data, uint64(x)) +return +} +func (x *testMammoth2Binary) UnmarshalBinary(data []byte) (err error) { +*x = testMammoth2Binary(bigen.Uint64(data)) +return +} + +type testMammoth2Text uint64 +func (x testMammoth2Text) MarshalText() (data []byte, err error) { +data = []byte(fmt.Sprintf("%b", uint64(x))) +return +} +func (x *testMammoth2Text) UnmarshalText(data []byte) (err error) { +_, err = fmt.Sscanf(string(data), "%b", (*uint64)(x)) +return +} + +type testMammoth2Json uint64 +func (x testMammoth2Json) MarshalJSON() (data []byte, err error) { +data = []byte(fmt.Sprintf("%v", uint64(x))) +return +} +func (x *testMammoth2Json) UnmarshalJSON(data []byte) (err error) { +_, err = fmt.Sscanf(string(data), "%v", (*uint64)(x)) +return +} + +type testMammoth2Basic [4]uint64 + +type TestMammoth2Wrapper struct { + V TestMammoth2 + T testMammoth2Text + B testMammoth2Binary + J testMammoth2Json + C testMammoth2Basic + M map[testMammoth2Basic]TestMammoth2 + L []TestMammoth2 + A [4]int64 +} diff --git a/vendor/github.com/ugorji/go/codec/msgpack.go b/vendor/github.com/ugorji/go/codec/msgpack.go index fcc3177aa..31265cc68 100644 --- a/vendor/github.com/ugorji/go/codec/msgpack.go +++ b/vendor/github.com/ugorji/go/codec/msgpack.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. /* @@ -15,8 +15,8 @@ For compatibility with behaviour of msgpack-c reference implementation: - Go intX (<0) IS ENCODED AS msgpack -ve fixnum, signed - */ + package codec import ( @@ -25,6 +25,7 @@ import ( "math" "net/rpc" "reflect" + "time" ) const ( @@ -78,6 +79,9 @@ const ( mpNegFixNumMax = 0xff ) +var mpTimeExtTag int8 = -1 +var mpTimeExtTagU = uint8(mpTimeExtTag) + // MsgpackSpecRpcMultiArgs is a special type which signifies to the MsgpackSpecRpcCodec // that the backend RPC service takes multiple arguments, which have been arranged // in sequence in the slice. @@ -94,10 +98,18 @@ type msgpackContainerType struct { } var ( - msgpackContainerStr = msgpackContainerType{32, mpFixStrMin, mpStr8, mpStr16, mpStr32, true, true, false} - msgpackContainerBin = msgpackContainerType{0, 0, mpBin8, mpBin16, mpBin32, false, true, true} - msgpackContainerList = msgpackContainerType{16, mpFixArrayMin, 0, mpArray16, mpArray32, true, false, false} - msgpackContainerMap = msgpackContainerType{16, mpFixMapMin, 0, mpMap16, mpMap32, true, false, false} + msgpackContainerStr = msgpackContainerType{ + 32, mpFixStrMin, mpStr8, mpStr16, mpStr32, true, true, false, + } + msgpackContainerBin = msgpackContainerType{ + 0, 0, mpBin8, mpBin16, mpBin32, false, true, true, + } + msgpackContainerList = msgpackContainerType{ + 16, mpFixArrayMin, 0, mpArray16, mpArray32, true, false, false, + } + msgpackContainerMap = msgpackContainerType{ + 16, mpFixMapMin, 0, mpMap16, mpMap32, true, false, false, + } ) //--------------------------------------------- @@ -110,6 +122,7 @@ type msgpackEncDriver struct { w encWriter h *MsgpackHandle x [8]byte + _ [3]uint64 // padding } func (e *msgpackEncDriver) EncodeNil() { @@ -117,10 +130,26 @@ func (e *msgpackEncDriver) EncodeNil() { } func (e *msgpackEncDriver) EncodeInt(i int64) { - if i >= 0 { - e.EncodeUint(uint64(i)) + // if i >= 0 { + // e.EncodeUint(uint64(i)) + // } else if false && + if i > math.MaxInt8 { + if i <= math.MaxInt16 { + e.w.writen1(mpInt16) + bigenHelper{e.x[:2], e.w}.writeUint16(uint16(i)) + } else if i <= math.MaxInt32 { + e.w.writen1(mpInt32) + bigenHelper{e.x[:4], e.w}.writeUint32(uint32(i)) + } else { + e.w.writen1(mpInt64) + bigenHelper{e.x[:8], e.w}.writeUint64(uint64(i)) + } } else if i >= -32 { - e.w.writen1(byte(i)) + if e.h.NoFixedNum { + e.w.writen2(mpInt8, byte(i)) + } else { + e.w.writen1(byte(i)) + } } else if i >= math.MinInt8 { e.w.writen2(mpInt8, byte(i)) } else if i >= math.MinInt16 { @@ -137,7 +166,11 @@ func (e *msgpackEncDriver) EncodeInt(i int64) { func (e *msgpackEncDriver) EncodeUint(i uint64) { if i <= math.MaxInt8 { - e.w.writen1(byte(i)) + if e.h.NoFixedNum { + e.w.writen2(mpUint8, byte(i)) + } else { + e.w.writen1(byte(i)) + } } else if i <= math.MaxUint8 { e.w.writen2(mpUint8, byte(i)) } else if i <= math.MaxUint16 { @@ -170,6 +203,39 @@ func (e *msgpackEncDriver) EncodeFloat64(f float64) { bigenHelper{e.x[:8], e.w}.writeUint64(math.Float64bits(f)) } +func (e *msgpackEncDriver) EncodeTime(t time.Time) { + if t.IsZero() { + e.EncodeNil() + return + } + t = t.UTC() + sec, nsec := t.Unix(), uint64(t.Nanosecond()) + var data64 uint64 + var l = 4 + if sec >= 0 && sec>>34 == 0 { + data64 = (nsec << 34) | uint64(sec) + if data64&0xffffffff00000000 != 0 { + l = 8 + } + } else { + l = 12 + } + if e.h.WriteExt { + e.encodeExtPreamble(mpTimeExtTagU, l) + } else { + e.writeContainerLen(msgpackContainerStr, l) + } + switch l { + case 4: + bigenHelper{e.x[:4], e.w}.writeUint32(uint32(data64)) + case 8: + bigenHelper{e.x[:8], e.w}.writeUint64(data64) + case 12: + bigenHelper{e.x[:4], e.w}.writeUint32(uint32(nsec)) + bigenHelper{e.x[:8], e.w}.writeUint64(uint64(sec)) + } +} + func (e *msgpackEncDriver) EncodeExt(v interface{}, xtag uint64, ext Ext, _ *Encoder) { bs := ext.WriteExt(v) if bs == nil { @@ -180,7 +246,7 @@ func (e *msgpackEncDriver) EncodeExt(v interface{}, xtag uint64, ext Ext, _ *Enc e.encodeExtPreamble(uint8(xtag), len(bs)) e.w.writeb(bs) } else { - e.EncodeStringBytes(c_RAW, bs) + e.EncodeStringBytes(cRAW, bs) } } @@ -224,7 +290,7 @@ func (e *msgpackEncDriver) WriteMapStart(length int) { func (e *msgpackEncDriver) EncodeString(c charEncoding, s string) { slen := len(s) - if c == c_RAW && e.h.WriteExt { + if c == cRAW && e.h.WriteExt { e.writeContainerLen(msgpackContainerBin, slen) } else { e.writeContainerLen(msgpackContainerStr, slen) @@ -234,13 +300,13 @@ func (e *msgpackEncDriver) EncodeString(c charEncoding, s string) { } } -func (e *msgpackEncDriver) EncodeSymbol(v string) { - e.EncodeString(c_UTF8, v) -} - func (e *msgpackEncDriver) EncodeStringBytes(c charEncoding, bs []byte) { + if bs == nil { + e.EncodeNil() + return + } slen := len(bs) - if c == c_RAW && e.h.WriteExt { + if c == cRAW && e.h.WriteExt { e.writeContainerLen(msgpackContainerBin, slen) } else { e.writeContainerLen(msgpackContainerStr, slen) @@ -267,10 +333,10 @@ func (e *msgpackEncDriver) writeContainerLen(ct msgpackContainerType, l int) { //--------------------------------------------- type msgpackDecDriver struct { - d *Decoder - r decReader // *Decoder decReader decReaderT - h *MsgpackHandle - b [scratchByteArrayLen]byte + d *Decoder + r decReader // *Decoder decReader decReaderT + h *MsgpackHandle + // b [scratchByteArrayLen]byte bd byte bdRead bool br bool // bytes reader @@ -278,6 +344,7 @@ type msgpackDecDriver struct { // noStreamingCodec // decNoSeparator decDriverNoopContainerReader + _ [3]uint64 // padding } // Note: This returns either a primitive (int, bool, etc) for non-containers, @@ -368,7 +435,12 @@ func (d *msgpackDecDriver) DecodeNaked() { n.v = valueTypeExt clen := d.readExtLen() n.u = uint64(d.r.readn1()) - n.l = d.r.readx(clen) + if n.u == uint64(mpTimeExtTagU) { + n.v = valueTypeTime + n.t = d.decodeTime(clen) + } else { + n.l = d.r.readx(clen) + } default: d.d.errorf("Nil-Deciphered DecodeValue: %s: hex: %x, dec: %d", msgBadDesc, bd, bd) } @@ -384,7 +456,7 @@ func (d *msgpackDecDriver) DecodeNaked() { } // int can be decoded from msgpack type: intXXX or uintXXX -func (d *msgpackDecDriver) DecodeInt(bitsize uint8) (i int64) { +func (d *msgpackDecDriver) DecodeInt64() (i int64) { if !d.bdRead { d.readNextBd() } @@ -416,19 +488,12 @@ func (d *msgpackDecDriver) DecodeInt(bitsize uint8) (i int64) { return } } - // check overflow (logic adapted from std pkg reflect/value.go OverflowUint() - if bitsize > 0 { - if trunc := (i << (64 - bitsize)) >> (64 - bitsize); i != trunc { - d.d.errorf("Overflow int value: %v", i) - return - } - } d.bdRead = false return } // uint can be decoded from msgpack type: intXXX or uintXXX -func (d *msgpackDecDriver) DecodeUint(bitsize uint8) (ui uint64) { +func (d *msgpackDecDriver) DecodeUint64() (ui uint64) { if !d.bdRead { d.readNextBd() } @@ -481,19 +546,12 @@ func (d *msgpackDecDriver) DecodeUint(bitsize uint8) (ui uint64) { return } } - // check overflow (logic adapted from std pkg reflect/value.go OverflowUint() - if bitsize > 0 { - if trunc := (ui << (64 - bitsize)) >> (64 - bitsize); ui != trunc { - d.d.errorf("Overflow uint value: %v", ui) - return - } - } d.bdRead = false return } // float can either be decoded from msgpack type: float, double or intX -func (d *msgpackDecDriver) DecodeFloat(chkOverflow32 bool) (f float64) { +func (d *msgpackDecDriver) DecodeFloat64() (f float64) { if !d.bdRead { d.readNextBd() } @@ -502,11 +560,7 @@ func (d *msgpackDecDriver) DecodeFloat(chkOverflow32 bool) (f float64) { } else if d.bd == mpDouble { f = math.Float64frombits(bigen.Uint64(d.r.readx(8))) } else { - f = float64(d.DecodeInt(0)) - } - if chkOverflow32 && chkOvf.Float32(f) { - d.d.errorf("msgpack: float32 overflow: %v", f) - return + f = float64(d.DecodeInt64()) } d.bdRead = false return @@ -534,13 +588,15 @@ func (d *msgpackDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) d.readNextBd() } + // check if an "array" of uint8's (see ContainerType for how to infer if an array) + bd := d.bd // DecodeBytes could be from: bin str fixstr fixarray array ... var clen int vt := d.ContainerType() switch vt { case valueTypeBytes: // valueTypeBytes may be a mpBin or an mpStr container - if bd := d.bd; bd == mpBin8 || bd == mpBin16 || bd == mpBin32 { + if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 { clen = d.readContainerLen(msgpackContainerBin) } else { clen = d.readContainerLen(msgpackContainerStr) @@ -548,28 +604,17 @@ func (d *msgpackDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) case valueTypeString: clen = d.readContainerLen(msgpackContainerStr) case valueTypeArray: - clen = d.readContainerLen(msgpackContainerList) - // ensure everything after is one byte each - for i := 0; i < clen; i++ { - d.readNextBd() - if d.bd == mpNil { - bs = append(bs, 0) - } else if d.bd == mpUint8 { - bs = append(bs, d.r.readn1()) - } else { - d.d.errorf("cannot read non-byte into a byte array") - return - } + if zerocopy && len(bs) == 0 { + bs = d.d.b[:] } - d.bdRead = false - return bs + bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d) + return default: - d.d.errorf("invalid container type: expecting bin|str|array") + d.d.errorf("invalid container type: expecting bin|str|array, got: 0x%x", uint8(vt)) return } // these are (bin|str)(8|16|32) - // println("DecodeBytes: clen: ", clen) d.bdRead = false // bytes may be nil, so handle it. if nil, clen=-1. if clen < 0 { @@ -579,18 +624,18 @@ func (d *msgpackDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) if d.br { return d.r.readx(clen) } else if len(bs) == 0 { - bs = d.b[:] + bs = d.d.b[:] } } - return decByteSlice(d.r, clen, d.d.h.MaxInitLen, bs) + return decByteSlice(d.r, clen, d.h.MaxInitLen, bs) } func (d *msgpackDecDriver) DecodeString() (s string) { - return string(d.DecodeBytes(d.b[:], true)) + return string(d.DecodeBytes(d.d.b[:], true)) } func (d *msgpackDecDriver) DecodeStringAsBytes() (s []byte) { - return d.DecodeBytes(d.b[:], true) + return d.DecodeBytes(d.d.b[:], true) } func (d *msgpackDecDriver) readNextBd() { @@ -623,9 +668,10 @@ func (d *msgpackDecDriver) ContainerType() (vt valueType) { return valueTypeArray } else if bd == mpMap16 || bd == mpMap32 || (bd >= mpFixMapMin && bd <= mpFixMapMax) { return valueTypeMap - } else { - // d.d.errorf("isContainerType: unsupported parameter: %v", vt) } + // else { + // d.d.errorf("isContainerType: unsupported parameter: %v", vt) + // } return valueTypeUnset } @@ -635,7 +681,7 @@ func (d *msgpackDecDriver) TryDecodeAsNil() (v bool) { } if d.bd == mpNil { d.bdRead = false - v = true + return true } return } @@ -701,6 +747,57 @@ func (d *msgpackDecDriver) readExtLen() (clen int) { return } +func (d *msgpackDecDriver) DecodeTime() (t time.Time) { + // decode time from string bytes or ext + if !d.bdRead { + d.readNextBd() + } + if d.bd == mpNil { + d.bdRead = false + return + } + var clen int + switch d.ContainerType() { + case valueTypeBytes, valueTypeString: + clen = d.readContainerLen(msgpackContainerStr) + default: + // expect to see mpFixExt4,-1 OR mpFixExt8,-1 OR mpExt8,12,-1 + d.bdRead = false + b2 := d.r.readn1() + if d.bd == mpFixExt4 && b2 == mpTimeExtTagU { + clen = 4 + } else if d.bd == mpFixExt8 && b2 == mpTimeExtTagU { + clen = 8 + } else if d.bd == mpExt8 && b2 == 12 && d.r.readn1() == mpTimeExtTagU { + clen = 12 + } else { + d.d.errorf("invalid bytes for decoding time as extension: got 0x%x, 0x%x", d.bd, b2) + return + } + } + return d.decodeTime(clen) +} + +func (d *msgpackDecDriver) decodeTime(clen int) (t time.Time) { + // bs = d.r.readx(clen) + d.bdRead = false + switch clen { + case 4: + t = time.Unix(int64(bigen.Uint32(d.r.readx(4))), 0).UTC() + case 8: + tv := bigen.Uint64(d.r.readx(8)) + t = time.Unix(int64(tv&0x00000003ffffffff), int64(tv>>34)).UTC() + case 12: + nsec := bigen.Uint32(d.r.readx(4)) + sec := bigen.Uint64(d.r.readx(8)) + t = time.Unix(int64(sec), int64(nsec)).UTC() + default: + d.d.errorf("invalid length of bytes for decoding time - expecting 4 or 8 or 12, got %d", clen) + return + } + return +} + func (d *msgpackDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxtag uint64) { if xtag > 0xff { d.d.errorf("decodeExt: tag must be <= 0xff; got: %v", xtag) @@ -750,6 +847,9 @@ type MsgpackHandle struct { // RawToString controls how raw bytes are decoded into a nil interface{}. RawToString bool + // NoFixedNum says to output all signed integers as 2-bytes, never as 1-byte fixednum. + NoFixedNum bool + // WriteExt flag supports encoding configured extensions with extension tags. // It also controls whether other elements of the new spec are encoded (ie Str8). // @@ -761,12 +861,19 @@ type MsgpackHandle struct { // type is provided (e.g. decoding into a nil interface{}), you get back // a []byte or string based on the setting of RawToString. WriteExt bool + binaryEncodingType noElemSeparators + + _ [1]uint64 // padding } +// Name returns the name of the handle: msgpack +func (h *MsgpackHandle) Name() string { return "msgpack" } + +// SetBytesExt sets an extension func (h *MsgpackHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) { - return h.SetExt(rt, tag, &setExtWrapper{b: ext}) + return h.SetExt(rt, tag, &extWrapper{ext, interfaceExtFailer{}}) } func (h *MsgpackHandle) newEncDriver(e *Encoder) encDriver { @@ -804,7 +911,7 @@ func (c *msgpackSpecRpcCodec) WriteRequest(r *rpc.Request, body interface{}) err bodyArr = []interface{}{body} } r2 := []interface{}{0, uint32(r.Seq), r.ServiceMethod, bodyArr} - return c.write(r2, nil, false, true) + return c.write(r2, nil, false) } func (c *msgpackSpecRpcCodec) WriteResponse(r *rpc.Response, body interface{}) error { @@ -816,7 +923,7 @@ func (c *msgpackSpecRpcCodec) WriteResponse(r *rpc.Response, body interface{}) e body = nil } r2 := []interface{}{1, uint32(r.Seq), moe, body} - return c.write(r2, nil, false, true) + return c.write(r2, nil, false) } func (c *msgpackSpecRpcCodec) ReadResponseHeader(r *rpc.Response) error { @@ -836,7 +943,6 @@ func (c *msgpackSpecRpcCodec) ReadRequestBody(body interface{}) error { } func (c *msgpackSpecRpcCodec) parseCustomHeader(expectTypeByte byte, msgid *uint64, methodOrError *string) (err error) { - if c.isClosed() { return io.EOF } @@ -850,28 +956,34 @@ func (c *msgpackSpecRpcCodec) parseCustomHeader(expectTypeByte byte, msgid *uint // err = fmt.Errorf("Unexpected value for array descriptor: Expecting %v. Received %v", fia, bs1) // return // } - var b byte - b, err = c.br.ReadByte() - if err != nil { - return + var ba [1]byte + var n int + for { + n, err = c.r.Read(ba[:]) + if err != nil { + return + } + if n == 1 { + break + } } + + var b = ba[0] if b != fia { err = fmt.Errorf("Unexpected value for array descriptor: Expecting %v. Received %v", fia, b) - return - } - - if err = c.read(&b); err != nil { - return - } - if b != expectTypeByte { - err = fmt.Errorf("Unexpected byte descriptor in header. Expecting %v. Received %v", expectTypeByte, b) - return - } - if err = c.read(msgid); err != nil { - return - } - if err = c.read(methodOrError); err != nil { - return + } else { + err = c.read(&b) + if err == nil { + if b != expectTypeByte { + err = fmt.Errorf("Unexpected byte descriptor. Expecting %v; Received %v", + expectTypeByte, b) + } else { + err = c.read(msgid) + if err == nil { + err = c.read(methodOrError) + } + } + } } return } @@ -884,7 +996,8 @@ type msgpackSpecRpc struct{} // MsgpackSpecRpc implements Rpc using the communication protocol defined in // the msgpack spec at https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md . -// Its methods (ServerCodec and ClientCodec) return values that implement RpcCodecBuffered. +// +// See GoRpc documentation, for information on buffering for better performance. var MsgpackSpecRpc msgpackSpecRpc func (x msgpackSpecRpc) ServerCodec(conn io.ReadWriteCloser, h Handle) rpc.ServerCodec { diff --git a/vendor/github.com/ugorji/go/codec/noop.go b/vendor/github.com/ugorji/go/codec/noop.go index 015af581a..424bd49d7 100644 --- a/vendor/github.com/ugorji/go/codec/noop.go +++ b/vendor/github.com/ugorji/go/codec/noop.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. // +build ignore @@ -91,8 +91,9 @@ func (h *noopDrv) EncodeArrayStart(length int) { h.start(true) } func (h *noopDrv) EncodeMapStart(length int) { h.start(false) } func (h *noopDrv) EncodeEnd() { h.end() } -func (h *noopDrv) EncodeString(c charEncoding, v string) {} -func (h *noopDrv) EncodeSymbol(v string) {} +func (h *noopDrv) EncodeString(c charEncoding, v string) {} + +// func (h *noopDrv) EncodeSymbol(v string) {} func (h *noopDrv) EncodeStringBytes(c charEncoding, v []byte) {} func (h *noopDrv) EncodeExt(rv interface{}, xtag uint64, ext Ext, e *Encoder) {} @@ -119,9 +120,12 @@ func (h *noopDrv) ReadArrayStart() int { h.start(false); return h.m(10) } func (h *noopDrv) ContainerType() (vt valueType) { // return h.m(2) == 0 - // handle kStruct, which will bomb is it calls this and doesn't get back a map or array. - // consequently, if the return value is not map or array, reset it to one of them based on h.m(7) % 2 - // for kstruct: at least one out of every 2 times, return one of valueTypeMap or Array (else kstruct bombs) + // handle kStruct, which will bomb is it calls this and + // doesn't get back a map or array. + // consequently, if the return value is not map or array, + // reset it to one of them based on h.m(7) % 2 + // for kstruct: at least one out of every 2 times, + // return one of valueTypeMap or Array (else kstruct bombs) // however, every 10th time it is called, we just return something else. var vals = [...]valueType{valueTypeArray, valueTypeMap} // ------------ TAKE ------------ @@ -150,7 +154,8 @@ func (h *noopDrv) ContainerType() (vt valueType) { // } // return valueTypeUnset // TODO: may need to tweak this so it works. - // if h.ct == valueTypeMap && vt == valueTypeArray || h.ct == valueTypeArray && vt == valueTypeMap { + // if h.ct == valueTypeMap && vt == valueTypeArray || + // h.ct == valueTypeArray && vt == valueTypeMap { // h.cb = !h.cb // h.ct = vt // return h.cb diff --git a/vendor/github.com/ugorji/go/codec/rpc.go b/vendor/github.com/ugorji/go/codec/rpc.go index 4c307804c..dc8c07c09 100644 --- a/vendor/github.com/ugorji/go/codec/rpc.go +++ b/vendor/github.com/ugorji/go/codec/rpc.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. package codec @@ -11,124 +11,143 @@ import ( "sync" ) -// // rpcEncodeTerminator allows a handler specify a []byte terminator to send after each Encode. -// // -// // Some codecs like json need to put a space after each encoded value, to serve as a -// // delimiter for things like numbers (else json codec will continue reading till EOF). -// type rpcEncodeTerminator interface { -// rpcEncodeTerminate() []byte -// } - // Rpc provides a rpc Server or Client Codec for rpc communication. type Rpc interface { ServerCodec(conn io.ReadWriteCloser, h Handle) rpc.ServerCodec ClientCodec(conn io.ReadWriteCloser, h Handle) rpc.ClientCodec } -// RpcCodecBuffered allows access to the underlying bufio.Reader/Writer -// used by the rpc connection. It accommodates use-cases where the connection -// should be used by rpc and non-rpc functions, e.g. streaming a file after -// sending an rpc response. -type RpcCodecBuffered interface { - BufferedReader() *bufio.Reader - BufferedWriter() *bufio.Writer +// RPCOptions holds options specific to rpc functionality +type RPCOptions struct { + // RPCNoBuffer configures whether we attempt to buffer reads and writes during RPC calls. + // + // Set RPCNoBuffer=true to turn buffering off. + // Buffering can still be done if buffered connections are passed in, or + // buffering is configured on the handle. + RPCNoBuffer bool } -// ------------------------------------- - // rpcCodec defines the struct members and common methods. type rpcCodec struct { - rwc io.ReadWriteCloser + c io.Closer + r io.Reader + w io.Writer + f ioFlusher + dec *Decoder enc *Encoder - bw *bufio.Writer - br *bufio.Reader - mu sync.Mutex - h Handle + // bw *bufio.Writer + // br *bufio.Reader + mu sync.Mutex + h Handle - cls bool - clsmu sync.RWMutex + cls bool + clsmu sync.RWMutex + clsErr error } func newRPCCodec(conn io.ReadWriteCloser, h Handle) rpcCodec { - bw := bufio.NewWriter(conn) - br := bufio.NewReader(conn) + // return newRPCCodec2(bufio.NewReader(conn), bufio.NewWriter(conn), conn, h) + return newRPCCodec2(conn, conn, conn, h) +} +func newRPCCodec2(r io.Reader, w io.Writer, c io.Closer, h Handle) rpcCodec { // defensive: ensure that jsonH has TermWhitespace turned on. if jsonH, ok := h.(*JsonHandle); ok && !jsonH.TermWhitespace { panic(errors.New("rpc requires a JsonHandle with TermWhitespace set to true")) } - + // always ensure that we use a flusher, and always flush what was written to the connection. + // we lose nothing by using a buffered writer internally. + f, ok := w.(ioFlusher) + bh := h.getBasicHandle() + if !bh.RPCNoBuffer { + if bh.WriterBufferSize <= 0 { + if !ok { + bw := bufio.NewWriter(w) + f, w = bw, bw + } + } + if bh.ReaderBufferSize <= 0 { + if _, ok = w.(ioPeeker); !ok { + if _, ok = w.(ioBuffered); !ok { + br := bufio.NewReader(r) + r = br + } + } + } + } return rpcCodec{ - rwc: conn, - bw: bw, - br: br, - enc: NewEncoder(bw, h), - dec: NewDecoder(br, h), + c: c, + w: w, + r: r, + f: f, h: h, + enc: NewEncoder(w, h), + dec: NewDecoder(r, h), } } -func (c *rpcCodec) BufferedReader() *bufio.Reader { - return c.br -} - -func (c *rpcCodec) BufferedWriter() *bufio.Writer { - return c.bw -} - -func (c *rpcCodec) write(obj1, obj2 interface{}, writeObj2, doFlush bool) (err error) { +func (c *rpcCodec) write(obj1, obj2 interface{}, writeObj2 bool) (err error) { if c.isClosed() { - return io.EOF + return c.clsErr } - if err = c.enc.Encode(obj1); err != nil { - return - } - // t, tOk := c.h.(rpcEncodeTerminator) - // if tOk { - // c.bw.Write(t.rpcEncodeTerminate()) - // } - if writeObj2 { - if err = c.enc.Encode(obj2); err != nil { - return + err = c.enc.Encode(obj1) + if err == nil { + if writeObj2 { + err = c.enc.Encode(obj2) + } + if err == nil && c.f != nil { + err = c.f.Flush() } - // if tOk { - // c.bw.Write(t.rpcEncodeTerminate()) - // } - } - if doFlush { - return c.bw.Flush() } return } +func (c *rpcCodec) swallow(err *error) { + defer panicToErr(c.dec, err) + c.dec.swallow() +} + func (c *rpcCodec) read(obj interface{}) (err error) { if c.isClosed() { - return io.EOF + return c.clsErr } - //If nil is passed in, we should still attempt to read content to nowhere. + //If nil is passed in, we should read and discard if obj == nil { - var obj2 interface{} - return c.dec.Decode(&obj2) + // var obj2 interface{} + // return c.dec.Decode(&obj2) + c.swallow(&err) + return } return c.dec.Decode(obj) } -func (c *rpcCodec) isClosed() bool { - c.clsmu.RLock() - x := c.cls - c.clsmu.RUnlock() - return x +func (c *rpcCodec) isClosed() (b bool) { + if c.c != nil { + c.clsmu.RLock() + b = c.cls + c.clsmu.RUnlock() + } + return } func (c *rpcCodec) Close() error { - if c.isClosed() { - return io.EOF + if c.c == nil || c.isClosed() { + return c.clsErr } c.clsmu.Lock() c.cls = true + var fErr error + if c.f != nil { + fErr = c.f.Flush() + } + _ = fErr + c.clsErr = c.c.Close() + if c.clsErr == nil && fErr != nil { + c.clsErr = fErr + } c.clsmu.Unlock() - return c.rwc.Close() + return c.clsErr } func (c *rpcCodec) ReadResponseBody(body interface{}) error { @@ -145,13 +164,13 @@ func (c *goRpcCodec) WriteRequest(r *rpc.Request, body interface{}) error { // Must protect for concurrent access as per API c.mu.Lock() defer c.mu.Unlock() - return c.write(r, body, true, true) + return c.write(r, body, true) } func (c *goRpcCodec) WriteResponse(r *rpc.Response, body interface{}) error { c.mu.Lock() defer c.mu.Unlock() - return c.write(r, body, true, true) + return c.write(r, body, true) } func (c *goRpcCodec) ReadResponseHeader(r *rpc.Response) error { @@ -173,7 +192,36 @@ func (c *goRpcCodec) ReadRequestBody(body interface{}) error { type goRpc struct{} // GoRpc implements Rpc using the communication protocol defined in net/rpc package. -// Its methods (ServerCodec and ClientCodec) return values that implement RpcCodecBuffered. +// +// Note: network connection (from net.Dial, of type io.ReadWriteCloser) is not buffered. +// +// For performance, you should configure WriterBufferSize and ReaderBufferSize on the handle. +// This ensures we use an adequate buffer during reading and writing. +// If not configured, we will internally initialize and use a buffer during reads and writes. +// This can be turned off via the RPCNoBuffer option on the Handle. +// var handle codec.JsonHandle +// handle.RPCNoBuffer = true // turns off attempt by rpc module to initialize a buffer +// +// Example 1: one way of configuring buffering explicitly: +// var handle codec.JsonHandle // codec handle +// handle.ReaderBufferSize = 1024 +// handle.WriterBufferSize = 1024 +// var conn io.ReadWriteCloser // connection got from a socket +// var serverCodec = GoRpc.ServerCodec(conn, handle) +// var clientCodec = GoRpc.ClientCodec(conn, handle) +// +// Example 2: you can also explicitly create a buffered connection yourself, +// and not worry about configuring the buffer sizes in the Handle. +// var handle codec.Handle // codec handle +// var conn io.ReadWriteCloser // connection got from a socket +// var bufconn = struct { // bufconn here is a buffered io.ReadWriteCloser +// io.Closer +// *bufio.Reader +// *bufio.Writer +// }{conn, bufio.NewReader(conn), bufio.NewWriter(conn)} +// var serverCodec = GoRpc.ServerCodec(bufconn, handle) +// var clientCodec = GoRpc.ClientCodec(bufconn, handle) +// var GoRpc goRpc func (x goRpc) ServerCodec(conn io.ReadWriteCloser, h Handle) rpc.ServerCodec { @@ -183,5 +231,3 @@ func (x goRpc) ServerCodec(conn io.ReadWriteCloser, h Handle) rpc.ServerCodec { func (x goRpc) ClientCodec(conn io.ReadWriteCloser, h Handle) rpc.ClientCodec { return &goRpcCodec{newRPCCodec(conn, h)} } - -var _ RpcCodecBuffered = (*rpcCodec)(nil) // ensure *rpcCodec implements RpcCodecBuffered diff --git a/vendor/github.com/ugorji/go/codec/simple.go b/vendor/github.com/ugorji/go/codec/simple.go index b69a15e75..a839d810e 100644 --- a/vendor/github.com/ugorji/go/codec/simple.go +++ b/vendor/github.com/ugorji/go/codec/simple.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. package codec @@ -6,6 +6,7 @@ package codec import ( "math" "reflect" + "time" ) const ( @@ -20,6 +21,8 @@ const ( simpleVdPosInt = 8 simpleVdNegInt = 12 + simpleVdTime = 24 + // containers: each lasts for 4 (ie n, n+1, n+2, ... n+7) simpleVdString = 216 simpleVdByteArray = 224 @@ -30,12 +33,15 @@ const ( type simpleEncDriver struct { noBuiltInTypes - encDriverNoopContainerWriter // encNoSeparator e *Encoder h *SimpleHandle w encWriter b [8]byte + // c containerState + encDriverTrackContainerWriter + // encDriverNoopContainerWriter + _ [2]uint64 // padding } func (e *simpleEncDriver) EncodeNil() { @@ -43,6 +49,10 @@ func (e *simpleEncDriver) EncodeNil() { } func (e *simpleEncDriver) EncodeBool(b bool) { + if e.h.EncZeroValuesAsNil && e.c != containerMapKey && !b { + e.EncodeNil() + return + } if b { e.w.writen1(simpleVdTrue) } else { @@ -51,11 +61,19 @@ func (e *simpleEncDriver) EncodeBool(b bool) { } func (e *simpleEncDriver) EncodeFloat32(f float32) { + if e.h.EncZeroValuesAsNil && e.c != containerMapKey && f == 0.0 { + e.EncodeNil() + return + } e.w.writen1(simpleVdFloat32) bigenHelper{e.b[:4], e.w}.writeUint32(math.Float32bits(f)) } func (e *simpleEncDriver) EncodeFloat64(f float64) { + if e.h.EncZeroValuesAsNil && e.c != containerMapKey && f == 0.0 { + e.EncodeNil() + return + } e.w.writen1(simpleVdFloat64) bigenHelper{e.b[:8], e.w}.writeUint64(math.Float64bits(f)) } @@ -73,6 +91,10 @@ func (e *simpleEncDriver) EncodeUint(v uint64) { } func (e *simpleEncDriver) encUint(v uint64, bd uint8) { + if e.h.EncZeroValuesAsNil && e.c != containerMapKey && v == 0 { + e.EncodeNil() + return + } if v <= math.MaxUint8 { e.w.writen2(bd, uint8(v)) } else if v <= math.MaxUint16 { @@ -126,27 +148,54 @@ func (e *simpleEncDriver) encodeExtPreamble(xtag byte, length int) { } func (e *simpleEncDriver) WriteArrayStart(length int) { + e.c = containerArrayStart e.encLen(simpleVdArray, length) } func (e *simpleEncDriver) WriteMapStart(length int) { + e.c = containerMapStart e.encLen(simpleVdMap, length) } func (e *simpleEncDriver) EncodeString(c charEncoding, v string) { + if false && e.h.EncZeroValuesAsNil && e.c != containerMapKey && v == "" { + e.EncodeNil() + return + } e.encLen(simpleVdString, len(v)) e.w.writestr(v) } -func (e *simpleEncDriver) EncodeSymbol(v string) { - e.EncodeString(c_UTF8, v) -} +// func (e *simpleEncDriver) EncodeSymbol(v string) { +// e.EncodeString(cUTF8, v) +// } func (e *simpleEncDriver) EncodeStringBytes(c charEncoding, v []byte) { + // if e.h.EncZeroValuesAsNil && e.c != containerMapKey && v == nil { + if v == nil { + e.EncodeNil() + return + } e.encLen(simpleVdByteArray, len(v)) e.w.writeb(v) } +func (e *simpleEncDriver) EncodeTime(t time.Time) { + // if e.h.EncZeroValuesAsNil && e.c != containerMapKey && t.IsZero() { + if t.IsZero() { + e.EncodeNil() + return + } + v, err := t.MarshalBinary() + if err != nil { + e.e.errorv(err) + return + } + // time.Time marshalbinary takes about 14 bytes. + e.w.writen2(simpleVdTime, uint8(len(v))) + e.w.writeb(v) +} + //------------------------------------ type simpleDecDriver struct { @@ -155,11 +204,13 @@ type simpleDecDriver struct { r decReader bdRead bool bd byte - br bool // bytes reader - b [scratchByteArrayLen]byte + br bool // a bytes reader? + c containerState + // b [scratchByteArrayLen]byte noBuiltInTypes // noStreamingCodec decDriverNoopContainerReader + _ [3]uint64 // padding } func (d *simpleDecDriver) readNextBd() { @@ -178,23 +229,27 @@ func (d *simpleDecDriver) ContainerType() (vt valueType) { if !d.bdRead { d.readNextBd() } - if d.bd == simpleVdNil { + switch d.bd { + case simpleVdNil: return valueTypeNil - } else if d.bd == simpleVdByteArray || d.bd == simpleVdByteArray+1 || - d.bd == simpleVdByteArray+2 || d.bd == simpleVdByteArray+3 || d.bd == simpleVdByteArray+4 { + case simpleVdByteArray, simpleVdByteArray + 1, + simpleVdByteArray + 2, simpleVdByteArray + 3, simpleVdByteArray + 4: return valueTypeBytes - } else if d.bd == simpleVdString || d.bd == simpleVdString+1 || - d.bd == simpleVdString+2 || d.bd == simpleVdString+3 || d.bd == simpleVdString+4 { + case simpleVdString, simpleVdString + 1, + simpleVdString + 2, simpleVdString + 3, simpleVdString + 4: return valueTypeString - } else if d.bd == simpleVdArray || d.bd == simpleVdArray+1 || - d.bd == simpleVdArray+2 || d.bd == simpleVdArray+3 || d.bd == simpleVdArray+4 { + case simpleVdArray, simpleVdArray + 1, + simpleVdArray + 2, simpleVdArray + 3, simpleVdArray + 4: return valueTypeArray - } else if d.bd == simpleVdMap || d.bd == simpleVdMap+1 || - d.bd == simpleVdMap+2 || d.bd == simpleVdMap+3 || d.bd == simpleVdMap+4 { + case simpleVdMap, simpleVdMap + 1, + simpleVdMap + 2, simpleVdMap + 3, simpleVdMap + 4: return valueTypeMap - } else { - // d.d.errorf("isContainerType: unsupported parameter: %v", vt) + // case simpleVdTime: + // return valueTypeTime } + // else { + // d.d.errorf("isContainerType: unsupported parameter: %v", vt) + // } return valueTypeUnset } @@ -235,7 +290,7 @@ func (d *simpleDecDriver) decCheckInteger() (ui uint64, neg bool) { ui = uint64(bigen.Uint64(d.r.readx(8))) neg = true default: - d.d.errorf("decIntAny: Integer only valid from pos/neg integer1..8. Invalid descriptor: %v", d.bd) + d.d.errorf("Integer only valid from pos/neg integer1..8. Invalid descriptor: %v", d.bd) return } // don't do this check, because callers may only want the unsigned value. @@ -246,39 +301,27 @@ func (d *simpleDecDriver) decCheckInteger() (ui uint64, neg bool) { return } -func (d *simpleDecDriver) DecodeInt(bitsize uint8) (i int64) { +func (d *simpleDecDriver) DecodeInt64() (i int64) { ui, neg := d.decCheckInteger() - i, overflow := chkOvf.SignedInt(ui) - if overflow { - d.d.errorf("simple: overflow converting %v to signed integer", ui) - return - } + i = chkOvf.SignedIntV(ui) if neg { i = -i } - if chkOvf.Int(i, bitsize) { - d.d.errorf("simple: overflow integer: %v", i) - return - } d.bdRead = false return } -func (d *simpleDecDriver) DecodeUint(bitsize uint8) (ui uint64) { +func (d *simpleDecDriver) DecodeUint64() (ui uint64) { ui, neg := d.decCheckInteger() if neg { d.d.errorf("Assigning negative signed value to unsigned type") return } - if chkOvf.Uint(ui, bitsize) { - d.d.errorf("simple: overflow integer: %v", ui) - return - } d.bdRead = false return } -func (d *simpleDecDriver) DecodeFloat(chkOverflow32 bool) (f float64) { +func (d *simpleDecDriver) DecodeFloat64() (f float64) { if !d.bdRead { d.readNextBd() } @@ -288,16 +331,12 @@ func (d *simpleDecDriver) DecodeFloat(chkOverflow32 bool) (f float64) { f = math.Float64frombits(bigen.Uint64(d.r.readx(8))) } else { if d.bd >= simpleVdPosInt && d.bd <= simpleVdNegInt+3 { - f = float64(d.DecodeInt(64)) + f = float64(d.DecodeInt64()) } else { d.d.errorf("Float only valid from float32/64: Invalid descriptor: %v", d.bd) return } } - if chkOverflow32 && chkOvf.Float32(f) { - d.d.errorf("msgpack: float32 overflow: %v", f) - return - } d.bdRead = false return } @@ -323,6 +362,7 @@ func (d *simpleDecDriver) ReadMapStart() (length int) { d.readNextBd() } d.bdRead = false + d.c = containerMapStart return d.decLen() } @@ -331,9 +371,30 @@ func (d *simpleDecDriver) ReadArrayStart() (length int) { d.readNextBd() } d.bdRead = false + d.c = containerArrayStart return d.decLen() } +func (d *simpleDecDriver) ReadArrayElem() { + d.c = containerArrayElem +} + +func (d *simpleDecDriver) ReadArrayEnd() { + d.c = containerArrayEnd +} + +func (d *simpleDecDriver) ReadMapElemKey() { + d.c = containerMapKey +} + +func (d *simpleDecDriver) ReadMapElemValue() { + d.c = containerMapValue +} + +func (d *simpleDecDriver) ReadMapEnd() { + d.c = containerMapEnd +} + func (d *simpleDecDriver) decLen() int { switch d.bd % 8 { case 0: @@ -345,14 +406,14 @@ func (d *simpleDecDriver) decLen() int { case 3: ui := uint64(bigen.Uint32(d.r.readx(4))) if chkOvf.Uint(ui, intBitsize) { - d.d.errorf("simple: overflow integer: %v", ui) + d.d.errorf("overflow integer: %v", ui) return 0 } return int(ui) case 4: ui := bigen.Uint64(d.r.readx(8)) if chkOvf.Uint(ui, intBitsize) { - d.d.errorf("simple: overflow integer: %v", ui) + d.d.errorf("overflow integer: %v", ui) return 0 } return int(ui) @@ -362,11 +423,11 @@ func (d *simpleDecDriver) decLen() int { } func (d *simpleDecDriver) DecodeString() (s string) { - return string(d.DecodeBytes(d.b[:], true)) + return string(d.DecodeBytes(d.d.b[:], true)) } func (d *simpleDecDriver) DecodeStringAsBytes() (s []byte) { - return d.DecodeBytes(d.b[:], true) + return d.DecodeBytes(d.d.b[:], true) } func (d *simpleDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { @@ -377,18 +438,48 @@ func (d *simpleDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { d.bdRead = false return } + // check if an "array" of uint8's (see ContainerType for how to infer if an array) + if d.bd >= simpleVdArray && d.bd <= simpleVdMap+4 { + if len(bs) == 0 && zerocopy { + bs = d.d.b[:] + } + bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d) + return + } + clen := d.decLen() d.bdRead = false if zerocopy { if d.br { return d.r.readx(clen) } else if len(bs) == 0 { - bs = d.b[:] + bs = d.d.b[:] } } return decByteSlice(d.r, clen, d.d.h.MaxInitLen, bs) } +func (d *simpleDecDriver) DecodeTime() (t time.Time) { + if !d.bdRead { + d.readNextBd() + } + if d.bd == simpleVdNil { + d.bdRead = false + return + } + if d.bd != simpleVdTime { + d.d.errorf("invalid descriptor for time.Time - expect 0x%x, received 0x%x", simpleVdTime, d.bd) + return + } + d.bdRead = false + clen := int(d.r.readn1()) + b := d.r.readx(clen) + if err := (&t).UnmarshalBinary(b); err != nil { + d.d.errorv(err) + } + return +} + func (d *simpleDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxtag uint64) { if xtag > 0xff { d.d.errorf("decodeExt: tag must be <= 0xff; got: %v", xtag) @@ -419,10 +510,11 @@ func (d *simpleDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs [ return } xbs = d.r.readx(l) - case simpleVdByteArray, simpleVdByteArray + 1, simpleVdByteArray + 2, simpleVdByteArray + 3, simpleVdByteArray + 4: + case simpleVdByteArray, simpleVdByteArray + 1, + simpleVdByteArray + 2, simpleVdByteArray + 3, simpleVdByteArray + 4: xbs = d.DecodeBytes(nil, true) default: - d.d.errorf("Invalid d.bd for extensions (Expecting extensions or byte array). Got: 0x%x", d.bd) + d.d.errorf("Invalid descriptor - expecting extensions/bytearray, got: 0x%x", d.bd) return } d.bdRead = false @@ -449,24 +541,29 @@ func (d *simpleDecDriver) DecodeNaked() { case simpleVdPosInt, simpleVdPosInt + 1, simpleVdPosInt + 2, simpleVdPosInt + 3: if d.h.SignedInteger { n.v = valueTypeInt - n.i = d.DecodeInt(64) + n.i = d.DecodeInt64() } else { n.v = valueTypeUint - n.u = d.DecodeUint(64) + n.u = d.DecodeUint64() } case simpleVdNegInt, simpleVdNegInt + 1, simpleVdNegInt + 2, simpleVdNegInt + 3: n.v = valueTypeInt - n.i = d.DecodeInt(64) + n.i = d.DecodeInt64() case simpleVdFloat32: n.v = valueTypeFloat - n.f = d.DecodeFloat(true) + n.f = d.DecodeFloat64() case simpleVdFloat64: n.v = valueTypeFloat - n.f = d.DecodeFloat(false) - case simpleVdString, simpleVdString + 1, simpleVdString + 2, simpleVdString + 3, simpleVdString + 4: + n.f = d.DecodeFloat64() + case simpleVdTime: + n.v = valueTypeTime + n.t = d.DecodeTime() + case simpleVdString, simpleVdString + 1, + simpleVdString + 2, simpleVdString + 3, simpleVdString + 4: n.v = valueTypeString n.s = d.DecodeString() - case simpleVdByteArray, simpleVdByteArray + 1, simpleVdByteArray + 2, simpleVdByteArray + 3, simpleVdByteArray + 4: + case simpleVdByteArray, simpleVdByteArray + 1, + simpleVdByteArray + 2, simpleVdByteArray + 3, simpleVdByteArray + 4: n.v = valueTypeBytes n.l = d.DecodeBytes(nil, false) case simpleVdExt, simpleVdExt + 1, simpleVdExt + 2, simpleVdExt + 3, simpleVdExt + 4: @@ -474,7 +571,8 @@ func (d *simpleDecDriver) DecodeNaked() { l := d.decLen() n.u = uint64(d.r.readn1()) n.l = d.r.readx(l) - case simpleVdArray, simpleVdArray + 1, simpleVdArray + 2, simpleVdArray + 3, simpleVdArray + 4: + case simpleVdArray, simpleVdArray + 1, simpleVdArray + 2, + simpleVdArray + 3, simpleVdArray + 4: n.v = valueTypeArray decodeFurther = true case simpleVdMap, simpleVdMap + 1, simpleVdMap + 2, simpleVdMap + 3, simpleVdMap + 4: @@ -500,7 +598,7 @@ func (d *simpleDecDriver) DecodeNaked() { // - Integers (intXXX, uintXXX) are encoded in 1, 2, 4 or 8 bytes (plus a descriptor byte). // There are positive (uintXXX and intXXX >= 0) and negative (intXXX < 0) integers. // - Floats are encoded in 4 or 8 bytes (plus a descriptor byte) -// - Lenght of containers (strings, bytes, array, map, extensions) +// - Length of containers (strings, bytes, array, map, extensions) // are encoded in 0, 1, 2, 4 or 8 bytes. // Zero-length containers have no length encoded. // For others, the number of bytes is given by pow(2, bd%3) @@ -508,18 +606,29 @@ func (d *simpleDecDriver) DecodeNaked() { // - arrays are encoded as [bd] [length] [value]... // - extensions are encoded as [bd] [length] [tag] [byte]... // - strings/bytearrays are encoded as [bd] [length] [byte]... +// - time.Time are encoded as [bd] [length] [byte]... // // The full spec will be published soon. type SimpleHandle struct { BasicHandle binaryEncodingType noElemSeparators + // EncZeroValuesAsNil says to encode zero values for numbers, bool, string, etc as nil + EncZeroValuesAsNil bool + + _ [1]uint64 // padding } +// Name returns the name of the handle: simple +func (h *SimpleHandle) Name() string { return "simple" } + +// SetBytesExt sets an extension func (h *SimpleHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) { - return h.SetExt(rt, tag, &setExtWrapper{b: ext}) + return h.SetExt(rt, tag, &extWrapper{ext, interfaceExtFailer{}}) } +func (h *SimpleHandle) hasElemSeparators() bool { return true } // as it implements Write(Map|Array)XXX + func (h *SimpleHandle) newEncDriver(e *Encoder) encDriver { return &simpleEncDriver{e: e, w: e.w, h: h} } @@ -529,10 +638,12 @@ func (h *SimpleHandle) newDecDriver(d *Decoder) decDriver { } func (e *simpleEncDriver) reset() { + e.c = 0 e.w = e.e.w } func (d *simpleDecDriver) reset() { + d.c = 0 d.r, d.br = d.d.r, d.d.bytes d.bd, d.bdRead = 0, false } diff --git a/vendor/github.com/ugorji/go/codec/time.go b/vendor/github.com/ugorji/go/codec/time.go deleted file mode 100644 index 55841d4ca..000000000 --- a/vendor/github.com/ugorji/go/codec/time.go +++ /dev/null @@ -1,220 +0,0 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "fmt" - "time" -) - -var timeDigits = [...]byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'} - -type timeExt struct{} - -func (x timeExt) WriteExt(v interface{}) (bs []byte) { - switch v2 := v.(type) { - case time.Time: - bs = encodeTime(v2) - case *time.Time: - bs = encodeTime(*v2) - default: - panic(fmt.Errorf("unsupported format for time conversion: expecting time.Time; got %T", v2)) - } - return -} -func (x timeExt) ReadExt(v interface{}, bs []byte) { - tt, err := decodeTime(bs) - if err != nil { - panic(err) - } - *(v.(*time.Time)) = tt -} - -func (x timeExt) ConvertExt(v interface{}) interface{} { - return x.WriteExt(v) -} -func (x timeExt) UpdateExt(v interface{}, src interface{}) { - x.ReadExt(v, src.([]byte)) -} - -// EncodeTime encodes a time.Time as a []byte, including -// information on the instant in time and UTC offset. -// -// Format Description -// -// A timestamp is composed of 3 components: -// -// - secs: signed integer representing seconds since unix epoch -// - nsces: unsigned integer representing fractional seconds as a -// nanosecond offset within secs, in the range 0 <= nsecs < 1e9 -// - tz: signed integer representing timezone offset in minutes east of UTC, -// and a dst (daylight savings time) flag -// -// When encoding a timestamp, the first byte is the descriptor, which -// defines which components are encoded and how many bytes are used to -// encode secs and nsecs components. *If secs/nsecs is 0 or tz is UTC, it -// is not encoded in the byte array explicitly*. -// -// Descriptor 8 bits are of the form `A B C DDD EE`: -// A: Is secs component encoded? 1 = true -// B: Is nsecs component encoded? 1 = true -// C: Is tz component encoded? 1 = true -// DDD: Number of extra bytes for secs (range 0-7). -// If A = 1, secs encoded in DDD+1 bytes. -// If A = 0, secs is not encoded, and is assumed to be 0. -// If A = 1, then we need at least 1 byte to encode secs. -// DDD says the number of extra bytes beyond that 1. -// E.g. if DDD=0, then secs is represented in 1 byte. -// if DDD=2, then secs is represented in 3 bytes. -// EE: Number of extra bytes for nsecs (range 0-3). -// If B = 1, nsecs encoded in EE+1 bytes (similar to secs/DDD above) -// -// Following the descriptor bytes, subsequent bytes are: -// -// secs component encoded in `DDD + 1` bytes (if A == 1) -// nsecs component encoded in `EE + 1` bytes (if B == 1) -// tz component encoded in 2 bytes (if C == 1) -// -// secs and nsecs components are integers encoded in a BigEndian -// 2-complement encoding format. -// -// tz component is encoded as 2 bytes (16 bits). Most significant bit 15 to -// Least significant bit 0 are described below: -// -// Timezone offset has a range of -12:00 to +14:00 (ie -720 to +840 minutes). -// Bit 15 = have\_dst: set to 1 if we set the dst flag. -// Bit 14 = dst\_on: set to 1 if dst is in effect at the time, or 0 if not. -// Bits 13..0 = timezone offset in minutes. It is a signed integer in Big Endian format. -// -func encodeTime(t time.Time) []byte { - //t := rv.Interface().(time.Time) - tsecs, tnsecs := t.Unix(), t.Nanosecond() - var ( - bd byte - btmp [8]byte - bs [16]byte - i int = 1 - ) - l := t.Location() - if l == time.UTC { - l = nil - } - if tsecs != 0 { - bd = bd | 0x80 - bigen.PutUint64(btmp[:], uint64(tsecs)) - f := pruneSignExt(btmp[:], tsecs >= 0) - bd = bd | (byte(7-f) << 2) - copy(bs[i:], btmp[f:]) - i = i + (8 - f) - } - if tnsecs != 0 { - bd = bd | 0x40 - bigen.PutUint32(btmp[:4], uint32(tnsecs)) - f := pruneSignExt(btmp[:4], true) - bd = bd | byte(3-f) - copy(bs[i:], btmp[f:4]) - i = i + (4 - f) - } - if l != nil { - bd = bd | 0x20 - // Note that Go Libs do not give access to dst flag. - _, zoneOffset := t.Zone() - //zoneName, zoneOffset := t.Zone() - zoneOffset /= 60 - z := uint16(zoneOffset) - bigen.PutUint16(btmp[:2], z) - // clear dst flags - bs[i] = btmp[0] & 0x3f - bs[i+1] = btmp[1] - i = i + 2 - } - bs[0] = bd - return bs[0:i] -} - -// DecodeTime decodes a []byte into a time.Time. -func decodeTime(bs []byte) (tt time.Time, err error) { - bd := bs[0] - var ( - tsec int64 - tnsec uint32 - tz uint16 - i byte = 1 - i2 byte - n byte - ) - if bd&(1<<7) != 0 { - var btmp [8]byte - n = ((bd >> 2) & 0x7) + 1 - i2 = i + n - copy(btmp[8-n:], bs[i:i2]) - //if first bit of bs[i] is set, then fill btmp[0..8-n] with 0xff (ie sign extend it) - if bs[i]&(1<<7) != 0 { - copy(btmp[0:8-n], bsAll0xff) - //for j,k := byte(0), 8-n; j < k; j++ { btmp[j] = 0xff } - } - i = i2 - tsec = int64(bigen.Uint64(btmp[:])) - } - if bd&(1<<6) != 0 { - var btmp [4]byte - n = (bd & 0x3) + 1 - i2 = i + n - copy(btmp[4-n:], bs[i:i2]) - i = i2 - tnsec = bigen.Uint32(btmp[:]) - } - if bd&(1<<5) == 0 { - tt = time.Unix(tsec, int64(tnsec)).UTC() - return - } - // In stdlib time.Parse, when a date is parsed without a zone name, it uses "" as zone name. - // However, we need name here, so it can be shown when time is printed. - // Zone name is in form: UTC-08:00. - // Note that Go Libs do not give access to dst flag, so we ignore dst bits - - i2 = i + 2 - tz = bigen.Uint16(bs[i:i2]) - i = i2 - // sign extend sign bit into top 2 MSB (which were dst bits): - if tz&(1<<13) == 0 { // positive - tz = tz & 0x3fff //clear 2 MSBs: dst bits - } else { // negative - tz = tz | 0xc000 //set 2 MSBs: dst bits - //tzname[3] = '-' (TODO: verify. this works here) - } - tzint := int16(tz) - if tzint == 0 { - tt = time.Unix(tsec, int64(tnsec)).UTC() - } else { - // For Go Time, do not use a descriptive timezone. - // It's unnecessary, and makes it harder to do a reflect.DeepEqual. - // The Offset already tells what the offset should be, if not on UTC and unknown zone name. - // var zoneName = timeLocUTCName(tzint) - tt = time.Unix(tsec, int64(tnsec)).In(time.FixedZone("", int(tzint)*60)) - } - return -} - -// func timeLocUTCName(tzint int16) string { -// if tzint == 0 { -// return "UTC" -// } -// var tzname = []byte("UTC+00:00") -// //tzname := fmt.Sprintf("UTC%s%02d:%02d", tzsign, tz/60, tz%60) //perf issue using Sprintf. inline below. -// //tzhr, tzmin := tz/60, tz%60 //faster if u convert to int first -// var tzhr, tzmin int16 -// if tzint < 0 { -// tzname[3] = '-' // (TODO: verify. this works here) -// tzhr, tzmin = -tzint/60, (-tzint)%60 -// } else { -// tzhr, tzmin = tzint/60, tzint%60 -// } -// tzname[4] = timeDigits[tzhr/10] -// tzname[5] = timeDigits[tzhr%10] -// tzname[7] = timeDigits[tzmin/10] -// tzname[8] = timeDigits[tzmin%10] -// return string(tzname) -// //return time.FixedZone(string(tzname), int(tzint)*60) -// } diff --git a/vendor/github.com/ugorji/go/codec/xml.go b/vendor/github.com/ugorji/go/codec/xml.go index 9386775d7..19fc36caf 100644 --- a/vendor/github.com/ugorji/go/codec/xml.go +++ b/vendor/github.com/ugorji/go/codec/xml.go @@ -1,3 +1,6 @@ +// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. +// Use of this source code is governed by a MIT license found in the LICENSE file. + // +build ignore package codec @@ -24,7 +27,6 @@ It is a replacement, based on the simplicity and performance of codec. Look at it like JAXB for Go. Challenges: - - Need to output XML preamble, with all namespaces at the right location in the output. - Each "end" block is dynamic, so we need to maintain a context-aware stack - How to decide when to use an attribute VS an element @@ -34,24 +36,26 @@ Challenges: Extend the struct tag. See representative example: type X struct { - ID uint8 codec:"xid|http://ugorji.net/x-namespace id,omitempty,toarray,attr,cdata" + ID uint8 `codec:"http://ugorji.net/x-namespace xid id,omitempty,toarray,attr,cdata"` + // format: [namespace-uri ][namespace-prefix ]local-name, ... } Based on this, we encode - - fields as elements, BUT encode as attributes if struct tag contains ",attr". + - fields as elements, BUT + encode as attributes if struct tag contains ",attr" and is a scalar (bool, number or string) - text as entity-escaped text, BUT encode as CDATA if struct tag contains ",cdata". -In this mode, we only encode as attribute if ",attr" is found, and only encode as CDATA -if ",cdata" is found in the struct tag. - To handle namespaces: - XMLHandle is denoted as being namespace-aware. Consequently, we WILL use the ns:name pair to encode and decode if defined, else use the plain name. - *Encoder and *Decoder know whether the Handle "prefers" namespaces. - add *Encoder.getEncName(*structFieldInfo). No one calls *structFieldInfo.indexForEncName directly anymore + - OR better yet: indexForEncName is namespace-aware, and helper.go is all namespace-aware + indexForEncName takes a parameter of the form namespace:local-name OR local-name - add *Decoder.getStructFieldInfo(encName string) // encName here is either like abc, or h1:nsabc - No one accesses .encName anymore except in + by being a method on *Decoder, or maybe a method on the Handle itself. + No one accesses .encName anymore - let encode.go and decode.go use these (for consistency) - only problem exists for gen.go, where we create a big switch on encName. Now, we also have to add a switch on strings.endsWith(kName, encNsName) @@ -62,13 +66,14 @@ To handle namespaces: default { switch { case !nsAware: panic(...) - case strings.endsWith("nsabc"): x.abc() + case strings.endsWith(":abc"): x.abc() + case strings.endsWith(":def"): x.def() default: panic(...) } } } -The structure below accomodates this: +The structure below accommodates this: type typeInfo struct { sfi []*structFieldInfo // sorted by encName @@ -88,7 +93,10 @@ indexForEncName is now an internal helper function that takes a sorted array (one of ti.sfins or ti.sfi). It is only used by *Encoder.getStructFieldInfo(...) There will be a separate parser from the builder. -The parser will have a method: next() xmlToken method. +The parser will have a method: next() xmlToken method. It has lookahead support, +so you can pop multiple tokens, make a determination, and push them back in the order popped. +This will be needed to determine whether we are "nakedly" decoding a container or not. +The stack will be implemented using a slice and push/pop happens at the [0] element. xmlToken has fields: - type uint8: 0 | ElementStart | ElementEnd | AttrKey | AttrVal | Text @@ -132,7 +140,7 @@ At decode time, a structure containing the following is kept - all internal entities (<>&"' and others written in the document) When decode starts, it parses XML namespace declarations and creates a map in the -xmlDecDriver. While parsing, that map continously gets updated. +xmlDecDriver. While parsing, that map continuously gets updated. The only problem happens when a namespace declaration happens on the node that it defines. e.g. To handle this, each Element must be fully parsed at a time, @@ -144,7 +152,7 @@ xmlns is a special attribute name. *We may decide later to allow user to use it e.g. you want to parse the xmlns mappings into a field.* Number, bool, null, mapKey, etc can all be decoded from any xmlToken. -This accomodates map[int]string for example. +This accommodates map[int]string for example. It should be possible to create a schema from the types, or vice versa (generate types from schema with appropriate tags). @@ -178,8 +186,8 @@ An XML document is a name, a map of attributes and a list of children. Consequently, we cannot "DecodeNaked" into a map[string]interface{} (for example). We have to "DecodeNaked" into something that resembles XML data. -To support DecodeNaked (decode into nil interface{}) we have to define some "supporting" types: - type Name struct { // Prefered. Less allocations due to conversions. +To support DecodeNaked (decode into nil interface{}), we have to define some "supporting" types: + type Name struct { // Preferred. Less allocations due to conversions. Local string Space string } @@ -190,6 +198,8 @@ To support DecodeNaked (decode into nil interface{}) we have to define some "sup } Only two "supporting" types are exposed for XML: Name and Element. +// ------------------ + We considered 'type Name string' where Name is like "Space Local" (space-separated). We decided against it, because each creation of a name would lead to double allocation (first convert []byte to string, then concatenate them into a string). @@ -215,16 +225,16 @@ intelligent accessor methods to extract information and for performance. } func (x *Element) child(i) interface{} // returns string or *Element -Per XML spec and our default handling, white space is insignificant between elements, -specifically between parent-child or siblings. White space occuring alone between start -and end element IS significant. However, if xml:space='preserve', then we 'preserve' -all whitespace. This is more critical when doing a DecodeNaked, but MAY not be as critical -when decoding into a typed value. +// ------------------ + +Per XML spec and our default handling, white space is always treated as +insignificant between elements, except in a text node. The xml:space='preserve' +attribute is ignored. **Note: there is no xml: namespace. The xml: attributes were defined before namespaces.** **So treat them as just "directives" that should be interpreted to mean something**. -On encoding, we don't add any prettifying markup (indenting, etc). +On encoding, we support indenting aka prettifying markup in the same way we support it for json. A document or element can only be encoded/decoded from/to a struct. In this mode: - struct name maps to element name (or tag-info from _struct field) @@ -258,15 +268,14 @@ the struct tag signifying it should be attr, then all its fields are encoded as e.g. type X struct { - M map[string]int `codec:"m,attr"` // encode as attributes + M map[string]int `codec:"m,attr"` // encode keys as attributes named } Question: - if encoding a map, what if map keys have spaces in them??? Then they cannot be attributes or child elements. Error. -Misc: - +Options to consider adding later: - For attribute values, normalize by trimming beginning and ending white space, and converting every white space sequence to a single space. - ATTLIST restrictions are enforced. @@ -284,6 +293,8 @@ Misc: CheckName bool } +Misc: + ROADMAP (1 weeks): - build encoder (1 day) - build decoder (based off xmlParser) (1 day) @@ -292,7 +303,78 @@ ROADMAP (1 weeks): - integrate and TEST (1 days) - write article and post it (1 day) - +// ---------- MORE NOTES FROM 2017-11-30 ------------ + +when parsing +- parse the attributes first +- then parse the nodes + +basically: +- if encoding a field: we use the field name for the wrapper +- if encoding a non-field, then just use the element type name + + map[string]string ==> abcval... or + val... OR + val1val2... <- PREFERED + []string ==> v1v2... + string v1 ==> v1 + bool true ==> true + float 1.0 ==> 1.0 + ... + + F1 map[string]string ==> abcval... OR + val... OR + val... <- PREFERED + F2 []string ==> v1v2... + F3 bool ==> true + ... + +- a scalar is encoded as: + (value) of type T ==> + (value) of field F ==> +- A kv-pair is encoded as: + (key,value) ==> OR + (key,value) of field F ==> OR +- A map or struct is just a list of kv-pairs +- A list is encoded as sequences of same node e.g. + + + value21 + value22 +- we may have to singularize the field name, when entering into xml, + and pluralize them when encoding. +- bi-directional encode->decode->encode is not a MUST. + even encoding/xml cannot decode correctly what was encoded: + + see https://play.golang.org/p/224V_nyhMS + func main() { + fmt.Println("Hello, playground") + v := []interface{}{"hello", 1, true, nil, time.Now()} + s, err := xml.Marshal(v) + fmt.Printf("err: %v, \ns: %s\n", err, s) + var v2 []interface{} + err = xml.Unmarshal(s, &v2) + fmt.Printf("err: %v, \nv2: %v\n", err, v2) + type T struct { + V []interface{} + } + v3 := T{V: v} + s, err = xml.Marshal(v3) + fmt.Printf("err: %v, \ns: %s\n", err, s) + var v4 T + err = xml.Unmarshal(s, &v4) + fmt.Printf("err: %v, \nv4: %v\n", err, v4) + } + Output: + err: , + s: hello1true + err: , + v2: [] + err: , + s: hello1true2009-11-10T23:00:00Z + err: , + v4: {[ ]} +- */ // ----------- PARSER ------------------- @@ -419,7 +501,7 @@ func (h *XMLHandle) newDecDriver(d *Decoder) decDriver { } func (h *XMLHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) { - return h.SetExt(rt, tag, &setExtWrapper{i: ext}) + return h.SetExt(rt, tag, &extWrapper{bytesExtFailer{}, ext}) } var _ decDriver = (*xmlDecDriver)(nil) diff --git a/vendor/github.com/ugorji/go/codec/z.go b/vendor/github.com/ugorji/go/codec/z.go deleted file mode 100644 index b6ac0769a..000000000 --- a/vendor/github.com/ugorji/go/codec/z.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import "sort" - -// TODO: this is brittle, as it depends on z.go's init() being called last. -// The current build tools all honor that files are passed in lexical order. -// However, we should consider using an init_channel, -// that each person doing init will write to. - -func init() { - if !useLookupRecognizedTypes { - return - } - sort.Sort(uintptrSlice(recognizedRtids)) - sort.Sort(uintptrSlice(recognizedRtidPtrs)) - recognizedRtidOrPtrs = make([]uintptr, len(recognizedRtids)+len(recognizedRtidPtrs)) - copy(recognizedRtidOrPtrs, recognizedRtids) - copy(recognizedRtidOrPtrs[len(recognizedRtids):], recognizedRtidPtrs) - sort.Sort(uintptrSlice(recognizedRtidOrPtrs)) -} diff --git a/vendor/github.com/ugorji/go/msgpack.org.md b/vendor/github.com/ugorji/go/msgpack.org.md deleted file mode 100644 index d5ebe71d6..000000000 --- a/vendor/github.com/ugorji/go/msgpack.org.md +++ /dev/null @@ -1,47 +0,0 @@ -**MessagePack and [Binc](http://github.com/ugorji/binc) Codec for [Go](http://golang.org) Language.** - -*A High Performance, Feature-Rich, Idiomatic encode/decode and rpc library*. - -To install: - - go get github.com/ugorji/go/codec - -Source: [http://github.com/ugorji/go] -Online documentation: [http://godoc.org/github.com/ugorji/go/codec] - -Typical usage: - -```go - // create and use decoder/encoder - var ( - v interface{} // value to decode/encode into - r io.Reader - w io.Writer - b []byte - mh codec.MsgpackHandle - ) - - dec = codec.NewDecoder(r, &mh) - dec = codec.NewDecoderBytes(b, &mh) - err = dec.Decode(&v) - - enc = codec.NewEncoder(w, &mh) - enc = codec.NewEncoderBytes(&b, &mh) - err = enc.Encode(v) - - //RPC Server - go func() { - for { - conn, err := listener.Accept() - rpcCodec := codec.GoRpc.ServerCodec(conn, h) - //OR rpcCodec := codec.MsgpackSpecRpc.ServerCodec(conn, h) - rpc.ServeCodec(rpcCodec) - } - }() - - //RPC Communication (client side) - conn, err = net.Dial("tcp", "localhost:5555") - rpcCodec := codec.GoRpc.ClientCodec(conn, h) - //OR rpcCodec := codec.MsgpackSpecRpc.ClientCodec(conn, h) - client := rpc.NewClientWithCodec(rpcCodec) -```