From 53663e65a43729592639646692e36f7013c579cb Mon Sep 17 00:00:00 2001 From: Joe Elliott Date: Thu, 26 Sep 2019 22:47:41 -0400 Subject: [PATCH] Added fluentbit dependency Signed-off-by: Joe Elliott --- go.mod | 2 + go.sum | 4 + .../ugorji/go/codec/{doc.go => 0doc.go} | 25 +- vendor/github.com/ugorji/go/codec/README.md | 207 + .../ugorji/go/codec/bench/values_test.go | 1 - vendor/github.com/ugorji/go/codec/binc.go | 530 +- vendor/github.com/ugorji/go/codec/build.sh | 80 +- vendor/github.com/ugorji/go/codec/cbor.go | 681 +- vendor/github.com/ugorji/go/codec/decode.go | 2673 +- vendor/github.com/ugorji/go/codec/encode.go | 1545 +- .../ugorji/go/codec/fast-path.generated.go | 37082 +++++++++++++--- .../ugorji/go/codec/fast-path.go.tmpl | 464 +- .../ugorji/go/codec/fast-path.not.go | 6 + vendor/github.com/ugorji/go/codec/float.go | 313 - .../ugorji/go/codec/gen-dec-array.go.tmpl | 46 +- .../ugorji/go/codec/gen-dec-map.go.tmpl | 47 +- .../ugorji/go/codec/gen-helper.generated.go | 186 +- .../ugorji/go/codec/gen-helper.go.tmpl | 167 +- .../ugorji/go/codec/gen.generated.go | 93 +- vendor/github.com/ugorji/go/codec/gen.go | 850 +- vendor/github.com/ugorji/go/codec/go.mod | 5 - .../go/codec/goversion_fmt_time_gte_go15.go | 12 - .../go/codec/goversion_fmt_time_lt_go15.go | 15 - .../go/codec/goversion_maprange_gte_go112.go | 44 - .../go/codec/goversion_maprange_lt_go112.go | 47 - vendor/github.com/ugorji/go/codec/helper.go | 1295 +- vendor/github.com/ugorji/go/codec/helper.s | 0 .../ugorji/go/codec/helper_internal.go | 3 - .../ugorji/go/codec/helper_not_unsafe.go | 312 +- .../ugorji/go/codec/helper_unsafe.go | 848 +- vendor/github.com/ugorji/go/codec/json.go | 1379 +- .../ugorji/go/codec/mammoth-test.go.tmpl | 50 +- vendor/github.com/ugorji/go/codec/msgpack.go | 494 +- vendor/github.com/ugorji/go/codec/prebuild.go | 136 - vendor/github.com/ugorji/go/codec/reader.go | 1017 - .../ugorji/go/codec/register_ext.go | 38 - vendor/github.com/ugorji/go/codec/rpc.go | 3 + vendor/github.com/ugorji/go/codec/simple.go | 363 +- .../ugorji/go/codec/sort-slice.generated.go | 266 - .../ugorji/go/codec/sort-slice.go.tmpl | 64 - vendor/github.com/ugorji/go/codec/test.py | 0 vendor/github.com/ugorji/go/codec/writer.go | 267 - vendor/github.com/ugorji/go/codec/xml.go | 8 +- vendor/modules.txt | 4 + 44 files changed, 37775 insertions(+), 13897 deletions(-) rename vendor/github.com/ugorji/go/codec/{doc.go => 0doc.go} (93%) create mode 100644 vendor/github.com/ugorji/go/codec/README.md delete mode 120000 vendor/github.com/ugorji/go/codec/bench/values_test.go mode change 100755 => 100644 vendor/github.com/ugorji/go/codec/build.sh delete mode 100644 vendor/github.com/ugorji/go/codec/float.go delete mode 100644 vendor/github.com/ugorji/go/codec/go.mod delete mode 100644 vendor/github.com/ugorji/go/codec/goversion_fmt_time_gte_go15.go delete mode 100644 vendor/github.com/ugorji/go/codec/goversion_fmt_time_lt_go15.go delete mode 100644 vendor/github.com/ugorji/go/codec/goversion_maprange_gte_go112.go delete mode 100644 vendor/github.com/ugorji/go/codec/goversion_maprange_lt_go112.go delete mode 100644 vendor/github.com/ugorji/go/codec/helper.s delete mode 100644 vendor/github.com/ugorji/go/codec/prebuild.go delete mode 100644 vendor/github.com/ugorji/go/codec/reader.go delete mode 100644 vendor/github.com/ugorji/go/codec/register_ext.go delete mode 100644 vendor/github.com/ugorji/go/codec/sort-slice.generated.go delete mode 100644 vendor/github.com/ugorji/go/codec/sort-slice.go.tmpl mode change 100755 => 100644 vendor/github.com/ugorji/go/codec/test.py delete mode 100644 vendor/github.com/ugorji/go/codec/writer.go diff --git a/go.mod b/go.mod index b81edb10adc1..9f98478ccd40 100644 --- a/go.mod +++ b/go.mod @@ -20,6 +20,7 @@ require ( github.com/docker/go-metrics v0.0.0-20181218153428-b84716841b82 // indirect github.com/docker/go-plugins-helpers v0.0.0-20181025120712-1e6269c305b8 github.com/fatih/color v1.7.0 + github.com/fluent/fluent-bit-go v0.0.0-20190925192703-ea13c021720c github.com/go-kit/kit v0.9.0 github.com/gocql/gocql v0.0.0-20181124151448-70385f88b28b // indirect github.com/gogo/protobuf v1.3.0 @@ -30,6 +31,7 @@ require ( github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 github.com/hpcloud/tail v1.0.0 github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af + github.com/json-iterator/go v1.1.7 github.com/klauspost/compress v1.7.4 github.com/klauspost/cpuid v1.2.1 // indirect github.com/mitchellh/mapstructure v1.1.2 diff --git a/go.sum b/go.sum index 1e92c13cdb9d..e0d21bce91f7 100644 --- a/go.sum +++ b/go.sum @@ -194,6 +194,8 @@ github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcb h1:IT4JYU7k4ikYg1S github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcb/go.mod h1:bH6Xx7IW64qjjJq8M2u4dxNaBiDfKK+z/3eGDpXEQhc= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fluent/fluent-bit-go v0.0.0-20190925192703-ea13c021720c h1:QwbffUs/+ptC4kTFPEN9Ej2latTq3bZJ5HO/OwPXYMs= +github.com/fluent/fluent-bit-go v0.0.0-20190925192703-ea13c021720c/go.mod h1:WQX+afhrekY9rGK+WT4xvKSlzmia9gDoLYu4GGYGASQ= github.com/fluent/fluent-logger-golang v1.2.1/go.mod h1:2/HCT/jTy78yGyeNGQLGQsjF3zzzAuy6Xlk6FCMV5eU= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= @@ -706,6 +708,8 @@ github.com/uber/jaeger-client-go v2.16.0+incompatible h1:Q2Pp6v3QYiocMxomCaJuwQG github.com/uber/jaeger-client-go v2.16.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= github.com/uber/jaeger-lib v2.0.0+incompatible h1:iMSCV0rmXEogjNWPh2D0xk9YVKvrtGoHJNe9ebLu/pw= github.com/uber/jaeger-lib v2.0.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= +github.com/ugorji/go v1.1.4 h1:j4s+tAvLfL3bZyefP2SEWmhBzmuIlH/eqNuPdFPgngw= +github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/weaveworks/billing-client v0.0.0-20171006123215-be0d55e547b1/go.mod h1:7gGdEUJaCrSlWi/mjd68CZv0sfqektYPDcro9cE+M9k= github.com/weaveworks/promrus v1.2.0 h1:jOLf6pe6/vss4qGHjXmGz4oDJQA+AOCqEL3FvvZGz7M= diff --git a/vendor/github.com/ugorji/go/codec/doc.go b/vendor/github.com/ugorji/go/codec/0doc.go similarity index 93% rename from vendor/github.com/ugorji/go/codec/doc.go rename to vendor/github.com/ugorji/go/codec/0doc.go index e987fa6babd5..295ee346fc24 100644 --- a/vendor/github.com/ugorji/go/codec/doc.go +++ b/vendor/github.com/ugorji/go/codec/0doc.go @@ -14,9 +14,15 @@ Supported Serialization formats are: - json: http://json.org http://tools.ietf.org/html/rfc7159 - simple: -This package will carefully use 'package unsafe' for performance reasons in specific places. +To install: + + go get github.com/ugorji/go/codec + +This package will carefully use 'unsafe' for performance reasons in specific places. You can build without unsafe use by passing the safe or appengine tag -i.e. 'go install -tags=safe ...'. +i.e. 'go install -tags=safe ...'. Note that unsafe is only supported for the last 3 +go sdk versions e.g. current go release is go 1.9, so we support unsafe use only from +go 1.7+ . This is because supporting unsafe requires knowledge of implementation details. For detailed usage information, read the primer at http://ugorji.net/blog/go-codec-primer . @@ -26,12 +32,12 @@ the standard library (ie json, xml, gob, etc). Rich Feature Set includes: - Simple but extremely powerful and feature-rich API - - Support for go 1.4 and above, while selectively using newer APIs for later releases + - Support for go1.4 and above, while selectively using newer APIs for later releases - 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% safe mode supported, where 'unsafe' is not used at all. + 100% mode exists where 'unsafe' is not used at all. - Lock-free (sans mutex) concurrency for scaling to 100's of cores - In-place updates during decode, with option to zero value in maps and slices prior to decode - Coerce types where appropriate @@ -56,7 +62,7 @@ Rich Feature Set includes: (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, supported in go 1.6+ + - Code-generation for faster performance. - Support binary (e.g. messagepack, cbor) and text (e.g. json) formats - Support indefinite-length formats to enable true streaming (for formats which support it e.g. json, cbor) @@ -94,16 +100,13 @@ 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. -There is also seamless support provided for registering an extension (with a tag) -but letting the encoding mechanism default to the standard way. - 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 there an extension registered for the type? - 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 and TextUnmarshaler? @@ -203,9 +206,6 @@ You can run the tag 'safe' to run tests or build in safe mode. e.g. Running Benchmarks - cd bench - go test -bench . -benchmem -benchtime 1s - Please see http://github.com/ugorji/go-codec-bench . Caveats @@ -224,3 +224,4 @@ with some caveats. See Encode documentation. */ package codec + diff --git a/vendor/github.com/ugorji/go/codec/README.md b/vendor/github.com/ugorji/go/codec/README.md new file mode 100644 index 000000000000..8aa68f5b0087 --- /dev/null +++ b/vendor/github.com/ugorji/go/codec/README.md @@ -0,0 +1,207 @@ +# Codec + +High Performance, Feature-Rich Idiomatic Go codec/encoding library for +binc, msgpack, cbor, json. + +Supported Serialization formats are: + + - 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 + - simple: + +To install: + + go get github.com/ugorji/go/codec + +This package will carefully use 'unsafe' for performance reasons in specific places. +You can build without unsafe use by passing the safe or appengine tag +i.e. 'go install -tags=safe ...'. Note that unsafe is only supported for the last 3 +go sdk versions e.g. current go release is go 1.9, so we support unsafe use only from +go 1.7+ . This is because supporting unsafe requires knowledge of implementation details. + +Online documentation: http://godoc.org/github.com/ugorji/go/codec +Detailed Usage/How-to Primer: http://ugorji.net/blog/go-codec-primer + +The idiomatic Go support is as seen in other encoding packages in +the standard library (ie json, xml, gob, etc). + +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 + - 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 + - In-place updates during decode, with option to zero the value in maps and slices prior to decode + - 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 + - Support for omitting empty fields during an encoding + - Encoding from any value and decoding into pointer to any value + (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. + - Support binary (e.g. messagepack, cbor) and text (e.g. json) formats + - Support indefinite-length formats to enable true streaming + (for formats which support it e.g. json, cbor) + - Support canonical encoding, where a value is ALWAYS encoded as same sequence of bytes. + This mostly applies to maps, where iteration order is non-deterministic. + - NIL in data stream decoded as zero value + - Never silently skip data when decoding. + User decides whether to return an error or silently skip data when keys or indexes + in the data stream do not map to fields in the struct. + - Encode/Decode from/to chan types (for iterative streaming support) + - Drop-in replacement for encoding/json. `json:` key in struct tag supported. + - Provides a RPC Server and Client Codec for net/rpc communication protocol. + - Handle unique idiosyncrasies of codecs e.g. + - For messagepack, configure how ambiguities in handling raw bytes are resolved + - For messagepack, provide rpc server/client codec to support + msgpack-rpc protocol defined at: + https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md + +## Extension Support + +Users can register a function to handle the encoding or decoding of +their custom types. + +There are no restrictions on what the custom type can be. Some examples: + + type BisSet []int + type BitSet64 uint64 + type UUID string + type MyStructWithUnexportedFields struct { a int; b bool; c []int; } + type GifImage struct { ... } + +As an illustration, MyStructWithUnexportedFields would normally be +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 and TextUnmarshaler? + - 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 +with the standard net/rpc package. + +## Usage + +Typical usage model: + + // create and configure Handle + var ( + bh codec.BincHandle + mh codec.MsgpackHandle + ch codec.CborHandle + ) + + mh.MapType = reflect.TypeOf(map[string]interface{}(nil)) + + // configure extensions + // e.g. for msgpack, define functions and enable Time support for tag 1 + // mh.SetExt(reflect.TypeOf(time.Time{}), 1, myExt) + + // create and use decoder/encoder + var ( + r io.Reader + w io.Writer + b []byte + h = &bh // or mh to use msgpack + ) + + dec = codec.NewDecoder(r, h) + dec = codec.NewDecoderBytes(b, h) + err = dec.Decode(&v) + + enc = codec.NewEncoder(w, h) + enc = codec.NewEncoderBytes(&b, h) + 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) + +## Running Tests + +To run tests, use the following: + + go test + +To run the full suite of tests, use the following: + + go test -tags alltests -run Suite + +You can run the tag 'safe' to run tests or build in safe mode. e.g. + + go test -tags safe -run Json + go test -tags "alltests safe" -run Suite + +## 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. diff --git a/vendor/github.com/ugorji/go/codec/bench/values_test.go b/vendor/github.com/ugorji/go/codec/bench/values_test.go deleted file mode 120000 index ca206becbc2a..000000000000 --- a/vendor/github.com/ugorji/go/codec/bench/values_test.go +++ /dev/null @@ -1 +0,0 @@ -../values_test.go \ No newline at end of file diff --git a/vendor/github.com/ugorji/go/codec/binc.go b/vendor/github.com/ugorji/go/codec/binc.go index 802b32cfcfaf..c9877ac7cd76 100644 --- a/vendor/github.com/ugorji/go/codec/binc.go +++ b/vendor/github.com/ugorji/go/codec/binc.go @@ -5,6 +5,7 @@ package codec import ( "math" + "reflect" "time" ) @@ -99,22 +100,21 @@ func bincdesc(vd, vs byte) string { } type bincEncDriver struct { - noBuiltInTypes - encDriverNoopContainerWriter + e *Encoder h *BincHandle + w *encWriterSwitch m map[string]uint16 // symbols - b [8]byte // scratch, used for encoding numbers - bigendian style + b [16]byte // scratch, used for encoding numbers - bigendian style s uint16 // symbols sequencer - _ [4]uint64 // padding - e Encoder -} - -func (e *bincEncDriver) encoder() *Encoder { - return &e.e + // c containerState + encDriverTrackContainerWriter + noBuiltInTypes + // encNoSeparator + _ [1]uint64 // padding } func (e *bincEncDriver) EncodeNil() { - e.e.encWr.writen1(bincVdSpecial<<4 | bincSpNil) + e.w.writen1(bincVdSpecial<<4 | bincSpNil) } func (e *bincEncDriver) EncodeTime(t time.Time) { @@ -122,31 +122,31 @@ func (e *bincEncDriver) EncodeTime(t time.Time) { e.EncodeNil() } else { bs := bincEncodeTime(t) - e.e.encWr.writen1(bincVdTimestamp<<4 | uint8(len(bs))) - e.e.encWr.writeb(bs) + e.w.writen1(bincVdTimestamp<<4 | uint8(len(bs))) + e.w.writeb(bs) } } func (e *bincEncDriver) EncodeBool(b bool) { if b { - e.e.encWr.writen1(bincVdSpecial<<4 | bincSpTrue) + e.w.writen1(bincVdSpecial<<4 | bincSpTrue) } else { - e.e.encWr.writen1(bincVdSpecial<<4 | bincSpFalse) + e.w.writen1(bincVdSpecial<<4 | bincSpFalse) } } func (e *bincEncDriver) EncodeFloat32(f float32) { if f == 0 { - e.e.encWr.writen1(bincVdSpecial<<4 | bincSpZeroFloat) + e.w.writen1(bincVdSpecial<<4 | bincSpZeroFloat) return } - e.e.encWr.writen1(bincVdFloat<<4 | bincFlBin32) - bigenHelper{e.b[:4], e.e.w()}.writeUint32(math.Float32bits(f)) + e.w.writen1(bincVdFloat<<4 | bincFlBin32) + bigenHelper{e.b[:4], e.w}.writeUint32(math.Float32bits(f)) } func (e *bincEncDriver) EncodeFloat64(f float64) { if f == 0 { - e.e.encWr.writen1(bincVdSpecial<<4 | bincSpZeroFloat) + e.w.writen1(bincVdSpecial<<4 | bincSpZeroFloat) return } bigen.PutUint64(e.b[:8], math.Float64bits(f)) @@ -156,14 +156,14 @@ func (e *bincEncDriver) EncodeFloat64(f float64) { } i++ if i <= 6 { - e.e.encWr.writen1(bincVdFloat<<4 | 0x8 | bincFlBin64) - e.e.encWr.writen1(byte(i)) - e.e.encWr.writeb(e.b[:i]) + e.w.writen1(bincVdFloat<<4 | 0x8 | bincFlBin64) + e.w.writen1(byte(i)) + e.w.writeb(e.b[:i]) return } } - e.e.encWr.writen1(bincVdFloat<<4 | bincFlBin64) - e.e.encWr.writeb(e.b[:8]) + e.w.writen1(bincVdFloat<<4 | bincFlBin64) + e.w.writeb(e.b[:8]) } func (e *bincEncDriver) encIntegerPrune(bd byte, pos bool, v uint64, lim uint8) { @@ -174,11 +174,11 @@ func (e *bincEncDriver) encIntegerPrune(bd byte, pos bool, v uint64, lim uint8) } if bincDoPrune { i := pruneSignExt(e.b[:lim], pos) - e.e.encWr.writen1(bd | lim - 1 - byte(i)) - e.e.encWr.writeb(e.b[i:lim]) + e.w.writen1(bd | lim - 1 - byte(i)) + e.w.writeb(e.b[i:lim]) } else { - e.e.encWr.writen1(bd | lim - 1) - e.e.encWr.writeb(e.b[:lim]) + e.w.writen1(bd | lim - 1) + e.w.writeb(e.b[:lim]) } } @@ -187,7 +187,7 @@ func (e *bincEncDriver) EncodeInt(v int64) { if v >= 0 { e.encUint(bincVdPosInt<<4, true, uint64(v)) } else if v == -1 { - e.e.encWr.writen1(bincVdSpecial<<4 | bincSpNegOne) + e.w.writen1(bincVdSpecial<<4 | bincSpNegOne) } else { e.encUint(bincVdNegInt<<4, false, uint64(-v)) } @@ -199,14 +199,14 @@ func (e *bincEncDriver) EncodeUint(v uint64) { func (e *bincEncDriver) encUint(bd byte, pos bool, v uint64) { if v == 0 { - e.e.encWr.writen1(bincVdSpecial<<4 | bincSpZero) + e.w.writen1(bincVdSpecial<<4 | bincSpZero) } else if pos && v >= 1 && v <= 16 { - e.e.encWr.writen1(bincVdSmallInt<<4 | byte(v-1)) + e.w.writen1(bincVdSmallInt<<4 | byte(v-1)) } else if v <= math.MaxUint8 { - e.e.encWr.writen2(bd|0x0, byte(v)) + e.w.writen2(bd|0x0, byte(v)) } else if v <= math.MaxUint16 { - e.e.encWr.writen1(bd | 0x01) - bigenHelper{e.b[:2], e.e.w()}.writeUint16(uint16(v)) + e.w.writen1(bd | 0x01) + bigenHelper{e.b[:2], e.w}.writeUint16(uint16(v)) } else if v <= math.MaxUint32 { e.encIntegerPrune(bd, pos, v, 4) } else { @@ -214,41 +214,34 @@ func (e *bincEncDriver) encUint(bd byte, pos bool, v uint64) { } } -func (e *bincEncDriver) EncodeExt(v interface{}, xtag uint64, ext Ext) { - var bs []byte - if ext == SelfExt { - bs = e.e.blist.get(1024)[:0] - e.e.sideEncode(v, &bs) - } else { - bs = ext.WriteExt(v) - } +func (e *bincEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext, _ *Encoder) { + bs := ext.WriteExt(rv) if bs == nil { e.EncodeNil() return } e.encodeExtPreamble(uint8(xtag), len(bs)) - e.e.encWr.writeb(bs) - if ext == SelfExt { - e.e.blist.put(bs) - } + e.w.writeb(bs) } -func (e *bincEncDriver) EncodeRawExt(re *RawExt) { +func (e *bincEncDriver) EncodeRawExt(re *RawExt, _ *Encoder) { e.encodeExtPreamble(uint8(re.Tag), len(re.Data)) - e.e.encWr.writeb(re.Data) + e.w.writeb(re.Data) } func (e *bincEncDriver) encodeExtPreamble(xtag byte, length int) { e.encLen(bincVdCustomExt<<4, uint64(length)) - e.e.encWr.writen1(xtag) + e.w.writen1(xtag) } 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) EncodeSymbol(v string) { @@ -267,7 +260,7 @@ func (e *bincEncDriver) EncodeSymbol(v string) { return } else if l == 1 { e.encBytesLen(cUTF8, 1) - e.e.encWr.writen1(v[0]) + e.w.writen1(v[0]) return } if e.m == nil { @@ -276,10 +269,10 @@ func (e *bincEncDriver) EncodeSymbol(v string) { ui, ok := e.m[v] if ok { if ui <= math.MaxUint8 { - e.e.encWr.writen2(bincVdSymbol<<4, byte(ui)) + e.w.writen2(bincVdSymbol<<4, byte(ui)) } else { - e.e.encWr.writen1(bincVdSymbol<<4 | 0x8) - bigenHelper{e.b[:2], e.e.w()}.writeUint16(ui) + e.w.writen1(bincVdSymbol<<4 | 0x8) + bigenHelper{e.b[:2], e.w}.writeUint16(ui) } } else { e.s++ @@ -297,43 +290,58 @@ func (e *bincEncDriver) EncodeSymbol(v string) { lenprec = 3 } if ui <= math.MaxUint8 { - e.e.encWr.writen2(bincVdSymbol<<4|0x0|0x4|lenprec, byte(ui)) + e.w.writen2(bincVdSymbol<<4|0x0|0x4|lenprec, byte(ui)) } else { - e.e.encWr.writen1(bincVdSymbol<<4 | 0x8 | 0x4 | lenprec) - bigenHelper{e.b[:2], e.e.w()}.writeUint16(ui) + e.w.writen1(bincVdSymbol<<4 | 0x8 | 0x4 | lenprec) + bigenHelper{e.b[:2], e.w}.writeUint16(ui) } if lenprec == 0 { - e.e.encWr.writen1(byte(l)) + e.w.writen1(byte(l)) } else if lenprec == 1 { - bigenHelper{e.b[:2], e.e.w()}.writeUint16(uint16(l)) + bigenHelper{e.b[:2], e.w}.writeUint16(uint16(l)) } else if lenprec == 2 { - bigenHelper{e.b[:4], e.e.w()}.writeUint32(uint32(l)) + bigenHelper{e.b[:4], e.w}.writeUint32(uint32(l)) } else { - bigenHelper{e.b[:8], e.e.w()}.writeUint64(uint64(l)) + bigenHelper{e.b[:8], e.w}.writeUint64(uint64(l)) } - e.e.encWr.writestr(v) + e.w.writestr(v) } } -func (e *bincEncDriver) EncodeString(v string) { - if e.h.StringToRaw { - e.encLen(bincVdByteArray<<4, uint64(len(v))) // e.encBytesLen(c, l) - if len(v) > 0 { - e.e.encWr.writestr(v) - } +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 } - e.EncodeStringEnc(cUTF8, v) + l := uint64(len(v)) + e.encBytesLen(c, l) + if l > 0 { + e.w.writestr(v) + } } func (e *bincEncDriver) EncodeStringEnc(c charEncoding, v string) { - if e.e.c == containerMapKey && c == cUTF8 && (e.h.AsSymbols == 1) { + if e.c == containerMapKey && c == cUTF8 && (e.h.AsSymbols == 0 || e.h.AsSymbols == 1) { e.EncodeSymbol(v) return } - e.encLen(bincVdString<<4, uint64(len(v))) // e.encBytesLen(c, l) - if len(v) > 0 { - e.e.encWr.writestr(v) + l := uint64(len(v)) + e.encLen(bincVdString<<4, l) // e.encBytesLen(c, l) + if l > 0 { + e.w.writestr(v) + } + +} + +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 { + e.w.writeb(v) } } @@ -342,16 +350,15 @@ func (e *bincEncDriver) EncodeStringBytesRaw(v []byte) { e.EncodeNil() return } - e.encLen(bincVdByteArray<<4, uint64(len(v))) // e.encBytesLen(c, l) - if len(v) > 0 { - e.e.encWr.writeb(v) + l := uint64(len(v)) + e.encLen(bincVdByteArray<<4, l) // e.encBytesLen(c, l) + if l > 0 { + e.w.writeb(v) } } func (e *bincEncDriver) encBytesLen(c charEncoding, length uint64) { - // NOTE: we currently only support UTF-8 (string) and RAW (bytearray). - // We should consider supporting bincUnicodeOther. - + //TODO: support bincUnicodeOther (for now, just use string or bytearray) if c == cRAW { e.encLen(bincVdByteArray<<4, length) } else { @@ -361,7 +368,7 @@ func (e *bincEncDriver) encBytesLen(c charEncoding, length uint64) { func (e *bincEncDriver) encLen(bd byte, l uint64) { if l < 12 { - e.e.encWr.writen1(bd | uint8(l+4)) + e.w.writen1(bd | uint8(l+4)) } else { e.encLenNumber(bd, l) } @@ -369,49 +376,52 @@ func (e *bincEncDriver) encLen(bd byte, l uint64) { func (e *bincEncDriver) encLenNumber(bd byte, v uint64) { if v <= math.MaxUint8 { - e.e.encWr.writen2(bd, byte(v)) + e.w.writen2(bd, byte(v)) } else if v <= math.MaxUint16 { - e.e.encWr.writen1(bd | 0x01) - bigenHelper{e.b[:2], e.e.w()}.writeUint16(uint16(v)) + e.w.writen1(bd | 0x01) + bigenHelper{e.b[:2], e.w}.writeUint16(uint16(v)) } else if v <= math.MaxUint32 { - e.e.encWr.writen1(bd | 0x02) - bigenHelper{e.b[:4], e.e.w()}.writeUint32(uint32(v)) + e.w.writen1(bd | 0x02) + bigenHelper{e.b[:4], e.w}.writeUint32(uint32(v)) } else { - e.e.encWr.writen1(bd | 0x03) - bigenHelper{e.b[:8], e.e.w()}.writeUint64(uint64(v)) + e.w.writen1(bd | 0x03) + bigenHelper{e.b[:8], e.w}.writeUint64(uint64(v)) } } //------------------------------------ +type bincDecSymbol struct { + s string + b []byte + i uint16 +} + type bincDecDriver struct { decDriverNoopContainerReader noBuiltInTypes + d *Decoder h *BincHandle + r *decReaderSwitch + br bool // bytes reader bdRead bool bd byte vd byte vs byte - - fnil bool - // _ [3]byte // padding + _ [3]byte // padding // linear searching on this slice is ok, // because we typically expect < 32 symbols in each stream. - s map[uint16][]byte // []bincDecSymbol - - b [8]byte // scratch for decoding numbers - big endian style - _ [4]uint64 // padding cache-aligned + s []bincDecSymbol - d Decoder -} + // noStreamingCodec + // decNoSeparator -func (d *bincDecDriver) decoder() *Decoder { - return &d.d + b [(8 + 1) * 8]byte // scratch } func (d *bincDecDriver) readNextBd() { - d.bd = d.d.decRd.readn1() + d.bd = d.r.readn1() d.vd = d.bd >> 4 d.vs = d.bd & 0x0f d.bdRead = true @@ -419,41 +429,16 @@ func (d *bincDecDriver) readNextBd() { func (d *bincDecDriver) uncacheRead() { if d.bdRead { - d.d.decRd.unreadn1() - d.bdRead = false - } -} - -func (d *bincDecDriver) advanceNil() (null bool) { - d.fnil = false - if !d.bdRead { - d.readNextBd() - } - if d.bd == bincVdSpecial<<4|bincSpNil { + d.r.unreadn1() d.bdRead = false - d.fnil = true - null = true } - return -} - -func (d *bincDecDriver) Nil() bool { - return d.fnil -} - -func (d *bincDecDriver) TryNil() bool { - return d.advanceNil() } func (d *bincDecDriver) ContainerType() (vt valueType) { if !d.bdRead { d.readNextBd() } - d.fnil = false - // if d.vd == bincVdSpecial && d.vs == bincSpNil { - if d.bd == bincVdSpecial<<4|bincSpNil { - d.bdRead = false - d.fnil = true + if d.vd == bincVdSpecial && d.vs == bincSpNil { return valueTypeNil } else if d.vd == bincVdByteArray { return valueTypeBytes @@ -464,18 +449,36 @@ func (d *bincDecDriver) ContainerType() (vt valueType) { } else if d.vd == bincVdMap { return valueTypeMap } + // else { + // d.d.errorf("isContainerType: unsupported parameter: %v", vt) + // } return valueTypeUnset } +func (d *bincDecDriver) TryDecodeAsNil() bool { + if !d.bdRead { + d.readNextBd() + } + if d.bd == bincVdSpecial<<4|bincSpNil { + d.bdRead = false + return true + } + return false +} + func (d *bincDecDriver) DecodeTime() (t time.Time) { - if d.advanceNil() { + if !d.bdRead { + d.readNextBd() + } + if d.bd == bincVdSpecial<<4|bincSpNil { + d.bdRead = false return } if d.vd != bincVdTimestamp { d.d.errorf("cannot decode time - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs)) return } - t, err := bincDecodeTime(d.d.decRd.readx(uint(d.vs))) + t, err := bincDecodeTime(d.r.readx(uint(d.vs))) if err != nil { panic(err) } @@ -485,9 +488,9 @@ func (d *bincDecDriver) DecodeTime() (t time.Time) { func (d *bincDecDriver) decFloatPre(vs, defaultLen byte) { if vs&0x8 == 0 { - d.d.decRd.readb(d.b[0:defaultLen]) + d.r.readb(d.b[0:defaultLen]) } else { - l := d.d.decRd.readn1() + l := d.r.readn1() if l > 8 { d.d.errorf("cannot read float - at most 8 bytes used to represent float - received %v bytes", l) return @@ -495,12 +498,12 @@ func (d *bincDecDriver) decFloatPre(vs, defaultLen byte) { for i := l; i < 8; i++ { d.b[i] = 0 } - d.d.decRd.readb(d.b[0:l]) + d.r.readb(d.b[0:l]) } } func (d *bincDecDriver) decFloat() (f float64) { - //if true { f = math.Float64frombits(bigen.Uint64(d.d.decRd.readx(8))); break; } + //if true { f = math.Float64frombits(bigen.Uint64(d.r.readx(8))); break; } if x := d.vs & 0x7; x == bincFlBin32 { d.decFloatPre(d.vs, 4) f = float64(math.Float32frombits(bigen.Uint32(d.b[0:4]))) @@ -519,26 +522,26 @@ func (d *bincDecDriver) decUint() (v uint64) { // need to inline the code (interface conversion and type assertion expensive) switch d.vs { case 0: - v = uint64(d.d.decRd.readn1()) + v = uint64(d.r.readn1()) case 1: - d.d.decRd.readb(d.b[6:8]) + d.r.readb(d.b[6:8]) v = uint64(bigen.Uint16(d.b[6:8])) case 2: d.b[4] = 0 - d.d.decRd.readb(d.b[5:8]) + d.r.readb(d.b[5:8]) v = uint64(bigen.Uint32(d.b[4:8])) case 3: - d.d.decRd.readb(d.b[4:8]) + d.r.readb(d.b[4:8]) v = uint64(bigen.Uint32(d.b[4:8])) case 4, 5, 6: lim := 7 - d.vs - d.d.decRd.readb(d.b[lim:8]) + d.r.readb(d.b[lim:8]) for i := uint8(0); i < lim; i++ { d.b[i] = 0 } v = uint64(bigen.Uint64(d.b[:8])) case 7: - d.d.decRd.readb(d.b[:8]) + d.r.readb(d.b[:8]) v = uint64(bigen.Uint64(d.b[:8])) default: d.d.errorf("unsigned integers with greater than 64 bits of precision not supported") @@ -548,6 +551,9 @@ func (d *bincDecDriver) decUint() (v uint64) { } func (d *bincDecDriver) decCheckInteger() (ui uint64, neg bool) { + if !d.bdRead { + d.readNextBd() + } vd, vs := d.vd, d.vs if vd == bincVdPosInt { ui = d.decUint() @@ -575,9 +581,6 @@ func (d *bincDecDriver) decCheckInteger() (ui uint64, neg bool) { } func (d *bincDecDriver) DecodeInt64() (i int64) { - if d.advanceNil() { - return - } ui, neg := d.decCheckInteger() i = chkOvf.SignedIntV(ui) if neg { @@ -588,9 +591,6 @@ func (d *bincDecDriver) DecodeInt64() (i int64) { } func (d *bincDecDriver) DecodeUint64() (ui uint64) { - if d.advanceNil() { - return - } ui, neg := d.decCheckInteger() if neg { d.d.errorf("assigning negative signed value to unsigned integer type") @@ -601,8 +601,8 @@ func (d *bincDecDriver) DecodeUint64() (ui uint64) { } func (d *bincDecDriver) DecodeFloat64() (f float64) { - if d.advanceNil() { - return + if !d.bdRead { + d.readNextBd() } vd, vs := d.vd, d.vs if vd == bincVdSpecial { @@ -631,12 +631,12 @@ func (d *bincDecDriver) DecodeFloat64() (f float64) { // bool can be decoded from bool only (single byte). func (d *bincDecDriver) DecodeBool() (b bool) { - if d.advanceNil() { - return + if !d.bdRead { + d.readNextBd() } - if d.bd == (bincVdSpecial | bincSpFalse) { + if bd := d.bd; bd == (bincVdSpecial | bincSpFalse) { // b = false - } else if d.bd == (bincVdSpecial | bincSpTrue) { + } else if bd == (bincVdSpecial | bincSpTrue) { b = true } else { d.d.errorf("bool - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs)) @@ -647,8 +647,8 @@ func (d *bincDecDriver) DecodeBool() (b bool) { } func (d *bincDecDriver) ReadMapStart() (length int) { - if d.advanceNil() { - return decContainerLenNil + if !d.bdRead { + d.readNextBd() } if d.vd != bincVdMap { d.d.errorf("map - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs)) @@ -660,8 +660,8 @@ func (d *bincDecDriver) ReadMapStart() (length int) { } func (d *bincDecDriver) ReadArrayStart() (length int) { - if d.advanceNil() { - return decContainerLenNil + if !d.bdRead { + d.readNextBd() } if d.vd != bincVdArray { d.d.errorf("array - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs)) @@ -681,22 +681,27 @@ func (d *bincDecDriver) decLen() int { func (d *bincDecDriver) decLenNumber() (v uint64) { if x := d.vs; x == 0 { - v = uint64(d.d.decRd.readn1()) + v = uint64(d.r.readn1()) } else if x == 1 { - d.d.decRd.readb(d.b[6:8]) + d.r.readb(d.b[6:8]) v = uint64(bigen.Uint16(d.b[6:8])) } else if x == 2 { - d.d.decRd.readb(d.b[4:8]) + d.r.readb(d.b[4:8]) v = uint64(bigen.Uint32(d.b[4:8])) } else { - d.d.decRd.readb(d.b[:8]) + d.r.readb(d.b[:8]) v = bigen.Uint64(d.b[:8]) } return } -func (d *bincDecDriver) decStringBytes(bs []byte, zerocopy bool) (bs2 []byte) { - if d.advanceNil() { +func (d *bincDecDriver) decStringAndBytes(bs []byte, withString, zerocopy bool) ( + bs2 []byte, s string) { + if !d.bdRead { + d.readNextBd() + } + if d.bd == bincVdSpecial<<4|bincSpNil { + d.bdRead = false return } var slen = -1 @@ -705,15 +710,18 @@ func (d *bincDecDriver) decStringBytes(bs []byte, zerocopy bool) (bs2 []byte) { case bincVdString, bincVdByteArray: slen = d.decLen() if zerocopy { - if d.d.bytes { - bs2 = d.d.decRd.readx(uint(slen)) + if d.br { + bs2 = d.r.readx(uint(slen)) } else if len(bs) == 0 { - bs2 = decByteSlice(d.d.r(), slen, d.d.h.MaxInitLen, d.d.b[:]) + bs2 = decByteSlice(d.r, slen, d.d.h.MaxInitLen, d.b[:]) } else { - bs2 = decByteSlice(d.d.r(), slen, d.d.h.MaxInitLen, bs) + bs2 = decByteSlice(d.r, slen, d.d.h.MaxInitLen, bs) } } else { - bs2 = decByteSlice(d.d.r(), slen, d.d.h.MaxInitLen, bs) + bs2 = decByteSlice(d.r, slen, d.d.h.MaxInitLen, bs) + } + if withString { + s = string(bs2) } case bincVdSymbol: // zerocopy doesn't apply for symbols, @@ -726,34 +734,47 @@ func (d *bincDecDriver) decStringBytes(bs []byte, zerocopy bool) (bs2 []byte) { var symbol uint16 vs := d.vs if vs&0x8 == 0 { - symbol = uint16(d.d.decRd.readn1()) + symbol = uint16(d.r.readn1()) } else { - symbol = uint16(bigen.Uint16(d.d.decRd.readx(2))) + symbol = uint16(bigen.Uint16(d.r.readx(2))) } if d.s == nil { - // d.s = pool4mapU16Bytes.Get().(map[uint16][]byte) // make([]bincDecSymbol, 0, 16) - d.s = make(map[uint16][]byte, 16) + d.s = make([]bincDecSymbol, 0, 16) } if vs&0x4 == 0 { - bs2 = d.s[symbol] + for i := range d.s { + j := &d.s[i] + if j.i == symbol { + bs2 = j.b + if withString { + if j.s == "" && bs2 != nil { + j.s = string(bs2) + } + s = j.s + } + break + } + } } else { switch vs & 0x3 { case 0: - slen = int(d.d.decRd.readn1()) + slen = int(d.r.readn1()) case 1: - slen = int(bigen.Uint16(d.d.decRd.readx(2))) + slen = int(bigen.Uint16(d.r.readx(2))) case 2: - slen = int(bigen.Uint32(d.d.decRd.readx(4))) + slen = int(bigen.Uint32(d.r.readx(4))) case 3: - slen = int(bigen.Uint64(d.d.decRd.readx(8))) + slen = int(bigen.Uint64(d.r.readx(8))) } // since using symbols, do not store any part of // the parameter bs in the map, as it might be a shared buffer. - // bs2 = decByteSlice(d.d.r(), slen, bs) - bs2 = decByteSlice(d.d.r(), slen, d.d.h.MaxInitLen, nil) - d.s[symbol] = bs2 - // d.s = append(d.s, bincDecSymbol{i: symbol, s: s, b: bs2}) + // bs2 = decByteSlice(d.r, slen, bs) + bs2 = decByteSlice(d.r, slen, d.d.h.MaxInitLen, nil) + if withString { + s = string(bs2) + } + d.s = append(d.s, bincDecSymbol{i: symbol, s: s, b: bs2}) } default: d.d.errorf("string/bytes - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs)) @@ -763,26 +784,31 @@ func (d *bincDecDriver) decStringBytes(bs []byte, zerocopy bool) (bs2 []byte) { return } +func (d *bincDecDriver) DecodeString() (s string) { + // DecodeBytes does not accommodate symbols, whose impl stores string version in map. + // Use decStringAndBytes directly. + // return string(d.DecodeBytes(d.b[:], true, true)) + _, s = d.decStringAndBytes(d.b[:], true, true) + return +} + func (d *bincDecDriver) DecodeStringAsBytes() (s []byte) { - return d.decStringBytes(d.d.b[:], true) + s, _ = d.decStringAndBytes(d.b[:], false, true) + return } func (d *bincDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { - if d.advanceNil() { - return + if !d.bdRead { + d.readNextBd() + } + if d.bd == bincVdSpecial<<4|bincSpNil { + 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 { - if zerocopy && len(bs) == 0 { - bs = d.d.b[:] - } - // bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d) - slen := d.ReadArrayStart() - bs = usableByteSlice(bs, slen) - for i := 0; i < slen; i++ { - bs[i] = uint8(chkOvf.UintV(d.DecodeUint64(), 8)) - } - return bs + bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d) + return } var clen int if d.vd == bincVdString || d.vd == bincVdByteArray { @@ -793,48 +819,47 @@ func (d *bincDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { } d.bdRead = false if zerocopy { - if d.d.bytes { - return d.d.decRd.readx(uint(clen)) + if d.br { + return d.r.readx(uint(clen)) } else if len(bs) == 0 { - bs = d.d.b[:] + bs = d.b[:] } } - return decByteSlice(d.d.r(), clen, d.d.h.MaxInitLen, bs) + return decByteSlice(d.r, clen, d.d.h.MaxInitLen, bs) } -func (d *bincDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) { +func (d *bincDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxtag uint64) { if xtag > 0xff { d.d.errorf("ext: tag must be <= 0xff; got: %v", xtag) return } - if d.advanceNil() { - return - } realxtag1, xbs := d.decodeExtV(ext != nil, uint8(xtag)) - realxtag := uint64(realxtag1) + realxtag = uint64(realxtag1) if ext == nil { re := rv.(*RawExt) re.Tag = realxtag - re.Data = detachZeroCopyBytes(d.d.bytes, re.Data, xbs) - } else if ext == SelfExt { - d.d.sideDecode(rv, xbs) + re.Data = detachZeroCopyBytes(d.br, re.Data, xbs) } else { ext.ReadExt(rv, xbs) } + return } func (d *bincDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs []byte) { + if !d.bdRead { + d.readNextBd() + } if d.vd == bincVdCustomExt { l := d.decLen() - xtag = d.d.decRd.readn1() + xtag = d.r.readn1() if verifyTag && xtag != tag { d.d.errorf("wrong extension tag - got %b, expecting: %v", xtag, tag) return } - if d.d.bytes { - xbs = d.d.decRd.readx(uint(l)) + if d.br { + xbs = d.r.readx(uint(l)) } else { - xbs = decByteSlice(d.d.r(), l, d.d.h.MaxInitLen, d.d.b[:]) + xbs = decByteSlice(d.r, l, d.d.h.MaxInitLen, d.d.b[:]) } } else if d.vd == bincVdByteArray { xbs = d.DecodeBytes(nil, true) @@ -852,7 +877,6 @@ func (d *bincDecDriver) DecodeNaked() { d.readNextBd() } - d.fnil = false n := d.d.naked() var decodeFurther bool @@ -861,7 +885,6 @@ func (d *bincDecDriver) DecodeNaked() { switch d.vs { case bincSpNil: n.v = valueTypeNil - d.fnil = true case bincSpFalse: n.v = valueTypeBool n.b = false @@ -904,15 +927,15 @@ func (d *bincDecDriver) DecodeNaked() { n.f = d.decFloat() case bincVdSymbol: n.v = valueTypeSymbol - n.s = string(d.DecodeStringAsBytes()) + n.s = d.DecodeString() case bincVdString: n.v = valueTypeString - n.s = string(d.DecodeStringAsBytes()) + n.s = d.DecodeString() case bincVdByteArray: - decNakedReadRawBytes(d, &d.d, n, d.h.RawToString) + decNakedReadRawBytes(d, d.d, n, d.h.RawToString) case bincVdTimestamp: n.v = valueTypeTime - tt, err := bincDecodeTime(d.d.decRd.readx(uint(d.vs))) + tt, err := bincDecodeTime(d.r.readx(uint(d.vs))) if err != nil { panic(err) } @@ -920,11 +943,11 @@ func (d *bincDecDriver) DecodeNaked() { case bincVdCustomExt: n.v = valueTypeExt l := d.decLen() - n.u = uint64(d.d.decRd.readn1()) - if d.d.bytes { - n.l = d.d.decRd.readx(uint(l)) + n.u = uint64(d.r.readn1()) + if d.br { + n.l = d.r.readx(uint(l)) } else { - n.l = decByteSlice(d.d.r(), l, d.d.h.MaxInitLen, d.d.b[:]) + n.l = decByteSlice(d.r, l, d.d.h.MaxInitLen, d.d.b[:]) } case bincVdArray: n.v = valueTypeArray @@ -962,7 +985,7 @@ func (d *bincDecDriver) DecodeNaked() { type BincHandle struct { BasicHandle binaryEncodingType - // noElemSeparators + noElemSeparators // AsSymbols defines what should be encoded as symbols. // @@ -984,53 +1007,36 @@ type BincHandle struct { // - n: none // - a: all: same as m, s, ... - _ [7]uint64 // padding (cache-aligned) + // _ [1]uint64 // padding } // Name returns the name of the handle: binc func (h *BincHandle) Name() string { return "binc" } -func (h *BincHandle) newEncDriver() encDriver { - var e = &bincEncDriver{h: h} - e.e.e = e - e.e.init(h) - e.reset() - return e +// SetBytesExt sets an extension +func (h *BincHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) { + return h.SetExt(rt, tag, &extWrapper{ext, interfaceExtFailer{}}) +} + +func (h *BincHandle) newEncDriver(e *Encoder) encDriver { + return &bincEncDriver{e: e, h: h, w: e.w} } -func (h *BincHandle) newDecDriver() decDriver { - d := &bincDecDriver{h: h} - d.d.d = d - d.d.init(h) - d.reset() - return d +func (h *BincHandle) newDecDriver(d *Decoder) decDriver { + return &bincDecDriver{d: d, h: h, r: d.r, br: d.bytes} } func (e *bincEncDriver) reset() { + e.w = e.e.w e.s = 0 + e.c = 0 e.m = nil } -func (e *bincEncDriver) atEndOfEncode() { - if e.m != nil { - for k := range e.m { - delete(e.m, k) - } - } -} - func (d *bincDecDriver) reset() { + d.r, d.br = d.d.r, d.d.bytes d.s = nil d.bd, d.bdRead, d.vd, d.vs = 0, false, 0, 0 - d.fnil = false -} - -func (d *bincDecDriver) atEndOfDecode() { - if d.s != nil { - for k := range d.s { - delete(d.s, k) - } - } } // var timeDigits = [...]byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'} @@ -1085,7 +1091,7 @@ func (d *bincDecDriver) atEndOfDecode() { // Bits 13..0 = timezone offset in minutes. It is a signed integer in Big Endian format. // func bincEncodeTime(t time.Time) []byte { - // t := rv2i(rv).(time.Time) + //t := rv.Interface().(time.Time) tsecs, tnsecs := t.Unix(), t.Nanosecond() var ( bd byte @@ -1117,7 +1123,7 @@ func bincEncodeTime(t time.Time) []byte { bd = bd | 0x20 // Note that Go Libs do not give access to dst flag. _, zoneOffset := t.Zone() - // zoneName, zoneOffset := t.Zone() + //zoneName, zoneOffset := t.Zone() zoneOffset /= 60 z := uint16(zoneOffset) bigen.PutUint16(btmp[:2], z) @@ -1146,10 +1152,10 @@ func bincDecodeTime(bs []byte) (tt time.Time, err error) { 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 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 } + //for j,k := byte(0), 8-n; j < k; j++ { btmp[j] = 0xff } } i = i2 tsec = int64(bigen.Uint64(btmp[:])) @@ -1167,7 +1173,7 @@ func bincDecodeTime(bs []byte) (tt time.Time, err error) { 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 printf.d. + // 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 @@ -1193,27 +1199,5 @@ func bincDecodeTime(bs []byte) (tt time.Time, err error) { 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] = '-' -// 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) -// } - var _ decDriver = (*bincDecDriver)(nil) var _ encDriver = (*bincEncDriver)(nil) diff --git a/vendor/github.com/ugorji/go/codec/build.sh b/vendor/github.com/ugorji/go/codec/build.sh old mode 100755 new mode 100644 index a71227fb2bf5..c08530783306 --- a/vendor/github.com/ugorji/go/codec/build.sh +++ b/vendor/github.com/ugorji/go/codec/build.sh @@ -4,7 +4,6 @@ # This helps ensure that nothing gets broken. _tests() { - local vet="" # TODO: make it off local gover=$( go version | cut -f 3 -d ' ' ) # note that codecgen requires fastpath, so you cannot do "codecgen notfastpath" local a=( "" "safe" "notfastpath" "notfastpath safe" "codecgen" "codecgen safe" ) @@ -13,9 +12,10 @@ _tests() { echo ">>>> TAGS: $i" local i2=${i:-default} case $gover in - go1.[0-6]*) go test ${zargs[*]} -tags "$i" "$@" ;; + go1.[0-6]*) go vet -printfuncs "errorf" "$@" && + go test ${zargs[*]} -vet off -tags "$i" "$@" ;; *) go vet -printfuncs "errorf" "$@" && - go test ${zargs[*]} -vet "$vet" -tags "alltests $i" -run "Suite" -coverprofile "${i2// /-}.cov.out" "$@" ;; + go test ${zargs[*]} -vet off -tags "alltests $i" -run "Suite" -coverprofile "${i2// /-}.cov.out" "$@" ;; esac if [[ "$?" != 0 ]]; then return 1; fi done @@ -116,67 +116,60 @@ run("fast-path.go.tmpl", "fast-path.generated.go") run("gen-helper.go.tmpl", "gen-helper.generated.go") run("mammoth-test.go.tmpl", "mammoth_generated_test.go") run("mammoth2-test.go.tmpl", "mammoth2_generated_test.go") -// run("sort-slice.go.tmpl", "sort-slice.generated.go") } EOF - sed -e 's+// __DO_NOT_REMOVE__NEEDED_FOR_REPLACING__IMPORT_PATH__FOR_CODEC_BENCH__+import . "github.com/ugorji/go/codec"+' \ - shared_test.go > bench/shared_test.go - # explicitly return 0 if this passes, else return 1 - go run -tags "prebuild" prebuild.go || return 1 - go run -tags "notfastpath safe codecgen.exec" gen-from-tmpl.generated.go || return 1 - rm -f gen-from-tmpl.*generated.go - return 0 + go run -tags "notfastpath safe codecgen.exec" gen-from-tmpl.generated.go && + rm -f gen-from-tmpl.*generated.go && + return 0 + return 1 } _codegenerators() { - local c5="_generated_test.go" - local c7="$PWD/codecgen" - local c8="$c7/__codecgen" - local c9="codecgen-scratch.go" + if ! [[ $zforce || $(_ng "values_codecgen${zsfx}") ]]; then return 0; fi - if ! [[ $zforce || $(_ng "values_codecgen${c5}") ]]; then return 0; fi - # Note: ensure you run the codecgen for this codebase/directory i.e. ./codecgen/codecgen + local c9="codecgen-scratch.go" + local c7="$zmydir/codecgen" true && echo "codecgen ... " && - if [[ $zforce || ! -f "$c8" || "$c7/gen.go" -nt "$c8" ]]; then - echo "rebuilding codecgen ... " && ( cd codecgen && go build -o $c8 ${zargs[*]} . ) + if [[ $zforce || ! -f "$c7/codecgen" || "$c7/gen.go" -nt "$c7/codecgen" ]]; then + echo "rebuilding codecgen ... " && ( cd codecgen && go build -o codecgen ${zargs[*]} . ) fi && - $c8 -rt codecgen -t 'codecgen generated' -o values_codecgen${c5} -d 19780 $zfin $zfin2 && + $c7/codecgen -rt codecgen -t 'codecgen generated' -o values_codecgen${zsfx} -d 19780 $zfin $zfin2 && cp mammoth2_generated_test.go $c9 && - $c8 -t 'codecgen,!notfastpath generated,!notfastpath' -o mammoth2_codecgen${c5} -d 19781 mammoth2_generated_test.go && + $c7/codecgen -t '!notfastpath' -o mammoth2_codecgen${zsfx} -d 19781 mammoth2_generated_test.go && rm -f $c9 && echo "generators done!" } _prebuild() { - echo "prebuild: zforce: $zforce" - local d="$PWD" - local zfin="test_values.generated.go" - local zfin2="test_values_flex.generated.go" - local zpkg="github.com/ugorji/go/codec" - # zpkg=${d##*/src/} - # zgobase=${d%%/src/*} + echo "prebuild: zforce: $zforce , zexternal: $zexternal" + zmydir=`pwd` + zfin="test_values.generated.go" + zfin2="test_values_flex.generated.go" + zsfx="_generated_test.go" + # zpkg="ugorji.net/codec" + zpkg=${zmydir##*/src/} + zgobase=${zmydir%%/src/*} # rm -f *_generated_test.go rm -f codecgen-*.go && _build && - cp $d/values_test.go $d/$zfin && - cp $d/values_flex_test.go $d/$zfin2 && + cp $zmydir/values_test.go $zmydir/$zfin && + cp $zmydir/values_flex_test.go $zmydir/$zfin2 && _codegenerators && if [[ "$(type -t _codegenerators_external )" = "function" ]]; then _codegenerators_external ; fi && if [[ $zforce ]]; then go install ${zargs[*]} .; fi && echo "prebuild done successfully" - rm -f $d/$zfin $d/$zfin2 - # unset zfin zfin2 zpkg + rm -f $zmydir/$zfin $zmydir/$zfin2 } _make() { - local makeforce=${zforce} zforce=1 + zexternal=1 (cd codecgen && go install ${zargs[*]} .) && _prebuild && go install ${zargs[*]} . - zforce=${makeforce} + unset zforce zexternal } _clean() { @@ -201,7 +194,6 @@ _release() { EOF # # go 1.6 and below kept giving memory errors on Mac OS X during SDK build or go run execution, # # that is fine, as we only explicitly test the last 3 releases and tip (2 years). - local makeforce=${zforce} zforce=1 for i in 1.10 1.11 1.12 master do @@ -218,7 +210,7 @@ EOF _tests "$@" if [[ "$?" != 0 ]]; then return 1; fi done - zforce=${makeforce} + unset zforce echo "++++++++ RELEASE TEST SUITES ALL PASSED ++++++++" } @@ -234,16 +226,16 @@ EOF _main() { if [[ -z "$1" ]]; then _usage; return 1; fi local x - local zforce - local zargs=() - local zverbose=() - local zbenchflags="" + unset zforce zexternal + zargs=() + zbenchflags="" OPTIND=1 - while getopts ":ctmnrgpfvlyzdb:" flag + while getopts ":ctmnrgupfvxlzdb:" flag do case "x$flag" in 'xf') zforce=1 ;; - 'xv') zverbose+=(1) ;; + 'xx') zexternal=1 ;; + 'xv') zverbose=1 ;; 'xl') zargs+=("-gcflags"); zargs+=("-l=4") ;; 'xn') zargs+=("-gcflags"); zargs+=("-m=2") ;; 'xd') zargs+=("-race") ;; @@ -259,13 +251,13 @@ _main() { 'xm') _make "$@" ;; 'xr') _release "$@" ;; 'xg') _go ;; + 'xu') _githubupdate ;; 'xp') _prebuild "$@" ;; 'xc') _clean "$@" ;; - 'xy') _analyze_extra "$@" ;; 'xz') _analyze "$@" ;; 'xb') _bench "$@" ;; esac - # unset zforce zargs zbenchflags + unset zforce zexternal } [ "." = `dirname $0` ] && _main "$@" diff --git a/vendor/github.com/ugorji/go/codec/cbor.go b/vendor/github.com/ugorji/go/codec/cbor.go index d84fbb226a81..7833f9d68f09 100644 --- a/vendor/github.com/ugorji/go/codec/cbor.go +++ b/vendor/github.com/ugorji/go/codec/cbor.go @@ -5,22 +5,21 @@ package codec import ( "math" + "reflect" "time" ) -// major const ( cborMajorUint byte = iota cborMajorNegInt cborMajorBytes - cborMajorString + cborMajorText cborMajorArray cborMajorMap cborMajorTag - cborMajorSimpleOrFloat + cborMajorOther ) -// simple const ( cborBdFalse byte = 0xf4 + iota cborBdTrue @@ -32,7 +31,6 @@ const ( cborBdFloat64 ) -// indefinite const ( cborBdIndefiniteBytes byte = 0x5f cborBdIndefiniteString byte = 0x7f @@ -51,7 +49,6 @@ const ( CborStreamBreak byte = 0xff ) -// base values const ( cborBaseUint byte = 0x00 cborBaseNegInt byte = 0x20 @@ -63,51 +60,44 @@ const ( cborBaseSimple byte = 0xe0 ) -// const ( -// cborSelfDesrTag byte = 0xd9 -// cborSelfDesrTag2 byte = 0xd9 -// cborSelfDesrTag3 byte = 0xf7 -// ) - func cbordesc(bd byte) string { - switch bd >> 5 { - case cborMajorUint: - return "(u)int" - case cborMajorNegInt: - return "int" - case cborMajorBytes: - return "bytes" - case cborMajorString: - return "string" - case cborMajorArray: - return "array" - case cborMajorMap: - return "map" - case cborMajorTag: - return "tag" - case cborMajorSimpleOrFloat: // default - switch bd { - case cborBdNil: - return "nil" - case cborBdFalse: - return "false" - case cborBdTrue: - return "true" - case cborBdFloat16, cborBdFloat32, cborBdFloat64: - return "float" - case cborBdIndefiniteBytes: - return "bytes*" - case cborBdIndefiniteString: - return "string*" - case cborBdIndefiniteArray: - return "array*" - case cborBdIndefiniteMap: - return "map*" + switch bd { + case cborBdNil: + return "nil" + case cborBdFalse: + return "false" + case cborBdTrue: + return "true" + case cborBdFloat16, cborBdFloat32, cborBdFloat64: + return "float" + case cborBdIndefiniteBytes: + return "bytes*" + case cborBdIndefiniteString: + return "string*" + case cborBdIndefiniteArray: + return "array*" + case cborBdIndefiniteMap: + return "map*" + default: + switch { + case bd >= cborBaseUint && bd < cborBaseNegInt: + return "(u)int" + case bd >= cborBaseNegInt && bd < cborBaseBytes: + return "int" + case bd >= cborBaseBytes && bd < cborBaseString: + return "bytes" + case bd >= cborBaseString && bd < cborBaseArray: + return "string" + case bd >= cborBaseArray && bd < cborBaseMap: + return "array" + case bd >= cborBaseMap && bd < cborBaseTag: + return "map" + case bd >= cborBaseTag && bd < cborBaseSimple: + return "ext" default: - return "unknown(simple)" + return "unknown" } } - return "unknown" } // ------------------- @@ -115,52 +105,49 @@ func cbordesc(bd byte) string { type cborEncDriver struct { noBuiltInTypes encDriverNoopContainerWriter + e *Encoder + w *encWriterSwitch h *CborHandle x [8]byte - _ [6]uint64 // padding - e Encoder -} - -func (e *cborEncDriver) encoder() *Encoder { - return &e.e + // _ [3]uint64 // padding } func (e *cborEncDriver) EncodeNil() { - e.e.encWr.writen1(cborBdNil) + e.w.writen1(cborBdNil) } func (e *cborEncDriver) EncodeBool(b bool) { if b { - e.e.encWr.writen1(cborBdTrue) + e.w.writen1(cborBdTrue) } else { - e.e.encWr.writen1(cborBdFalse) + e.w.writen1(cborBdFalse) } } func (e *cborEncDriver) EncodeFloat32(f float32) { - e.e.encWr.writen1(cborBdFloat32) - bigenHelper{e.x[:4], e.e.w()}.writeUint32(math.Float32bits(f)) + e.w.writen1(cborBdFloat32) + bigenHelper{e.x[:4], e.w}.writeUint32(math.Float32bits(f)) } func (e *cborEncDriver) EncodeFloat64(f float64) { - e.e.encWr.writen1(cborBdFloat64) - bigenHelper{e.x[:8], e.e.w()}.writeUint64(math.Float64bits(f)) + e.w.writen1(cborBdFloat64) + bigenHelper{e.x[:8], e.w}.writeUint64(math.Float64bits(f)) } func (e *cborEncDriver) encUint(v uint64, bd byte) { if v <= 0x17 { - e.e.encWr.writen1(byte(v) + bd) + e.w.writen1(byte(v) + bd) } else if v <= math.MaxUint8 { - e.e.encWr.writen2(bd+0x18, uint8(v)) + e.w.writen2(bd+0x18, uint8(v)) } else if v <= math.MaxUint16 { - e.e.encWr.writen1(bd + 0x19) - bigenHelper{e.x[:2], e.e.w()}.writeUint16(uint16(v)) + e.w.writen1(bd + 0x19) + bigenHelper{e.x[:2], e.w}.writeUint16(uint16(v)) } else if v <= math.MaxUint32 { - e.e.encWr.writen1(bd + 0x1a) - bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(v)) + e.w.writen1(bd + 0x1a) + bigenHelper{e.x[:4], e.w}.writeUint32(uint32(v)) } else { // if v <= math.MaxUint64 { - e.e.encWr.writen1(bd + 0x1b) - bigenHelper{e.x[:8], e.e.w()}.writeUint64(v) + e.w.writen1(bd + 0x1b) + bigenHelper{e.x[:8], e.w}.writeUint64(v) } } @@ -185,7 +172,7 @@ func (e *cborEncDriver) EncodeTime(t time.Time) { e.EncodeNil() } else if e.h.TimeRFC3339 { e.encUint(0, cborBaseTag) - e.encStringBytesS(cborBaseString, t.Format(time.RFC3339Nano)) + e.EncodeStringEnc(cUTF8, t.Format(time.RFC3339Nano)) } else { e.encUint(1, cborBaseTag) t = t.UTC().Round(time.Microsecond) @@ -198,23 +185,23 @@ func (e *cborEncDriver) EncodeTime(t time.Time) { } } -func (e *cborEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext) { +func (e *cborEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext, en *Encoder) { e.encUint(uint64(xtag), cborBaseTag) - if ext == SelfExt { - rv2 := baseRV(rv) - e.e.encodeValue(rv2, e.h.fnNoExt(rv2.Type())) - } else if v := ext.ConvertExt(rv); v == nil { + if v := ext.ConvertExt(rv); v == nil { e.EncodeNil() } else { - e.e.encode(v) + en.encode(v) } } -func (e *cborEncDriver) EncodeRawExt(re *RawExt) { +func (e *cborEncDriver) EncodeRawExt(re *RawExt, en *Encoder) { e.encUint(uint64(re.Tag), cborBaseTag) // only encodes re.Value (never re.Data) + // if false && re.Data != nil { + // en.encode(re.Data) + // } else if re.Value != nil { if re.Value != nil { - e.e.encode(re.Value) + en.encode(re.Value) } else { e.EncodeNil() } @@ -222,7 +209,7 @@ func (e *cborEncDriver) EncodeRawExt(re *RawExt) { func (e *cborEncDriver) WriteArrayStart(length int) { if e.h.IndefiniteLength { - e.e.encWr.writen1(cborBdIndefiniteArray) + e.w.writen1(cborBdIndefiniteArray) } else { e.encLen(cborBaseArray, length) } @@ -230,7 +217,7 @@ func (e *cborEncDriver) WriteArrayStart(length int) { func (e *cborEncDriver) WriteMapStart(length int) { if e.h.IndefiniteLength { - e.e.encWr.writen1(cborBdIndefiniteMap) + e.w.writen1(cborBdIndefiniteMap) } else { e.encLen(cborBaseMap, length) } @@ -238,24 +225,34 @@ func (e *cborEncDriver) WriteMapStart(length int) { func (e *cborEncDriver) WriteMapEnd() { if e.h.IndefiniteLength { - e.e.encWr.writen1(cborBdBreak) + e.w.writen1(cborBdBreak) } } func (e *cborEncDriver) WriteArrayEnd() { if e.h.IndefiniteLength { - e.e.encWr.writen1(cborBdBreak) + e.w.writen1(cborBdBreak) } } -func (e *cborEncDriver) EncodeString(v string) { - if e.h.StringToRaw { - e.EncodeStringBytesRaw(bytesView(v)) - return - } +func (e *cborEncDriver) EncodeString(c charEncoding, v string) { e.encStringBytesS(cborBaseString, v) } +func (e *cborEncDriver) EncodeStringEnc(c charEncoding, v string) { + e.encStringBytesS(cborBaseString, 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) EncodeStringBytesRaw(v []byte) { if v == nil { e.EncodeNil() @@ -267,9 +264,9 @@ func (e *cborEncDriver) EncodeStringBytesRaw(v []byte) { func (e *cborEncDriver) encStringBytesS(bb byte, v string) { if e.h.IndefiniteLength { if bb == cborBaseBytes { - e.e.encWr.writen1(cborBdIndefiniteBytes) + e.w.writen1(cborBdIndefiniteBytes) } else { - e.e.encWr.writen1(cborBdIndefiniteString) + e.w.writen1(cborBdIndefiniteString) } var vlen uint = uint(len(v)) blen := vlen / 4 @@ -281,120 +278,91 @@ func (e *cborEncDriver) encStringBytesS(bb byte, v string) { for i := uint(0); i < vlen; { var v2 string i2 := i + blen - if i2 >= i && i2 < vlen { + if i2 < vlen { v2 = v[i:i2] } else { v2 = v[i:] } e.encLen(bb, len(v2)) - e.e.encWr.writestr(v2) + e.w.writestr(v2) i = i2 } - e.e.encWr.writen1(cborBdBreak) + e.w.writen1(cborBdBreak) } else { e.encLen(bb, len(v)) - e.e.encWr.writestr(v) + e.w.writestr(v) } } // ---------------------- type cborDecDriver struct { - decDriverNoopContainerReader + d *Decoder h *CborHandle + r *decReaderSwitch + br bool // bytes reader bdRead bool bd byte - st bool // skip tags - fnil bool // found nil noBuiltInTypes - _ [6]uint64 // padding cache-aligned - d Decoder -} - -func (d *cborDecDriver) decoder() *Decoder { - return &d.d + // decNoSeparator + decDriverNoopContainerReader + // _ [3]uint64 // padding } func (d *cborDecDriver) readNextBd() { - d.bd = d.d.decRd.readn1() + d.bd = d.r.readn1() d.bdRead = true } -func (d *cborDecDriver) advanceNil() (null bool) { - d.fnil = false - if !d.bdRead { - d.readNextBd() - } - if d.bd == cborBdNil || d.bd == cborBdUndefined { - d.bdRead = false - d.fnil = true - null = true - } - return -} - -// skipTags is called to skip any tags in the stream. -// -// Since any value can be tagged, then we should call skipTags -// before any value is decoded. -// -// By definition, skipTags should not be called before -// checking for break, or nil or undefined. -func (d *cborDecDriver) skipTags() { - for d.bd>>5 == cborMajorTag { - d.decUint() - d.bd = d.d.decRd.readn1() - } -} - func (d *cborDecDriver) uncacheRead() { if d.bdRead { - d.d.decRd.unreadn1() + d.r.unreadn1() d.bdRead = false } } func (d *cborDecDriver) ContainerType() (vt valueType) { - d.fnil = false if !d.bdRead { d.readNextBd() } - if d.st { - d.skipTags() - } if d.bd == cborBdNil { - d.bdRead = false // always consume nil after seeing it in container type - d.fnil = true return valueTypeNil - } else if d.bd == cborBdIndefiniteBytes || (d.bd>>5 == cborMajorBytes) { + } else if d.bd == cborBdIndefiniteBytes || (d.bd >= cborBaseBytes && d.bd < cborBaseString) { return valueTypeBytes - } else if d.bd == cborBdIndefiniteString || (d.bd>>5 == cborMajorString) { + } else if d.bd == cborBdIndefiniteString || (d.bd >= cborBaseString && d.bd < cborBaseArray) { return valueTypeString - } else if d.bd == cborBdIndefiniteArray || (d.bd>>5 == cborMajorArray) { + } else if d.bd == cborBdIndefiniteArray || (d.bd >= cborBaseArray && d.bd < cborBaseMap) { return valueTypeArray - } else if d.bd == cborBdIndefiniteMap || (d.bd>>5 == cborMajorMap) { + } else if d.bd == cborBdIndefiniteMap || (d.bd >= cborBaseMap && d.bd < cborBaseTag) { return valueTypeMap } + // else { + // d.d.errorf("isContainerType: unsupported parameter: %v", vt) + // } return valueTypeUnset } -func (d *cborDecDriver) Nil() bool { - return d.fnil -} - -func (d *cborDecDriver) TryNil() bool { - return d.advanceNil() +func (d *cborDecDriver) TryDecodeAsNil() bool { + if !d.bdRead { + d.readNextBd() + } + // treat Nil and Undefined as nil values + if d.bd == cborBdNil || d.bd == cborBdUndefined { + d.bdRead = false + return true + } + return false } -func (d *cborDecDriver) CheckBreak() (v bool) { +func (d *cborDecDriver) CheckBreak() bool { if !d.bdRead { d.readNextBd() } if d.bd == cborBdBreak { d.bdRead = false - v = true + return true } - return + return false } func (d *cborDecDriver) decUint() (ui uint64) { @@ -403,13 +371,13 @@ func (d *cborDecDriver) decUint() (ui uint64) { ui = uint64(v) } else { if v == 0x18 { - ui = uint64(d.d.decRd.readn1()) + ui = uint64(d.r.readn1()) } else if v == 0x19 { - ui = uint64(bigen.Uint16(d.d.decRd.readx(2))) + ui = uint64(bigen.Uint16(d.r.readx(2))) } else if v == 0x1a { - ui = uint64(bigen.Uint32(d.d.decRd.readx(4))) + ui = uint64(bigen.Uint32(d.r.readx(4))) } else if v == 0x1b { - ui = uint64(bigen.Uint64(d.d.decRd.readx(8))) + ui = uint64(bigen.Uint64(d.r.readx(8))) } else { d.d.errorf("invalid descriptor decoding uint: %x/%s", d.bd, cbordesc(d.bd)) return @@ -419,75 +387,38 @@ func (d *cborDecDriver) decUint() (ui uint64) { } func (d *cborDecDriver) decCheckInteger() (neg bool) { - if d.st { - d.skipTags() + if !d.bdRead { + d.readNextBd() } major := d.bd >> 5 if major == cborMajorUint { } else if major == cborMajorNegInt { neg = true } else { - d.d.errorf("invalid integer; got major %v from descriptor %x/%s, expected %v or %v", - major, d.bd, cbordesc(d.bd), cborMajorUint, cborMajorNegInt) + d.d.errorf("not an integer - invalid major %v from descriptor %x/%s", + major, d.bd, cbordesc(d.bd)) + return } return } -func cborDecInt64(ui uint64, neg bool) (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 if neg { i = -(chkOvf.SignedIntV(ui + 1)) } else { i = chkOvf.SignedIntV(ui) } - return -} - -func (d *cborDecDriver) decLen() int { - return int(d.decUint()) -} - -func (d *cborDecDriver) decAppendIndefiniteBytes(bs []byte) []byte { - d.bdRead = false - for !d.CheckBreak() { - if major := d.bd >> 5; major != cborMajorBytes && major != cborMajorString { - d.d.errorf("invalid indefinite string/bytes; got major %v, expected %x/%s", - major, d.bd, cbordesc(d.bd)) - } - n := uint(d.decLen()) - oldLen := uint(len(bs)) - newLen := oldLen + n - if newLen > uint(cap(bs)) { - bs2 := make([]byte, newLen, 2*uint(cap(bs))+n) - copy(bs2, bs) - bs = bs2 - } else { - bs = bs[:newLen] - } - d.d.decRd.readb(bs[oldLen:newLen]) - // bs = append(bs, d.d.decRd.readn()...) - d.bdRead = false - } d.bdRead = false - return bs -} - -func (d *cborDecDriver) DecodeInt64() (i int64) { - if d.advanceNil() { - return - } - neg := d.decCheckInteger() - ui := d.decUint() - d.bdRead = false - return cborDecInt64(ui, neg) + return } func (d *cborDecDriver) DecodeUint64() (ui uint64) { - if d.advanceNil() { - return - } if d.decCheckInteger() { - d.d.errorf("cannot assign negative signed value to unsigned type") + d.d.errorf("assigning negative signed value to unsigned type") + return } ui = d.decUint() d.bdRead = false @@ -495,29 +426,20 @@ func (d *cborDecDriver) DecodeUint64() (ui uint64) { } func (d *cborDecDriver) DecodeFloat64() (f float64) { - if d.advanceNil() { - return - } - if d.st { - d.skipTags() + if !d.bdRead { + d.readNextBd() } - switch d.bd { - case cborBdFloat16: - f = float64(math.Float32frombits(halfFloatToFloatBits(bigen.Uint16(d.d.decRd.readx(2))))) - case cborBdFloat32: - f = float64(math.Float32frombits(bigen.Uint32(d.d.decRd.readx(4)))) - case cborBdFloat64: - f = math.Float64frombits(bigen.Uint64(d.d.decRd.readx(8))) - default: - major := d.bd >> 5 - if major == cborMajorUint { - f = float64(cborDecInt64(d.decUint(), false)) - } else if major == cborMajorNegInt { - f = float64(cborDecInt64(d.decUint(), true)) - } else { - d.d.errorf("invalid float descriptor; got %d/%s, expected float16/32/64 or (-)int", - d.bd, cbordesc(d.bd)) - } + if bd := d.bd; bd == cborBdFloat16 { + f = float64(math.Float32frombits(halfFloatToFloatBits(bigen.Uint16(d.r.readx(2))))) + } else if bd == cborBdFloat32 { + f = float64(math.Float32frombits(bigen.Uint32(d.r.readx(4)))) + } else if bd == cborBdFloat64 { + f = math.Float64frombits(bigen.Uint64(d.r.readx(8))) + } else if bd >= cborBaseUint && bd < cborBaseBytes { + f = float64(d.DecodeInt64()) + } else { + d.d.errorf("float only valid from float16/32/64 - invalid descriptor %x/%s", bd, cbordesc(bd)) + return } d.bdRead = false return @@ -525,15 +447,12 @@ func (d *cborDecDriver) DecodeFloat64() (f float64) { // bool can be decoded from bool only (single byte). func (d *cborDecDriver) DecodeBool() (b bool) { - if d.advanceNil() { - return - } - if d.st { - d.skipTags() + if !d.bdRead { + d.readNextBd() } - if d.bd == cborBdTrue { + if bd := d.bd; bd == cborBdTrue { b = true - } else if d.bd == cborBdFalse { + } else if bd == cborBdFalse { } else { d.d.errorf("not bool - %s %x/%s", msgBadDesc, d.bd, cbordesc(d.bd)) return @@ -543,47 +462,67 @@ func (d *cborDecDriver) DecodeBool() (b bool) { } func (d *cborDecDriver) ReadMapStart() (length int) { - if d.advanceNil() { - return decContainerLenNil - } - if d.st { - d.skipTags() + if !d.bdRead { + d.readNextBd() } d.bdRead = false if d.bd == cborBdIndefiniteMap { - return decContainerLenUnknown - } - if d.bd>>5 != cborMajorMap { - d.d.errorf("error reading map; got major type: %x, expected %x/%s", - d.bd>>5, cborMajorMap, cbordesc(d.bd)) + return -1 } return d.decLen() } func (d *cborDecDriver) ReadArrayStart() (length int) { - if d.advanceNil() { - return decContainerLenNil - } - if d.st { - d.skipTags() + if !d.bdRead { + d.readNextBd() } d.bdRead = false if d.bd == cborBdIndefiniteArray { - return decContainerLenUnknown - } - if d.bd>>5 != cborMajorArray { - d.d.errorf("invalid array; got major type: %x, expect: %x/%s", - d.bd>>5, cborMajorArray, cbordesc(d.bd)) + return -1 } return d.decLen() } +func (d *cborDecDriver) decLen() int { + return int(d.decUint()) +} + +func (d *cborDecDriver) decAppendIndefiniteBytes(bs []byte) []byte { + d.bdRead = false + for { + if d.CheckBreak() { + break + } + if major := d.bd >> 5; major != cborMajorBytes && major != cborMajorText { + d.d.errorf("expect bytes/string major type in indefinite string/bytes;"+ + " got major %v from descriptor %x/%x", major, d.bd, cbordesc(d.bd)) + return nil + } + n := d.decLen() + oldLen := len(bs) + newLen := oldLen + n + if newLen > cap(bs) { + bs2 := make([]byte, newLen, 2*cap(bs)+n) + copy(bs2, bs) + bs = bs2 + } else { + bs = bs[:newLen] + } + d.r.readb(bs[oldLen:newLen]) + // bs = append(bs, d.r.readn()...) + d.bdRead = false + } + d.bdRead = false + return bs +} + func (d *cborDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { - if d.advanceNil() { - return + if !d.bdRead { + d.readNextBd() } - if d.st { - d.skipTags() + if d.bd == cborBdNil || d.bd == cborBdUndefined { + d.bdRead = false + return nil } if d.bd == cborBdIndefiniteBytes || d.bd == cborBdIndefiniteString { d.bdRead = false @@ -595,43 +534,25 @@ func (d *cborDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { } return d.decAppendIndefiniteBytes(bs[:0]) } - if d.bd == cborBdIndefiniteArray { - d.bdRead = false - if zerocopy && len(bs) == 0 { - bs = d.d.b[:] - } - if bs == nil { - bs = []byte{} - } else { - bs = bs[:0] - } - for !d.CheckBreak() { - bs = append(bs, uint8(chkOvf.UintV(d.DecodeUint64(), 8))) - } - return bs - } - if d.bd>>5 == cborMajorArray { - d.bdRead = false - if zerocopy && len(bs) == 0 { - bs = d.d.b[:] - } - slen := d.decLen() - bs = usableByteSlice(bs, slen) - for i := 0; i < len(bs); i++ { - bs[i] = uint8(chkOvf.UintV(d.DecodeUint64(), 8)) - } - return bs + // 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.d.bytes { - return d.d.decRd.readx(uint(clen)) + if d.br { + return d.r.readx(uint(clen)) } else if len(bs) == 0 { bs = d.d.b[:] } } - return decByteSlice(d.d.r(), clen, d.h.MaxInitLen, bs) + return decByteSlice(d.r, clen, d.h.MaxInitLen, bs) +} + +func (d *cborDecDriver) DecodeString() (s string) { + return string(d.DecodeBytes(d.d.b[:], true)) } func (d *cborDecDriver) DecodeStringAsBytes() (s []byte) { @@ -639,11 +560,12 @@ func (d *cborDecDriver) DecodeStringAsBytes() (s []byte) { } func (d *cborDecDriver) DecodeTime() (t time.Time) { - if d.advanceNil() { - return + if !d.bdRead { + d.readNextBd() } - if d.bd>>5 != cborMajorTag { - d.d.errorf("error reading tag; expected major type: %x, got: %x", cborMajorTag, d.bd>>5) + if d.bd == cborBdNil || d.bd == cborBdUndefined { + d.bdRead = false + return } xtag := d.decUint() d.bdRead = false @@ -651,6 +573,9 @@ func (d *cborDecDriver) DecodeTime() (t time.Time) { } func (d *cborDecDriver) decodeTime(xtag uint64) (t time.Time) { + if !d.bdRead { + d.readNextBd() + } switch xtag { case 0: var err error @@ -658,8 +583,21 @@ func (d *cborDecDriver) decodeTime(xtag uint64) (t time.Time) { d.d.errorv(err) } case 1: - f1, f2 := math.Modf(d.DecodeFloat64()) - t = time.Unix(int64(f1), int64(f2*1e9)) + // 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) } @@ -667,15 +605,13 @@ func (d *cborDecDriver) decodeTime(xtag uint64) (t time.Time) { return } -func (d *cborDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) { - if d.advanceNil() { - return - } - if d.bd>>5 != cborMajorTag { - d.d.errorf("error reading tag; expected major type: %x, got: %x", cborMajorTag, d.bd>>5) +func (d *cborDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxtag uint64) { + if !d.bdRead { + d.readNextBd() } - realxtag := d.decUint() + u := d.decUint() d.bdRead = false + realxtag = u if ext == nil { re := rv.(*RawExt) re.Tag = realxtag @@ -683,13 +619,13 @@ func (d *cborDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) { } else if xtag != realxtag { d.d.errorf("Wrong extension tag. Got %b. Expecting: %v", realxtag, xtag) return - } else if ext == SelfExt { - rv2 := baseRV(rv) - d.d.decodeValue(rv2, d.h.fnNoExt(rv2.Type())) } else { - d.d.interfaceExtConvertAndDecode(rv, ext) + var v interface{} + d.d.decode(&v) + ext.UpdateExt(rv, v) } d.bdRead = false + return } func (d *cborDecDriver) DecodeNaked() { @@ -697,78 +633,74 @@ func (d *cborDecDriver) DecodeNaked() { d.readNextBd() } - d.fnil = false n := d.d.naked() var decodeFurther bool - switch d.bd >> 5 { - case cborMajorUint: - if d.h.SignedInteger { - n.v = valueTypeInt - n.i = d.DecodeInt64() - } else { - n.v = valueTypeUint - n.u = d.DecodeUint64() - } - case cborMajorNegInt: - n.v = valueTypeInt - n.i = d.DecodeInt64() - case cborMajorBytes: - decNakedReadRawBytes(d, &d.d, n, d.h.RawToString) - case cborMajorString: + switch d.bd { + case cborBdNil: + n.v = valueTypeNil + case cborBdFalse: + n.v = valueTypeBool + n.b = false + case cborBdTrue: + n.v = valueTypeBool + n.b = true + case cborBdFloat16, cborBdFloat32, cborBdFloat64: + n.v = valueTypeFloat + n.f = d.DecodeFloat64() + case cborBdIndefiniteBytes: + decNakedReadRawBytes(d, d.d, n, d.h.RawToString) + case cborBdIndefiniteString: n.v = valueTypeString - n.s = string(d.DecodeStringAsBytes()) - case cborMajorArray: + n.s = d.DecodeString() + case cborBdIndefiniteArray: n.v = valueTypeArray decodeFurther = true - case cborMajorMap: + case cborBdIndefiniteMap: n.v = valueTypeMap decodeFurther = true - case cborMajorTag: - 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) - } else if d.st && d.h.getExtForTag(n.u) == nil { - // d.skipTags() // no need to call this - tags already skipped - d.bdRead = false - d.DecodeNaked() - return // return when done (as true recursive function) - } - case cborMajorSimpleOrFloat: - switch d.bd { - case cborBdNil, cborBdUndefined: - n.v = valueTypeNil - d.fnil = true - case cborBdFalse: - n.v = valueTypeBool - n.b = false - case cborBdTrue: - n.v = valueTypeBool - n.b = true - case cborBdFloat16, cborBdFloat32, cborBdFloat64: - n.v = valueTypeFloat - n.f = d.DecodeFloat64() - case cborBdIndefiniteBytes: - decNakedReadRawBytes(d, &d.d, n, d.h.RawToString) - case cborBdIndefiniteString: + default: + switch { + case d.bd >= cborBaseUint && d.bd < cborBaseNegInt: + if d.h.SignedInteger { + n.v = valueTypeInt + n.i = d.DecodeInt64() + } else { + n.v = valueTypeUint + n.u = d.DecodeUint64() + } + case d.bd >= cborBaseNegInt && d.bd < cborBaseBytes: + n.v = valueTypeInt + n.i = d.DecodeInt64() + case d.bd >= cborBaseBytes && d.bd < cborBaseString: + decNakedReadRawBytes(d, d.d, n, d.h.RawToString) + case d.bd >= cborBaseString && d.bd < cborBaseArray: n.v = valueTypeString - n.s = string(d.DecodeStringAsBytes()) - case cborBdIndefiniteArray: + n.s = d.DecodeString() + case d.bd >= cborBaseArray && d.bd < cborBaseMap: n.v = valueTypeArray decodeFurther = true - case cborBdIndefiniteMap: + case d.bd >= cborBaseMap && d.bd < cborBaseTag: n.v = valueTypeMap decodeFurther = true + case d.bd >= cborBaseTag && d.bd < cborBaseSimple: + 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 default: d.d.errorf("decodeNaked: Unrecognized d.bd: 0x%x", d.bd) + return } - default: // should never happen - d.d.errorf("decodeNaked: Unrecognized d.bd: 0x%x", d.bd) } + if !decodeFurther { d.bdRead = false } @@ -793,7 +725,7 @@ func (d *cborDecDriver) DecodeNaked() { // - Encoded Text (e.g. URL, regexp, base64, MIME Message), etc. type CborHandle struct { binaryEncodingType - // noElemSeparators + noElemSeparators BasicHandle // IndefiniteLength=true, means that we encode using indefinitelength @@ -803,43 +735,32 @@ type CborHandle struct { // If unset, we encode time.Time using seconds past epoch. TimeRFC3339 bool - // SkipUnexpectedTags says to skip over any tags for which extensions are - // not defined. This is in keeping with the cbor spec on "Optional Tagging of Items". - // - // Furthermore, this allows the skipping over of the Self Describing Tag 0xd9d9f7. - SkipUnexpectedTags bool - - _ [7]uint64 // padding (cache-aligned) + // _ [1]uint64 // padding } // Name returns the name of the handle: cbor func (h *CborHandle) Name() string { return "cbor" } -func (h *CborHandle) newEncDriver() encDriver { - var e = &cborEncDriver{h: h} - e.e.e = e - e.e.init(h) - e.reset() - return e +// SetInterfaceExt sets an extension +func (h *CborHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) { + return h.SetExt(rt, tag, &extWrapper{bytesExtFailer{}, ext}) } -func (h *CborHandle) newDecDriver() decDriver { - d := &cborDecDriver{h: h, st: h.SkipUnexpectedTags} - d.d.d = d - d.d.cbor = true - d.d.init(h) - d.reset() - return d +func (h *CborHandle) newEncDriver(e *Encoder) encDriver { + return &cborEncDriver{e: e, w: e.w, h: h} +} + +func (h *CborHandle) newDecDriver(d *Decoder) decDriver { + return &cborDecDriver{d: d, h: h, r: d.r, br: d.bytes} } func (e *cborEncDriver) reset() { + e.w = e.e.w } func (d *cborDecDriver) reset() { - d.bd = 0 - d.bdRead = false - d.fnil = false - d.st = d.h.SkipUnexpectedTags + d.r, d.br = d.d.r, d.d.bytes + d.bd, d.bdRead = 0, false } var _ decDriver = (*cborDecDriver)(nil) diff --git a/vendor/github.com/ugorji/go/codec/decode.go b/vendor/github.com/ugorji/go/codec/decode.go index a33252bd4cd9..1f14e7a51aa9 100644 --- a/vendor/github.com/ugorji/go/codec/decode.go +++ b/vendor/github.com/ugorji/go/codec/decode.go @@ -8,8 +8,8 @@ import ( "errors" "fmt" "io" - "math" "reflect" + "runtime" "strconv" "time" ) @@ -23,37 +23,15 @@ const ( const ( decDefMaxDepth = 1024 // maximum depth decDefSliceCap = 8 - decDefChanCap = 64 // should be large, as cap cannot be expanded - decScratchByteArrayLen = (6 * 8) // ??? cacheLineSize + - - // decContainerLenUnknown is length returned from Read(Map|Array)Len - // when a format doesn't know apiori. - // For example, json doesn't pre-determine the length of a container (sequence/map). - decContainerLenUnknown = -1 - - // decContainerLenNil is length returned from Read(Map|Array)Len - // when a 'nil' was encountered in the stream. - decContainerLenNil = math.MinInt32 - - // decFailNonEmptyIntf configures whether we error - // when decoding naked into a non-empty interface. - // - // Typically, we cannot decode non-nil stream value into - // nil interface with methods (e.g. io.Reader). - // However, in some scenarios, this should be allowed: - // - MapType - // - SliceType - // - Extensions - // - // Consequently, we should relax this. Put it behind a const flag for now. - decFailNonEmptyIntf = false + decDefChanCap = 64 // should be large, as cap cannot be expanded + decScratchByteArrayLen = cacheLineSize // + (8 * 2) // - (8 * 1) ) var ( errstrOnlyMapOrArrayCanDecodeIntoStruct = "only encoded map or array can be decoded into a struct" errstrCannotDecodeIntoNil = "cannot decode into nil" - // errmsgExpandSliceOverflow = "expand slice: slice overflow" + errmsgExpandSliceOverflow = "expand slice: slice overflow" errmsgExpandSliceCannotChange = "expand slice: cannot change" errDecoderNotInitialized = errors.New("Decoder not initialized") @@ -62,23 +40,48 @@ var ( errDecUnreadByteLastByteNotRead = errors.New("cannot unread - last byte has not been read") errDecUnreadByteUnknown = errors.New("cannot unread - reason unknown") errMaxDepthExceeded = errors.New("maximum decoding depth exceeded") - - errBytesDecReaderCannotUnread = errors.New("cannot unread last byte read") ) +/* + +// decReader abstracts the reading source, allowing implementations that can +// read from an io.Reader or directly off a byte slice with zero-copying. +// +// Deprecated: Use decReaderSwitch instead. +type decReader interface { + unreadn1() + // readx will use the implementation scratch buffer if possible i.e. n < len(scratchbuf), OR + // just return a view of the []byte being decoded from. + // Ensure you call detachZeroCopyBytes later if this needs to be sent outside codec control. + readx(n int) []byte + readb([]byte) + readn1() uint8 + numread() uint // number of bytes read + track() + stopTrack() []byte + + // skip will skip any byte that matches, and return the first non-matching byte + skip(accept *bitset256) (token byte) + // readTo will read any byte that matches, stopping once no-longer matching. + readTo(in []byte, accept *bitset256) (out []byte) + // readUntil will read, only stopping once it matches the 'stop' byte. + readUntil(in []byte, stop byte) (out []byte) +} + +*/ + type decDriver interface { // this will check if the next token is a break. CheckBreak() bool - - // TryNil tries to decode as nil. - TryNil() bool - - // ContainerType returns one of: Bytes, String, Nil, Slice or Map. - // - // Return unSet if not known. - // - // Note: Implementations MUST fully consume sentinel container types, specifically Nil. + // TryDecodeAsNil tries to decode as nil. + // Note: TryDecodeAsNil should be careful not to share any temporary []byte with + // the rest of the decDriver. This is because sometimes, we optimize by holding onto + // a transient []byte, and ensuring the only other call we make to the decDriver + // during that time is maybe a TryDecodeAsNil() call. + TryDecodeAsNil() bool + // ContainerType returns one of: Bytes, String, Nil, Slice or Map. Return unSet if not known. ContainerType() (vt valueType) + // IsBuiltinType(rt uintptr) bool // 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 @@ -93,18 +96,21 @@ type decDriver interface { // kInterface will extract the detached byte slice if it has to pass it outside its realm. DecodeNaked() + // 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) - - // DecodeStringAsBytes returns the bytes representing a string. - // By definition, it will return a view into a scratch buffer. - // - // Note: This can also decode symbols, if supported. - // - // Users should consume it right away and not store it for later use. + // DecodeString can also decode symbols. + // It looks redundant as DecodeBytes is available. + // However, some codecs (e.g. binc) support symbols and can + // return a pre-stored string value, meaning that it can bypass + // the cost of []byte->string conversion. + DecodeString() (s string) DecodeStringAsBytes() (v []byte) // DecodeBytes may be called directly, without going through reflection. @@ -112,35 +118,22 @@ type decDriver interface { DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) // DecodeBytes(bs []byte, isstring, zerocopy bool) (bsOut []byte) - // DecodeExt will decode into a *RawExt or into an extension. - DecodeExt(v interface{}, xtag uint64, ext Ext) + // 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 will return the length of the array. - // If the format doesn't prefix the length, it returns decContainerLenUnknown. - // If the expected array was a nil in the stream, it returns decContainerLenNil. ReadArrayStart() int + ReadArrayElem() ReadArrayEnd() - - // ReadMapStart will return the length of the array. - // If the format doesn't prefix the length, it returns decContainerLenUnknown. - // If the expected array was a nil in the stream, it returns decContainerLenNil. ReadMapStart() int + ReadMapElemKey() + ReadMapElemValue() ReadMapEnd() reset() - atEndOfDecode() uncacheRead() - - decoder() *Decoder -} - -type decDriverContainerTracker interface { - ReadArrayElem() - ReadMapElemKey() - ReadMapElemValue() } type decodeError struct { @@ -155,11 +148,15 @@ func (d decodeError) Error() string { type decDriverNoopContainerReader struct{} 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 (x decDriverNoopContainerReader) atEndOfDecode() {} + +// func (x decNoSeparator) uncacheRead() {} // DecodeOptions captures configuration options during decode. type DecodeOptions struct { @@ -249,7 +246,6 @@ type DecodeOptions struct { // PreferArrayOverSlice controls whether to decode to an array or a slice. // // This only impacts decoding into a nil interface{}. - // // Consequently, it has no effect on codecgen. // // *Note*: This only applies if using go1.5 and above, @@ -260,10 +256,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. - // - // Deprecated: This does NOTHING and is left behind for compiling compatibility. - // This change is necessitated because 'nil' in a stream now consistently - // means the zero value (ie reset the value to its zero state). DeleteOnNilMapValue bool // RawToString controls how raw bytes in a stream are decoded into a nil interface{}. @@ -271,136 +263,986 @@ type DecodeOptions struct { RawToString bool } -// ---------------------------------------- +// ------------------------------------------------ -func (d *Decoder) rawExt(f *codecFnInfo, rv reflect.Value) { - d.d.DecodeExt(rv2i(rv), 0, nil) +type unreadByteStatus uint8 + +// unreadByteStatus goes from +// undefined (when initialized) -- (read) --> canUnread -- (unread) --> canRead ... +const ( + unreadByteUndefined unreadByteStatus = iota + unreadByteCanRead + unreadByteCanUnread +) + +type ioDecReaderCommon struct { + r io.Reader // the reader passed in + + n uint // num read + + l byte // last byte + ls unreadByteStatus // last byte status + trb bool // tracking bytes turned on + _ bool + b [4]byte // tiny buffer for reading single bytes + + tr []byte // tracking bytes read } -func (d *Decoder) ext(f *codecFnInfo, rv reflect.Value) { - d.d.DecodeExt(rv2i(rv), f.xfTag, f.xfFn) +func (z *ioDecReaderCommon) reset(r io.Reader) { + z.r = r + z.ls = unreadByteUndefined + z.l, z.n = 0, 0 + z.trb = false + if z.tr != nil { + z.tr = z.tr[:0] + } } -func (d *Decoder) selferUnmarshal(f *codecFnInfo, rv reflect.Value) { - rv2i(rv).(Selfer).CodecDecodeSelf(d) +func (z *ioDecReaderCommon) numread() uint { + return z.n } -func (d *Decoder) binaryUnmarshal(f *codecFnInfo, rv reflect.Value) { - bm := rv2i(rv).(encoding.BinaryUnmarshaler) - xbs := d.d.DecodeBytes(nil, true) - if fnerr := bm.UnmarshalBinary(xbs); fnerr != nil { - panic(fnerr) +func (z *ioDecReaderCommon) track() { + if z.tr != nil { + z.tr = z.tr[:0] } + z.trb = true } -func (d *Decoder) textUnmarshal(f *codecFnInfo, rv reflect.Value) { - tm := rv2i(rv).(encoding.TextUnmarshaler) - fnerr := tm.UnmarshalText(d.d.DecodeStringAsBytes()) - if fnerr != nil { - panic(fnerr) +func (z *ioDecReaderCommon) stopTrack() (bs []byte) { + z.trb = false + return z.tr +} + +// ------------------------------------------ + +// ioDecReader is a decReader that reads off an io.Reader. +// +// It also has a fallback implementation of ByteScanner if needed. +type ioDecReader struct { + ioDecReaderCommon + + rr io.Reader + br io.ByteScanner + + x [scratchByteArrayLen]byte // for: get struct field name, swallow valueTypeBytes, etc + _ [1]uint64 // padding +} + +func (z *ioDecReader) reset(r io.Reader) { + z.ioDecReaderCommon.reset(r) + + var ok bool + z.rr = r + z.br, ok = r.(io.ByteScanner) + if !ok { + z.br = z + z.rr = z } } -func (d *Decoder) jsonUnmarshal(f *codecFnInfo, rv reflect.Value) { - 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()) - if fnerr != nil { - panic(fnerr) +func (z *ioDecReader) Read(p []byte) (n int, err error) { + if len(p) == 0 { + return + } + var firstByte bool + if z.ls == unreadByteCanRead { + z.ls = unreadByteCanUnread + p[0] = z.l + if len(p) == 1 { + n = 1 + return + } + firstByte = true + p = p[1:] } + n, err = z.r.Read(p) + if n > 0 { + if err == io.EOF && n == len(p) { + err = nil // read was successful, so postpone EOF (till next time) + } + z.l = p[n-1] + z.ls = unreadByteCanUnread + } + if firstByte { + n++ + } + return } -func (d *Decoder) kErr(f *codecFnInfo, rv reflect.Value) { - d.errorf("no decoding function defined for kind %v", rv.Kind()) +func (z *ioDecReader) ReadByte() (c byte, err error) { + n, err := z.Read(z.b[:1]) + if n == 1 { + c = z.b[0] + if err == io.EOF { + err = nil // read was successful, so postpone EOF (till next time) + } + } + return +} + +func (z *ioDecReader) UnreadByte() (err error) { + switch z.ls { + case unreadByteCanUnread: + z.ls = unreadByteCanRead + case unreadByteCanRead: + err = errDecUnreadByteLastByteNotRead + case unreadByteUndefined: + err = errDecUnreadByteNothingToRead + default: + err = errDecUnreadByteUnknown + } + return +} + +func (z *ioDecReader) readx(n uint) (bs []byte) { + if n == 0 { + return + } + if n < uint(len(z.x)) { + bs = z.x[:n] + } else { + bs = make([]byte, n) + } + if _, err := decReadFull(z.rr, bs); err != nil { + panic(err) + } + z.n += uint(len(bs)) + if z.trb { + z.tr = append(z.tr, bs...) + } + return +} + +func (z *ioDecReader) readb(bs []byte) { + if len(bs) == 0 { + return + } + if _, err := decReadFull(z.rr, bs); err != nil { + panic(err) + } + z.n += uint(len(bs)) + if z.trb { + z.tr = append(z.tr, bs...) + } +} + +func (z *ioDecReader) readn1eof() (b uint8, eof bool) { + b, err := z.br.ReadByte() + if err == nil { + z.n++ + if z.trb { + z.tr = append(z.tr, b) + } + } else if err == io.EOF { + eof = true + } else { + panic(err) + } + return +} + +func (z *ioDecReader) readn1() (b uint8) { + b, err := z.br.ReadByte() + if err == nil { + z.n++ + if z.trb { + z.tr = append(z.tr, b) + } + return + } + panic(err) +} + +func (z *ioDecReader) skip(accept *bitset256) (token byte) { + var eof bool + // for { + // token, eof = z.readn1eof() + // if eof { + // return + // } + // if accept.isset(token) { + // continue + // } + // return + // } +LOOP: + token, eof = z.readn1eof() + if eof { + return + } + if accept.isset(token) { + goto LOOP + } + return +} + +func (z *ioDecReader) readTo(in []byte, accept *bitset256) []byte { + // out = in + + // for { + // token, eof := z.readn1eof() + // if eof { + // return + // } + // if accept.isset(token) { + // out = append(out, token) + // } else { + // z.unreadn1() + // return + // } + // } +LOOP: + token, eof := z.readn1eof() + if eof { + return in + } + if accept.isset(token) { + // out = append(out, token) + in = append(in, token) + goto LOOP + } + z.unreadn1() + return in +} + +func (z *ioDecReader) readUntil(in []byte, stop byte) (out []byte) { + out = in + // for { + // token, eof := z.readn1eof() + // if eof { + // panic(io.EOF) + // } + // out = append(out, token) + // if token == stop { + // return + // } + // } +LOOP: + token, eof := z.readn1eof() + if eof { + panic(io.EOF) + } + out = append(out, token) + if token == stop { + return + } + goto LOOP +} + +//go:noinline +func (z *ioDecReader) unreadn1() { + err := z.br.UnreadByte() + if err != nil { + panic(err) + } + z.n-- + if z.trb { + if l := len(z.tr) - 1; l >= 0 { + z.tr = z.tr[:l] + } + } +} + +// ------------------------------------ + +type bufioDecReader struct { + ioDecReaderCommon + + c uint // cursor + buf []byte + + bytesBufPooler + + // err error + + // Extensions can call Decode() within a current Decode() call. + // We need to know when the top level Decode() call returns, + // so we can decide whether to Release() or not. + calls uint16 // what depth in mustDecode are we in now. + + _ [6]uint8 // padding + + _ [1]uint64 // padding +} + +func (z *bufioDecReader) reset(r io.Reader, bufsize int) { + z.ioDecReaderCommon.reset(r) + z.c = 0 + z.calls = 0 + if cap(z.buf) >= bufsize { + z.buf = z.buf[:0] + } else { + z.buf = z.bytesBufPooler.get(bufsize)[:0] + // z.buf = make([]byte, 0, bufsize) + } +} + +func (z *bufioDecReader) release() { + z.buf = nil + z.bytesBufPooler.end() +} + +func (z *bufioDecReader) readb(p []byte) { + var n = uint(copy(p, z.buf[z.c:])) + z.n += n + z.c += n + if len(p) == int(n) { + if z.trb { + z.tr = append(z.tr, p...) // cost=9 + } + } else { + z.readbFill(p, n) + } +} + +//go:noinline - fallback when z.buf is consumed +func (z *bufioDecReader) readbFill(p0 []byte, n uint) { + // at this point, there's nothing in z.buf to read (z.buf is fully consumed) + p := p0[n:] + var n2 uint + var err error + if len(p) > cap(z.buf) { + n2, err = decReadFull(z.r, p) + if err != nil { + panic(err) + } + n += n2 + z.n += n2 + // always keep last byte in z.buf + z.buf = z.buf[:1] + z.buf[0] = p[len(p)-1] + z.c = 1 + if z.trb { + z.tr = append(z.tr, p0[:n]...) + } + return + } + // z.c is now 0, and len(p) <= cap(z.buf) +LOOP: + // for len(p) > 0 && z.err == nil { + if len(p) > 0 { + z.buf = z.buf[0:cap(z.buf)] + var n1 int + n1, err = z.r.Read(z.buf) + n2 = uint(n1) + if n2 == 0 && err != nil { + panic(err) + } + z.buf = z.buf[:n2] + n2 = uint(copy(p, z.buf)) + z.c = n2 + n += n2 + z.n += n2 + p = p[n2:] + goto LOOP + } + if z.c == 0 { + z.buf = z.buf[:1] + z.buf[0] = p[len(p)-1] + z.c = 1 + } + if z.trb { + z.tr = append(z.tr, p0[:n]...) + } +} + +func (z *bufioDecReader) readn1() (b byte) { + // fast-path, so we elide calling into Read() most of the time + if z.c < uint(len(z.buf)) { + b = z.buf[z.c] + z.c++ + z.n++ + if z.trb { + z.tr = append(z.tr, b) + } + } else { // meaning z.c == len(z.buf) or greater ... so need to fill + z.readbFill(z.b[:1], 0) + b = z.b[0] + } + return +} + +func (z *bufioDecReader) unreadn1() { + if z.c == 0 { + panic(errDecUnreadByteNothingToRead) + } + z.c-- + z.n-- + if z.trb { + z.tr = z.tr[:len(z.tr)-1] + } +} + +func (z *bufioDecReader) readx(n uint) (bs []byte) { + if n == 0 { + // return + } else if z.c+n <= uint(len(z.buf)) { + bs = z.buf[z.c : z.c+n] + z.n += n + z.c += n + if z.trb { + z.tr = append(z.tr, bs...) + } + } else { + bs = make([]byte, n) + // n no longer used - can reuse + n = uint(copy(bs, z.buf[z.c:])) + z.n += n + z.c += n + z.readbFill(bs, n) + } + return +} + +//go:noinline - track called by Decoder.nextValueBytes() (called by jsonUnmarshal,rawBytes) +func (z *bufioDecReader) doTrack(y uint) { + z.tr = append(z.tr, z.buf[z.c:y]...) // cost=14??? +} + +func (z *bufioDecReader) skipLoopFn(i uint) { + z.n += (i - z.c) - 1 + i++ + if z.trb { + // z.tr = append(z.tr, z.buf[z.c:i]...) + z.doTrack(i) + } + z.c = i +} + +func (z *bufioDecReader) skip(accept *bitset256) (token byte) { + // token, _ = z.search(nil, accept, 0, 1); return + + // for i := z.c; i < len(z.buf); i++ { + // if token = z.buf[i]; !accept.isset(token) { + // z.skipLoopFn(i) + // return + // } + // } + + i := z.c +LOOP: + if i < uint(len(z.buf)) { + // inline z.skipLoopFn(i) and refactor, so cost is within inline budget + token = z.buf[i] + i++ + if accept.isset(token) { + goto LOOP + } + z.n += i - 2 - z.c + if z.trb { + z.doTrack(i) + } + z.c = i + return + } + return z.skipFill(accept) +} + +func (z *bufioDecReader) skipFill(accept *bitset256) (token byte) { + z.n += uint(len(z.buf)) - z.c + if z.trb { + z.tr = append(z.tr, z.buf[z.c:]...) + } + var n2 int + var err error + for { + z.c = 0 + z.buf = z.buf[0:cap(z.buf)] + n2, err = z.r.Read(z.buf) + if n2 == 0 && err != nil { + panic(err) + } + z.buf = z.buf[:n2] + var i int + for i, token = range z.buf { + if !accept.isset(token) { + z.skipLoopFn(uint(i)) + return + } + } + // for i := 0; i < n2; i++ { + // if token = z.buf[i]; !accept.isset(token) { + // z.skipLoopFn(i) + // return + // } + // } + z.n += uint(n2) + if z.trb { + z.tr = append(z.tr, z.buf...) + } + } +} + +func (z *bufioDecReader) readToLoopFn(i uint, out0 []byte) (out []byte) { + // out0 is never nil + z.n += (i - z.c) - 1 + out = append(out0, z.buf[z.c:i]...) + if z.trb { + z.doTrack(i) + } + z.c = i + return +} + +func (z *bufioDecReader) readTo(in []byte, accept *bitset256) (out []byte) { + // _, out = z.search(in, accept, 0, 2); return + + // for i := z.c; i < len(z.buf); i++ { + // if !accept.isset(z.buf[i]) { + // return z.readToLoopFn(i, nil) + // } + // } + + i := z.c +LOOP: + if i < uint(len(z.buf)) { + if !accept.isset(z.buf[i]) { + // return z.readToLoopFn(i, nil) + // inline readToLoopFn here (for performance) + z.n += (i - z.c) - 1 + out = z.buf[z.c:i] + if z.trb { + z.doTrack(i) + } + z.c = i + return + } + i++ + goto LOOP + } + return z.readToFill(in, accept) +} + +func (z *bufioDecReader) readToFill(in []byte, accept *bitset256) (out []byte) { + z.n += uint(len(z.buf)) - z.c + out = append(in, z.buf[z.c:]...) + if z.trb { + z.tr = append(z.tr, z.buf[z.c:]...) + } + var n2 int + var err error + for { + z.c = 0 + z.buf = z.buf[0:cap(z.buf)] + n2, err = z.r.Read(z.buf) + if n2 == 0 && err != nil { + if err == io.EOF { + return // readTo should read until it matches or end is reached + } + panic(err) + } + z.buf = z.buf[:n2] + for i, token := range z.buf { + if !accept.isset(token) { + return z.readToLoopFn(uint(i), out) + } + } + // for i := 0; i < n2; i++ { + // if !accept.isset(z.buf[i]) { + // return z.readToLoopFn(i, out) + // } + // } + out = append(out, z.buf...) + z.n += uint(n2) + if z.trb { + z.tr = append(z.tr, z.buf...) + } + } } -func (d *Decoder) raw(f *codecFnInfo, rv reflect.Value) { - rvSetBytes(rv, d.rawBytes()) +func (z *bufioDecReader) readUntilLoopFn(i uint, out0 []byte) (out []byte) { + z.n += (i - z.c) - 1 + i++ + out = append(out0, z.buf[z.c:i]...) + if z.trb { + // z.tr = append(z.tr, z.buf[z.c:i]...) + z.doTrack(i) + } + z.c = i + return } -func (d *Decoder) kString(f *codecFnInfo, rv reflect.Value) { - rvSetString(rv, string(d.d.DecodeStringAsBytes())) +func (z *bufioDecReader) readUntil(in []byte, stop byte) (out []byte) { + // _, out = z.search(in, nil, stop, 4); return + + // for i := z.c; i < len(z.buf); i++ { + // if z.buf[i] == stop { + // return z.readUntilLoopFn(i, nil) + // } + // } + + i := z.c +LOOP: + if i < uint(len(z.buf)) { + if z.buf[i] == stop { + // inline readUntilLoopFn + // return z.readUntilLoopFn(i, nil) + z.n += (i - z.c) - 1 + i++ + out = z.buf[z.c:i] + if z.trb { + z.doTrack(i) + } + z.c = i + return + } + i++ + goto LOOP + } + return z.readUntilFill(in, stop) +} + +func (z *bufioDecReader) readUntilFill(in []byte, stop byte) (out []byte) { + z.n += uint(len(z.buf)) - z.c + out = append(in, z.buf[z.c:]...) + if z.trb { + z.tr = append(z.tr, z.buf[z.c:]...) + } + var n1 int + var n2 uint + var err error + for { + z.c = 0 + z.buf = z.buf[0:cap(z.buf)] + n1, err = z.r.Read(z.buf) + n2 = uint(n1) + if n2 == 0 && err != nil { + panic(err) + } + z.buf = z.buf[:n2] + for i, token := range z.buf { + if token == stop { + return z.readUntilLoopFn(uint(i), out) + } + } + // for i := 0; i < n2; i++ { + // if z.buf[i] == stop { + // return z.readUntilLoopFn(i, out) + // } + // } + out = append(out, z.buf...) + z.n += n2 + if z.trb { + z.tr = append(z.tr, z.buf...) + } + } } -func (d *Decoder) kBool(f *codecFnInfo, rv reflect.Value) { - rvSetBool(rv, d.d.DecodeBool()) +// ------------------------------------ + +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 { + b []byte // data + c uint // cursor + t uint // track start + // a int // available } -func (d *Decoder) kTime(f *codecFnInfo, rv reflect.Value) { - rvSetTime(rv, d.d.DecodeTime()) +func (z *bytesDecReader) reset(in []byte) { + z.b = in + // z.a = len(in) + z.c = 0 + z.t = 0 } -func (d *Decoder) kFloat32(f *codecFnInfo, rv reflect.Value) { - rvSetFloat32(rv, d.decodeFloat32()) +func (z *bytesDecReader) numread() uint { + return z.c } -func (d *Decoder) kFloat64(f *codecFnInfo, rv reflect.Value) { - rvSetFloat64(rv, d.d.DecodeFloat64()) +func (z *bytesDecReader) unreadn1() { + if z.c == 0 || len(z.b) == 0 { + panic(errBytesDecReaderCannotUnread) + } + z.c-- + // z.a++ } -func (d *Decoder) kInt(f *codecFnInfo, rv reflect.Value) { - rvSetInt(rv, int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))) +func (z *bytesDecReader) readx(n uint) (bs []byte) { + // slicing from a non-constant start position is more expensive, + // as more computation is required to decipher the pointer start position. + // However, we do it only once, and it's better than reslicing both z.b and return value. + + // if n <= 0 { + // } else if z.a == 0 { + // panic(io.EOF) + // } else if n > z.a { + // panic(io.ErrUnexpectedEOF) + // } else { + // c0 := z.c + // z.c = c0 + n + // z.a = z.a - n + // bs = z.b[c0:z.c] + // } + // return + + if n != 0 { + z.c += n + if z.c > uint(len(z.b)) { + z.c = uint(len(z.b)) + panic(io.EOF) + } + bs = z.b[z.c-n : z.c] + } + return + + // if n == 0 { + // } else if z.c+n > uint(len(z.b)) { + // z.c = uint(len(z.b)) + // panic(io.EOF) + // } else { + // z.c += n + // bs = z.b[z.c-n : z.c] + // } + // return + + // if n == 0 { + // return + // } + // if z.c == uint(len(z.b)) { + // panic(io.EOF) + // } + // if z.c+n > uint(len(z.b)) { + // panic(io.ErrUnexpectedEOF) + // } + // // z.a -= n + // z.c += n + // return z.b[z.c-n : z.c] +} + +func (z *bytesDecReader) readb(bs []byte) { + copy(bs, z.readx(uint(len(bs)))) +} + +func (z *bytesDecReader) readn1() (v uint8) { + if z.c == uint(len(z.b)) { + panic(io.EOF) + } + v = z.b[z.c] + z.c++ + // z.a-- + return } -func (d *Decoder) kInt8(f *codecFnInfo, rv reflect.Value) { - rvSetInt8(rv, int8(chkOvf.IntV(d.d.DecodeInt64(), 8))) +// func (z *bytesDecReader) readn1eof() (v uint8, eof bool) { +// if z.a == 0 { +// eof = true +// return +// } +// v = z.b[z.c] +// z.c++ +// z.a-- +// return +// } + +func (z *bytesDecReader) skip(accept *bitset256) (token byte) { + i := z.c + // if i == len(z.b) { + // goto END + // // panic(io.EOF) + // } + + // Replace loop with goto construct, so that this can be inlined + // for i := z.c; i < blen; i++ { + // if !accept.isset(z.b[i]) { + // token = z.b[i] + // i++ + // z.a -= (i - z.c) + // z.c = i + // return + // } + // } + + // i := z.c +LOOP: + if i < uint(len(z.b)) { + token = z.b[i] + i++ + if accept.isset(token) { + goto LOOP + } + // z.a -= (i - z.c) + z.c = i + return + } + // END: + panic(io.EOF) + // // z.a = 0 + // z.c = blen + // return +} + +func (z *bytesDecReader) readTo(_ []byte, accept *bitset256) (out []byte) { + return z.readToNoInput(accept) +} + +func (z *bytesDecReader) readToNoInput(accept *bitset256) (out []byte) { + i := z.c + if i == uint(len(z.b)) { + panic(io.EOF) + } + + // Replace loop with goto construct, so that this can be inlined + // for i := z.c; i < blen; i++ { + // if !accept.isset(z.b[i]) { + // out = z.b[z.c:i] + // z.a -= (i - z.c) + // z.c = i + // return + // } + // } + // out = z.b[z.c:] + // z.a, z.c = 0, blen + // return + + // i := z.c + // LOOP: + // if i < blen { + // if accept.isset(z.b[i]) { + // i++ + // goto LOOP + // } + // out = z.b[z.c:i] + // z.a -= (i - z.c) + // z.c = i + // return + // } + // out = z.b[z.c:] + // // z.a, z.c = 0, blen + // z.a = 0 + // z.c = blen + // return + + // c := i +LOOP: + if i < uint(len(z.b)) { + if accept.isset(z.b[i]) { + i++ + goto LOOP + } + } + + out = z.b[z.c:i] + // z.a -= (i - z.c) + z.c = i + return // z.b[c:i] + // z.c, i = i, z.c + // return z.b[i:z.c] +} + +func (z *bytesDecReader) readUntil(_ []byte, stop byte) (out []byte) { + return z.readUntilNoInput(stop) +} + +func (z *bytesDecReader) readUntilNoInput(stop byte) (out []byte) { + i := z.c + // if i == len(z.b) { + // panic(io.EOF) + // } + + // Replace loop with goto construct, so that this can be inlined + // for i := z.c; i < blen; i++ { + // if z.b[i] == stop { + // i++ + // out = z.b[z.c:i] + // z.a -= (i - z.c) + // z.c = i + // return + // } + // } +LOOP: + if i < uint(len(z.b)) { + if z.b[i] == stop { + i++ + out = z.b[z.c:i] + // z.a -= (i - z.c) + z.c = i + return + } + i++ + goto LOOP + } + // z.a = 0 + // z.c = blen + panic(io.EOF) } -func (d *Decoder) kInt16(f *codecFnInfo, rv reflect.Value) { - rvSetInt16(rv, int16(chkOvf.IntV(d.d.DecodeInt64(), 16))) +func (z *bytesDecReader) track() { + z.t = z.c } -func (d *Decoder) kInt32(f *codecFnInfo, rv reflect.Value) { - rvSetInt32(rv, int32(chkOvf.IntV(d.d.DecodeInt64(), 32))) +func (z *bytesDecReader) stopTrack() (bs []byte) { + return z.b[z.t:z.c] } -func (d *Decoder) kInt64(f *codecFnInfo, rv reflect.Value) { - rvSetInt64(rv, d.d.DecodeInt64()) +// ---------------------------------------- + +// 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) } -func (d *Decoder) kUint(f *codecFnInfo, rv reflect.Value) { - rvSetUint(rv, uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))) +func (d *Decoder) ext(f *codecFnInfo, rv reflect.Value) { + d.d.DecodeExt(rv2i(rv), f.xfTag, f.xfFn) } -func (d *Decoder) kUintptr(f *codecFnInfo, rv reflect.Value) { - rvSetUintptr(rv, uintptr(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))) +func (d *Decoder) selferUnmarshal(f *codecFnInfo, rv reflect.Value) { + rv2i(rv).(Selfer).CodecDecodeSelf(d) } -func (d *Decoder) kUint8(f *codecFnInfo, rv reflect.Value) { - rvSetUint8(rv, uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))) +func (d *Decoder) binaryUnmarshal(f *codecFnInfo, rv reflect.Value) { + bm := rv2i(rv).(encoding.BinaryUnmarshaler) + xbs := d.d.DecodeBytes(nil, true) + if fnerr := bm.UnmarshalBinary(xbs); fnerr != nil { + panic(fnerr) + } } -func (d *Decoder) kUint16(f *codecFnInfo, rv reflect.Value) { - rvSetUint16(rv, uint16(chkOvf.UintV(d.d.DecodeUint64(), 16))) +func (d *Decoder) textUnmarshal(f *codecFnInfo, rv reflect.Value) { + tm := rv2i(rv).(encoding.TextUnmarshaler) + fnerr := tm.UnmarshalText(d.d.DecodeStringAsBytes()) + if fnerr != nil { + panic(fnerr) + } } -func (d *Decoder) kUint32(f *codecFnInfo, rv reflect.Value) { - rvSetUint32(rv, uint32(chkOvf.UintV(d.d.DecodeUint64(), 32))) +func (d *Decoder) jsonUnmarshal(f *codecFnInfo, rv reflect.Value) { + 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()) + if fnerr != nil { + panic(fnerr) + } } -func (d *Decoder) kUint64(f *codecFnInfo, rv reflect.Value) { - rvSetUint64(rv, d.d.DecodeUint64()) +func (d *Decoder) kErr(f *codecFnInfo, rv reflect.Value) { + d.errorf("no decoding function defined for kind %v", rv.Kind()) } +// var kIntfCtr uint64 + func (d *Decoder) kInterfaceNaked(f *codecFnInfo) (rvn reflect.Value) { // nil interface: // use some hieristics to decode it appropriately // based on the detected next value in the stream. n := d.naked() d.d.DecodeNaked() - + if n.v == valueTypeNil { + return + } // We cannot decode non-nil stream value into nil interface with methods (e.g. io.Reader). - // Howver, it is possible that the user has ways to pass in a type for a given interface - // - MapType - // - SliceType - // - Extensions - // - // Consequently, we should relax this. Put it behind a const flag for now. - if decFailNonEmptyIntf && f.ti.numMeth > 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 } + // var useRvn bool switch n.v { case valueTypeMap: // if json, default to a map type with string keys @@ -415,76 +1257,64 @@ func (d *Decoder) kInterfaceNaked(f *codecFnInfo) (rvn reflect.Value) { if mtid == mapIntfIntfTypId { var v2 map[interface{}]interface{} d.decode(&v2) - rvn = rv4i(&v2).Elem() + rvn = reflect.ValueOf(&v2).Elem() } else if mtid == mapStrIntfTypId { // for json performance var v2 map[string]interface{} d.decode(&v2) - rvn = rv4i(&v2).Elem() + rvn = reflect.ValueOf(&v2).Elem() } else { if d.mtr { rvn = reflect.New(d.h.MapType) d.decode(rv2i(rvn)) rvn = rvn.Elem() } else { - rvn = rvZeroAddrK(d.h.MapType, reflect.Map) - d.decodeValue(rvn, nil) + rvn = reflect.New(d.h.MapType).Elem() + d.decodeValue(rvn, nil, true) } } case valueTypeArray: if d.stid == 0 || d.stid == intfSliceTypId { var v2 []interface{} d.decode(&v2) - rvn = rv4i(&v2).Elem() + rvn = reflect.ValueOf(&v2).Elem() + if reflectArrayOfSupported && d.stid == 0 && d.h.PreferArrayOverSlice { + rvn2 := reflect.New(reflectArrayOf(rvn.Len(), intfTyp)).Elem() + reflect.Copy(rvn2, rvn) + rvn = rvn2 + } } else { if d.str { rvn = reflect.New(d.h.SliceType) d.decode(rv2i(rvn)) rvn = rvn.Elem() } else { - rvn = rvZeroAddrK(d.h.SliceType, reflect.Slice) - d.decodeValue(rvn, nil) + rvn = reflect.New(d.h.SliceType).Elem() + d.decodeValue(rvn, nil, true) } } - if reflectArrayOfSupported && d.h.PreferArrayOverSlice { - rvn = rvGetArray4Slice(rvn) - } case valueTypeExt: + var v interface{} tag, bytes := n.u, n.l // calling decode below might taint the values - bfn := d.h.getExtForTag(tag) - var re = RawExt{Tag: tag} if bytes == nil { - // it is one of the InterfaceExt ones: json and cbor. - // most likely cbor, as json decoding never reveals valueTypeExt (no tagging support) - if bfn == nil { - d.decode(&re.Value) - rvn = rv4i(&re).Elem() - } else { - if bfn.ext == SelfExt { - rvn = rvZeroAddrK(bfn.rt, bfn.rt.Kind()) - d.decodeValue(rvn, d.h.fnNoExt(bfn.rt)) - } else { - rvn = reflect.New(bfn.rt) - d.interfaceExtConvertAndDecode(rv2i(rvn), bfn.ext) - rvn = rvn.Elem() - } - } + d.decode(&v) + } + bfn := d.h.getExtForTag(tag) + if bfn == nil { + var re RawExt + re.Tag = tag + re.Data = detachZeroCopyBytes(d.bytes, nil, bytes) + re.Value = v + rvn = reflect.ValueOf(&re).Elem() } else { - // one of the BytesExt ones: binc, msgpack, simple - if bfn == nil { - re.Data = detachZeroCopyBytes(d.bytes, nil, bytes) - rvn = rv4i(&re).Elem() + rvnA := reflect.New(bfn.rt) + if bytes != nil { + bfn.ext.ReadExt(rv2i(rvnA), bytes) } else { - rvn = reflect.New(bfn.rt) - if bfn.ext == SelfExt { - d.sideDecode(rv2i(rvn), bytes) - } else { - bfn.ext.ReadExt(rv2i(rvn), bytes) - } - rvn = rvn.Elem() + bfn.ext.UpdateExt(rv2i(rvnA), v) } + rvn = rvnA.Elem() } case valueTypeNil: - // rvn = reflect.Zero(f.ti.rt) // no-op case valueTypeInt: rvn = n.ri() @@ -515,21 +1345,18 @@ func (d *Decoder) kInterface(f *codecFnInfo, rv reflect.Value) { // every interface passed here MUST be settable. var rvn reflect.Value - if rvIsNil(rv) || d.h.InterfaceReset { + 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 { rvn = d.kInterfaceNaked(f) - // xdebugf("kInterface: %v", rvn) if rvn.IsValid() { rv.Set(rvn) } else if d.h.InterfaceReset { // reset to zero value based on current type in there. - if rvelem := rv.Elem(); rvelem.IsValid() { - rv.Set(reflect.Zero(rvelem.Type())) - } + rv.Set(reflect.Zero(rv.Elem().Type())) } return } @@ -537,20 +1364,25 @@ func (d *Decoder) kInterface(f *codecFnInfo, rv reflect.Value) { // 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 + } // Note: interface{} is settable, but underlying type may not be. // Consequently, we MAY have to create a decodable value out of the underlying value, // decode into it, and reset the interface itself. // fmt.Printf(">>>> kInterface: rvn type: %v, rv type: %v\n", rvn.Type(), rv.Type()) - if isDecodeable(rvn) { - d.decodeValue(rvn, nil) + rvn2, canDecode := isDecodeable(rvn) + if canDecode { + d.decodeValue(rvn2, nil, true) return } - rvn2 := rvZeroAddrK(rvn.Type(), rvn.Kind()) - rvSetDirect(rvn2, rvn) - d.decodeValue(rvn2, nil) + rvn2 = reflect.New(rvn.Type()).Elem() + rvn2.Set(rvn) + d.decodeValue(rvn2, nil, true) rv.Set(rvn2) } @@ -569,39 +1401,47 @@ func decStructFieldKey(dd decDriver, keyType valueType, b *[decScratchByteArrayL } else { rvkencname = dd.DecodeStringAsBytes() } - return + return rvkencname } func (d *Decoder) kStruct(f *codecFnInfo, rv reflect.Value) { + fti := f.ti + dd := d.d + elemsep := d.esep sfn := structFieldNode{v: rv, update: true} - ctyp := d.d.ContainerType() - if ctyp == valueTypeNil { - rvSetDirect(rv, f.ti.rv0) - return - } + ctyp := dd.ContainerType() var mf MissingFielder - if f.ti.isFlag(tiflagMissingFielder) { + if fti.mf { mf = rv2i(rv).(MissingFielder) - } else if f.ti.isFlag(tiflagMissingFielderPtr) { + } else if fti.mfp { mf = rv2i(rv.Addr()).(MissingFielder) } if ctyp == valueTypeMap { - containerLen := d.mapStart() + containerLen := dd.ReadMapStart() if containerLen == 0 { - d.mapEnd() + dd.ReadMapEnd() return } - tisfi := f.ti.sfiSort + d.depthIncr() + tisfi := fti.sfiSort hasLen := containerLen >= 0 var rvkencname []byte - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - rvkencname = decStructFieldKey(d.d, f.ti.keyType, &d.b) - d.mapElemValue() - if k := f.ti.indexForEncName(rvkencname); k > -1 { + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if elemsep { + dd.ReadMapElemKey() + } + rvkencname = decStructFieldKey(dd, fti.keyType, &d.b) + if elemsep { + dd.ReadMapElemValue() + } + if k := fti.indexForEncName(rvkencname); k > -1 { si := tisfi[k] - d.decodeValue(sfn.field(si), nil) + if dd.TryDecodeAsNil() { + si.setToZeroValue(rv) + } else { + d.decodeValue(sfn.field(si), nil, true) + } } else if mf != nil { // store rvkencname in new []byte, as it previously shares Decoder.b, which is used in decode name2 := rvkencname @@ -609,7 +1449,9 @@ func (d *Decoder) kStruct(f *codecFnInfo, rv reflect.Value) { copy(rvkencname, name2) var f interface{} + // xdebugf("kStruct: mf != nil: before decode: rvkencname: %s", rvkencname) d.decode(&f) + // xdebugf("kStruct: mf != nil: after decode: rvkencname: %s", rvkencname) if !mf.CodecMissingField(rvkencname, f) && d.h.ErrorIfNoField { d.errorf("no matching struct field found when decoding stream map with key: %s ", stringView(rvkencname)) @@ -619,39 +1461,50 @@ func (d *Decoder) kStruct(f *codecFnInfo, rv reflect.Value) { } // keepAlive4StringView(rvkencnameB) // not needed, as reference is outside loop } - d.mapEnd() + dd.ReadMapEnd() + d.depthDecr() } else if ctyp == valueTypeArray { - containerLen := d.arrayStart() + containerLen := dd.ReadArrayStart() if containerLen == 0 { - d.arrayEnd() + dd.ReadArrayEnd() return } + d.depthIncr() // Not much gain from doing it two ways for array. // Arrays are not used as much for structs. hasLen := containerLen >= 0 var checkbreak bool - for j, si := range f.ti.sfiSrc { + for j, si := range fti.sfiSrc { if hasLen && j == containerLen { break } - if !hasLen && d.checkBreak() { + if !hasLen && dd.CheckBreak() { checkbreak = true break } - d.arrayElem() - d.decodeValue(sfn.field(si), nil) + if elemsep { + dd.ReadArrayElem() + } + if dd.TryDecodeAsNil() { + si.setToZeroValue(rv) + } else { + d.decodeValue(sfn.field(si), nil, true) + } } - if (hasLen && containerLen > len(f.ti.sfiSrc)) || (!hasLen && !checkbreak) { + if (hasLen && containerLen > len(fti.sfiSrc)) || (!hasLen && !checkbreak) { // read remaining values and throw away - for j := len(f.ti.sfiSrc); ; j++ { - if (hasLen && j == containerLen) || (!hasLen && d.checkBreak()) { + for j := len(fti.sfiSrc); ; j++ { + if (hasLen && j == containerLen) || (!hasLen && dd.CheckBreak()) { break } - d.arrayElem() + if elemsep { + dd.ReadArrayElem() + } d.structFieldNotFound(j, "") } } - d.arrayEnd() + dd.ReadArrayEnd() + d.depthDecr() } else { d.errorstr(errstrOnlyMapOrArrayCanDecodeIntoStruct) return @@ -661,50 +1514,68 @@ func (d *Decoder) kStruct(f *codecFnInfo, rv reflect.Value) { 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). - - // Note: rv is a slice type here - guaranteed - - rtelem0 := f.ti.elem - ctyp := d.d.ContainerType() - if ctyp == valueTypeNil { - if rv.CanSet() { - rvSetDirect(rv, f.ti.rv0) - } - return + ti := f.ti + if f.seq == seqTypeChan && ti.chandir&uint8(reflect.SendDir) == 0 { + d.errorf("receive-only channel cannot be decoded") } + dd := d.d + 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 !(f.ti.rtid == uint8SliceTypId || rtelem0.Kind() == reflect.Uint8) { - d.errorf("bytes/string in stream must decode into slice/array of bytes, not %v", f.ti.rt) + if !(ti.rtid == uint8SliceTypId || rtelem0.Kind() == reflect.Uint8) { + d.errorf("bytes/string in stream must decode into slice/array of bytes, not %v", ti.rt) } - rvbs := rvGetBytes(rv) - bs2 := d.d.DecodeBytes(rvbs, false) - // 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() { - rvSetBytes(rv, bs2) - } else if len(rvbs) > 0 && len(bs2) > 0 { - copy(rvbs, bs2) + if f.seq == seqTypeChan { + bs2 := dd.DecodeBytes(nil, true) + 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 !(len(bs2) > 0 && len(bs2) == len(rvbs) && &bs2[0] == &rvbs[0]) { + if rv.CanSet() { + rv.SetBytes(bs2) + } else if len(rvbs) > 0 && len(bs2) > 0 { + copy(rvbs, bs2) + } } } return } - slh, containerLenS := d.decSliceHelperStart() // only expects valueType(Array|Map) - never Nil + // array := f.seq == seqTypeChan + + slh, containerLenS := d.decSliceHelperStart() // only expects valueType(Array|Map) // an array can never return a nil slice. so no need to check f.array here. if containerLenS == 0 { if rv.CanSet() { - if rvIsNil(rv) { - rvSetDirect(rv, reflect.MakeSlice(f.ti.rt, 0, 0)) - } else { - rvSetSliceLen(rv, 0) + if f.seq == seqTypeSlice { + if rv.IsNil() { + rv.Set(reflect.MakeSlice(ti.rt, 0, 0)) + } else { + rv.SetLen(0) + } + } else if f.seq == seqTypeChan { + if rv.IsNil() { + rv.Set(reflect.MakeChan(ti.rt, 0)) + } } } slh.End() return } + d.depthIncr() + rtelem0Size := int(rtelem0.Size()) rtElem0Kind := rtelem0.Kind() rtelem0Mut := !isImmutableKind(rtElem0Kind) @@ -717,227 +1588,149 @@ func (d *Decoder) kSlice(f *codecFnInfo, rv reflect.Value) { var fn *codecFn - var rv0 = rv - var rvChanged bool var rvCanset = rv.CanSet() + var rvChanged bool + var rv0 = rv var rv9 reflect.Value - rvlen := rvGetSliceLen(rv) - rvcap := rvGetSliceCap(rv) + rvlen := rv.Len() + rvcap := rv.Cap() hasLen := containerLenS > 0 - if hasLen { + if hasLen && f.seq == seqTypeSlice { if containerLenS > rvcap { oldRvlenGtZero := rvlen > 0 rvlen = decInferLen(containerLenS, d.h.MaxInitLen, int(rtelem0.Size())) if rvlen <= rvcap { if rvCanset { - rvSetSliceLen(rv, rvlen) + rv.SetLen(rvlen) } } else if rvCanset { - rv = reflect.MakeSlice(f.ti.rt, rvlen, rvlen) + rv = reflect.MakeSlice(ti.rt, rvlen, rvlen) rvcap = rvlen rvChanged = true } else { d.errorf("cannot decode into non-settable slice") } - if rvChanged && oldRvlenGtZero && rtelem0Mut { // !isImmutableKind(rtelem0.Kind()) { - rvCopySlice(rv, rv0) // only copy up to length NOT cap i.e. rv0.Slice(0, rvcap) + 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 rvCanset { - rvSetSliceLen(rv, rvlen) + rv.SetLen(rvlen) } + // else { + // rv = rv.Slice(0, rvlen) + // rvChanged = true + // d.errorf("cannot decode into non-settable slice") + // } } } // consider creating new element once, and just decoding into it. var rtelem0Zero reflect.Value var rtelem0ZeroValid bool + var decodeAsNil bool var j int - for ; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && f.seq == seqTypeSlice && rvIsNil(rv) { + for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { + if j == 0 && (f.seq == seqTypeSlice || f.seq == seqTypeChan) && rv.IsNil() { if hasLen { rvlen = decInferLen(containerLenS, d.h.MaxInitLen, rtelem0Size) - } else { + } else if f.seq == seqTypeSlice { rvlen = decDefSliceCap + } else { + rvlen = decDefChanCap } if rvCanset { - rv = reflect.MakeSlice(f.ti.rt, rvlen, rvlen) - rvcap = rvlen - rvChanged = true + 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) - // if indefinite, etc, then expand the slice if necessary - if j >= rvlen { - if f.seq == seqTypeArray { - d.arrayCannotExpand(rvlen, j+1) - // drain completely and return - d.swallow() - j++ - for ; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - slh.ElemContainerState(j) - d.swallow() + decodeAsNil = dd.TryDecodeAsNil() + if f.seq == seqTypeChan { + if decodeAsNil { + rv.Send(reflect.Zero(rtelem0)) + continue + } + if rtelem0Mut || !rv9.IsValid() { // || (rtElem0Kind == reflect.Ptr && rv9.IsNil()) { + rv9 = reflect.New(rtelem0).Elem() + } + if fn == nil { + fn = d.h.fn(rtelem, true, true) + } + d.decodeValue(rv9, fn, true) + rv.Send(rv9) + } else { + // if indefinite, etc, then expand the slice if necessary + var decodeIntoBlank bool + if j >= rvlen { + if f.seq == seqTypeArray { + d.arrayCannotExpand(rvlen, j+1) + decodeIntoBlank = true + } else { // if f.seq == seqTypeSlice + // rv = reflect.Append(rv, reflect.Zero(rtelem0)) // append logic + varargs + var rvcap2 int + 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 + rvcap = rvcap2 + } } - slh.End() - return } - // rv = reflect.Append(rv, reflect.Zero(rtelem0)) // append logic + varargs - - // expand the slice up to the cap. - // Note that we did, so we have to reset it later. - - if rvlen < rvcap { - if rv.CanSet() { - rvSetSliceLen(rv, rvcap) - } else if rvCanset { - rv = rvSlice(rv, rvcap) - rvChanged = true - } else { - d.errorf(errmsgExpandSliceCannotChange) - return + if decodeIntoBlank { + if !decodeAsNil { + d.swallow() } - rvlen = rvcap } else { - if !rvCanset { - d.errorf(errmsgExpandSliceCannotChange) - return + rv9 = rv.Index(j) + if d.h.SliceElementReset || decodeAsNil { + if !rtelem0ZeroValid { + rtelem0ZeroValid = true + rtelem0Zero = reflect.Zero(rtelem0) + } + rv9.Set(rtelem0Zero) + if decodeAsNil { + continue + } } - rvcap = growCap(rvcap, rtelem0Size, rvcap) - rv9 = reflect.MakeSlice(f.ti.rt, rvcap, rvcap) - rvCopySlice(rv9, rv) - rv = rv9 - rvChanged = true - rvlen = rvcap - } - } - rv9 = rvSliceIndex(rv, j, f.ti) - if d.h.SliceElementReset { - if !rtelem0ZeroValid { - rtelem0ZeroValid = true - rtelem0Zero = reflect.Zero(rtelem0) - } - rv9.Set(rtelem0Zero) - } - - if fn == nil { - fn = d.h.fn(rtelem) - } - d.decodeValue(rv9, fn) - } - if j < rvlen { - if rv.CanSet() { - rvSetSliceLen(rv, j) - } else if rvCanset { - rv = rvSlice(rv, j) - rvChanged = true - } - rvlen = j - } else if j == 0 && rvIsNil(rv) { - if rvCanset { - rv = reflect.MakeSlice(f.ti.rt, 0, 0) - rvChanged = true - } - } - slh.End() - - if rvChanged { // infers rvCanset=true, so it can be reset - rv0.Set(rv) - } - -} - -func (d *Decoder) kSliceForChan(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). - - if f.ti.chandir&uint8(reflect.SendDir) == 0 { - d.errorf("receive-only channel cannot be decoded") - } - rtelem0 := f.ti.elem - ctyp := d.d.ContainerType() - if ctyp == valueTypeNil { - rvSetDirect(rv, f.ti.rv0) - return - } - if ctyp == valueTypeBytes || ctyp == valueTypeString { - // you can only decode bytes or string in the stream into a slice or array of bytes - if !(f.ti.rtid == uint8SliceTypId || rtelem0.Kind() == reflect.Uint8) { - d.errorf("bytes/string in stream must decode into slice/array of bytes, not %v", f.ti.rt) - } - bs2 := d.d.DecodeBytes(nil, true) - irv := rv2i(rv) - ch, ok := irv.(chan<- byte) - if !ok { - ch = irv.(chan byte) - } - for _, b := range bs2 { - ch <- b - } - return - } - - // only expects valueType(Array|Map - nil handled above) - slh, containerLenS := d.decSliceHelperStart() - // an array can never return a nil slice. so no need to check f.array here. - if containerLenS == 0 { - if rv.CanSet() && rvIsNil(rv) { - rvSetDirect(rv, reflect.MakeChan(f.ti.rt, 0)) + if fn == nil { + fn = d.h.fn(rtelem, true, true) + } + d.decodeValue(rv9, fn, true) + } } - slh.End() - return } - - rtelem0Size := int(rtelem0.Size()) - rtElem0Kind := rtelem0.Kind() - rtelem0Mut := !isImmutableKind(rtElem0Kind) - rtelem := rtelem0 - rtelemkind := rtelem.Kind() - for rtelemkind == reflect.Ptr { - rtelem = rtelem.Elem() - rtelemkind = rtelem.Kind() - } - - var fn *codecFn - - var rvCanset = rv.CanSet() - var rvChanged bool - var rv0 = rv - var rv9 reflect.Value - - var rvlen int // := rv.Len() - hasLen := containerLenS > 0 - - var j int - - for ; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && rvIsNil(rv) { - if hasLen { - rvlen = decInferLen(containerLenS, d.h.MaxInitLen, rtelem0Size) - } else { - rvlen = decDefChanCap - } - if rvCanset { - rv = reflect.MakeChan(f.ti.rt, rvlen) + if f.seq == seqTypeSlice { + if j < rvlen { + if rv.CanSet() { + rv.SetLen(j) + } else if rvCanset { + rv = rv.Slice(0, j) rvChanged = true - } else { - d.errorf("cannot decode into non-settable chan") - } - } - slh.ElemContainerState(j) - if rtelem0Mut || !rv9.IsValid() { // || (rtElem0Kind == reflect.Ptr && rvIsNil(rv9)) { - rv9 = rvZeroAddrK(rtelem0, rtElem0Kind) - } - if fn == nil { - fn = d.h.fn(rtelem) + } // else { d.errorf("kSlice: cannot change non-settable slice") } + rvlen = j + } else if j == 0 && rv.IsNil() { + if rvCanset { + rv = reflect.MakeSlice(ti.rt, 0, 0) + rvChanged = true + } // else { d.errorf("kSlice: cannot change non-settable slice") } } - d.decodeValue(rv9, fn) - rv.Send(rv9) } slh.End() @@ -945,31 +1738,34 @@ func (d *Decoder) kSliceForChan(f *codecFnInfo, rv reflect.Value) { rv0.Set(rv) } + d.depthDecr() } +// func (d *Decoder) kArray(f *codecFnInfo, rv reflect.Value) { +// // d.decodeValueFn(rv.Slice(0, rv.Len())) +// f.kSlice(rv.Slice(0, rv.Len())) +// } + func (d *Decoder) kMap(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - rvSetDirect(rv, f.ti.rv0) - return - } + dd := d.d + containerLen := dd.ReadMapStart() + elemsep := d.esep ti := f.ti - if rvIsNil(rv) { + if rv.IsNil() { rvlen := decInferLen(containerLen, d.h.MaxInitLen, int(ti.key.Size()+ti.elem.Size())) - rvSetDirect(rv, makeMapReflect(ti.rt, rvlen)) + rv.Set(makeMapReflect(ti.rt, rvlen)) } if containerLen == 0 { - d.mapEnd() + dd.ReadMapEnd() return } + d.depthIncr() + ktype, vtype := ti.key, ti.elem ktypeId := rt2id(ktype) vtypeKind := vtype.Kind() - ktypeKind := ktype.Kind() - - var vtypeElem reflect.Type var keyFn, valFn *codecFn var ktypeLo, vtypeLo reflect.Type @@ -980,116 +1776,137 @@ func (d *Decoder) kMap(f *codecFnInfo, rv reflect.Value) { for vtypeLo = vtype; vtypeLo.Kind() == reflect.Ptr; vtypeLo = vtypeLo.Elem() { } - rvvMut := !isImmutableKind(vtypeKind) - - // we do a doMapGet if kind is mutable, and InterfaceReset=true if interface - var doMapGet, doMapSet bool + var mapGet, mapSet bool + rvvImmut := isImmutableKind(vtypeKind) if !d.h.MapValueReset { - if rvvMut { - if vtypeKind == reflect.Interface { - if !d.h.InterfaceReset { - doMapGet = true - } - } else { - doMapGet = true + // if pointer, mapGet = true + // if interface, mapGet = true if !DecodeNakedAlways (else false) + // if builtin, mapGet = false + // else mapGet = true + if vtypeKind == reflect.Ptr { + mapGet = true + } else if vtypeKind == reflect.Interface { + if !d.h.InterfaceReset { + mapGet = true } + } else if !rvvImmut { + mapGet = true } } - var rvk, rvkn, rvv, rvvn, rvva reflect.Value - var rvvaSet bool + var rvk, rvkp, rvv, rvz reflect.Value rvkMut := !isImmutableKind(ktype.Kind()) // if ktype is immutable, then re-use the same rvk. ktypeIsString := ktypeId == stringTypId ktypeIsIntf := ktypeId == intfTypId hasLen := containerLen > 0 var kstrbs []byte - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - if j == 0 { - if !rvkMut { - rvkn = rvZeroAddrK(ktype, ktypeKind) - } - if !rvvMut { - rvvn = rvZeroAddrK(vtype, vtypeKind) - } + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if rvkMut || !rvkp.IsValid() { + rvkp = reflect.New(ktype) + rvk = rvkp.Elem() } - - if rvkMut { - rvk = rvZeroAddrK(ktype, ktypeKind) - } else { - rvk = rvkn + if elemsep { + dd.ReadMapElemKey() } - - d.mapElemKey() - + // 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 { if ktypeIsString { - kstrbs = d.d.DecodeStringAsBytes() - rvk.SetString(stringView(kstrbs)) // NOTE: if doing an insert, use real string (not stringview) + kstrbs = dd.DecodeStringAsBytes() + rvk.SetString(stringView(kstrbs)) + // NOTE: if doing an insert, you MUST use a real string (not stringview) } else { if keyFn == nil { - keyFn = d.h.fn(ktypeLo) + keyFn = d.h.fn(ktypeLo, true, true) } - d.decodeValue(rvk, keyFn) + d.decodeValue(rvk, keyFn, true) } - - // special case if interface wrapping a byte array. + // special case if a byte array. if ktypeIsIntf { - if rvk2 := rvk.Elem(); rvk2.IsValid() && rvk2.Type() == uint8SliceTyp { - rvk.Set(rv4i(d.string(rvGetBytes(rvk2)))) + if rvk2 := rvk.Elem(); rvk2.IsValid() { + if rvk2.Type() == uint8SliceTyp { + rvk = reflect.ValueOf(d.string(rvk2.Bytes())) + } else { + rvk = rvk2 + } } - // NOTE: consider failing early if map/slice/func } - d.mapElemValue() + if elemsep { + dd.ReadMapElemValue() + } - doMapSet = true // set to false if u do a get, and its a non-nil pointer - if doMapGet { - if !rvvaSet { - rvva = mapAddressableRV(vtype, vtypeKind) - rvvaSet = true + // Brittle, but OK per TryDecodeAsNil() contract. + // i.e. TryDecodeAsNil never shares slices with other decDriver procedures + if dd.TryDecodeAsNil() { + if ktypeIsString { + rvk.SetString(d.string(kstrbs)) } - rvv = mapGet(rv, rvk, rvva) // reflect.Value{}) - if vtypeKind == reflect.Ptr { - if rvv.IsValid() && !rvIsNil(rvv) { - doMapSet = false - } else { - if vtypeElem == nil { - vtypeElem = vtype.Elem() - } - rvv = reflect.New(vtypeElem) - } - } else if rvv.IsValid() && vtypeKind == reflect.Interface && !rvIsNil(rvv) { - rvvn = rvZeroAddrK(vtype, vtypeKind) - rvvn.Set(rvv) - rvv = rvvn - } else if rvvMut { - rvv = rvZeroAddrK(vtype, vtypeKind) + if d.h.DeleteOnNilMapValue { + rv.SetMapIndex(rvk, reflect.Value{}) } else { - rvv = rvvn + rv.SetMapIndex(rvk, reflect.Zero(vtype)) } - } else if rvvMut { - rvv = rvZeroAddrK(vtype, vtypeKind) - } else { - rvv = rvvn + continue } - if valFn == nil { - valFn = d.h.fn(vtypeLo) + mapSet = true // set to false if u do a get, and its a non-nil pointer + if mapGet { + // mapGet true only in case where kind=Ptr|Interface or kind is otherwise mutable. + rvv = rv.MapIndex(rvk) + if !rvv.IsValid() { + rvv = reflect.New(vtype).Elem() + } else if vtypeKind == reflect.Ptr { + if rvv.IsNil() { + rvv = reflect.New(vtype).Elem() + } else { + mapSet = false + } + } else if vtypeKind == reflect.Interface { + // not addressable, and thus not settable. + // e MUST create a settable/addressable variant + rvv2 := reflect.New(rvv.Type()).Elem() + if !rvv.IsNil() { + rvv2.Set(rvv) + } + rvv = rvv2 + } + // else it is ~mutable, and we can just decode into it directly + } else if rvvImmut { + if !rvz.IsValid() { + rvz = reflect.New(vtype).Elem() + } + rvv = rvz + } else { + rvv = reflect.New(vtype).Elem() } - // We MUST be done with the stringview of the key, BEFORE decoding the value (rvv) - // so that we don't unknowingly reuse the rvk backing buffer during rvv decode. - if doMapSet && ktypeIsString { // set to a real string (not string view) + // We MUST be done with the stringview of the key, before decoding the value + // so that we don't bastardize the reused byte array. + if mapSet && ktypeIsString { rvk.SetString(d.string(kstrbs)) } - d.decodeValue(rvv, valFn) - if doMapSet { - mapSet(rv, rvk, rvv) + if valFn == nil { + valFn = d.h.fn(vtypeLo, true, true) + } + d.decodeValue(rvv, valFn, true) + // d.decodeValueFn(rvv, valFn) + if mapSet { + rv.SetMapIndex(rvk, rvv) } + // if ktypeIsString { + // // keepAlive4StringView(kstrbs) // not needed, as reference is outside loop + // } } - d.mapEnd() + dd.ReadMapEnd() + d.depthDecr() } // decNaked is used to keep track of the primitives decoded. @@ -1127,6 +1944,331 @@ type decNaked struct { // state v valueType + _ [6]bool // padding + + // ru, ri, rf, rl, rs, rb, rt reflect.Value // mapping to the primitives above + // + // _ [3]uint64 // padding +} + +// func (n *decNaked) init() { +// 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.rr[] = reflect.ValueOf(&n.) +// } + +// type decNakedPooler struct { +// n *decNaked +// nsp *sync.Pool +// } + +// // naked must be called before each call to .DecodeNaked, as they will use it. +// func (d *decNakedPooler) 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 *decNakedPooler) end() { +// 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 +// } +// } + +// type rtid2rv struct { +// rtid uintptr +// rv reflect.Value +// } + +// -------------- + +type decReaderSwitch struct { + rb bytesDecReader + // ---- cpu cache line boundary? + ri *ioDecReader + bi *bufioDecReader + + mtr, str bool // whether maptype or slicetype are known types + + be bool // is binary encoding + js bool // is json handle + jsms bool // is json handle, and MapKeyAsString + esep bool // has elem separators + + // typ entryType + bytes bool // is bytes reader + bufio bool // is this a bufioDecReader? +} + +// numread, track and stopTrack are always inlined, as they just check int fields, etc. + +/* +func (z *decReaderSwitch) numread() int { + switch z.typ { + case entryTypeBytes: + return z.rb.numread() + case entryTypeIo: + return z.ri.numread() + default: + return z.bi.numread() + } +} +func (z *decReaderSwitch) track() { + switch z.typ { + case entryTypeBytes: + z.rb.track() + case entryTypeIo: + z.ri.track() + default: + z.bi.track() + } +} +func (z *decReaderSwitch) stopTrack() []byte { + switch z.typ { + case entryTypeBytes: + return z.rb.stopTrack() + case entryTypeIo: + return z.ri.stopTrack() + default: + return z.bi.stopTrack() + } +} + +func (z *decReaderSwitch) unreadn1() { + switch z.typ { + case entryTypeBytes: + z.rb.unreadn1() + case entryTypeIo: + z.ri.unreadn1() + default: + z.bi.unreadn1() + } +} +func (z *decReaderSwitch) readx(n int) []byte { + switch z.typ { + case entryTypeBytes: + return z.rb.readx(n) + case entryTypeIo: + return z.ri.readx(n) + default: + return z.bi.readx(n) + } +} +func (z *decReaderSwitch) readb(s []byte) { + switch z.typ { + case entryTypeBytes: + z.rb.readb(s) + case entryTypeIo: + z.ri.readb(s) + default: + z.bi.readb(s) + } +} +func (z *decReaderSwitch) readn1() uint8 { + switch z.typ { + case entryTypeBytes: + return z.rb.readn1() + case entryTypeIo: + return z.ri.readn1() + default: + return z.bi.readn1() + } +} +func (z *decReaderSwitch) skip(accept *bitset256) (token byte) { + switch z.typ { + case entryTypeBytes: + return z.rb.skip(accept) + case entryTypeIo: + return z.ri.skip(accept) + default: + return z.bi.skip(accept) + } +} +func (z *decReaderSwitch) readTo(in []byte, accept *bitset256) (out []byte) { + switch z.typ { + case entryTypeBytes: + return z.rb.readTo(in, accept) + case entryTypeIo: + return z.ri.readTo(in, accept) + default: + return z.bi.readTo(in, accept) + } +} +func (z *decReaderSwitch) readUntil(in []byte, stop byte) (out []byte) { + switch z.typ { + case entryTypeBytes: + return z.rb.readUntil(in, stop) + case entryTypeIo: + return z.ri.readUntil(in, stop) + default: + return z.bi.readUntil(in, stop) + } +} + +*/ + +// the if/else-if/else block is expensive to inline. +// Each node of this construct costs a lot and dominates the budget. +// Best to only do an if fast-path else block (so fast-path is inlined). +// This is irrespective of inlineExtraCallCost set in $GOROOT/src/cmd/compile/internal/gc/inl.go +// +// In decReaderSwitch methods below, we delegate all IO functions into their own methods. +// This allows for the inlining of the common path when z.bytes=true. +// Go 1.12+ supports inlining methods with up to 1 inlined function (or 2 if no other constructs). + +func (z *decReaderSwitch) numread() uint { + if z.bytes { + return z.rb.numread() + } else if z.bufio { + return z.bi.numread() + } else { + return z.ri.numread() + } +} +func (z *decReaderSwitch) track() { + if z.bytes { + z.rb.track() + } else if z.bufio { + z.bi.track() + } else { + z.ri.track() + } +} +func (z *decReaderSwitch) stopTrack() []byte { + if z.bytes { + return z.rb.stopTrack() + } else if z.bufio { + return z.bi.stopTrack() + } else { + return z.ri.stopTrack() + } +} + +// func (z *decReaderSwitch) unreadn1() { +// if z.bytes { +// z.rb.unreadn1() +// } else { +// z.unreadn1IO() +// } +// } +// func (z *decReaderSwitch) unreadn1IO() { +// if z.bufio { +// z.bi.unreadn1() +// } else { +// z.ri.unreadn1() +// } +// } + +func (z *decReaderSwitch) unreadn1() { + if z.bytes { + z.rb.unreadn1() + } else if z.bufio { + z.bi.unreadn1() + } else { + z.ri.unreadn1() // not inlined + } +} + +func (z *decReaderSwitch) readx(n uint) []byte { + if z.bytes { + return z.rb.readx(n) + } + return z.readxIO(n) +} +func (z *decReaderSwitch) readxIO(n uint) []byte { + if z.bufio { + return z.bi.readx(n) + } + return z.ri.readx(n) +} + +func (z *decReaderSwitch) readb(s []byte) { + if z.bytes { + z.rb.readb(s) + } else { + z.readbIO(s) + } +} + +//go:noinline - fallback for io, ensures z.bytes path is inlined +func (z *decReaderSwitch) readbIO(s []byte) { + if z.bufio { + z.bi.readb(s) + } else { + z.ri.readb(s) + } +} + +func (z *decReaderSwitch) readn1() uint8 { + if z.bytes { + return z.rb.readn1() + } + return z.readn1IO() +} +func (z *decReaderSwitch) readn1IO() uint8 { + if z.bufio { + return z.bi.readn1() + } + return z.ri.readn1() +} + +func (z *decReaderSwitch) skip(accept *bitset256) (token byte) { + if z.bytes { + return z.rb.skip(accept) + } + return z.skipIO(accept) +} +func (z *decReaderSwitch) skipIO(accept *bitset256) (token byte) { + if z.bufio { + return z.bi.skip(accept) + } + return z.ri.skip(accept) +} + +func (z *decReaderSwitch) readTo(in []byte, accept *bitset256) (out []byte) { + if z.bytes { + return z.rb.readToNoInput(accept) // z.rb.readTo(in, accept) + } + return z.readToIO(in, accept) +} + +//go:noinline - fallback for io, ensures z.bytes path is inlined +func (z *decReaderSwitch) readToIO(in []byte, accept *bitset256) (out []byte) { + if z.bufio { + return z.bi.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.readUntilNoInput(stop) + } + return z.readUntilIO(in, stop) +} + +func (z *decReaderSwitch) readUntilIO(in []byte, stop byte) (out []byte) { + if z.bufio { + return z.bi.readUntil(in, stop) + } + return z.ri.readUntil(in, stop) } // Decoder reads and decodes an object from an input stream in a supported format. @@ -1144,44 +2286,39 @@ type Decoder struct { d decDriver + // NOTE: Decoder shouldn't call it's read methods, + // as the handler MAY need to do some coordination. + r *decReaderSwitch + + // bi *bufioDecReader // cache the mapTypeId and sliceTypeId for faster comparisons mtid uintptr stid uintptr - h *BasicHandle - - blist bytesFreelist + hh Handle + h *BasicHandle // ---- cpu cache line boundary? - decRd + decReaderSwitch // ---- cpu cache line boundary? n decNaked - hh Handle + // cr containerStateRecv err error - // ---- cpu cache line boundary? - is map[string]string // used for interning strings - - // ---- writable fields during execution --- *try* to keep in sep cache line - maxdepth int16 depth int16 + maxdepth int16 - // Extensions can call Decode() within a current Decode() call. - // We need to know when the top level Decode() call returns, - // so we can decide whether to Release() or not. - calls uint16 // what depth in mustDecode are we in now. + _ [4]uint8 // padding - c containerState - _ [1]byte // padding + is map[string]string // used for interning strings // ---- cpu cache line boundary? + b [decScratchByteArrayLen]byte // scratch buffer, used by Decoder and xxxEncDrivers - // b is an always-available scratch buffer used by Decoder and decDrivers. - // By being always-available, it can be used for one-off things without - // having to get from freelist, use, and return back to freelist. - b [decScratchByteArrayLen]byte + // 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. @@ -1189,7 +2326,7 @@ type Decoder struct { // For efficiency, Users are encouraged to configure ReaderBufferSize on the handle // OR pass in a memory buffered reader (eg bufio.Reader, bytes.Buffer). func NewDecoder(r io.Reader, h Handle) *Decoder { - d := h.newDecDriver().decoder() + d := newDecoder(h) d.Reset(r) return d } @@ -1197,32 +2334,43 @@ func NewDecoder(r io.Reader, h Handle) *Decoder { // NewDecoderBytes returns a Decoder which efficiently decodes directly // from a byte slice with zero copying. func NewDecoderBytes(in []byte, h Handle) *Decoder { - d := h.newDecDriver().decoder() + d := newDecoder(h) d.ResetBytes(in) return d } -func (d *Decoder) r() *decRd { - return &d.decRd -} +// var defaultDecNaked decNaked -func (d *Decoder) init(h Handle) { +func newDecoder(h Handle) *Decoder { + d := &Decoder{h: basicHandle(h), err: errDecoderNotInitialized} d.bytes = true - d.err = errDecoderNotInitialized - d.h = basicHandle(h) + if useFinalizers { + runtime.SetFinalizer(d, (*Decoder).finalize) + // xdebugf(">>>> new(Decoder) with finalizer") + } + d.r = &d.decReaderSwitch d.hh = h d.be = h.isBinary() // NOTE: do not initialize d.n here. It is lazily initialized in d.naked() + 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) } + d.d = h.newDecDriver(d) + // d.cr, _ = d.d.(containerStateRecv) + return d } func (d *Decoder) resetCommon() { + // d.r = &d.decReaderSwitch d.d.reset() d.err = nil d.depth = 0 - d.calls = 0 d.maxdepth = d.h.MaxDepth if d.maxdepth <= 0 { d.maxdepth = decDefMaxDepth @@ -1247,17 +2395,24 @@ func (d *Decoder) Reset(r io.Reader) { return } d.bytes = false + // d.typ = entryTypeUnset if d.h.ReaderBufferSize > 0 { if d.bi == nil { d.bi = new(bufioDecReader) } - d.bi.reset(r, d.h.ReaderBufferSize, &d.blist) + d.bi.reset(r, d.h.ReaderBufferSize) + // d.r = d.bi + // d.typ = entryTypeBufio d.bufio = true } else { + // d.ri.x = &d.b + // d.s = d.sa[:0] if d.ri == nil { d.ri = new(ioDecReader) } - d.ri.reset(r, &d.blist) + d.ri.reset(r) + // d.r = d.ri + // d.typ = entryTypeIo d.bufio = false } d.resetCommon() @@ -1271,7 +2426,9 @@ func (d *Decoder) ResetBytes(in []byte) { } d.bytes = true d.bufio = false + // d.typ = entryTypeBytes d.rb.reset(in) + // d.r = &d.rb d.resetCommon() } @@ -1353,9 +2510,7 @@ func (d *Decoder) Decode(v interface{}) (err error) { defer func() { if x := recover(); x != nil { panicValToErr(d, x, &d.err) - if d.err != err { - err = d.err - } + err = d.err } }() } @@ -1377,58 +2532,105 @@ func (d *Decoder) MustDecode(v interface{}) { // MustDecode is like Decode, but panics if unable to Decode. // This provides insight to the code location that triggered the error. func (d *Decoder) mustDecode(v interface{}) { - // Top-level: v is a pointer and not nil. + // TODO: Top-level: ensure that v is a pointer and not nil. + if d.d.TryDecodeAsNil() { + setZero(v) + return + } + if d.bi == nil { + d.decode(v) + return + } - d.calls++ + d.bi.calls++ d.decode(v) - d.calls-- - if d.calls == 0 { - d.d.atEndOfDecode() + // xprintf(">>>>>>>> >>>>>>>> num decFns: %v\n", d.cf.sn) + d.bi.calls-- + if !d.h.ExplicitRelease && d.bi.calls == 0 { + d.bi.release() } } +// func (d *Decoder) deferred(err1 *error) { +// if recoverPanicToErr { +// if x := recover(); x != nil { +// panicValToErr(d, x, err1) +// panicValToErr(d, x, &d.err) +// } +// } +// } + +//go:noinline -- as it is run by finalizer +func (d *Decoder) finalize() { + // xdebugf("finalizing Decoder") + d.Release() +} + // Release releases shared (pooled) resources. // // It is important to call Release() when done with a Decoder, so those resources // are released instantly for use by subsequently created Decoders. // // By default, Release() is automatically called unless the option ExplicitRelease is set. -// -// Deprecated: Release is a no-op as pooled resources are not used with an Decoder. -// This method is kept for compatibility reasons only. func (d *Decoder) Release() { + if d.bi != nil { + d.bi.release() + } + // d.decNakedPooler.end() } +// // this is not a smart swallow, as it allocates objects and does unnecessary work. +// func (d *Decoder) swallowViaHammer() { +// var blank interface{} +// d.decodeValueNoFn(reflect.ValueOf(&blank).Elem()) +// } + func (d *Decoder) swallow() { - switch d.d.ContainerType() { - case valueTypeNil: + // smarter decode that just swallows the content + dd := d.d + if dd.TryDecodeAsNil() { + return + } + elemsep := d.esep + switch dd.ContainerType() { case valueTypeMap: - containerLen := d.mapStart() + containerLen := dd.ReadMapStart() + d.depthIncr() hasLen := containerLen >= 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + // if clenGtEqualZero {if j >= containerLen {break} } else if dd.CheckBreak() {break} + if elemsep { + dd.ReadMapElemKey() + } d.swallow() - d.mapElemValue() + if elemsep { + dd.ReadMapElemValue() + } d.swallow() } - d.mapEnd() + dd.ReadMapEnd() + d.depthDecr() case valueTypeArray: - containerLen := d.arrayStart() + containerLen := dd.ReadArrayStart() + d.depthIncr() hasLen := containerLen >= 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.arrayElem() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if elemsep { + dd.ReadArrayElem() + } d.swallow() } - d.arrayEnd() + dd.ReadArrayEnd() + d.depthDecr() case valueTypeBytes: - d.d.DecodeBytes(d.b[:], true) + dd.DecodeBytes(d.b[:], true) case valueTypeString: - d.d.DecodeStringAsBytes() + dd.DecodeStringAsBytes() default: // these are all primitives, which we can get from decodeNaked // if RawExt using Value, complete the processing. n := d.naked() - d.d.DecodeNaked() + dd.DecodeNaked() if n.v == valueTypeExt && n.l == nil { var v2 interface{} d.decode(&v2) @@ -1437,13 +2639,10 @@ func (d *Decoder) swallow() { } func setZero(iv interface{}) { - if iv == nil { - return - } - if _, ok := isNil(iv); ok { + if iv == nil || definitelyNil(iv) { return } - // var canDecode bool + var canDecode bool switch v := iv.(type) { case *string: *v = "" @@ -1480,29 +2679,15 @@ func setZero(iv interface{}) { case *time.Time: *v = time.Time{} case reflect.Value: - setZeroRV(v) + 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) { - setZeroRV(rv4i(iv)) - } - } -} - -func setZeroRV(v reflect.Value) { - // It not decodeable, we do not touch it. - // We considered empty'ing it if not decodeable e.g. - // - if chan, drain it - // - if map, clear it - // - if slice or array, zero all elements up to len - // - // However, we decided instead that we either will set the - // whole value to the zero value, or leave AS IS. - if isDecodeable(v) { - if v.Kind() == reflect.Ptr { - v = v.Elem() - } - if v.CanSet() { - v.Set(reflect.Zero(v.Type())) + v := reflect.ValueOf(iv) + 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??? } } } @@ -1520,11 +2705,11 @@ func (d *Decoder) decode(iv interface{}) { // case nil: // case Selfer: case reflect.Value: - d.ensureDecodeable(v) - d.decodeValue(v, nil) + v = d.ensureDecodeable(v) + d.decodeValue(v, nil, true) case *string: - *v = string(d.d.DecodeStringAsBytes()) + *v = d.d.DecodeString() case *bool: *v = d.d.DecodeBool() case *int: @@ -1548,7 +2733,11 @@ func (d *Decoder) decode(iv interface{}) { case *uint64: *v = d.d.DecodeUint64() case *float32: - *v = float32(d.decodeFloat32()) + f64 := d.d.DecodeFloat64() + if chkOvf.Float32(f64) { + d.errorf("float32 overflow: %v", f64) + } + *v = float32(f64) case *float64: *v = d.d.DecodeFloat64() case *[]uint8: @@ -1564,48 +2753,43 @@ func (d *Decoder) decode(iv interface{}) { *v = d.rawBytes() case *interface{}: - d.decodeValue(rv4i(iv), nil) + d.decodeValue(reflect.ValueOf(iv).Elem(), nil, true) + // d.decodeValueNotNil(reflect.ValueOf(iv).Elem()) default: if v, ok := iv.(Selfer); ok { v.CodecDecodeSelf(d) } else if !fastpathDecodeTypeSwitch(iv, d) { - v := rv4i(iv) - d.ensureDecodeable(v) - d.decodeValue(v, nil) + v := reflect.ValueOf(iv) + v = d.ensureDecodeable(v) + d.decodeValue(v, nil, false) + // d.decodeValueFallback(v) } } } -// decodeValue MUST be called by the actual value we want to decode into, -// not its addr or a reference to it. -// -// This way, we know if it is itself a pointer, and can handle nil in -// the stream effectively. -func (d *Decoder) decodeValue(rv reflect.Value, fn *codecFn) { +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 var rvpValid bool if rv.Kind() == reflect.Ptr { - if d.d.TryNil() { - if rvelem := rv.Elem(); rvelem.CanSet() { - rvelem.Set(reflect.Zero(rvelem.Type())) - } - return - } rvpValid = true - for rv.Kind() == reflect.Ptr { - if rvIsNil(rv) { - rvSetDirect(rv, reflect.New(rv.Type().Elem())) + for { + if rv.IsNil() { + rv.Set(reflect.New(rv.Type().Elem())) } rvp = rv rv = rv.Elem() + if rv.Kind() != reflect.Ptr { + break + } } } if fn == nil { - fn = d.h.fn(rv.Type()) + // always pass checkCodecSelfer=true, in case T or ****T is passed, where *T is a Selfer + fn = d.h.fn(rv.Type(), chkAll, true) // chkAll, chkAll) } if fn.i.addrD { if rvpValid { @@ -1620,6 +2804,7 @@ func (d *Decoder) decodeValue(rv reflect.Value, fn *codecFn) { } else { fn.fd(d, &fn.i, rv) } + // return rv } func (d *Decoder) structFieldNotFound(index int, rvkencname string) { @@ -1642,30 +2827,31 @@ func (d *Decoder) arrayCannotExpand(sliceLen, streamLen int) { } } -func isDecodeable(rv reflect.Value) (canDecode bool) { +func isDecodeable(rv reflect.Value) (rv2 reflect.Value, canDecode bool) { switch rv.Kind() { case reflect.Array: - return rv.CanAddr() + return rv, rv.CanAddr() case reflect.Ptr: - if !rvIsNil(rv) { - return true + if !rv.IsNil() { + return rv.Elem(), true } case reflect.Slice, reflect.Chan, reflect.Map: - if !rvIsNil(rv) { - return true + if !rv.IsNil() { + return rv, true } } return } -func (d *Decoder) ensureDecodeable(rv reflect.Value) { +func (d *Decoder) ensureDecodeable(rv reflect.Value) (rv2 reflect.Value) { // decode can take any reflect.Value that is a inherently addressable i.e. // - array // - non-nil chan (we will SEND to it) // - non-nil slice (we will set its elements) // - non-nil map (we will put into it) // - non-nil pointer (we can "update" it) - if isDecodeable(rv) { + rv2, canDecode := isDecodeable(rv) + if canDecode { return } if !rv.IsValid() { @@ -1678,7 +2864,8 @@ func (d *Decoder) ensureDecodeable(rv reflect.Value) { } rvi := rv2i(rv) rvk := rv.Kind() - d.errorf("cannot decode into value of kind: %v, type: %T, %#v", rvk, rvi, rvi) + d.errorf("cannot decode into value of kind: %v, type: %T, %v", rvk, rvi, rvi) + return } func (d *Decoder) depthIncr() { @@ -1697,9 +2884,6 @@ func (d *Decoder) depthDecr() { // This should mostly be used for map keys, where the key type is string. // This is because keys of a map/struct are typically reused across many objects. func (d *Decoder) string(v []byte) (s string) { - if v == nil { - return - } if d.is == nil { return string(v) // don't return stringView, as we need a real string here. } @@ -1708,15 +2892,15 @@ func (d *Decoder) string(v []byte) (s string) { s = string(v) // new allocation here d.is[s] = s } - return + return s } // nextValueBytes returns the next value in the stream as a set of bytes. func (d *Decoder) nextValueBytes() (bs []byte) { d.d.uncacheRead() - d.r().track() + d.r.track() d.swallow() - bs = d.r().stopTrack() + bs = d.r.stopTrack() return } @@ -1730,180 +2914,60 @@ func (d *Decoder) rawBytes() []byte { } func (d *Decoder) wrapErr(v interface{}, err *error) { - *err = decodeError{codecError: codecError{name: d.hh.Name(), err: v}, pos: d.NumBytesRead()} + *err = decodeError{codecError: codecError{name: d.hh.Name(), err: v}, pos: int(d.r.numread())} } // NumBytesRead returns the number of bytes read func (d *Decoder) NumBytesRead() int { - return int(d.r().numread()) -} - -// decodeFloat32 will delegate to an appropriate DecodeFloat32 implementation (if exists), -// else if will call DecodeFloat64 and ensure the value doesn't overflow. -// -// Note that we return float64 to reduce unnecessary conversions -func (d *Decoder) decodeFloat32() float32 { - if d.js { - return d.jsondriver().DecodeFloat32() // custom implementation for 32-bit - } - return float32(chkOvf.Float32V(d.d.DecodeFloat64())) -} - -// ---- container tracking -// Note: We update the .c after calling the callback. -// This way, the callback can know what the last status was. - -// Note: if you call mapStart and it returns decContainerLenNil, -// then do NOT call mapEnd. - -func (d *Decoder) mapStart() (v int) { - v = d.d.ReadMapStart() - if v != decContainerLenNil { - d.depthIncr() - d.c = containerMapStart - } - return -} - -func (d *Decoder) mapElemKey() { - if d.js { - d.jsondriver().ReadMapElemKey() - } - d.c = containerMapKey -} - -func (d *Decoder) mapElemValue() { - if d.js { - d.jsondriver().ReadMapElemValue() - } - d.c = containerMapValue -} - -func (d *Decoder) mapEnd() { - d.d.ReadMapEnd() - d.depthDecr() - // d.c = containerMapEnd - d.c = 0 -} - -func (d *Decoder) arrayStart() (v int) { - v = d.d.ReadArrayStart() - if v != decContainerLenNil { - d.depthIncr() - d.c = containerArrayStart - } - return -} - -func (d *Decoder) arrayElem() { - if d.js { - d.jsondriver().ReadArrayElem() - } - d.c = containerArrayElem -} - -func (d *Decoder) arrayEnd() { - d.d.ReadArrayEnd() - d.depthDecr() - // d.c = containerArrayEnd - d.c = 0 -} - -func (d *Decoder) interfaceExtConvertAndDecode(v interface{}, ext Ext) { - // var v interface{} = ext.ConvertExt(rv) - // d.d.decode(&v) - // ext.UpdateExt(rv, v) - - // assume v is a pointer: - // - if struct|array, pass as is to ConvertExt - // - else make it non-addressable and pass to ConvertExt - // - make return value from ConvertExt addressable - // - decode into it - // - return the interface for passing into UpdateExt. - // - interface should be a pointer if struct|array, else a value - - var s interface{} - rv := rv4i(v) - rv2 := rv.Elem() - rvk := rv2.Kind() - if rvk == reflect.Struct || rvk == reflect.Array { - s = ext.ConvertExt(v) - } else { - s = ext.ConvertExt(rv2i(rv2)) - } - rv = rv4i(s) - if !rv.CanAddr() { - if rv.Kind() == reflect.Ptr { - rv2 = reflect.New(rv.Type().Elem()) - } else { - rv2 = rvZeroAddrK(rv.Type(), rv.Kind()) - } - rvSetDirect(rv2, rv) - rv = rv2 - } - d.decodeValue(rv, nil) - ext.UpdateExt(v, rv2i(rv)) -} - -func (d *Decoder) sideDecode(v interface{}, bs []byte) { - rv := baseRV(v) - NewDecoderBytes(bs, d.hh).decodeValue(rv, d.h.fnNoExt(rv.Type())) + return int(d.r.numread()) } // -------------------------------------------------- // decSliceHelper assists when decoding into a slice, from a map or an array in the stream. // A slice can be set from a map or array in stream. This supports the MapBySlice interface. -// -// Note: if IsNil, do not call ElemContainerState. type decSliceHelper struct { - d *Decoder - ct valueType - Array bool - IsNil bool + d *Decoder + // ct valueType + array bool } func (d *Decoder) decSliceHelperStart() (x decSliceHelper, clen int) { - x.ct = d.d.ContainerType() - x.d = d - switch x.ct { - case valueTypeNil: - x.IsNil = true + dd := d.d + ctyp := dd.ContainerType() + switch ctyp { case valueTypeArray: - x.Array = true - clen = d.arrayStart() + x.array = true + clen = dd.ReadArrayStart() case valueTypeMap: - clen = d.mapStart() * 2 + clen = dd.ReadMapStart() * 2 default: - d.errorf("only encoded map or array can be decoded into a slice (%d)", x.ct) + d.errorf("only encoded map or array can be decoded into a slice (%d)", ctyp) } + // x.ct = ctyp + x.d = d return } func (x decSliceHelper) End() { - if x.IsNil { - } else if x.Array { - x.d.arrayEnd() + if x.array { + x.d.d.ReadArrayEnd() } else { - x.d.mapEnd() + x.d.d.ReadMapEnd() } } func (x decSliceHelper) ElemContainerState(index int) { - // Note: if isnil, clen=0, so we never call into ElemContainerState - - if x.Array { - x.d.arrayElem() + if x.array { + x.d.d.ReadArrayElem() + } else if index%2 == 0 { + x.d.d.ReadMapElemKey() } else { - if index%2 == 0 { - x.d.mapElemKey() - } else { - x.d.mapElemValue() - } + x.d.d.ReadMapElemValue() } } -func decByteSlice(r *decRd, clen, maxInitLen int, bs []byte) (bsOut []byte) { +func decByteSlice(r *decReaderSwitch, clen, maxInitLen int, bs []byte) (bsOut []byte) { if clen == 0 { return zeroByteSlice } @@ -1914,6 +2978,7 @@ func decByteSlice(r *decRd, clen, maxInitLen int, bs []byte) (bsOut []byte) { bsOut = bs[:clen] r.readb(bsOut) } else { + // bsOut = make([]byte, clen) len2 := decInferLen(clen, maxInitLen, 1) bsOut = make([]byte, len2) r.readb(bsOut) @@ -1929,29 +2994,24 @@ func decByteSlice(r *decRd, clen, maxInitLen int, bs []byte) (bsOut []byte) { return } -// detachZeroCopyBytes will copy the in bytes into dest, -// or create a new one if not large enough. -// -// It is used to ensure that the []byte returned is not -// part of the input stream or input stream buffers. +// func decByteSliceZeroCopy(r decReader, clen, maxInitLen int, bs []byte) (bsOut []byte) { +// if _, ok := r.(*bytesDecReader); ok && clen <= maxInitLen { +// return r.readx(clen) +// } +// return decByteSlice(r, clen, maxInitLen, bs) +// } + func detachZeroCopyBytes(isBytesReader bool, dest []byte, in []byte) (out []byte) { - if len(in) > 0 { - // if isBytesReader || len(in) <= scratchByteArrayLen { - // if cap(dest) >= len(in) { - // out = dest[:len(in)] - // } else { - // out = make([]byte, len(in)) - // } - // copy(out, in) - // return - // } - if cap(dest) >= len(in) { - out = dest[:len(in)] - } else { - out = make([]byte, len(in)) + if xlen := len(in); xlen > 0 { + if isBytesReader || xlen <= scratchByteArrayLen { + if cap(dest) >= xlen { + out = dest[:xlen] + } else { + out = make([]byte, xlen) + } + copy(out, in) + return } - copy(out, in) - return } return in } @@ -1962,24 +3022,10 @@ func detachZeroCopyBytes(isBytesReader bool, dest []byte, in []byte) (out []byte // if <= 0, it is unset, and we infer it based on the unit size // - unit: number of bytes for each element of the collection func decInferLen(clen, maxlen, unit int) (rvlen int) { - const maxLenIfUnset = 8 // 64 // handle when maxlen is not set i.e. <= 0 - - // clen==0: use 0 - // maxlen<=0, clen<0: use default - // maxlen> 0, clen<0: use default - // maxlen<=0, clen>0: infer maxlen, and cap on it - // maxlen> 0, clen>0: cap at maxlen - - if clen == 0 { + if clen <= 0 { return } - if clen < 0 { - if clen == decContainerLenNil { - return 0 - } - return maxLenIfUnset - } if unit == 0 { return clen } @@ -1994,9 +3040,6 @@ func decInferLen(clen, maxlen, unit int) (rvlen int) { } else { maxlen = 4 * 1024 } - // if maxlen > maxLenIfUnset { - // maxlen = maxLenIfUnset - // } } if clen > maxlen { rvlen = maxlen @@ -2006,6 +3049,37 @@ func decInferLen(clen, maxlen, unit int) (rvlen int) { return } +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 { + err = errmsgExpandSliceOverflow + return + } + if l1 <= scap { + if s.CanSet() { + s.SetLen(l1) + } 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 + reflect.Copy(s2, s) + return +} + func decReadFull(r io.Reader, bs []byte) (n uint, err error) { var nn int for n < uint(len(bs)) && err == nil { @@ -2018,6 +3092,7 @@ func decReadFull(r io.Reader, bs []byte) (n uint, err error) { n += uint(nn) } } + // xdebugf("decReadFull: len(bs): %v, n: %v, err: %v", len(bs), n, err) // do not do this - it serves no purpose // if n != len(bs) && err == io.EOF { err = io.ErrUnexpectedEOF } return diff --git a/vendor/github.com/ugorji/go/codec/encode.go b/vendor/github.com/ugorji/go/codec/encode.go index 351dd2d0b261..8462440c3718 100644 --- a/vendor/github.com/ugorji/go/codec/encode.go +++ b/vendor/github.com/ugorji/go/codec/encode.go @@ -9,6 +9,7 @@ import ( "fmt" "io" "reflect" + "runtime" "sort" "strconv" "time" @@ -20,6 +21,22 @@ const defEncByteBufSize = 1 << 10 // 4:16, 6:64, 8:256, 10:1024 var errEncoderNotInitialized = errors.New("Encoder not initialized") +/* + +// encWriter abstracts writing to a byte array or to an io.Writer. +// +// +// Deprecated: Use encWriterSwitch instead. +type encWriter interface { + writeb([]byte) + writestr(string) + writen1(byte) + writen2(byte, byte) + end() +} + +*/ + // encDriver abstracts the actual codec (binc vs msgpack, etc) type encDriver interface { EncodeNil() @@ -28,26 +45,33 @@ type encDriver interface { EncodeBool(b bool) EncodeFloat32(f float32) EncodeFloat64(f float64) - EncodeRawExt(re *RawExt) - EncodeExt(v interface{}, xtag uint64, ext Ext) - // EncodeString using cUTF8, honor'ing StringToRaw flag - EncodeString(v string) + // encodeExtPreamble(xtag byte, length int) + EncodeRawExt(re *RawExt, e *Encoder) + EncodeExt(v interface{}, xtag uint64, ext Ext, e *Encoder) + // Deprecated: use EncodeStringEnc instead + EncodeString(c charEncoding, v string) + // Deprecated: use EncodeStringBytesRaw instead + EncodeStringBytes(c charEncoding, v []byte) + EncodeStringEnc(c charEncoding, v string) // c cannot be cRAW + // EncodeSymbol(v string) EncodeStringBytesRaw(v []byte) EncodeTime(time.Time) + //encBignum(f *big.Int) + //encStringRunes(c charEncoding, v []rune) WriteArrayStart(length int) + WriteArrayElem() WriteArrayEnd() WriteMapStart(length int) + WriteMapElemKey() + WriteMapElemValue() WriteMapEnd() reset() atEndOfEncode() - encoder() *Encoder } -type encDriverContainerTracker interface { - WriteArrayElem() - WriteMapElemKey() - WriteMapElemValue() +type encDriverAsis interface { + EncodeAsis(v []byte) } type encodeError struct { @@ -61,11 +85,33 @@ func (e encodeError) Error() string { 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() {} +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 +// WriteString(s string) (n int, err error) +// 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. @@ -153,99 +199,264 @@ type EncodeOptions struct { // --------------------------------------------- -func (e *Encoder) rawExt(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeRawExt(rv2i(rv).(*RawExt)) +/* + +type ioEncStringWriter interface { + WriteString(s string) (n int, err error) } -func (e *Encoder) ext(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeExt(rv2i(rv), f.xfTag, f.xfFn) +// 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 ioFlusher + b [8]byte } -func (e *Encoder) selferMarshal(f *codecFnInfo, rv reflect.Value) { - rv2i(rv).(Selfer).CodecEncodeSelf(e) +func (z *ioEncWriter) reset(w io.Writer) { + z.w = w + var ok bool + if z.bw, ok = w.(io.ByteWriter); !ok { + z.bw = z + } + if z.sw, ok = w.(ioEncStringWriter); !ok { + z.sw = z + } + z.fw, _ = w.(ioFlusher) + z.ww = w } -func (e *Encoder) binaryMarshal(f *codecFnInfo, rv reflect.Value) { - bs, fnerr := rv2i(rv).(encoding.BinaryMarshaler).MarshalBinary() - e.marshalRaw(bs, fnerr) +func (z *ioEncWriter) WriteByte(b byte) (err error) { + z.b[0] = b + _, err = z.w.Write(z.b[:1]) + return } -func (e *Encoder) textMarshal(f *codecFnInfo, rv reflect.Value) { - bs, fnerr := rv2i(rv).(encoding.TextMarshaler).MarshalText() - e.marshalUtf8(bs, fnerr) +func (z *ioEncWriter) WriteString(s string) (n int, err error) { + return z.w.Write(bytesView(s)) } -func (e *Encoder) jsonMarshal(f *codecFnInfo, rv reflect.Value) { - bs, fnerr := rv2i(rv).(jsonMarshaler).MarshalJSON() - e.marshalAsis(bs, fnerr) +func (z *ioEncWriter) writeb(bs []byte) { + if _, err := z.ww.Write(bs); err != nil { + panic(err) + } } -func (e *Encoder) raw(f *codecFnInfo, rv reflect.Value) { - e.rawBytes(rv2i(rv).(Raw)) +func (z *ioEncWriter) writestr(s string) { + if _, err := z.sw.WriteString(s); err != nil { + panic(err) + } +} + +func (z *ioEncWriter) writen1(b byte) { + if err := z.bw.WriteByte(b); err != nil { + panic(err) + } +} + +func (z *ioEncWriter) writen2(b1, b2 byte) { + var err error + if err = z.bw.WriteByte(b1); err == nil { + if err = z.bw.WriteByte(b2); err == nil { + return + } + } + 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) +// } +// } + +//go:noinline - so *encWriterSwitch.XXX has the bytesEncAppender.XXX inlined +func (z *ioEncWriter) end() { + if z.fw != nil { + if err := z.fw.Flush(); err != nil { + panic(err) + } + } +} + +*/ + +// --------------------------------------------- + +// bufioEncWriter +type bufioEncWriter struct { + buf []byte + w io.Writer + n int + sz int // buf size + + // Extensions can call Encode() within a current Encode() call. + // We need to know when the top level Encode() call returns, + // so we can decide whether to Release() or not. + calls uint16 // what depth in mustDecode are we in now. + + _ [6]uint8 // padding + + bytesBufPooler + + _ [1]uint64 // padding + // a int + // b [4]byte + // err } -func (e *Encoder) kBool(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeBool(rvGetBool(rv)) +func (z *bufioEncWriter) reset(w io.Writer, bufsize int) { + z.w = w + z.n = 0 + z.calls = 0 + if bufsize <= 0 { + bufsize = defEncByteBufSize + } + z.sz = bufsize + if cap(z.buf) >= bufsize { + z.buf = z.buf[:cap(z.buf)] + } else { + z.buf = z.bytesBufPooler.get(bufsize) + // z.buf = make([]byte, bufsize) + } } -func (e *Encoder) kTime(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeTime(rvGetTime(rv)) +func (z *bufioEncWriter) release() { + z.buf = nil + z.bytesBufPooler.end() } -func (e *Encoder) kString(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeString(rvGetString(rv)) +//go:noinline - flush only called intermittently +func (z *bufioEncWriter) flushErr() (err error) { + n, err := z.w.Write(z.buf[:z.n]) + z.n -= n + if z.n > 0 && err == nil { + err = io.ErrShortWrite + } + if n > 0 && z.n > 0 { + copy(z.buf, z.buf[n:z.n+n]) + } + return err } -func (e *Encoder) kFloat64(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeFloat64(rvGetFloat64(rv)) +func (z *bufioEncWriter) flush() { + if err := z.flushErr(); err != nil { + panic(err) + } } -func (e *Encoder) kFloat32(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeFloat32(rvGetFloat32(rv)) +func (z *bufioEncWriter) writeb(s []byte) { +LOOP: + a := len(z.buf) - z.n + if len(s) > a { + z.n += copy(z.buf[z.n:], s[:a]) + s = s[a:] + z.flush() + goto LOOP + } + z.n += copy(z.buf[z.n:], s) +} + +func (z *bufioEncWriter) writestr(s string) { + // z.writeb(bytesView(s)) // inlined below +LOOP: + a := len(z.buf) - z.n + if len(s) > a { + z.n += copy(z.buf[z.n:], s[:a]) + s = s[a:] + z.flush() + goto LOOP + } + z.n += copy(z.buf[z.n:], s) } -func (e *Encoder) kInt(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeInt(int64(rvGetInt(rv))) +func (z *bufioEncWriter) writen1(b1 byte) { + if 1 > len(z.buf)-z.n { + z.flush() + } + z.buf[z.n] = b1 + z.n++ } -func (e *Encoder) kInt8(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeInt(int64(rvGetInt8(rv))) +func (z *bufioEncWriter) writen2(b1, b2 byte) { + if 2 > len(z.buf)-z.n { + z.flush() + } + z.buf[z.n+1] = b2 + z.buf[z.n] = b1 + z.n += 2 } -func (e *Encoder) kInt16(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeInt(int64(rvGetInt16(rv))) +func (z *bufioEncWriter) endErr() (err error) { + if z.n > 0 { + err = z.flushErr() + } + return } -func (e *Encoder) kInt32(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeInt(int64(rvGetInt32(rv))) +// --------------------------------------------- + +// bytesEncAppender implements encWriter and can write to an byte slice. +type bytesEncAppender struct { + b []byte + out *[]byte } -func (e *Encoder) kInt64(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeInt(int64(rvGetInt64(rv))) +func (z *bytesEncAppender) writeb(s []byte) { + z.b = append(z.b, s...) +} +func (z *bytesEncAppender) writestr(s string) { + z.b = append(z.b, s...) +} +func (z *bytesEncAppender) writen1(b1 byte) { + z.b = append(z.b, b1) +} +func (z *bytesEncAppender) writen2(b1, b2 byte) { + z.b = append(z.b, b1, b2) +} +func (z *bytesEncAppender) endErr() error { + *(z.out) = z.b + return nil } +func (z *bytesEncAppender) reset(in []byte, out *[]byte) { + z.b = in[:0] + z.out = out +} + +// --------------------------------------------- -func (e *Encoder) kUint(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeUint(uint64(rvGetUint(rv))) +func (e *Encoder) rawExt(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeRawExt(rv2i(rv).(*RawExt), e) } -func (e *Encoder) kUint8(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeUint(uint64(rvGetUint8(rv))) +func (e *Encoder) ext(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeExt(rv2i(rv), f.xfTag, f.xfFn, e) } -func (e *Encoder) kUint16(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeUint(uint64(rvGetUint16(rv))) +func (e *Encoder) selferMarshal(f *codecFnInfo, rv reflect.Value) { + rv2i(rv).(Selfer).CodecEncodeSelf(e) } -func (e *Encoder) kUint32(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeUint(uint64(rvGetUint32(rv))) +func (e *Encoder) binaryMarshal(f *codecFnInfo, rv reflect.Value) { + bs, fnerr := rv2i(rv).(encoding.BinaryMarshaler).MarshalBinary() + e.marshalRaw(bs, fnerr) } -func (e *Encoder) kUint64(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeUint(uint64(rvGetUint64(rv))) +func (e *Encoder) textMarshal(f *codecFnInfo, rv reflect.Value) { + bs, fnerr := rv2i(rv).(encoding.TextMarshaler).MarshalText() + e.marshalUtf8(bs, fnerr) } -func (e *Encoder) kUintptr(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeUint(uint64(rvGetUintptr(rv))) +func (e *Encoder) jsonMarshal(f *codecFnInfo, rv reflect.Value) { + bs, fnerr := rv2i(rv).(jsonMarshaler).MarshalJSON() + e.marshalAsis(bs, fnerr) +} + +func (e *Encoder) raw(f *codecFnInfo, rv reflect.Value) { + e.rawBytes(rv2i(rv).(Raw)) } func (e *Encoder) kInvalid(f *codecFnInfo, rv reflect.Value) { @@ -256,354 +467,373 @@ func (e *Encoder) kErr(f *codecFnInfo, rv reflect.Value) { e.errorf("unsupported kind %s, for %#v", rv.Kind(), rv) } -func chanToSlice(rv reflect.Value, rtslice reflect.Type, timeout time.Duration) (rvcs reflect.Value) { - rvcs = reflect.Zero(rtslice) - if timeout < 0 { // consume until close - for { - recv, recvOk := rv.Recv() - if !recvOk { - break - } - rvcs = reflect.Append(rvcs, recv) - } - } else { - cases := make([]reflect.SelectCase, 2) - cases[0] = reflect.SelectCase{Dir: reflect.SelectRecv, Chan: rv} - if timeout == 0 { - cases[1] = reflect.SelectCase{Dir: reflect.SelectDefault} - } else { - tt := time.NewTimer(timeout) - cases[1] = reflect.SelectCase{Dir: reflect.SelectRecv, Chan: rv4i(tt.C)} +func (e *Encoder) kSlice(f *codecFnInfo, rv reflect.Value) { + ti := f.ti + ee := e.e + // array may be non-addressable, so we have to manage with care + // (don't call rv.Bytes, rv.Slice, etc). + // E.g. type struct S{B [2]byte}; + // Encode(S{}) will bomb on "panic: slice of unaddressable array". + if f.seq != seqTypeArray { + if rv.IsNil() { + ee.EncodeNil() + return } - for { - chosen, recv, recvOk := reflect.Select(cases) - if chosen == 1 || !recvOk { - break - } - rvcs = reflect.Append(rvcs, recv) + // If in this method, then there was no extension function defined. + // So it's okay to treat as []byte. + if ti.rtid == uint8SliceTypId { + ee.EncodeStringBytesRaw(rv.Bytes()) + return } } - return -} - -func (e *Encoder) kSeqFn(rtelem reflect.Type) (fn *codecFn) { - 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.h.fn(rtelem) + if f.seq == seqTypeChan && ti.chandir&uint8(reflect.RecvDir) == 0 { + e.errorf("send-only channel cannot be encoded") } - return -} - -func (e *Encoder) kSliceWMbs(rv reflect.Value, ti *typeInfo) { - var l = rvGetSliceLen(rv) - if l == 0 { - e.mapStart(0) - } else { - if l%2 == 1 { - e.errorf("mapBySlice requires even slice length, but got %v", l) - return - } - e.mapStart(l / 2) - fn := e.kSeqFn(ti.elem) - for j := 0; j < l; j++ { - if j%2 == 0 { - e.mapElemKey() + elemsep := e.esep + rtelem := ti.elem + rtelemIsByte := uint8TypId == rt2id(rtelem) // NOT rtelem.Kind() == reflect.Uint8 + var l int + // if a slice, array or chan of bytes, treat specially + if rtelemIsByte { + switch f.seq { + case seqTypeSlice: + ee.EncodeStringBytesRaw(rv.Bytes()) + case seqTypeArray: + l = rv.Len() + if rv.CanAddr() { + ee.EncodeStringBytesRaw(rv.Slice(0, l).Bytes()) } else { - e.mapElemValue() + var bs []byte + if l <= cap(e.b) { + bs = e.b[:l] + } else { + bs = make([]byte, l) + } + reflect.Copy(reflect.ValueOf(bs), rv) + ee.EncodeStringBytesRaw(bs) + } + case seqTypeChan: + // 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. + + if rv.IsNil() { + ee.EncodeNil() + break + } + bs := e.b[:0] + irv := rv2i(rv) + ch, ok := irv.(<-chan byte) + if !ok { + ch = irv.(chan byte) } - e.encodeValue(rvSliceIndex(rv, j, ti), fn) + + L1: + switch timeout := e.h.ChanRecvTimeout; { + case timeout == 0: // only consume available + for { + select { + case b := <-ch: + bs = append(bs, b) + default: + break L1 + } + } + case timeout > 0: // consume until timeout + tt := time.NewTimer(timeout) + for { + select { + case b := <-ch: + bs = append(bs, b) + case <-tt.C: + // close(tt.C) + break L1 + } + } + default: // consume until close + for b := range ch { + bs = append(bs, b) + } + } + + ee.EncodeStringBytesRaw(bs) } + return } - e.mapEnd() -} -func (e *Encoder) kSliceW(rv reflect.Value, ti *typeInfo) { - var l = rvGetSliceLen(rv) - e.arrayStart(l) - if l > 0 { - fn := e.kSeqFn(ti.elem) - for j := 0; j < l; j++ { - e.arrayElem() - e.encodeValue(rvSliceIndex(rv, j, ti), fn) + // if chan, consume chan into a slice, and work off that slice. + if f.seq == seqTypeChan { + rvcs := reflect.Zero(reflect.SliceOf(rtelem)) + timeout := e.h.ChanRecvTimeout + if timeout < 0 { // consume until close + for { + recv, recvOk := rv.Recv() + if !recvOk { + break + } + rvcs = reflect.Append(rvcs, recv) + } + } else { + cases := make([]reflect.SelectCase, 2) + cases[0] = reflect.SelectCase{Dir: reflect.SelectRecv, Chan: rv} + if timeout == 0 { + cases[1] = reflect.SelectCase{Dir: reflect.SelectDefault} + } else { + tt := time.NewTimer(timeout) + cases[1] = reflect.SelectCase{Dir: reflect.SelectRecv, Chan: reflect.ValueOf(tt.C)} + } + for { + chosen, recv, recvOk := reflect.Select(cases) + if chosen == 1 || !recvOk { + break + } + rvcs = reflect.Append(rvcs, recv) + } } + rv = rvcs // TODO: ensure this doesn't mess up anywhere that rv of kind chan is expected } - e.arrayEnd() -} -func (e *Encoder) kSeqWMbs(rv reflect.Value, ti *typeInfo) { - var l = rv.Len() - if l == 0 { - e.mapStart(0) - } else { + l = rv.Len() + if ti.mbs { if l%2 == 1 { e.errorf("mapBySlice requires even slice length, but got %v", l) return } - e.mapStart(l / 2) - fn := e.kSeqFn(ti.elem) - for j := 0; j < l; j++ { - if j%2 == 0 { - e.mapElemKey() - } else { - e.mapElemValue() - } - e.encodeValue(rv.Index(j), fn) - } + ee.WriteMapStart(l / 2) + } else { + ee.WriteArrayStart(l) } - e.mapEnd() -} -func (e *Encoder) kSeqW(rv reflect.Value, ti *typeInfo) { - var l = rv.Len() - e.arrayStart(l) if l > 0 { - fn := e.kSeqFn(ti.elem) + var fn *codecFn + 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.h.fn(rtelem, true, true) + } for j := 0; j < l; j++ { - e.arrayElem() - e.encodeValue(rv.Index(j), fn) + if elemsep { + if ti.mbs { + if j%2 == 0 { + ee.WriteMapElemKey() + } else { + ee.WriteMapElemValue() + } + } else { + ee.WriteArrayElem() + } + } + e.encodeValue(rv.Index(j), fn, true) } } - e.arrayEnd() -} -func (e *Encoder) kChan(f *codecFnInfo, rv reflect.Value) { - if rvIsNil(rv) { - e.e.EncodeNil() - return - } - if f.ti.chandir&uint8(reflect.RecvDir) == 0 { - e.errorf("send-only channel cannot be encoded") - return - } - if !f.ti.mbs && uint8TypId == rt2id(f.ti.elem) { - e.kSliceBytesChan(rv) - return - } - rtslice := reflect.SliceOf(f.ti.elem) - rv = chanToSlice(rv, rtslice, e.h.ChanRecvTimeout) - ti := e.h.getTypeInfo(rt2id(rtslice), rtslice) - if f.ti.mbs { - e.kSliceWMbs(rv, ti) - } else { - e.kSliceW(rv, ti) - } -} - -func (e *Encoder) kSlice(f *codecFnInfo, rv reflect.Value) { - if rvIsNil(rv) { - e.e.EncodeNil() - return - } - if f.ti.mbs { - e.kSliceWMbs(rv, f.ti) + if ti.mbs { + ee.WriteMapEnd() } else { - if f.ti.rtid == uint8SliceTypId || uint8TypId == rt2id(f.ti.elem) { - e.e.EncodeStringBytesRaw(rvGetBytes(rv)) - } else { - e.kSliceW(rv, f.ti) - } + ee.WriteArrayEnd() } } -func (e *Encoder) kArray(f *codecFnInfo, rv reflect.Value) { - if f.ti.mbs { - e.kSeqWMbs(rv, f.ti) - } else { - if uint8TypId == rt2id(f.ti.elem) { - e.e.EncodeStringBytesRaw(rvGetArrayBytesRO(rv, e.b[:])) - } else { - e.kSeqW(rv, f.ti) - } +func (e *Encoder) kStructNoOmitempty(f *codecFnInfo, rv reflect.Value) { + fti := f.ti + tisfi := fti.sfiSrc + toMap := !(fti.toArray || e.h.StructToArray) + if toMap { + tisfi = fti.sfiSort } -} - -func (e *Encoder) kSliceBytesChan(rv reflect.Value) { - // 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. + ee := e.e - bs := e.b[:0] - irv := rv2i(rv) - ch, ok := irv.(<-chan byte) - if !ok { - ch = irv.(chan byte) - } - -L1: - switch timeout := e.h.ChanRecvTimeout; { - case timeout == 0: // only consume available - for { - select { - case b := <-ch: - bs = append(bs, b) - default: - break L1 + sfn := structFieldNode{v: rv, update: false} + if toMap { + ee.WriteMapStart(len(tisfi)) + if e.esep { + for _, si := range tisfi { + ee.WriteMapElemKey() + e.kStructFieldKey(fti.keyType, si.encNameAsciiAlphaNum, si.encName) + ee.WriteMapElemValue() + e.encodeValue(sfn.field(si), nil, true) } - } - case timeout > 0: // consume until timeout - tt := time.NewTimer(timeout) - for { - select { - case b := <-ch: - bs = append(bs, b) - case <-tt.C: - // close(tt.C) - break L1 + } else { + for _, si := range tisfi { + e.kStructFieldKey(fti.keyType, si.encNameAsciiAlphaNum, si.encName) + e.encodeValue(sfn.field(si), nil, true) } } - default: // consume until close - for b := range ch { - bs = append(bs, b) - } - } - - e.e.EncodeStringBytesRaw(bs) -} - -func (e *Encoder) kStructNoOmitempty(f *codecFnInfo, rv reflect.Value) { - sfn := structFieldNode{v: rv, update: false} - if f.ti.toArray || e.h.StructToArray { // toArray - e.arrayStart(len(f.ti.sfiSrc)) - for _, si := range f.ti.sfiSrc { - e.arrayElem() - e.encodeValue(sfn.field(si), nil) - } - e.arrayEnd() + ee.WriteMapEnd() } else { - e.mapStart(len(f.ti.sfiSort)) - for _, si := range f.ti.sfiSort { - e.mapElemKey() - e.kStructFieldKey(f.ti.keyType, si.encNameAsciiAlphaNum, si.encName) - e.mapElemValue() - e.encodeValue(sfn.field(si), nil) + ee.WriteArrayStart(len(tisfi)) + if e.esep { + for _, si := range tisfi { + ee.WriteArrayElem() + e.encodeValue(sfn.field(si), nil, true) + } + } else { + for _, si := range tisfi { + e.encodeValue(sfn.field(si), nil, true) + } } - e.mapEnd() + ee.WriteArrayEnd() } } func (e *Encoder) kStructFieldKey(keyType valueType, encNameAsciiAlphaNum bool, encName string) { - encStructFieldKey(encName, e.e, e.w(), keyType, encNameAsciiAlphaNum, e.js) + encStructFieldKey(encName, e.e, e.w, keyType, encNameAsciiAlphaNum, e.js) } func (e *Encoder) kStruct(f *codecFnInfo, rv reflect.Value) { + fti := f.ti + elemsep := e.esep + tisfi := fti.sfiSrc var newlen int - toMap := !(f.ti.toArray || e.h.StructToArray) + toMap := !(fti.toArray || e.h.StructToArray) var mf map[string]interface{} - if f.ti.isFlag(tiflagMissingFielder) { + if f.ti.mf { mf = rv2i(rv).(MissingFielder).CodecMissingFields() toMap = true newlen += len(mf) - } else if f.ti.isFlag(tiflagMissingFielderPtr) { + } else if f.ti.mfp { if rv.CanAddr() { mf = rv2i(rv.Addr()).(MissingFielder).CodecMissingFields() } else { // make a new addressable value of same one, and use it rv2 := reflect.New(rv.Type()) - rvSetDirect(rv2.Elem(), rv) + rv2.Elem().Set(rv) mf = rv2i(rv2).(MissingFielder).CodecMissingFields() } toMap = true newlen += len(mf) } - newlen += len(f.ti.sfiSrc) + // if toMap, use the sorted array. If toArray, use unsorted array (to match sequence in struct) + if toMap { + tisfi = fti.sfiSort + } + newlen += len(tisfi) + ee := e.e - var fkvs = e.slist.get(newlen) + // Use sync.Pool to reduce allocating slices unnecessarily. + // The cost of sync.Pool is less than the cost of new allocation. + // + // Each element of the array pools one of encStructPool(8|16|32|64). + // It allows the re-use of slices up to 64 in length. + // A performance cost of encoding structs was collecting + // which values were empty and should be omitted. + // We needed slices of reflect.Value and string to collect them. + // This shared pool reduces the amount of unnecessary creation we do. + // The cost is that of locking sometimes, but sync.Pool is efficient + // enough to reduce thread contention. + + // fmt.Printf(">>>>>>>>>>>>>> encode.kStruct: newlen: %d\n", newlen) + var spool sfiRvPooler + var fkvs = spool.get(newlen) + var kv sfiRv recur := e.h.RecursiveEmptyCheck sfn := structFieldNode{v: rv, update: false} - - var kv sfiRv - var j int - if toMap { - newlen = 0 - for _, si := range f.ti.sfiSort { // use sorted array - kv.r = sfn.field(si) + newlen = 0 + for _, si := range tisfi { + // kv.r = si.field(rv, false) + kv.r = sfn.field(si) + if toMap { if si.omitEmpty() && isEmptyValue(kv.r, e.h.TypeInfos, recur, recur) { continue } kv.v = si // si.encName - fkvs[newlen] = kv - newlen++ + } 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, 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 + } + } } - var mflen int - for k, v := range mf { - if k == "" { - delete(mf, k) - continue + fkvs[newlen] = kv + newlen++ + } + fkvs = fkvs[:newlen] + + var mflen int + for k, v := range mf { + if k == "" { + delete(mf, k) + continue + } + if fti.infoFieldOmitempty && isEmptyValue(reflect.ValueOf(v), e.h.TypeInfos, recur, recur) { + delete(mf, k) + continue + } + mflen++ + } + + var j int + if toMap { + ee.WriteMapStart(newlen + mflen) + if elemsep { + for j = 0; j < len(fkvs); j++ { + kv = fkvs[j] + ee.WriteMapElemKey() + e.kStructFieldKey(fti.keyType, kv.v.encNameAsciiAlphaNum, kv.v.encName) + ee.WriteMapElemValue() + e.encodeValue(kv.r, nil, true) } - if f.ti.infoFieldOmitempty && isEmptyValue(rv4i(v), e.h.TypeInfos, recur, recur) { - delete(mf, k) - continue + } else { + for j = 0; j < len(fkvs); j++ { + kv = fkvs[j] + e.kStructFieldKey(fti.keyType, kv.v.encNameAsciiAlphaNum, kv.v.encName) + e.encodeValue(kv.r, nil, true) } - mflen++ - } - // encode it all - e.mapStart(newlen + mflen) - for j = 0; j < newlen; j++ { - kv = fkvs[j] - e.mapElemKey() - e.kStructFieldKey(f.ti.keyType, kv.v.encNameAsciiAlphaNum, kv.v.encName) - e.mapElemValue() - e.encodeValue(kv.r, nil) } // now, add the others for k, v := range mf { - e.mapElemKey() - e.kStructFieldKey(f.ti.keyType, false, k) - e.mapElemValue() + ee.WriteMapElemKey() + e.kStructFieldKey(fti.keyType, false, k) + ee.WriteMapElemValue() e.encode(v) } - e.mapEnd() + ee.WriteMapEnd() } else { - newlen = len(f.ti.sfiSrc) - for i, si := range f.ti.sfiSrc { // use unsorted array (to match sequence in struct) - kv.r = sfn.field(si) - // 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, 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 - } + ee.WriteArrayStart(newlen) + if elemsep { + for j = 0; j < len(fkvs); j++ { + ee.WriteArrayElem() + e.encodeValue(fkvs[j].r, nil, true) + } + } else { + for j = 0; j < len(fkvs); j++ { + e.encodeValue(fkvs[j].r, nil, true) } - fkvs[i] = kv - } - // encode it all - e.arrayStart(newlen) - for j = 0; j < newlen; j++ { - e.arrayElem() - e.encodeValue(fkvs[j].r, nil) } - e.arrayEnd() + ee.WriteArrayEnd() } // do not use defer. Instead, use explicit pool return at end of function. // defer has a cost we are trying to avoid. // If there is a panic and these slices are not returned, it is ok. - // spool.end() - e.slist.put(fkvs) + spool.end() } func (e *Encoder) kMap(f *codecFnInfo, rv reflect.Value) { - if rvIsNil(rv) { - e.e.EncodeNil() + ee := e.e + if rv.IsNil() { + ee.EncodeNil() return } l := rv.Len() - e.mapStart(l) + ee.WriteMapStart(l) if l == 0 { - e.mapEnd() + ee.WriteMapEnd() return } - + // 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. @@ -611,77 +841,67 @@ func (e *Encoder) kMap(f *codecFnInfo, rv reflect.Value) { // However, 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. - var keyFn, valFn *codecFn - - ktypeKind := f.ti.key.Kind() - vtypeKind := f.ti.elem.Kind() - - rtval := f.ti.elem - rtvalkind := vtypeKind - for rtvalkind == reflect.Ptr { + ti := f.ti + rtkey0 := ti.key + rtkey := rtkey0 + rtval0 := ti.elem + rtval := rtval0 + // rtkeyid := rt2id(rtkey0) + for rtval.Kind() == reflect.Ptr { rtval = rtval.Elem() - rtvalkind = rtval.Kind() } - if rtvalkind != reflect.Interface { - valFn = e.h.fn(rtval) + if rtval.Kind() != reflect.Interface { + valFn = e.h.fn(rtval, true, true) } - - var rvv = mapAddressableRV(f.ti.elem, vtypeKind) + mks := rv.MapKeys() if e.h.Canonical { - e.kMapCanonical(f.ti.key, f.ti.elem, rv, rvv, valFn) - e.mapEnd() + e.kMapCanonical(rtkey, rv, mks, valFn) + ee.WriteMapEnd() return } - rtkey := f.ti.key - var keyTypeIsString = stringTypId == rt2id(rtkey) // rtkeyid + var keyTypeIsString = stringTypId == rt2id(rtkey0) // rtkeyid if !keyTypeIsString { for rtkey.Kind() == reflect.Ptr { rtkey = rtkey.Elem() } if rtkey.Kind() != reflect.Interface { - keyFn = e.h.fn(rtkey) + // rtkeyid = rt2id(rtkey) + keyFn = e.h.fn(rtkey, true, true) } } - var rvk = mapAddressableRV(f.ti.key, ktypeKind) - - var it mapIter - mapRange(&it, rv, rvk, rvv, true) - validKV := it.ValidKV() - var vx reflect.Value - for it.Next() { - e.mapElemKey() - if validKV { - vx = it.Key() - } else { - vx = rvk + // for j, lmks := 0, len(mks); j < lmks; j++ { + for j := range mks { + if e.esep { + ee.WriteMapElemKey() } if keyTypeIsString { - e.e.EncodeString(vx.String()) + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(mks[j].String())) + } else { + ee.EncodeStringEnc(cUTF8, mks[j].String()) + } } else { - e.encodeValue(vx, keyFn) + e.encodeValue(mks[j], keyFn, true) } - e.mapElemValue() - if validKV { - vx = it.Value() - } else { - vx = rvv + if e.esep { + ee.WriteMapElemValue() } - e.encodeValue(vx, valFn) - } - it.Done() + e.encodeValue(rv.MapIndex(mks[j]), valFn, true) - e.mapEnd() + } + ee.WriteMapEnd() } -func (e *Encoder) kMapCanonical(rtkey, rtval reflect.Type, rv, rvv reflect.Value, valFn *codecFn) { +func (e *Encoder) kMapCanonical(rtkey reflect.Type, rv reflect.Value, mks []reflect.Value, valFn *codecFn) { + ee := e.e + 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. - mks := rv.MapKeys() switch rtkey.Kind() { case reflect.Bool: mksv := make([]boolRv, len(mks)) @@ -692,10 +912,14 @@ func (e *Encoder) kMapCanonical(rtkey, rtval reflect.Type, rv, rvv reflect.Value } sort.Sort(boolRvSlice(mksv)) for i := range mksv { - e.mapElemKey() - e.e.EncodeBool(mksv[i].v) - e.mapElemValue() - e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn) + if elemsep { + ee.WriteMapElemKey() + } + ee.EncodeBool(mksv[i].v) + if elemsep { + ee.WriteMapElemValue() + } + e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true) } case reflect.String: mksv := make([]stringRv, len(mks)) @@ -706,69 +930,93 @@ func (e *Encoder) kMapCanonical(rtkey, rtval reflect.Type, rv, rvv reflect.Value } sort.Sort(stringRvSlice(mksv)) for i := range mksv { - e.mapElemKey() - e.e.EncodeString(mksv[i].v) - e.mapElemValue() - e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn) + if elemsep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(mksv[i].v)) + } else { + ee.EncodeStringEnc(cUTF8, mksv[i].v) + } + if elemsep { + ee.WriteMapElemValue() + } + e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true) } case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint, reflect.Uintptr: - mksv := make([]uint64Rv, len(mks)) + mksv := make([]uintRv, len(mks)) for i, k := range mks { v := &mksv[i] v.r = k v.v = k.Uint() } - sort.Sort(uint64RvSlice(mksv)) + sort.Sort(uintRvSlice(mksv)) for i := range mksv { - e.mapElemKey() - e.e.EncodeUint(mksv[i].v) - e.mapElemValue() - e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn) + if elemsep { + ee.WriteMapElemKey() + } + ee.EncodeUint(mksv[i].v) + if elemsep { + ee.WriteMapElemValue() + } + e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true) } case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: - mksv := make([]int64Rv, len(mks)) + mksv := make([]intRv, len(mks)) for i, k := range mks { v := &mksv[i] v.r = k v.v = k.Int() } - sort.Sort(int64RvSlice(mksv)) + sort.Sort(intRvSlice(mksv)) for i := range mksv { - e.mapElemKey() - e.e.EncodeInt(mksv[i].v) - e.mapElemValue() - e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn) + if elemsep { + ee.WriteMapElemKey() + } + ee.EncodeInt(mksv[i].v) + if elemsep { + ee.WriteMapElemValue() + } + e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true) } case reflect.Float32: - mksv := make([]float64Rv, len(mks)) + mksv := make([]floatRv, len(mks)) for i, k := range mks { v := &mksv[i] v.r = k v.v = k.Float() } - sort.Sort(float64RvSlice(mksv)) + sort.Sort(floatRvSlice(mksv)) for i := range mksv { - e.mapElemKey() - e.e.EncodeFloat32(float32(mksv[i].v)) - e.mapElemValue() - e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn) + if elemsep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(float32(mksv[i].v)) + if elemsep { + ee.WriteMapElemValue() + } + e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true) } case reflect.Float64: - mksv := make([]float64Rv, len(mks)) + mksv := make([]floatRv, len(mks)) for i, k := range mks { v := &mksv[i] v.r = k v.v = k.Float() } - sort.Sort(float64RvSlice(mksv)) + sort.Sort(floatRvSlice(mksv)) for i := range mksv { - e.mapElemKey() - e.e.EncodeFloat64(mksv[i].v) - e.mapElemValue() - e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn) + if elemsep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(mksv[i].v) + if elemsep { + ee.WriteMapElemValue() + } + e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true) } case reflect.Struct: - if rtkey == timeTyp { + if rv.Type() == timeTyp { mksv := make([]timeRv, len(mks)) for i, k := range mks { v := &mksv[i] @@ -777,10 +1025,14 @@ func (e *Encoder) kMapCanonical(rtkey, rtval reflect.Type, rv, rvv reflect.Value } sort.Sort(timeRvSlice(mksv)) for i := range mksv { - e.mapElemKey() - e.e.EncodeTime(mksv[i].v) - e.mapElemValue() - e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn) + if elemsep { + ee.WriteMapElemKey() + } + ee.EncodeTime(mksv[i].v) + if elemsep { + ee.WriteMapElemValue() + } + e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true) } break } @@ -788,7 +1040,7 @@ func (e *Encoder) kMapCanonical(rtkey, rtval reflect.Type, rv, rvv reflect.Value default: // out-of-band // first encode each key to a []byte first, then sort them, then record - var mksv []byte = e.blist.get(len(mks) * 16)[:0] + var mksv []byte = make([]byte, 0, len(mks)*16) // temporary byte slice for the encoding e2 := NewEncoderBytes(&mksv, e.hh) mksbv := make([]bytesRv, len(mks)) for i, k := range mks { @@ -800,15 +1052,169 @@ func (e *Encoder) kMapCanonical(rtkey, rtval reflect.Type, rv, rvv reflect.Value } sort.Sort(bytesRvSlice(mksbv)) for j := range mksbv { - e.mapElemKey() - e.encWr.writeb(mksbv[j].v) // e.asis(mksbv[j].v) - e.mapElemValue() - e.encodeValue(mapGet(rv, mksbv[j].r, rvv), valFn) + if elemsep { + ee.WriteMapElemKey() + } + e.asis(mksbv[j].v) + if elemsep { + ee.WriteMapElemValue() + } + e.encodeValue(rv.MapIndex(mksbv[j].r), valFn, true) } - e.blist.put(mksv) } } +// // -------------------------------------------------- + +type encWriterSwitch struct { + // wi *ioEncWriter + wb bytesEncAppender + wf *bufioEncWriter + // typ entryType + bytes bool // encoding to []byte + esep bool // whether it has elem separators + isas bool // whether e.as != nil + js bool // is json encoder? + be bool // is binary encoder? + _ [2]byte // padding + // _ [2]uint64 // padding + // _ uint64 // padding +} + +func (z *encWriterSwitch) writeb(s []byte) { + if z.bytes { + z.wb.writeb(s) + } else { + z.wf.writeb(s) + } +} +func (z *encWriterSwitch) writestr(s string) { + if z.bytes { + z.wb.writestr(s) + } else { + z.wf.writestr(s) + } +} +func (z *encWriterSwitch) writen1(b1 byte) { + if z.bytes { + z.wb.writen1(b1) + } else { + z.wf.writen1(b1) + } +} +func (z *encWriterSwitch) writen2(b1, b2 byte) { + if z.bytes { + z.wb.writen2(b1, b2) + } else { + z.wf.writen2(b1, b2) + } +} +func (z *encWriterSwitch) endErr() error { + if z.bytes { + return z.wb.endErr() + } + return z.wf.endErr() +} + +func (z *encWriterSwitch) end() { + if err := z.endErr(); err != nil { + panic(err) + } +} + +/* + +// ------------------------------------------ +func (z *encWriterSwitch) writeb(s []byte) { + switch z.typ { + case entryTypeBytes: + z.wb.writeb(s) + case entryTypeIo: + z.wi.writeb(s) + default: + z.wf.writeb(s) + } +} +func (z *encWriterSwitch) writestr(s string) { + switch z.typ { + case entryTypeBytes: + z.wb.writestr(s) + case entryTypeIo: + z.wi.writestr(s) + default: + z.wf.writestr(s) + } +} +func (z *encWriterSwitch) writen1(b1 byte) { + switch z.typ { + case entryTypeBytes: + z.wb.writen1(b1) + case entryTypeIo: + z.wi.writen1(b1) + default: + z.wf.writen1(b1) + } +} +func (z *encWriterSwitch) writen2(b1, b2 byte) { + switch z.typ { + case entryTypeBytes: + z.wb.writen2(b1, b2) + case entryTypeIo: + z.wi.writen2(b1, b2) + default: + z.wf.writen2(b1, b2) + } +} +func (z *encWriterSwitch) end() { + switch z.typ { + case entryTypeBytes: + z.wb.end() + case entryTypeIo: + z.wi.end() + default: + z.wf.end() + } +} + +// ------------------------------------------ +func (z *encWriterSwitch) writeb(s []byte) { + if z.bytes { + z.wb.writeb(s) + } else { + z.wi.writeb(s) + } +} +func (z *encWriterSwitch) writestr(s string) { + if z.bytes { + z.wb.writestr(s) + } else { + z.wi.writestr(s) + } +} +func (z *encWriterSwitch) writen1(b1 byte) { + if z.bytes { + z.wb.writen1(b1) + } else { + z.wi.writen1(b1) + } +} +func (z *encWriterSwitch) writen2(b1, b2 byte) { + if z.bytes { + z.wb.writen2(b1, b2) + } else { + z.wi.writen2(b1, b2) + } +} +func (z *encWriterSwitch) end() { + if z.bytes { + z.wb.end() + } else { + z.wi.end() + } +} + +*/ + // Encoder writes an object to an output stream in a supported format. // // Encoder is NOT safe for concurrent use i.e. a Encoder cannot be used @@ -819,30 +1225,33 @@ func (e *Encoder) kMapCanonical(rtkey, rtval reflect.Type, rv, rvv reflect.Value // This is the idiomatic way to use. type Encoder struct { panicHdl - + // hopefully, reduce derefencing cost by laying the encWriter inside the Encoder e encDriver - h *BasicHandle + // NOTE: Encoder shouldn't call it's write methods, + // as the handler MAY need to do some coordination. + w *encWriterSwitch - // hopefully, reduce derefencing cost by laying the encWriter inside the Encoder - encWr + // bw *bufio.Writer + as encDriverAsis + + err error - // ---- cpu cache line boundary + h *BasicHandle hh Handle + // ---- cpu cache line boundary? + 3 + encWriterSwitch - blist bytesFreelist - err error + ci set - // ---- cpu cache line boundary + b [(5 * 8)]byte // for encoding chan or (non-addressable) [N]byte // ---- writable fields during execution --- *try* to keep in sep cache line - ci set // holds set of addresses found during an encoding (if CheckCircularRef=true) - - slist sfiRvFreelist - - b [(2 * 8)]byte // for encoding chan byte, (non-addressable) [N]byte, etc // ---- cpu cache line boundary? + // b [scratchByteArrayLen]byte + // _ [cacheLineSize - scratchByteArrayLen]byte // padding + // b [cacheLineSize - (8 * 0)]byte // used for encoding a chan or (non-addressable) array of bytes } // NewEncoder returns an Encoder for encoding into an io.Writer. @@ -850,7 +1259,7 @@ type Encoder struct { // For efficiency, Users are encouraged to configure WriterBufferSize on the handle // OR pass in a memory buffered writer (eg bufio.Writer, bytes.Buffer). func NewEncoder(w io.Writer, h Handle) *Encoder { - e := h.newEncDriver().encoder() + e := newEncoder(h) e.Reset(w) return e } @@ -861,31 +1270,35 @@ func NewEncoder(w io.Writer, h Handle) *Encoder { // It will potentially replace the output byte slice pointed to. // After encoding, the out parameter contains the encoded contents. func NewEncoderBytes(out *[]byte, h Handle) *Encoder { - e := h.newEncDriver().encoder() + e := newEncoder(h) e.ResetBytes(out) return e } -func (e *Encoder) init(h Handle) { - e.err = errEncoderNotInitialized +func newEncoder(h Handle) *Encoder { + e := &Encoder{h: basicHandle(h), err: errEncoderNotInitialized} e.bytes = true + if useFinalizers { + runtime.SetFinalizer(e, (*Encoder).finalize) + // xdebugf(">>>> new(Encoder) with finalizer") + } + e.w = &e.encWriterSwitch e.hh = h - e.h = basicHandle(h) - e.be = e.hh.isBinary() -} + e.esep = h.hasElemSeparators() -func (e *Encoder) w() *encWr { - return &e.encWr + return e } func (e *Encoder) resetCommon() { - e.e.reset() - if e.ci == nil { - // e.ci = (set)(e.cidef[:0]) - } else { - e.ci = e.ci[:0] + // e.w = &e.encWriterSwitch + 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.c = 0 + e.be = e.hh.isBinary() + _, e.js = e.hh.(*JsonHandle) + e.e.reset() e.err = nil } @@ -897,11 +1310,34 @@ func (e *Encoder) Reset(w io.Writer) { if w == nil { return } + // var ok bool e.bytes = false if e.wf == nil { e.wf = new(bufioEncWriter) } - e.wf.reset(w, e.h.WriterBufferSize, &e.blist) + // e.typ = entryTypeUnset + // if e.h.WriterBufferSize > 0 { + // // bw := bufio.NewWriterSize(w, e.h.WriterBufferSize) + // // e.wi.bw = bw + // // e.wi.sw = bw + // // e.wi.fw = bw + // // e.wi.ww = bw + // if e.wf == nil { + // e.wf = new(bufioEncWriter) + // } + // e.wf.reset(w, e.h.WriterBufferSize) + // e.typ = entryTypeBufio + // } else { + // if e.wi == nil { + // e.wi = new(ioEncWriter) + // } + // e.wi.reset(w) + // e.typ = entryTypeIo + // } + e.wf.reset(w, e.h.WriterBufferSize) + // e.typ = entryTypeBufio + + // e.w = e.wi e.resetCommon() } @@ -915,7 +1351,9 @@ func (e *Encoder) ResetBytes(out *[]byte) { in = make([]byte, defEncByteBufSize) } e.bytes = true + // e.typ = entryTypeBytes e.wb.reset(in, out) + // e.w = &e.wb e.resetCommon() } @@ -1008,7 +1446,6 @@ func (e *Encoder) Encode(v interface{}) (err error) { // Also, see https://github.com/golang/go/issues/14939#issuecomment-417836139 // defer func() { e.deferred(&err) }() } // { x, y := e, &err; defer func() { x.deferred(y) }() } - if e.err != nil { return e.err } @@ -1016,17 +1453,13 @@ func (e *Encoder) Encode(v interface{}) (err error) { defer func() { // if error occurred during encoding, return that error; // else if error occurred on end'ing (i.e. during flush), return that error. - err = e.w().endErr() + err = e.w.endErr() x := recover() if x == nil { - if e.err != err { - e.err = err - } + e.err = err } else { panicValToErr(e, x, &e.err) - if e.err != err { - err = e.err - } + err = e.err } }() } @@ -1046,52 +1479,78 @@ func (e *Encoder) MustEncode(v interface{}) { } func (e *Encoder) mustEncode(v interface{}) { - e.calls++ - e.encode(v) - e.calls-- - if e.calls == 0 { + if e.wf == nil { + e.encode(v) e.e.atEndOfEncode() - e.w().end() + e.w.end() + return + } + + if e.wf.buf == nil { + e.wf.buf = e.wf.bytesBufPooler.get(e.wf.sz) + } + e.wf.calls++ + + e.encode(v) + e.e.atEndOfEncode() + e.w.end() + + e.wf.calls-- + + if !e.h.ExplicitRelease && e.wf.calls == 0 { + e.wf.release() } } +// func (e *Encoder) deferred(err1 *error) { +// e.w.end() +// if recoverPanicToErr { +// if x := recover(); x != nil { +// panicValToErr(e, x, err1) +// panicValToErr(e, x, &e.err) +// } +// } +// } + +//go:noinline -- as it is run by finalizer +func (e *Encoder) finalize() { + // xdebugf("finalizing Encoder") + e.Release() +} + // Release releases shared (pooled) resources. // // It is important to call Release() when done with an Encoder, so those resources // are released instantly for use by subsequently created Encoders. -// -// Deprecated: Release is a no-op as pooled resources are not used with an Encoder. -// This method is kept for compatibility reasons only. func (e *Encoder) Release() { + if e.wf != nil { + e.wf.release() + } } func (e *Encoder) encode(iv interface{}) { // a switch with only concrete types can be optimized. // consequently, we deal with nil and interfaces outside the switch. - if iv == nil { - e.e.EncodeNil() - return - } - - rv, ok := isNil(iv) - if ok { + if iv == nil || definitelyNil(iv) { e.e.EncodeNil() return } - var vself Selfer - switch v := iv.(type) { // case nil: // case Selfer: case Raw: e.rawBytes(v) case reflect.Value: - e.encodeValue(v, nil) + e.encodeValue(v, nil, true) case string: - e.e.EncodeString(v) + if e.h.StringToRaw { + e.e.EncodeStringBytesRaw(bytesView(v)) + } else { + e.e.EncodeStringEnc(cUTF8, v) + } case bool: e.e.EncodeBool(v) case int: @@ -1124,10 +1583,16 @@ func (e *Encoder) encode(iv interface{}) { e.e.EncodeTime(v) case []uint8: e.e.EncodeStringBytesRaw(v) + case *Raw: e.rawBytes(*v) + case *string: - e.e.EncodeString(*v) + if e.h.StringToRaw { + e.e.EncodeStringBytesRaw(bytesView(*v)) + } else { + e.e.EncodeStringEnc(cUTF8, *v) + } case *bool: e.e.EncodeBool(*v) case *int: @@ -1158,39 +1623,29 @@ func (e *Encoder) encode(iv interface{}) { e.e.EncodeFloat64(*v) case *time.Time: e.e.EncodeTime(*v) + case *[]uint8: - if *v == nil { - e.e.EncodeNil() - } else { - e.e.EncodeStringBytesRaw(*v) - } + e.e.EncodeStringBytesRaw(*v) + default: - if vself, ok = iv.(Selfer); ok { - vself.CodecEncodeSelf(e) + if v, ok := iv.(Selfer); ok { + v.CodecEncodeSelf(e) } else if !fastpathEncodeTypeSwitch(iv, e) { - if !rv.IsValid() { - rv = rv4i(iv) - } - e.encodeValue(rv, nil) + // checkfastpath=true (not false), as underlying slice/map type may be fast-path + e.encodeValue(reflect.ValueOf(iv), nil, true) } } } -func (e *Encoder) encodeValue(rv reflect.Value, fn *codecFn) { +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 - - // We considered using a uintptr (a pointer) retrievable via rv.UnsafeAddr. - // However, it is possible for the same pointer to point to 2 different types e.g. - // type T struct { tHelper } - // Here, for var v T; &v and &v.tHelper are the same pointer. - // Consequently, we need a tuple of type and pointer, which interface{} natively provides. - var sptr interface{} // uintptr + var sptr uintptr var rvp reflect.Value var rvpValid bool TOP: switch rv.Kind() { case reflect.Ptr: - if rvIsNil(rv) { + if rv.IsNil() { e.e.EncodeNil() return } @@ -1198,19 +1653,20 @@ TOP: rvp = rv rv = rv.Elem() if e.h.CheckCircularRef && rv.Kind() == reflect.Struct { - sptr = rv2i(rvp) // rv.UnsafeAddr() + // TODO: Movable pointers will be an issue here. Future problem. + sptr = rv.UnsafeAddr() break TOP } goto TOP case reflect.Interface: - if rvIsNil(rv) { + if rv.IsNil() { e.e.EncodeNil() return } rv = rv.Elem() goto TOP case reflect.Slice, reflect.Map: - if rvIsNil(rv) { + if rv.IsNil() { e.e.EncodeNil() return } @@ -1219,14 +1675,14 @@ TOP: return } - if sptr != nil && (&e.ci).add(sptr) { - e.errorf("circular reference found: # %p, %T", sptr, sptr) + if sptr != 0 && (&e.ci).add(sptr) { + e.errorf("circular reference found: # %d", sptr) } - var rt reflect.Type if fn == nil { - rt = rv.Type() - fn = e.h.fn(rt) + rt := rv.Type() + // always pass checkCodecSelfer=true, in case T or ****T is passed, where *T is a Selfer + fn = e.h.fn(rt, checkFastpath, true) } if fn.i.addrE { if rvpValid { @@ -1234,11 +1690,8 @@ TOP: } else if rv.CanAddr() { fn.fe(e, &fn.i, rv.Addr()) } else { - if rt == nil { - rt = rv.Type() - } - rv2 := reflect.New(rt) - rvSetDirect(rv2.Elem(), rv) + rv2 := reflect.New(rv.Type()) + rv2.Elem().Set(rv) fn.fe(e, &fn.i, rv2) } } else { @@ -1249,6 +1702,19 @@ TOP: } } +// func (e *Encoder) marshal(bs []byte, fnerr error, asis bool, c charEncoding) { +// if fnerr != nil { +// panic(fnerr) +// } +// if bs == nil { +// e.e.EncodeNil() +// } else if asis { +// e.asis(bs) +// } else { +// e.e.EncodeStringBytesRaw(bs) +// } +// } + func (e *Encoder) marshalUtf8(bs []byte, fnerr error) { if fnerr != nil { panic(fnerr) @@ -1256,8 +1722,7 @@ func (e *Encoder) marshalUtf8(bs []byte, fnerr error) { if bs == nil { e.e.EncodeNil() } else { - e.e.EncodeString(stringView(bs)) - // e.e.EncodeStringEnc(cUTF8, stringView(bs)) + e.e.EncodeStringEnc(cUTF8, stringView(bs)) } } @@ -1268,7 +1733,7 @@ func (e *Encoder) marshalAsis(bs []byte, fnerr error) { if bs == nil { e.e.EncodeNil() } else { - e.encWr.writeb(bs) // e.asis(bs) + e.asis(bs) } } @@ -1283,85 +1748,47 @@ func (e *Encoder) marshalRaw(bs []byte, fnerr error) { } } +func (e *Encoder) asis(v []byte) { + if e.isas { + e.as.EncodeAsis(v) + } else { + e.w.writeb(v) + } +} + func (e *Encoder) rawBytes(vv Raw) { v := []byte(vv) if !e.h.Raw { e.errorf("Raw values cannot be encoded: %v", v) } - e.encWr.writeb(v) // e.asis(v) + e.asis(v) } func (e *Encoder) wrapErr(v interface{}, err *error) { *err = encodeError{codecError{name: e.hh.Name(), err: v}} } -// ---- container tracker methods -// Note: We update the .c after calling the callback. -// This way, the callback can know what the last status was. - -func (e *Encoder) mapStart(length int) { - e.e.WriteMapStart(length) - e.c = containerMapStart -} - -func (e *Encoder) mapElemKey() { - if e.js { - e.jsondriver().WriteMapElemKey() - } - e.c = containerMapKey -} - -func (e *Encoder) mapElemValue() { - if e.js { - e.jsondriver().WriteMapElemValue() - } - e.c = containerMapValue -} - -func (e *Encoder) mapEnd() { - e.e.WriteMapEnd() - // e.c = containerMapEnd - e.c = 0 -} - -func (e *Encoder) arrayStart(length int) { - e.e.WriteArrayStart(length) - e.c = containerArrayStart -} - -func (e *Encoder) arrayElem() { - if e.js { - e.jsondriver().WriteArrayElem() - } - e.c = containerArrayElem -} - -func (e *Encoder) arrayEnd() { - e.e.WriteArrayEnd() - e.c = 0 - // e.c = containerArrayEnd -} - -// ---------- - -func (e *Encoder) sideEncode(v interface{}, bs *[]byte) { - rv := baseRV(v) - e2 := NewEncoderBytes(bs, e.hh) - e2.encodeValue(rv, e.h.fnNoExt(rv.Type())) - e2.e.atEndOfEncode() - e2.w().end() -} - -func encStructFieldKey(encName string, ee encDriver, w *encWr, +func encStructFieldKey(encName string, ee encDriver, w *encWriterSwitch, keyType valueType, encNameAsciiAlphaNum bool, js bool) { 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 { if js && encNameAsciiAlphaNum { // keyType == valueTypeString - w.writeqstr(encName) + // w.writen1('"') + // w.writestr(encName) + // w.writen1('"') + // ---- + // w.writestr(`"` + encName + `"`) + // ---- + // do concat myself, so it is faster than the generic string concat + b := make([]byte, len(encName)+2) + copy(b[1:], encName) + b[0] = '"' + b[len(b)-1] = '"' + w.writeb(b) } else { // keyType == valueTypeString - ee.EncodeString(encName) + ee.EncodeStringEnc(cUTF8, encName) } } else if keyType == valueTypeInt { ee.EncodeInt(m.Int(strconv.ParseInt(encName, 10, 64))) @@ -1371,3 +1798,11 @@ func encStructFieldKey(encName string, ee encDriver, w *encWr, ee.EncodeFloat64(m.Float(strconv.ParseFloat(encName, 64))) } } + +// func encStringAsRawBytesMaybe(ee encDriver, s string, stringToRaw bool) { +// if stringToRaw { +// ee.EncodeStringBytesRaw(bytesView(s)) +// } else { +// ee.EncodeStringEnc(cUTF8, s) +// } +// } 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 e9b7f230fa1b..9bc14bd638a3 100644 --- a/vendor/github.com/ugorji/go/codec/fast-path.generated.go +++ b/vendor/github.com/ugorji/go/codec/fast-path.generated.go @@ -10,7 +10,7 @@ package codec // Fast path functions try to create a fast path encode or decode implementation // for common maps and slices. // -// We define the functions and register them in this single file +// We define the functions and register then in this single file // so as not to pollute the encode.go and decode.go, and create a dependency in there. // This file can be omitted without causing a build failure. // @@ -18,10 +18,9 @@ package codec // - Many calls bypass reflection altogether // // Currently support -// - slice of all builtin types (numeric, bool, string, []byte) -// - maps of builtin types to builtin or interface{} type, EXCEPT FOR -// keys of type uintptr, int8/16/32, uint16/32, float32/64, bool, interface{} -// AND values of type type int8/16/32, uint16/32 +// - 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. @@ -51,7 +50,7 @@ type fastpathE struct { decfn func(*Decoder, *codecFnInfo, reflect.Value) } -type fastpathA [81]fastpathE +type fastpathA [271]fastpathE func (x *fastpathA) index(rtid uintptr) int { // use binary search to grab the index (adapted from sort/search.go) @@ -97,13 +96,13 @@ func init() { fn([]interface{}(nil), (*Encoder).fastpathEncSliceIntfR, (*Decoder).fastpathDecSliceIntfR) fn([]string(nil), (*Encoder).fastpathEncSliceStringR, (*Decoder).fastpathDecSliceStringR) - fn([][]byte(nil), (*Encoder).fastpathEncSliceBytesR, (*Decoder).fastpathDecSliceBytesR) fn([]float32(nil), (*Encoder).fastpathEncSliceFloat32R, (*Decoder).fastpathDecSliceFloat32R) fn([]float64(nil), (*Encoder).fastpathEncSliceFloat64R, (*Decoder).fastpathDecSliceFloat64R) fn([]uint(nil), (*Encoder).fastpathEncSliceUintR, (*Decoder).fastpathDecSliceUintR) fn([]uint16(nil), (*Encoder).fastpathEncSliceUint16R, (*Decoder).fastpathDecSliceUint16R) fn([]uint32(nil), (*Encoder).fastpathEncSliceUint32R, (*Decoder).fastpathDecSliceUint32R) fn([]uint64(nil), (*Encoder).fastpathEncSliceUint64R, (*Decoder).fastpathDecSliceUint64R) + fn([]uintptr(nil), (*Encoder).fastpathEncSliceUintptrR, (*Decoder).fastpathDecSliceUintptrR) fn([]int(nil), (*Encoder).fastpathEncSliceIntR, (*Decoder).fastpathDecSliceIntR) fn([]int8(nil), (*Encoder).fastpathEncSliceInt8R, (*Decoder).fastpathDecSliceInt8R) fn([]int16(nil), (*Encoder).fastpathEncSliceInt16R, (*Decoder).fastpathDecSliceInt16R) @@ -111,72 +110,262 @@ func init() { fn([]int64(nil), (*Encoder).fastpathEncSliceInt64R, (*Decoder).fastpathDecSliceInt64R) fn([]bool(nil), (*Encoder).fastpathEncSliceBoolR, (*Decoder).fastpathDecSliceBoolR) + fn(map[interface{}]interface{}(nil), (*Encoder).fastpathEncMapIntfIntfR, (*Decoder).fastpathDecMapIntfIntfR) + fn(map[interface{}]string(nil), (*Encoder).fastpathEncMapIntfStringR, (*Decoder).fastpathDecMapIntfStringR) + fn(map[interface{}]uint(nil), (*Encoder).fastpathEncMapIntfUintR, (*Decoder).fastpathDecMapIntfUintR) + fn(map[interface{}]uint8(nil), (*Encoder).fastpathEncMapIntfUint8R, (*Decoder).fastpathDecMapIntfUint8R) + fn(map[interface{}]uint16(nil), (*Encoder).fastpathEncMapIntfUint16R, (*Decoder).fastpathDecMapIntfUint16R) + fn(map[interface{}]uint32(nil), (*Encoder).fastpathEncMapIntfUint32R, (*Decoder).fastpathDecMapIntfUint32R) + fn(map[interface{}]uint64(nil), (*Encoder).fastpathEncMapIntfUint64R, (*Decoder).fastpathDecMapIntfUint64R) + fn(map[interface{}]uintptr(nil), (*Encoder).fastpathEncMapIntfUintptrR, (*Decoder).fastpathDecMapIntfUintptrR) + fn(map[interface{}]int(nil), (*Encoder).fastpathEncMapIntfIntR, (*Decoder).fastpathDecMapIntfIntR) + fn(map[interface{}]int8(nil), (*Encoder).fastpathEncMapIntfInt8R, (*Decoder).fastpathDecMapIntfInt8R) + fn(map[interface{}]int16(nil), (*Encoder).fastpathEncMapIntfInt16R, (*Decoder).fastpathDecMapIntfInt16R) + fn(map[interface{}]int32(nil), (*Encoder).fastpathEncMapIntfInt32R, (*Decoder).fastpathDecMapIntfInt32R) + fn(map[interface{}]int64(nil), (*Encoder).fastpathEncMapIntfInt64R, (*Decoder).fastpathDecMapIntfInt64R) + fn(map[interface{}]float32(nil), (*Encoder).fastpathEncMapIntfFloat32R, (*Decoder).fastpathDecMapIntfFloat32R) + fn(map[interface{}]float64(nil), (*Encoder).fastpathEncMapIntfFloat64R, (*Decoder).fastpathDecMapIntfFloat64R) + fn(map[interface{}]bool(nil), (*Encoder).fastpathEncMapIntfBoolR, (*Decoder).fastpathDecMapIntfBoolR) fn(map[string]interface{}(nil), (*Encoder).fastpathEncMapStringIntfR, (*Decoder).fastpathDecMapStringIntfR) fn(map[string]string(nil), (*Encoder).fastpathEncMapStringStringR, (*Decoder).fastpathDecMapStringStringR) - fn(map[string][]byte(nil), (*Encoder).fastpathEncMapStringBytesR, (*Decoder).fastpathDecMapStringBytesR) fn(map[string]uint(nil), (*Encoder).fastpathEncMapStringUintR, (*Decoder).fastpathDecMapStringUintR) fn(map[string]uint8(nil), (*Encoder).fastpathEncMapStringUint8R, (*Decoder).fastpathDecMapStringUint8R) + fn(map[string]uint16(nil), (*Encoder).fastpathEncMapStringUint16R, (*Decoder).fastpathDecMapStringUint16R) + fn(map[string]uint32(nil), (*Encoder).fastpathEncMapStringUint32R, (*Decoder).fastpathDecMapStringUint32R) fn(map[string]uint64(nil), (*Encoder).fastpathEncMapStringUint64R, (*Decoder).fastpathDecMapStringUint64R) + fn(map[string]uintptr(nil), (*Encoder).fastpathEncMapStringUintptrR, (*Decoder).fastpathDecMapStringUintptrR) fn(map[string]int(nil), (*Encoder).fastpathEncMapStringIntR, (*Decoder).fastpathDecMapStringIntR) + fn(map[string]int8(nil), (*Encoder).fastpathEncMapStringInt8R, (*Decoder).fastpathDecMapStringInt8R) + fn(map[string]int16(nil), (*Encoder).fastpathEncMapStringInt16R, (*Decoder).fastpathDecMapStringInt16R) + fn(map[string]int32(nil), (*Encoder).fastpathEncMapStringInt32R, (*Decoder).fastpathDecMapStringInt32R) fn(map[string]int64(nil), (*Encoder).fastpathEncMapStringInt64R, (*Decoder).fastpathDecMapStringInt64R) fn(map[string]float32(nil), (*Encoder).fastpathEncMapStringFloat32R, (*Decoder).fastpathDecMapStringFloat32R) fn(map[string]float64(nil), (*Encoder).fastpathEncMapStringFloat64R, (*Decoder).fastpathDecMapStringFloat64R) fn(map[string]bool(nil), (*Encoder).fastpathEncMapStringBoolR, (*Decoder).fastpathDecMapStringBoolR) + fn(map[float32]interface{}(nil), (*Encoder).fastpathEncMapFloat32IntfR, (*Decoder).fastpathDecMapFloat32IntfR) + fn(map[float32]string(nil), (*Encoder).fastpathEncMapFloat32StringR, (*Decoder).fastpathDecMapFloat32StringR) + fn(map[float32]uint(nil), (*Encoder).fastpathEncMapFloat32UintR, (*Decoder).fastpathDecMapFloat32UintR) + fn(map[float32]uint8(nil), (*Encoder).fastpathEncMapFloat32Uint8R, (*Decoder).fastpathDecMapFloat32Uint8R) + fn(map[float32]uint16(nil), (*Encoder).fastpathEncMapFloat32Uint16R, (*Decoder).fastpathDecMapFloat32Uint16R) + fn(map[float32]uint32(nil), (*Encoder).fastpathEncMapFloat32Uint32R, (*Decoder).fastpathDecMapFloat32Uint32R) + fn(map[float32]uint64(nil), (*Encoder).fastpathEncMapFloat32Uint64R, (*Decoder).fastpathDecMapFloat32Uint64R) + fn(map[float32]uintptr(nil), (*Encoder).fastpathEncMapFloat32UintptrR, (*Decoder).fastpathDecMapFloat32UintptrR) + fn(map[float32]int(nil), (*Encoder).fastpathEncMapFloat32IntR, (*Decoder).fastpathDecMapFloat32IntR) + fn(map[float32]int8(nil), (*Encoder).fastpathEncMapFloat32Int8R, (*Decoder).fastpathDecMapFloat32Int8R) + fn(map[float32]int16(nil), (*Encoder).fastpathEncMapFloat32Int16R, (*Decoder).fastpathDecMapFloat32Int16R) + fn(map[float32]int32(nil), (*Encoder).fastpathEncMapFloat32Int32R, (*Decoder).fastpathDecMapFloat32Int32R) + fn(map[float32]int64(nil), (*Encoder).fastpathEncMapFloat32Int64R, (*Decoder).fastpathDecMapFloat32Int64R) + fn(map[float32]float32(nil), (*Encoder).fastpathEncMapFloat32Float32R, (*Decoder).fastpathDecMapFloat32Float32R) + fn(map[float32]float64(nil), (*Encoder).fastpathEncMapFloat32Float64R, (*Decoder).fastpathDecMapFloat32Float64R) + fn(map[float32]bool(nil), (*Encoder).fastpathEncMapFloat32BoolR, (*Decoder).fastpathDecMapFloat32BoolR) + fn(map[float64]interface{}(nil), (*Encoder).fastpathEncMapFloat64IntfR, (*Decoder).fastpathDecMapFloat64IntfR) + fn(map[float64]string(nil), (*Encoder).fastpathEncMapFloat64StringR, (*Decoder).fastpathDecMapFloat64StringR) + fn(map[float64]uint(nil), (*Encoder).fastpathEncMapFloat64UintR, (*Decoder).fastpathDecMapFloat64UintR) + fn(map[float64]uint8(nil), (*Encoder).fastpathEncMapFloat64Uint8R, (*Decoder).fastpathDecMapFloat64Uint8R) + fn(map[float64]uint16(nil), (*Encoder).fastpathEncMapFloat64Uint16R, (*Decoder).fastpathDecMapFloat64Uint16R) + fn(map[float64]uint32(nil), (*Encoder).fastpathEncMapFloat64Uint32R, (*Decoder).fastpathDecMapFloat64Uint32R) + fn(map[float64]uint64(nil), (*Encoder).fastpathEncMapFloat64Uint64R, (*Decoder).fastpathDecMapFloat64Uint64R) + fn(map[float64]uintptr(nil), (*Encoder).fastpathEncMapFloat64UintptrR, (*Decoder).fastpathDecMapFloat64UintptrR) + fn(map[float64]int(nil), (*Encoder).fastpathEncMapFloat64IntR, (*Decoder).fastpathDecMapFloat64IntR) + fn(map[float64]int8(nil), (*Encoder).fastpathEncMapFloat64Int8R, (*Decoder).fastpathDecMapFloat64Int8R) + fn(map[float64]int16(nil), (*Encoder).fastpathEncMapFloat64Int16R, (*Decoder).fastpathDecMapFloat64Int16R) + fn(map[float64]int32(nil), (*Encoder).fastpathEncMapFloat64Int32R, (*Decoder).fastpathDecMapFloat64Int32R) + fn(map[float64]int64(nil), (*Encoder).fastpathEncMapFloat64Int64R, (*Decoder).fastpathDecMapFloat64Int64R) + fn(map[float64]float32(nil), (*Encoder).fastpathEncMapFloat64Float32R, (*Decoder).fastpathDecMapFloat64Float32R) + fn(map[float64]float64(nil), (*Encoder).fastpathEncMapFloat64Float64R, (*Decoder).fastpathDecMapFloat64Float64R) + fn(map[float64]bool(nil), (*Encoder).fastpathEncMapFloat64BoolR, (*Decoder).fastpathDecMapFloat64BoolR) fn(map[uint]interface{}(nil), (*Encoder).fastpathEncMapUintIntfR, (*Decoder).fastpathDecMapUintIntfR) fn(map[uint]string(nil), (*Encoder).fastpathEncMapUintStringR, (*Decoder).fastpathDecMapUintStringR) - fn(map[uint][]byte(nil), (*Encoder).fastpathEncMapUintBytesR, (*Decoder).fastpathDecMapUintBytesR) fn(map[uint]uint(nil), (*Encoder).fastpathEncMapUintUintR, (*Decoder).fastpathDecMapUintUintR) fn(map[uint]uint8(nil), (*Encoder).fastpathEncMapUintUint8R, (*Decoder).fastpathDecMapUintUint8R) + fn(map[uint]uint16(nil), (*Encoder).fastpathEncMapUintUint16R, (*Decoder).fastpathDecMapUintUint16R) + fn(map[uint]uint32(nil), (*Encoder).fastpathEncMapUintUint32R, (*Decoder).fastpathDecMapUintUint32R) fn(map[uint]uint64(nil), (*Encoder).fastpathEncMapUintUint64R, (*Decoder).fastpathDecMapUintUint64R) + fn(map[uint]uintptr(nil), (*Encoder).fastpathEncMapUintUintptrR, (*Decoder).fastpathDecMapUintUintptrR) fn(map[uint]int(nil), (*Encoder).fastpathEncMapUintIntR, (*Decoder).fastpathDecMapUintIntR) + fn(map[uint]int8(nil), (*Encoder).fastpathEncMapUintInt8R, (*Decoder).fastpathDecMapUintInt8R) + fn(map[uint]int16(nil), (*Encoder).fastpathEncMapUintInt16R, (*Decoder).fastpathDecMapUintInt16R) + fn(map[uint]int32(nil), (*Encoder).fastpathEncMapUintInt32R, (*Decoder).fastpathDecMapUintInt32R) fn(map[uint]int64(nil), (*Encoder).fastpathEncMapUintInt64R, (*Decoder).fastpathDecMapUintInt64R) fn(map[uint]float32(nil), (*Encoder).fastpathEncMapUintFloat32R, (*Decoder).fastpathDecMapUintFloat32R) fn(map[uint]float64(nil), (*Encoder).fastpathEncMapUintFloat64R, (*Decoder).fastpathDecMapUintFloat64R) fn(map[uint]bool(nil), (*Encoder).fastpathEncMapUintBoolR, (*Decoder).fastpathDecMapUintBoolR) fn(map[uint8]interface{}(nil), (*Encoder).fastpathEncMapUint8IntfR, (*Decoder).fastpathDecMapUint8IntfR) fn(map[uint8]string(nil), (*Encoder).fastpathEncMapUint8StringR, (*Decoder).fastpathDecMapUint8StringR) - fn(map[uint8][]byte(nil), (*Encoder).fastpathEncMapUint8BytesR, (*Decoder).fastpathDecMapUint8BytesR) fn(map[uint8]uint(nil), (*Encoder).fastpathEncMapUint8UintR, (*Decoder).fastpathDecMapUint8UintR) fn(map[uint8]uint8(nil), (*Encoder).fastpathEncMapUint8Uint8R, (*Decoder).fastpathDecMapUint8Uint8R) + fn(map[uint8]uint16(nil), (*Encoder).fastpathEncMapUint8Uint16R, (*Decoder).fastpathDecMapUint8Uint16R) + fn(map[uint8]uint32(nil), (*Encoder).fastpathEncMapUint8Uint32R, (*Decoder).fastpathDecMapUint8Uint32R) fn(map[uint8]uint64(nil), (*Encoder).fastpathEncMapUint8Uint64R, (*Decoder).fastpathDecMapUint8Uint64R) + fn(map[uint8]uintptr(nil), (*Encoder).fastpathEncMapUint8UintptrR, (*Decoder).fastpathDecMapUint8UintptrR) fn(map[uint8]int(nil), (*Encoder).fastpathEncMapUint8IntR, (*Decoder).fastpathDecMapUint8IntR) + fn(map[uint8]int8(nil), (*Encoder).fastpathEncMapUint8Int8R, (*Decoder).fastpathDecMapUint8Int8R) + fn(map[uint8]int16(nil), (*Encoder).fastpathEncMapUint8Int16R, (*Decoder).fastpathDecMapUint8Int16R) + fn(map[uint8]int32(nil), (*Encoder).fastpathEncMapUint8Int32R, (*Decoder).fastpathDecMapUint8Int32R) fn(map[uint8]int64(nil), (*Encoder).fastpathEncMapUint8Int64R, (*Decoder).fastpathDecMapUint8Int64R) fn(map[uint8]float32(nil), (*Encoder).fastpathEncMapUint8Float32R, (*Decoder).fastpathDecMapUint8Float32R) fn(map[uint8]float64(nil), (*Encoder).fastpathEncMapUint8Float64R, (*Decoder).fastpathDecMapUint8Float64R) fn(map[uint8]bool(nil), (*Encoder).fastpathEncMapUint8BoolR, (*Decoder).fastpathDecMapUint8BoolR) + fn(map[uint16]interface{}(nil), (*Encoder).fastpathEncMapUint16IntfR, (*Decoder).fastpathDecMapUint16IntfR) + fn(map[uint16]string(nil), (*Encoder).fastpathEncMapUint16StringR, (*Decoder).fastpathDecMapUint16StringR) + fn(map[uint16]uint(nil), (*Encoder).fastpathEncMapUint16UintR, (*Decoder).fastpathDecMapUint16UintR) + fn(map[uint16]uint8(nil), (*Encoder).fastpathEncMapUint16Uint8R, (*Decoder).fastpathDecMapUint16Uint8R) + fn(map[uint16]uint16(nil), (*Encoder).fastpathEncMapUint16Uint16R, (*Decoder).fastpathDecMapUint16Uint16R) + fn(map[uint16]uint32(nil), (*Encoder).fastpathEncMapUint16Uint32R, (*Decoder).fastpathDecMapUint16Uint32R) + fn(map[uint16]uint64(nil), (*Encoder).fastpathEncMapUint16Uint64R, (*Decoder).fastpathDecMapUint16Uint64R) + fn(map[uint16]uintptr(nil), (*Encoder).fastpathEncMapUint16UintptrR, (*Decoder).fastpathDecMapUint16UintptrR) + fn(map[uint16]int(nil), (*Encoder).fastpathEncMapUint16IntR, (*Decoder).fastpathDecMapUint16IntR) + fn(map[uint16]int8(nil), (*Encoder).fastpathEncMapUint16Int8R, (*Decoder).fastpathDecMapUint16Int8R) + fn(map[uint16]int16(nil), (*Encoder).fastpathEncMapUint16Int16R, (*Decoder).fastpathDecMapUint16Int16R) + fn(map[uint16]int32(nil), (*Encoder).fastpathEncMapUint16Int32R, (*Decoder).fastpathDecMapUint16Int32R) + fn(map[uint16]int64(nil), (*Encoder).fastpathEncMapUint16Int64R, (*Decoder).fastpathDecMapUint16Int64R) + fn(map[uint16]float32(nil), (*Encoder).fastpathEncMapUint16Float32R, (*Decoder).fastpathDecMapUint16Float32R) + fn(map[uint16]float64(nil), (*Encoder).fastpathEncMapUint16Float64R, (*Decoder).fastpathDecMapUint16Float64R) + fn(map[uint16]bool(nil), (*Encoder).fastpathEncMapUint16BoolR, (*Decoder).fastpathDecMapUint16BoolR) + fn(map[uint32]interface{}(nil), (*Encoder).fastpathEncMapUint32IntfR, (*Decoder).fastpathDecMapUint32IntfR) + fn(map[uint32]string(nil), (*Encoder).fastpathEncMapUint32StringR, (*Decoder).fastpathDecMapUint32StringR) + fn(map[uint32]uint(nil), (*Encoder).fastpathEncMapUint32UintR, (*Decoder).fastpathDecMapUint32UintR) + fn(map[uint32]uint8(nil), (*Encoder).fastpathEncMapUint32Uint8R, (*Decoder).fastpathDecMapUint32Uint8R) + fn(map[uint32]uint16(nil), (*Encoder).fastpathEncMapUint32Uint16R, (*Decoder).fastpathDecMapUint32Uint16R) + fn(map[uint32]uint32(nil), (*Encoder).fastpathEncMapUint32Uint32R, (*Decoder).fastpathDecMapUint32Uint32R) + fn(map[uint32]uint64(nil), (*Encoder).fastpathEncMapUint32Uint64R, (*Decoder).fastpathDecMapUint32Uint64R) + fn(map[uint32]uintptr(nil), (*Encoder).fastpathEncMapUint32UintptrR, (*Decoder).fastpathDecMapUint32UintptrR) + fn(map[uint32]int(nil), (*Encoder).fastpathEncMapUint32IntR, (*Decoder).fastpathDecMapUint32IntR) + fn(map[uint32]int8(nil), (*Encoder).fastpathEncMapUint32Int8R, (*Decoder).fastpathDecMapUint32Int8R) + fn(map[uint32]int16(nil), (*Encoder).fastpathEncMapUint32Int16R, (*Decoder).fastpathDecMapUint32Int16R) + fn(map[uint32]int32(nil), (*Encoder).fastpathEncMapUint32Int32R, (*Decoder).fastpathDecMapUint32Int32R) + fn(map[uint32]int64(nil), (*Encoder).fastpathEncMapUint32Int64R, (*Decoder).fastpathDecMapUint32Int64R) + fn(map[uint32]float32(nil), (*Encoder).fastpathEncMapUint32Float32R, (*Decoder).fastpathDecMapUint32Float32R) + fn(map[uint32]float64(nil), (*Encoder).fastpathEncMapUint32Float64R, (*Decoder).fastpathDecMapUint32Float64R) + fn(map[uint32]bool(nil), (*Encoder).fastpathEncMapUint32BoolR, (*Decoder).fastpathDecMapUint32BoolR) fn(map[uint64]interface{}(nil), (*Encoder).fastpathEncMapUint64IntfR, (*Decoder).fastpathDecMapUint64IntfR) fn(map[uint64]string(nil), (*Encoder).fastpathEncMapUint64StringR, (*Decoder).fastpathDecMapUint64StringR) - fn(map[uint64][]byte(nil), (*Encoder).fastpathEncMapUint64BytesR, (*Decoder).fastpathDecMapUint64BytesR) fn(map[uint64]uint(nil), (*Encoder).fastpathEncMapUint64UintR, (*Decoder).fastpathDecMapUint64UintR) fn(map[uint64]uint8(nil), (*Encoder).fastpathEncMapUint64Uint8R, (*Decoder).fastpathDecMapUint64Uint8R) + fn(map[uint64]uint16(nil), (*Encoder).fastpathEncMapUint64Uint16R, (*Decoder).fastpathDecMapUint64Uint16R) + fn(map[uint64]uint32(nil), (*Encoder).fastpathEncMapUint64Uint32R, (*Decoder).fastpathDecMapUint64Uint32R) fn(map[uint64]uint64(nil), (*Encoder).fastpathEncMapUint64Uint64R, (*Decoder).fastpathDecMapUint64Uint64R) + fn(map[uint64]uintptr(nil), (*Encoder).fastpathEncMapUint64UintptrR, (*Decoder).fastpathDecMapUint64UintptrR) fn(map[uint64]int(nil), (*Encoder).fastpathEncMapUint64IntR, (*Decoder).fastpathDecMapUint64IntR) + fn(map[uint64]int8(nil), (*Encoder).fastpathEncMapUint64Int8R, (*Decoder).fastpathDecMapUint64Int8R) + fn(map[uint64]int16(nil), (*Encoder).fastpathEncMapUint64Int16R, (*Decoder).fastpathDecMapUint64Int16R) + fn(map[uint64]int32(nil), (*Encoder).fastpathEncMapUint64Int32R, (*Decoder).fastpathDecMapUint64Int32R) fn(map[uint64]int64(nil), (*Encoder).fastpathEncMapUint64Int64R, (*Decoder).fastpathDecMapUint64Int64R) fn(map[uint64]float32(nil), (*Encoder).fastpathEncMapUint64Float32R, (*Decoder).fastpathDecMapUint64Float32R) fn(map[uint64]float64(nil), (*Encoder).fastpathEncMapUint64Float64R, (*Decoder).fastpathDecMapUint64Float64R) fn(map[uint64]bool(nil), (*Encoder).fastpathEncMapUint64BoolR, (*Decoder).fastpathDecMapUint64BoolR) + fn(map[uintptr]interface{}(nil), (*Encoder).fastpathEncMapUintptrIntfR, (*Decoder).fastpathDecMapUintptrIntfR) + fn(map[uintptr]string(nil), (*Encoder).fastpathEncMapUintptrStringR, (*Decoder).fastpathDecMapUintptrStringR) + fn(map[uintptr]uint(nil), (*Encoder).fastpathEncMapUintptrUintR, (*Decoder).fastpathDecMapUintptrUintR) + fn(map[uintptr]uint8(nil), (*Encoder).fastpathEncMapUintptrUint8R, (*Decoder).fastpathDecMapUintptrUint8R) + fn(map[uintptr]uint16(nil), (*Encoder).fastpathEncMapUintptrUint16R, (*Decoder).fastpathDecMapUintptrUint16R) + fn(map[uintptr]uint32(nil), (*Encoder).fastpathEncMapUintptrUint32R, (*Decoder).fastpathDecMapUintptrUint32R) + fn(map[uintptr]uint64(nil), (*Encoder).fastpathEncMapUintptrUint64R, (*Decoder).fastpathDecMapUintptrUint64R) + fn(map[uintptr]uintptr(nil), (*Encoder).fastpathEncMapUintptrUintptrR, (*Decoder).fastpathDecMapUintptrUintptrR) + fn(map[uintptr]int(nil), (*Encoder).fastpathEncMapUintptrIntR, (*Decoder).fastpathDecMapUintptrIntR) + fn(map[uintptr]int8(nil), (*Encoder).fastpathEncMapUintptrInt8R, (*Decoder).fastpathDecMapUintptrInt8R) + fn(map[uintptr]int16(nil), (*Encoder).fastpathEncMapUintptrInt16R, (*Decoder).fastpathDecMapUintptrInt16R) + fn(map[uintptr]int32(nil), (*Encoder).fastpathEncMapUintptrInt32R, (*Decoder).fastpathDecMapUintptrInt32R) + fn(map[uintptr]int64(nil), (*Encoder).fastpathEncMapUintptrInt64R, (*Decoder).fastpathDecMapUintptrInt64R) + fn(map[uintptr]float32(nil), (*Encoder).fastpathEncMapUintptrFloat32R, (*Decoder).fastpathDecMapUintptrFloat32R) + fn(map[uintptr]float64(nil), (*Encoder).fastpathEncMapUintptrFloat64R, (*Decoder).fastpathDecMapUintptrFloat64R) + fn(map[uintptr]bool(nil), (*Encoder).fastpathEncMapUintptrBoolR, (*Decoder).fastpathDecMapUintptrBoolR) fn(map[int]interface{}(nil), (*Encoder).fastpathEncMapIntIntfR, (*Decoder).fastpathDecMapIntIntfR) fn(map[int]string(nil), (*Encoder).fastpathEncMapIntStringR, (*Decoder).fastpathDecMapIntStringR) - fn(map[int][]byte(nil), (*Encoder).fastpathEncMapIntBytesR, (*Decoder).fastpathDecMapIntBytesR) fn(map[int]uint(nil), (*Encoder).fastpathEncMapIntUintR, (*Decoder).fastpathDecMapIntUintR) fn(map[int]uint8(nil), (*Encoder).fastpathEncMapIntUint8R, (*Decoder).fastpathDecMapIntUint8R) + fn(map[int]uint16(nil), (*Encoder).fastpathEncMapIntUint16R, (*Decoder).fastpathDecMapIntUint16R) + fn(map[int]uint32(nil), (*Encoder).fastpathEncMapIntUint32R, (*Decoder).fastpathDecMapIntUint32R) fn(map[int]uint64(nil), (*Encoder).fastpathEncMapIntUint64R, (*Decoder).fastpathDecMapIntUint64R) + fn(map[int]uintptr(nil), (*Encoder).fastpathEncMapIntUintptrR, (*Decoder).fastpathDecMapIntUintptrR) fn(map[int]int(nil), (*Encoder).fastpathEncMapIntIntR, (*Decoder).fastpathDecMapIntIntR) + fn(map[int]int8(nil), (*Encoder).fastpathEncMapIntInt8R, (*Decoder).fastpathDecMapIntInt8R) + fn(map[int]int16(nil), (*Encoder).fastpathEncMapIntInt16R, (*Decoder).fastpathDecMapIntInt16R) + fn(map[int]int32(nil), (*Encoder).fastpathEncMapIntInt32R, (*Decoder).fastpathDecMapIntInt32R) fn(map[int]int64(nil), (*Encoder).fastpathEncMapIntInt64R, (*Decoder).fastpathDecMapIntInt64R) fn(map[int]float32(nil), (*Encoder).fastpathEncMapIntFloat32R, (*Decoder).fastpathDecMapIntFloat32R) fn(map[int]float64(nil), (*Encoder).fastpathEncMapIntFloat64R, (*Decoder).fastpathDecMapIntFloat64R) fn(map[int]bool(nil), (*Encoder).fastpathEncMapIntBoolR, (*Decoder).fastpathDecMapIntBoolR) + fn(map[int8]interface{}(nil), (*Encoder).fastpathEncMapInt8IntfR, (*Decoder).fastpathDecMapInt8IntfR) + fn(map[int8]string(nil), (*Encoder).fastpathEncMapInt8StringR, (*Decoder).fastpathDecMapInt8StringR) + fn(map[int8]uint(nil), (*Encoder).fastpathEncMapInt8UintR, (*Decoder).fastpathDecMapInt8UintR) + fn(map[int8]uint8(nil), (*Encoder).fastpathEncMapInt8Uint8R, (*Decoder).fastpathDecMapInt8Uint8R) + fn(map[int8]uint16(nil), (*Encoder).fastpathEncMapInt8Uint16R, (*Decoder).fastpathDecMapInt8Uint16R) + fn(map[int8]uint32(nil), (*Encoder).fastpathEncMapInt8Uint32R, (*Decoder).fastpathDecMapInt8Uint32R) + fn(map[int8]uint64(nil), (*Encoder).fastpathEncMapInt8Uint64R, (*Decoder).fastpathDecMapInt8Uint64R) + fn(map[int8]uintptr(nil), (*Encoder).fastpathEncMapInt8UintptrR, (*Decoder).fastpathDecMapInt8UintptrR) + fn(map[int8]int(nil), (*Encoder).fastpathEncMapInt8IntR, (*Decoder).fastpathDecMapInt8IntR) + fn(map[int8]int8(nil), (*Encoder).fastpathEncMapInt8Int8R, (*Decoder).fastpathDecMapInt8Int8R) + fn(map[int8]int16(nil), (*Encoder).fastpathEncMapInt8Int16R, (*Decoder).fastpathDecMapInt8Int16R) + fn(map[int8]int32(nil), (*Encoder).fastpathEncMapInt8Int32R, (*Decoder).fastpathDecMapInt8Int32R) + fn(map[int8]int64(nil), (*Encoder).fastpathEncMapInt8Int64R, (*Decoder).fastpathDecMapInt8Int64R) + fn(map[int8]float32(nil), (*Encoder).fastpathEncMapInt8Float32R, (*Decoder).fastpathDecMapInt8Float32R) + fn(map[int8]float64(nil), (*Encoder).fastpathEncMapInt8Float64R, (*Decoder).fastpathDecMapInt8Float64R) + fn(map[int8]bool(nil), (*Encoder).fastpathEncMapInt8BoolR, (*Decoder).fastpathDecMapInt8BoolR) + fn(map[int16]interface{}(nil), (*Encoder).fastpathEncMapInt16IntfR, (*Decoder).fastpathDecMapInt16IntfR) + fn(map[int16]string(nil), (*Encoder).fastpathEncMapInt16StringR, (*Decoder).fastpathDecMapInt16StringR) + fn(map[int16]uint(nil), (*Encoder).fastpathEncMapInt16UintR, (*Decoder).fastpathDecMapInt16UintR) + fn(map[int16]uint8(nil), (*Encoder).fastpathEncMapInt16Uint8R, (*Decoder).fastpathDecMapInt16Uint8R) + fn(map[int16]uint16(nil), (*Encoder).fastpathEncMapInt16Uint16R, (*Decoder).fastpathDecMapInt16Uint16R) + fn(map[int16]uint32(nil), (*Encoder).fastpathEncMapInt16Uint32R, (*Decoder).fastpathDecMapInt16Uint32R) + fn(map[int16]uint64(nil), (*Encoder).fastpathEncMapInt16Uint64R, (*Decoder).fastpathDecMapInt16Uint64R) + fn(map[int16]uintptr(nil), (*Encoder).fastpathEncMapInt16UintptrR, (*Decoder).fastpathDecMapInt16UintptrR) + fn(map[int16]int(nil), (*Encoder).fastpathEncMapInt16IntR, (*Decoder).fastpathDecMapInt16IntR) + fn(map[int16]int8(nil), (*Encoder).fastpathEncMapInt16Int8R, (*Decoder).fastpathDecMapInt16Int8R) + fn(map[int16]int16(nil), (*Encoder).fastpathEncMapInt16Int16R, (*Decoder).fastpathDecMapInt16Int16R) + fn(map[int16]int32(nil), (*Encoder).fastpathEncMapInt16Int32R, (*Decoder).fastpathDecMapInt16Int32R) + fn(map[int16]int64(nil), (*Encoder).fastpathEncMapInt16Int64R, (*Decoder).fastpathDecMapInt16Int64R) + fn(map[int16]float32(nil), (*Encoder).fastpathEncMapInt16Float32R, (*Decoder).fastpathDecMapInt16Float32R) + fn(map[int16]float64(nil), (*Encoder).fastpathEncMapInt16Float64R, (*Decoder).fastpathDecMapInt16Float64R) + fn(map[int16]bool(nil), (*Encoder).fastpathEncMapInt16BoolR, (*Decoder).fastpathDecMapInt16BoolR) + fn(map[int32]interface{}(nil), (*Encoder).fastpathEncMapInt32IntfR, (*Decoder).fastpathDecMapInt32IntfR) + fn(map[int32]string(nil), (*Encoder).fastpathEncMapInt32StringR, (*Decoder).fastpathDecMapInt32StringR) + fn(map[int32]uint(nil), (*Encoder).fastpathEncMapInt32UintR, (*Decoder).fastpathDecMapInt32UintR) + fn(map[int32]uint8(nil), (*Encoder).fastpathEncMapInt32Uint8R, (*Decoder).fastpathDecMapInt32Uint8R) + fn(map[int32]uint16(nil), (*Encoder).fastpathEncMapInt32Uint16R, (*Decoder).fastpathDecMapInt32Uint16R) + fn(map[int32]uint32(nil), (*Encoder).fastpathEncMapInt32Uint32R, (*Decoder).fastpathDecMapInt32Uint32R) + fn(map[int32]uint64(nil), (*Encoder).fastpathEncMapInt32Uint64R, (*Decoder).fastpathDecMapInt32Uint64R) + fn(map[int32]uintptr(nil), (*Encoder).fastpathEncMapInt32UintptrR, (*Decoder).fastpathDecMapInt32UintptrR) + fn(map[int32]int(nil), (*Encoder).fastpathEncMapInt32IntR, (*Decoder).fastpathDecMapInt32IntR) + fn(map[int32]int8(nil), (*Encoder).fastpathEncMapInt32Int8R, (*Decoder).fastpathDecMapInt32Int8R) + fn(map[int32]int16(nil), (*Encoder).fastpathEncMapInt32Int16R, (*Decoder).fastpathDecMapInt32Int16R) + fn(map[int32]int32(nil), (*Encoder).fastpathEncMapInt32Int32R, (*Decoder).fastpathDecMapInt32Int32R) + fn(map[int32]int64(nil), (*Encoder).fastpathEncMapInt32Int64R, (*Decoder).fastpathDecMapInt32Int64R) + fn(map[int32]float32(nil), (*Encoder).fastpathEncMapInt32Float32R, (*Decoder).fastpathDecMapInt32Float32R) + fn(map[int32]float64(nil), (*Encoder).fastpathEncMapInt32Float64R, (*Decoder).fastpathDecMapInt32Float64R) + fn(map[int32]bool(nil), (*Encoder).fastpathEncMapInt32BoolR, (*Decoder).fastpathDecMapInt32BoolR) fn(map[int64]interface{}(nil), (*Encoder).fastpathEncMapInt64IntfR, (*Decoder).fastpathDecMapInt64IntfR) fn(map[int64]string(nil), (*Encoder).fastpathEncMapInt64StringR, (*Decoder).fastpathDecMapInt64StringR) - fn(map[int64][]byte(nil), (*Encoder).fastpathEncMapInt64BytesR, (*Decoder).fastpathDecMapInt64BytesR) fn(map[int64]uint(nil), (*Encoder).fastpathEncMapInt64UintR, (*Decoder).fastpathDecMapInt64UintR) fn(map[int64]uint8(nil), (*Encoder).fastpathEncMapInt64Uint8R, (*Decoder).fastpathDecMapInt64Uint8R) + fn(map[int64]uint16(nil), (*Encoder).fastpathEncMapInt64Uint16R, (*Decoder).fastpathDecMapInt64Uint16R) + fn(map[int64]uint32(nil), (*Encoder).fastpathEncMapInt64Uint32R, (*Decoder).fastpathDecMapInt64Uint32R) fn(map[int64]uint64(nil), (*Encoder).fastpathEncMapInt64Uint64R, (*Decoder).fastpathDecMapInt64Uint64R) + fn(map[int64]uintptr(nil), (*Encoder).fastpathEncMapInt64UintptrR, (*Decoder).fastpathDecMapInt64UintptrR) fn(map[int64]int(nil), (*Encoder).fastpathEncMapInt64IntR, (*Decoder).fastpathDecMapInt64IntR) + fn(map[int64]int8(nil), (*Encoder).fastpathEncMapInt64Int8R, (*Decoder).fastpathDecMapInt64Int8R) + fn(map[int64]int16(nil), (*Encoder).fastpathEncMapInt64Int16R, (*Decoder).fastpathDecMapInt64Int16R) + fn(map[int64]int32(nil), (*Encoder).fastpathEncMapInt64Int32R, (*Decoder).fastpathDecMapInt64Int32R) fn(map[int64]int64(nil), (*Encoder).fastpathEncMapInt64Int64R, (*Decoder).fastpathDecMapInt64Int64R) fn(map[int64]float32(nil), (*Encoder).fastpathEncMapInt64Float32R, (*Decoder).fastpathDecMapInt64Float32R) fn(map[int64]float64(nil), (*Encoder).fastpathEncMapInt64Float64R, (*Decoder).fastpathDecMapInt64Float64R) fn(map[int64]bool(nil), (*Encoder).fastpathEncMapInt64BoolR, (*Decoder).fastpathDecMapInt64BoolR) + fn(map[bool]interface{}(nil), (*Encoder).fastpathEncMapBoolIntfR, (*Decoder).fastpathDecMapBoolIntfR) + fn(map[bool]string(nil), (*Encoder).fastpathEncMapBoolStringR, (*Decoder).fastpathDecMapBoolStringR) + fn(map[bool]uint(nil), (*Encoder).fastpathEncMapBoolUintR, (*Decoder).fastpathDecMapBoolUintR) + fn(map[bool]uint8(nil), (*Encoder).fastpathEncMapBoolUint8R, (*Decoder).fastpathDecMapBoolUint8R) + fn(map[bool]uint16(nil), (*Encoder).fastpathEncMapBoolUint16R, (*Decoder).fastpathDecMapBoolUint16R) + fn(map[bool]uint32(nil), (*Encoder).fastpathEncMapBoolUint32R, (*Decoder).fastpathDecMapBoolUint32R) + fn(map[bool]uint64(nil), (*Encoder).fastpathEncMapBoolUint64R, (*Decoder).fastpathDecMapBoolUint64R) + fn(map[bool]uintptr(nil), (*Encoder).fastpathEncMapBoolUintptrR, (*Decoder).fastpathDecMapBoolUintptrR) + fn(map[bool]int(nil), (*Encoder).fastpathEncMapBoolIntR, (*Decoder).fastpathDecMapBoolIntR) + fn(map[bool]int8(nil), (*Encoder).fastpathEncMapBoolInt8R, (*Decoder).fastpathDecMapBoolInt8R) + fn(map[bool]int16(nil), (*Encoder).fastpathEncMapBoolInt16R, (*Decoder).fastpathDecMapBoolInt16R) + fn(map[bool]int32(nil), (*Encoder).fastpathEncMapBoolInt32R, (*Decoder).fastpathDecMapBoolInt32R) + fn(map[bool]int64(nil), (*Encoder).fastpathEncMapBoolInt64R, (*Decoder).fastpathDecMapBoolInt64R) + fn(map[bool]float32(nil), (*Encoder).fastpathEncMapBoolFloat32R, (*Decoder).fastpathDecMapBoolFloat32R) + fn(map[bool]float64(nil), (*Encoder).fastpathEncMapBoolFloat64R, (*Decoder).fastpathDecMapBoolFloat64R) + fn(map[bool]bool(nil), (*Encoder).fastpathEncMapBoolBoolR, (*Decoder).fastpathDecMapBoolBoolR) sort.Sort(fastpathAslice(fastpathAV[:])) } @@ -186,654 +375,1093 @@ func init() { // -- -- fast path type switch func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { switch v := iv.(type) { + case []interface{}: fastpathTV.EncSliceIntfV(v, e) case *[]interface{}: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceIntfV(*v, e) - } + fastpathTV.EncSliceIntfV(*v, e) case []string: fastpathTV.EncSliceStringV(v, e) case *[]string: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceStringV(*v, e) - } - case [][]byte: - fastpathTV.EncSliceBytesV(v, e) - case *[][]byte: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceBytesV(*v, e) - } + fastpathTV.EncSliceStringV(*v, e) case []float32: fastpathTV.EncSliceFloat32V(v, e) case *[]float32: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceFloat32V(*v, e) - } + fastpathTV.EncSliceFloat32V(*v, e) case []float64: fastpathTV.EncSliceFloat64V(v, e) case *[]float64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceFloat64V(*v, e) - } + fastpathTV.EncSliceFloat64V(*v, e) case []uint: fastpathTV.EncSliceUintV(v, e) case *[]uint: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceUintV(*v, e) - } + fastpathTV.EncSliceUintV(*v, e) case []uint16: fastpathTV.EncSliceUint16V(v, e) case *[]uint16: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceUint16V(*v, e) - } + fastpathTV.EncSliceUint16V(*v, e) case []uint32: fastpathTV.EncSliceUint32V(v, e) case *[]uint32: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceUint32V(*v, e) - } + fastpathTV.EncSliceUint32V(*v, e) case []uint64: fastpathTV.EncSliceUint64V(v, e) case *[]uint64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceUint64V(*v, e) - } + fastpathTV.EncSliceUint64V(*v, e) + case []uintptr: + fastpathTV.EncSliceUintptrV(v, e) + case *[]uintptr: + fastpathTV.EncSliceUintptrV(*v, e) case []int: fastpathTV.EncSliceIntV(v, e) case *[]int: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceIntV(*v, e) - } + fastpathTV.EncSliceIntV(*v, e) case []int8: fastpathTV.EncSliceInt8V(v, e) case *[]int8: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceInt8V(*v, e) - } + fastpathTV.EncSliceInt8V(*v, e) case []int16: fastpathTV.EncSliceInt16V(v, e) case *[]int16: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceInt16V(*v, e) - } + fastpathTV.EncSliceInt16V(*v, e) case []int32: fastpathTV.EncSliceInt32V(v, e) case *[]int32: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceInt32V(*v, e) - } + fastpathTV.EncSliceInt32V(*v, e) case []int64: fastpathTV.EncSliceInt64V(v, e) case *[]int64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceInt64V(*v, e) - } + fastpathTV.EncSliceInt64V(*v, e) case []bool: fastpathTV.EncSliceBoolV(v, e) case *[]bool: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceBoolV(*v, e) - } + 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 map[string]interface{}: fastpathTV.EncMapStringIntfV(v, e) case *map[string]interface{}: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringIntfV(*v, e) - } + fastpathTV.EncMapStringIntfV(*v, e) case map[string]string: fastpathTV.EncMapStringStringV(v, e) case *map[string]string: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringStringV(*v, e) - } - case map[string][]byte: - fastpathTV.EncMapStringBytesV(v, e) - case *map[string][]byte: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringBytesV(*v, e) - } + fastpathTV.EncMapStringStringV(*v, e) case map[string]uint: fastpathTV.EncMapStringUintV(v, e) case *map[string]uint: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringUintV(*v, e) - } + fastpathTV.EncMapStringUintV(*v, e) case map[string]uint8: fastpathTV.EncMapStringUint8V(v, e) case *map[string]uint8: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringUint8V(*v, e) - } + 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: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringUint64V(*v, e) - } + 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: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringIntV(*v, e) - } + 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: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringInt64V(*v, e) - } + fastpathTV.EncMapStringInt64V(*v, e) case map[string]float32: fastpathTV.EncMapStringFloat32V(v, e) case *map[string]float32: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringFloat32V(*v, e) - } + fastpathTV.EncMapStringFloat32V(*v, e) case map[string]float64: fastpathTV.EncMapStringFloat64V(v, e) case *map[string]float64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringFloat64V(*v, e) - } + fastpathTV.EncMapStringFloat64V(*v, e) case map[string]bool: fastpathTV.EncMapStringBoolV(v, e) case *map[string]bool: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringBoolV(*v, e) - } + 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{}: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintIntfV(*v, e) - } + fastpathTV.EncMapUintIntfV(*v, e) case map[uint]string: fastpathTV.EncMapUintStringV(v, e) case *map[uint]string: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintStringV(*v, e) - } - case map[uint][]byte: - fastpathTV.EncMapUintBytesV(v, e) - case *map[uint][]byte: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintBytesV(*v, e) - } + fastpathTV.EncMapUintStringV(*v, e) case map[uint]uint: fastpathTV.EncMapUintUintV(v, e) case *map[uint]uint: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintUintV(*v, e) - } + fastpathTV.EncMapUintUintV(*v, e) case map[uint]uint8: fastpathTV.EncMapUintUint8V(v, e) case *map[uint]uint8: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintUint8V(*v, e) - } + 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: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintUint64V(*v, e) - } + 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: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintIntV(*v, e) - } + 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: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintInt64V(*v, e) - } + fastpathTV.EncMapUintInt64V(*v, e) case map[uint]float32: fastpathTV.EncMapUintFloat32V(v, e) case *map[uint]float32: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintFloat32V(*v, e) - } + fastpathTV.EncMapUintFloat32V(*v, e) case map[uint]float64: fastpathTV.EncMapUintFloat64V(v, e) case *map[uint]float64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintFloat64V(*v, e) - } + fastpathTV.EncMapUintFloat64V(*v, e) case map[uint]bool: fastpathTV.EncMapUintBoolV(v, e) case *map[uint]bool: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintBoolV(*v, e) - } + fastpathTV.EncMapUintBoolV(*v, e) case map[uint8]interface{}: fastpathTV.EncMapUint8IntfV(v, e) case *map[uint8]interface{}: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8IntfV(*v, e) - } + fastpathTV.EncMapUint8IntfV(*v, e) case map[uint8]string: fastpathTV.EncMapUint8StringV(v, e) case *map[uint8]string: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8StringV(*v, e) - } - case map[uint8][]byte: - fastpathTV.EncMapUint8BytesV(v, e) - case *map[uint8][]byte: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8BytesV(*v, e) - } + fastpathTV.EncMapUint8StringV(*v, e) case map[uint8]uint: fastpathTV.EncMapUint8UintV(v, e) case *map[uint8]uint: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8UintV(*v, e) - } + fastpathTV.EncMapUint8UintV(*v, e) case map[uint8]uint8: fastpathTV.EncMapUint8Uint8V(v, e) case *map[uint8]uint8: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8Uint8V(*v, e) - } + 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: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8Uint64V(*v, e) - } + 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: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8IntV(*v, e) - } + 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: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8Int64V(*v, e) - } + fastpathTV.EncMapUint8Int64V(*v, e) case map[uint8]float32: fastpathTV.EncMapUint8Float32V(v, e) case *map[uint8]float32: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8Float32V(*v, e) - } + fastpathTV.EncMapUint8Float32V(*v, e) case map[uint8]float64: fastpathTV.EncMapUint8Float64V(v, e) case *map[uint8]float64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8Float64V(*v, e) - } + fastpathTV.EncMapUint8Float64V(*v, e) case map[uint8]bool: fastpathTV.EncMapUint8BoolV(v, e) case *map[uint8]bool: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8BoolV(*v, e) - } + 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{}: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64IntfV(*v, e) - } + fastpathTV.EncMapUint64IntfV(*v, e) case map[uint64]string: fastpathTV.EncMapUint64StringV(v, e) case *map[uint64]string: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64StringV(*v, e) - } - case map[uint64][]byte: - fastpathTV.EncMapUint64BytesV(v, e) - case *map[uint64][]byte: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64BytesV(*v, e) - } + fastpathTV.EncMapUint64StringV(*v, e) case map[uint64]uint: fastpathTV.EncMapUint64UintV(v, e) case *map[uint64]uint: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64UintV(*v, e) - } + fastpathTV.EncMapUint64UintV(*v, e) case map[uint64]uint8: fastpathTV.EncMapUint64Uint8V(v, e) case *map[uint64]uint8: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64Uint8V(*v, e) - } + 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: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64Uint64V(*v, e) - } + 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: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64IntV(*v, e) - } + 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: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64Int64V(*v, e) - } + fastpathTV.EncMapUint64Int64V(*v, e) case map[uint64]float32: fastpathTV.EncMapUint64Float32V(v, e) case *map[uint64]float32: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64Float32V(*v, e) - } + fastpathTV.EncMapUint64Float32V(*v, e) case map[uint64]float64: fastpathTV.EncMapUint64Float64V(v, e) case *map[uint64]float64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64Float64V(*v, e) - } + fastpathTV.EncMapUint64Float64V(*v, e) case map[uint64]bool: fastpathTV.EncMapUint64BoolV(v, e) case *map[uint64]bool: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64BoolV(*v, e) - } + 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{}: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntIntfV(*v, e) - } + fastpathTV.EncMapIntIntfV(*v, e) case map[int]string: fastpathTV.EncMapIntStringV(v, e) case *map[int]string: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntStringV(*v, e) - } - case map[int][]byte: - fastpathTV.EncMapIntBytesV(v, e) - case *map[int][]byte: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntBytesV(*v, e) - } + fastpathTV.EncMapIntStringV(*v, e) case map[int]uint: fastpathTV.EncMapIntUintV(v, e) case *map[int]uint: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntUintV(*v, e) - } + fastpathTV.EncMapIntUintV(*v, e) case map[int]uint8: fastpathTV.EncMapIntUint8V(v, e) case *map[int]uint8: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntUint8V(*v, e) - } + 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: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntUint64V(*v, e) - } + 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: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntIntV(*v, e) - } + 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: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntInt64V(*v, e) - } + fastpathTV.EncMapIntInt64V(*v, e) case map[int]float32: fastpathTV.EncMapIntFloat32V(v, e) case *map[int]float32: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntFloat32V(*v, e) - } + fastpathTV.EncMapIntFloat32V(*v, e) case map[int]float64: fastpathTV.EncMapIntFloat64V(v, e) case *map[int]float64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntFloat64V(*v, e) - } + fastpathTV.EncMapIntFloat64V(*v, e) case map[int]bool: fastpathTV.EncMapIntBoolV(v, e) case *map[int]bool: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntBoolV(*v, e) - } + 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{}: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64IntfV(*v, e) - } + fastpathTV.EncMapInt64IntfV(*v, e) case map[int64]string: fastpathTV.EncMapInt64StringV(v, e) case *map[int64]string: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64StringV(*v, e) - } - case map[int64][]byte: - fastpathTV.EncMapInt64BytesV(v, e) - case *map[int64][]byte: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64BytesV(*v, e) - } + fastpathTV.EncMapInt64StringV(*v, e) case map[int64]uint: fastpathTV.EncMapInt64UintV(v, e) case *map[int64]uint: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64UintV(*v, e) - } + fastpathTV.EncMapInt64UintV(*v, e) case map[int64]uint8: fastpathTV.EncMapInt64Uint8V(v, e) case *map[int64]uint8: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64Uint8V(*v, e) - } + 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: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64Uint64V(*v, e) - } + 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: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64IntV(*v, e) - } + 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: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64Int64V(*v, e) - } + fastpathTV.EncMapInt64Int64V(*v, e) case map[int64]float32: fastpathTV.EncMapInt64Float32V(v, e) case *map[int64]float32: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64Float32V(*v, e) - } + fastpathTV.EncMapInt64Float32V(*v, e) case map[int64]float64: fastpathTV.EncMapInt64Float64V(v, e) case *map[int64]float64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64Float64V(*v, e) - } + fastpathTV.EncMapInt64Float64V(*v, e) case map[int64]bool: fastpathTV.EncMapInt64BoolV(v, e) case *map[int64]bool: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64BoolV(*v, e) - } + 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 // workaround https://github.com/golang/go/issues/12927 seen in go1.4 return false @@ -842,6 +1470,7 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { } // -- -- fast path functions + func (e *Encoder) fastpathEncSliceIntfR(f *codecFnInfo, rv reflect.Value) { if f.ti.mbs { fastpathTV.EncAsMapSliceIntfV(rv2i(rv).([]interface{}), e) @@ -849,30 +1478,41 @@ func (e *Encoder) fastpathEncSliceIntfR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncSliceIntfV(rv2i(rv).([]interface{}), e) } } -func (fastpathT) EncSliceIntfV(v []interface{}, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.encode(v[j]) +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 { + ee.WriteArrayElem() + } + e.encode(v2) } - e.arrayEnd() + ee.WriteArrayEnd() } -func (fastpathT) EncAsMapSliceIntfV(v []interface{}, e *Encoder) { +func (_ fastpathT) EncAsMapSliceIntfV(v []interface{}, e *Encoder) { + ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { + return + } + ee.WriteMapStart(len(v) / 2) + for j, v2 := range v { + if esep { if j%2 == 0 { - e.mapElemKey() + ee.WriteMapElemKey() } else { - e.mapElemValue() + ee.WriteMapElemValue() } - e.encode(v[j]) } - e.mapEnd() + e.encode(v2) } + ee.WriteMapEnd() } + func (e *Encoder) fastpathEncSliceStringR(f *codecFnInfo, rv reflect.Value) { if f.ti.mbs { fastpathTV.EncAsMapSliceStringV(rv2i(rv).([]string), e) @@ -880,154 +1520,217 @@ func (e *Encoder) fastpathEncSliceStringR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncSliceStringV(rv2i(rv).([]string), e) } } -func (fastpathT) EncSliceStringV(v []string, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeString(v[j]) +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 { + ee.WriteArrayElem() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v2)) + } else { + ee.EncodeStringEnc(cUTF8, v2) + } } - e.arrayEnd() + ee.WriteArrayEnd() } -func (fastpathT) EncAsMapSliceStringV(v []string, e *Encoder) { +func (_ fastpathT) EncAsMapSliceStringV(v []string, e *Encoder) { + ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { + return + } + ee.WriteMapStart(len(v) / 2) + for j, v2 := range v { + if esep { if j%2 == 0 { - e.mapElemKey() + ee.WriteMapElemKey() } else { - e.mapElemValue() + ee.WriteMapElemValue() } - e.e.EncodeString(v[j]) } - e.mapEnd() + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v2)) + } else { + ee.EncodeStringEnc(cUTF8, v2) + } } + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncSliceBytesR(f *codecFnInfo, rv reflect.Value) { + +func (e *Encoder) fastpathEncSliceFloat32R(f *codecFnInfo, rv reflect.Value) { if f.ti.mbs { - fastpathTV.EncAsMapSliceBytesV(rv2i(rv).([][]byte), e) + fastpathTV.EncAsMapSliceFloat32V(rv2i(rv).([]float32), e) } else { - fastpathTV.EncSliceBytesV(rv2i(rv).([][]byte), e) + fastpathTV.EncSliceFloat32V(rv2i(rv).([]float32), e) } } -func (fastpathT) EncSliceBytesV(v [][]byte, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeStringBytesRaw(v[j]) +func (_ fastpathT) EncSliceFloat32V(v []float32, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return } - e.arrayEnd() + ee, esep := e.e, e.hh.hasElemSeparators() + ee.WriteArrayStart(len(v)) + for _, v2 := range v { + if esep { + ee.WriteArrayElem() + } + ee.EncodeFloat32(v2) + } + ee.WriteArrayEnd() } -func (fastpathT) EncAsMapSliceBytesV(v [][]byte, e *Encoder) { +func (_ fastpathT) EncAsMapSliceFloat32V(v []float32, e *Encoder) { + ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { + return + } + ee.WriteMapStart(len(v) / 2) + for j, v2 := range v { + if esep { if j%2 == 0 { - e.mapElemKey() + ee.WriteMapElemKey() } else { - e.mapElemValue() + ee.WriteMapElemValue() } - e.e.EncodeStringBytesRaw(v[j]) } - e.mapEnd() + ee.EncodeFloat32(v2) } + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncSliceFloat32R(f *codecFnInfo, rv reflect.Value) { + +func (e *Encoder) fastpathEncSliceFloat64R(f *codecFnInfo, rv reflect.Value) { if f.ti.mbs { - fastpathTV.EncAsMapSliceFloat32V(rv2i(rv).([]float32), e) + fastpathTV.EncAsMapSliceFloat64V(rv2i(rv).([]float64), e) } else { - fastpathTV.EncSliceFloat32V(rv2i(rv).([]float32), e) + fastpathTV.EncSliceFloat64V(rv2i(rv).([]float64), e) } } -func (fastpathT) EncSliceFloat32V(v []float32, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeFloat32(v[j]) +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 { + ee.WriteArrayElem() + } + ee.EncodeFloat64(v2) } - e.arrayEnd() + ee.WriteArrayEnd() } -func (fastpathT) EncAsMapSliceFloat32V(v []float32, e *Encoder) { +func (_ fastpathT) EncAsMapSliceFloat64V(v []float64, e *Encoder) { + ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { + return + } + ee.WriteMapStart(len(v) / 2) + for j, v2 := range v { + if esep { if j%2 == 0 { - e.mapElemKey() + ee.WriteMapElemKey() } else { - e.mapElemValue() + ee.WriteMapElemValue() } - e.e.EncodeFloat32(v[j]) } - e.mapEnd() + ee.EncodeFloat64(v2) } + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncSliceFloat64R(f *codecFnInfo, rv reflect.Value) { + +func (e *Encoder) fastpathEncSliceUintR(f *codecFnInfo, rv reflect.Value) { if f.ti.mbs { - fastpathTV.EncAsMapSliceFloat64V(rv2i(rv).([]float64), e) + fastpathTV.EncAsMapSliceUintV(rv2i(rv).([]uint), e) } else { - fastpathTV.EncSliceFloat64V(rv2i(rv).([]float64), e) + fastpathTV.EncSliceUintV(rv2i(rv).([]uint), e) } } -func (fastpathT) EncSliceFloat64V(v []float64, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeFloat64(v[j]) +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 { + ee.WriteArrayElem() + } + ee.EncodeUint(uint64(v2)) } - e.arrayEnd() + ee.WriteArrayEnd() } -func (fastpathT) EncAsMapSliceFloat64V(v []float64, e *Encoder) { +func (_ fastpathT) EncAsMapSliceUintV(v []uint, e *Encoder) { + ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { + return + } + ee.WriteMapStart(len(v) / 2) + for j, v2 := range v { + if esep { if j%2 == 0 { - e.mapElemKey() + ee.WriteMapElemKey() } else { - e.mapElemValue() + ee.WriteMapElemValue() } - e.e.EncodeFloat64(v[j]) } - e.mapEnd() + ee.EncodeUint(uint64(v2)) } + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncSliceUintR(f *codecFnInfo, rv reflect.Value) { + +func (e *Encoder) fastpathEncSliceUint8R(f *codecFnInfo, rv reflect.Value) { if f.ti.mbs { - fastpathTV.EncAsMapSliceUintV(rv2i(rv).([]uint), e) + fastpathTV.EncAsMapSliceUint8V(rv2i(rv).([]uint8), e) } else { - fastpathTV.EncSliceUintV(rv2i(rv).([]uint), e) + fastpathTV.EncSliceUint8V(rv2i(rv).([]uint8), e) } } -func (fastpathT) EncSliceUintV(v []uint, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeUint(uint64(v[j])) +func (_ fastpathT) EncSliceUint8V(v []uint8, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return } - e.arrayEnd() + ee, esep := e.e, e.hh.hasElemSeparators() + ee.WriteArrayStart(len(v)) + for _, v2 := range v { + if esep { + ee.WriteArrayElem() + } + ee.EncodeUint(uint64(v2)) + } + ee.WriteArrayEnd() } -func (fastpathT) EncAsMapSliceUintV(v []uint, e *Encoder) { +func (_ fastpathT) EncAsMapSliceUint8V(v []uint8, e *Encoder) { + ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { + return + } + ee.WriteMapStart(len(v) / 2) + for j, v2 := range v { + if esep { if j%2 == 0 { - e.mapElemKey() + ee.WriteMapElemKey() } else { - e.mapElemValue() + ee.WriteMapElemValue() } - e.e.EncodeUint(uint64(v[j])) } - e.mapEnd() + ee.EncodeUint(uint64(v2)) } + ee.WriteMapEnd() } + func (e *Encoder) fastpathEncSliceUint16R(f *codecFnInfo, rv reflect.Value) { if f.ti.mbs { fastpathTV.EncAsMapSliceUint16V(rv2i(rv).([]uint16), e) @@ -1035,30 +1738,41 @@ func (e *Encoder) fastpathEncSliceUint16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncSliceUint16V(rv2i(rv).([]uint16), e) } } -func (fastpathT) EncSliceUint16V(v []uint16, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeUint(uint64(v[j])) +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 { + ee.WriteArrayElem() + } + ee.EncodeUint(uint64(v2)) } - e.arrayEnd() + ee.WriteArrayEnd() } -func (fastpathT) EncAsMapSliceUint16V(v []uint16, e *Encoder) { +func (_ fastpathT) EncAsMapSliceUint16V(v []uint16, e *Encoder) { + ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { + return + } + ee.WriteMapStart(len(v) / 2) + for j, v2 := range v { + if esep { if j%2 == 0 { - e.mapElemKey() + ee.WriteMapElemKey() } else { - e.mapElemValue() + ee.WriteMapElemValue() } - e.e.EncodeUint(uint64(v[j])) } - e.mapEnd() + ee.EncodeUint(uint64(v2)) } + ee.WriteMapEnd() } + func (e *Encoder) fastpathEncSliceUint32R(f *codecFnInfo, rv reflect.Value) { if f.ti.mbs { fastpathTV.EncAsMapSliceUint32V(rv2i(rv).([]uint32), e) @@ -1066,30 +1780,41 @@ func (e *Encoder) fastpathEncSliceUint32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncSliceUint32V(rv2i(rv).([]uint32), e) } } -func (fastpathT) EncSliceUint32V(v []uint32, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeUint(uint64(v[j])) +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 { + ee.WriteArrayElem() + } + ee.EncodeUint(uint64(v2)) } - e.arrayEnd() + ee.WriteArrayEnd() } -func (fastpathT) EncAsMapSliceUint32V(v []uint32, e *Encoder) { +func (_ fastpathT) EncAsMapSliceUint32V(v []uint32, e *Encoder) { + ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { + return + } + ee.WriteMapStart(len(v) / 2) + for j, v2 := range v { + if esep { if j%2 == 0 { - e.mapElemKey() + ee.WriteMapElemKey() } else { - e.mapElemValue() + ee.WriteMapElemValue() } - e.e.EncodeUint(uint64(v[j])) } - e.mapEnd() + ee.EncodeUint(uint64(v2)) } + ee.WriteMapEnd() } + func (e *Encoder) fastpathEncSliceUint64R(f *codecFnInfo, rv reflect.Value) { if f.ti.mbs { fastpathTV.EncAsMapSliceUint64V(rv2i(rv).([]uint64), e) @@ -1097,61 +1822,125 @@ func (e *Encoder) fastpathEncSliceUint64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncSliceUint64V(rv2i(rv).([]uint64), e) } } -func (fastpathT) EncSliceUint64V(v []uint64, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeUint(v[j]) +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 { + ee.WriteArrayElem() + } + ee.EncodeUint(uint64(v2)) } - e.arrayEnd() + ee.WriteArrayEnd() } -func (fastpathT) EncAsMapSliceUint64V(v []uint64, e *Encoder) { +func (_ fastpathT) EncAsMapSliceUint64V(v []uint64, e *Encoder) { + ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { + return + } + ee.WriteMapStart(len(v) / 2) + for j, v2 := range v { + if esep { if j%2 == 0 { - e.mapElemKey() + ee.WriteMapElemKey() } else { - e.mapElemValue() + ee.WriteMapElemValue() } - e.e.EncodeUint(v[j]) } - e.mapEnd() + ee.EncodeUint(uint64(v2)) } + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncSliceIntR(f *codecFnInfo, rv reflect.Value) { + +func (e *Encoder) fastpathEncSliceUintptrR(f *codecFnInfo, rv reflect.Value) { if f.ti.mbs { - fastpathTV.EncAsMapSliceIntV(rv2i(rv).([]int), e) + fastpathTV.EncAsMapSliceUintptrV(rv2i(rv).([]uintptr), e) } else { - fastpathTV.EncSliceIntV(rv2i(rv).([]int), e) + fastpathTV.EncSliceUintptrV(rv2i(rv).([]uintptr), e) } } -func (fastpathT) EncSliceIntV(v []int, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeInt(int64(v[j])) +func (_ fastpathT) EncSliceUintptrV(v []uintptr, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return } - e.arrayEnd() -} -func (fastpathT) EncAsMapSliceIntV(v []int, e *Encoder) { + ee, esep := e.e, e.hh.hasElemSeparators() + ee.WriteArrayStart(len(v)) + for _, v2 := range v { + if esep { + ee.WriteArrayElem() + } + e.encode(v2) + } + ee.WriteArrayEnd() +} +func (_ fastpathT) EncAsMapSliceUintptrV(v []uintptr, e *Encoder) { + ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { e.errorf(fastpathMapBySliceErrMsg, len(v)) + return + } + ee.WriteMapStart(len(v) / 2) + for j, v2 := range v { + if esep { + if j%2 == 0 { + ee.WriteMapElemKey() + } else { + ee.WriteMapElemValue() + } + } + e.encode(v2) + } + ee.WriteMapEnd() +} + +func (e *Encoder) fastpathEncSliceIntR(f *codecFnInfo, rv reflect.Value) { + if f.ti.mbs { + fastpathTV.EncAsMapSliceIntV(rv2i(rv).([]int), e) } else { - e.mapStart(len(v) / 2) - for j := range v { + fastpathTV.EncSliceIntV(rv2i(rv).([]int), e) + } +} +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 { + ee.WriteArrayElem() + } + 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 { + e.errorf(fastpathMapBySliceErrMsg, len(v)) + return + } + ee.WriteMapStart(len(v) / 2) + for j, v2 := range v { + if esep { if j%2 == 0 { - e.mapElemKey() + ee.WriteMapElemKey() } else { - e.mapElemValue() + ee.WriteMapElemValue() } - e.e.EncodeInt(int64(v[j])) } - e.mapEnd() + ee.EncodeInt(int64(v2)) } + ee.WriteMapEnd() } + func (e *Encoder) fastpathEncSliceInt8R(f *codecFnInfo, rv reflect.Value) { if f.ti.mbs { fastpathTV.EncAsMapSliceInt8V(rv2i(rv).([]int8), e) @@ -1159,30 +1948,41 @@ func (e *Encoder) fastpathEncSliceInt8R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncSliceInt8V(rv2i(rv).([]int8), e) } } -func (fastpathT) EncSliceInt8V(v []int8, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeInt(int64(v[j])) +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 { + ee.WriteArrayElem() + } + ee.EncodeInt(int64(v2)) } - e.arrayEnd() + ee.WriteArrayEnd() } -func (fastpathT) EncAsMapSliceInt8V(v []int8, e *Encoder) { +func (_ fastpathT) EncAsMapSliceInt8V(v []int8, e *Encoder) { + ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { + return + } + ee.WriteMapStart(len(v) / 2) + for j, v2 := range v { + if esep { if j%2 == 0 { - e.mapElemKey() + ee.WriteMapElemKey() } else { - e.mapElemValue() + ee.WriteMapElemValue() } - e.e.EncodeInt(int64(v[j])) } - e.mapEnd() + ee.EncodeInt(int64(v2)) } + ee.WriteMapEnd() } + func (e *Encoder) fastpathEncSliceInt16R(f *codecFnInfo, rv reflect.Value) { if f.ti.mbs { fastpathTV.EncAsMapSliceInt16V(rv2i(rv).([]int16), e) @@ -1190,30 +1990,41 @@ func (e *Encoder) fastpathEncSliceInt16R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncSliceInt16V(rv2i(rv).([]int16), e) } } -func (fastpathT) EncSliceInt16V(v []int16, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeInt(int64(v[j])) +func (_ fastpathT) EncSliceInt16V(v []int16, e *Encoder) { + if v == nil { + e.e.EncodeNil() + return } - e.arrayEnd() + ee, esep := e.e, e.hh.hasElemSeparators() + ee.WriteArrayStart(len(v)) + for _, v2 := range v { + if esep { + ee.WriteArrayElem() + } + ee.EncodeInt(int64(v2)) + } + ee.WriteArrayEnd() } -func (fastpathT) EncAsMapSliceInt16V(v []int16, e *Encoder) { +func (_ fastpathT) EncAsMapSliceInt16V(v []int16, e *Encoder) { + ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { + return + } + ee.WriteMapStart(len(v) / 2) + for j, v2 := range v { + if esep { if j%2 == 0 { - e.mapElemKey() + ee.WriteMapElemKey() } else { - e.mapElemValue() + ee.WriteMapElemValue() } - e.e.EncodeInt(int64(v[j])) } - e.mapEnd() + ee.EncodeInt(int64(v2)) } + ee.WriteMapEnd() } + func (e *Encoder) fastpathEncSliceInt32R(f *codecFnInfo, rv reflect.Value) { if f.ti.mbs { fastpathTV.EncAsMapSliceInt32V(rv2i(rv).([]int32), e) @@ -1221,30 +2032,41 @@ func (e *Encoder) fastpathEncSliceInt32R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncSliceInt32V(rv2i(rv).([]int32), e) } } -func (fastpathT) EncSliceInt32V(v []int32, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeInt(int64(v[j])) +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 { + ee.WriteArrayElem() + } + ee.EncodeInt(int64(v2)) } - e.arrayEnd() + ee.WriteArrayEnd() } -func (fastpathT) EncAsMapSliceInt32V(v []int32, e *Encoder) { +func (_ fastpathT) EncAsMapSliceInt32V(v []int32, e *Encoder) { + ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { + return + } + ee.WriteMapStart(len(v) / 2) + for j, v2 := range v { + if esep { if j%2 == 0 { - e.mapElemKey() + ee.WriteMapElemKey() } else { - e.mapElemValue() + ee.WriteMapElemValue() } - e.e.EncodeInt(int64(v[j])) } - e.mapEnd() + ee.EncodeInt(int64(v2)) } + ee.WriteMapEnd() } + func (e *Encoder) fastpathEncSliceInt64R(f *codecFnInfo, rv reflect.Value) { if f.ti.mbs { fastpathTV.EncAsMapSliceInt64V(rv2i(rv).([]int64), e) @@ -1252,30 +2074,41 @@ func (e *Encoder) fastpathEncSliceInt64R(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncSliceInt64V(rv2i(rv).([]int64), e) } } -func (fastpathT) EncSliceInt64V(v []int64, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeInt(v[j]) +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 { + ee.WriteArrayElem() + } + ee.EncodeInt(int64(v2)) } - e.arrayEnd() + ee.WriteArrayEnd() } -func (fastpathT) EncAsMapSliceInt64V(v []int64, e *Encoder) { +func (_ fastpathT) EncAsMapSliceInt64V(v []int64, e *Encoder) { + ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { + return + } + ee.WriteMapStart(len(v) / 2) + for j, v2 := range v { + if esep { if j%2 == 0 { - e.mapElemKey() + ee.WriteMapElemKey() } else { - e.mapElemValue() + ee.WriteMapElemValue() } - e.e.EncodeInt(v[j]) } - e.mapEnd() + ee.EncodeInt(int64(v2)) } + ee.WriteMapEnd() } + func (e *Encoder) fastpathEncSliceBoolR(f *codecFnInfo, rv reflect.Value) { if f.ti.mbs { fastpathTV.EncAsMapSliceBoolV(rv2i(rv).([]bool), e) @@ -1283,6062 +2116,29645 @@ func (e *Encoder) fastpathEncSliceBoolR(f *codecFnInfo, rv reflect.Value) { fastpathTV.EncSliceBoolV(rv2i(rv).([]bool), e) } } -func (fastpathT) EncSliceBoolV(v []bool, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeBool(v[j]) +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 { + ee.WriteArrayElem() + } + ee.EncodeBool(v2) } - e.arrayEnd() + ee.WriteArrayEnd() } -func (fastpathT) EncAsMapSliceBoolV(v []bool, e *Encoder) { +func (_ fastpathT) EncAsMapSliceBoolV(v []bool, e *Encoder) { + ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { + return + } + ee.WriteMapStart(len(v) / 2) + for j, v2 := range v { + if esep { if j%2 == 0 { - e.mapElemKey() + ee.WriteMapElemKey() } else { - e.mapElemValue() + ee.WriteMapElemValue() } - e.e.EncodeBool(v[j]) } - e.mapEnd() + ee.EncodeBool(v2) } + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapStringIntfR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringIntfV(rv2i(rv).(map[string]interface{}), e) + +func (e *Encoder) fastpathEncMapIntfIntfR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapIntfIntfV(rv2i(rv).(map[interface{}]interface{}), e) } -func (fastpathT) EncMapStringIntfV(v map[string]interface{}, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k + var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding + e2 := NewEncoderBytes(&mksv, e.hh) + v2 := make([]bytesI, len(v)) + var i, l uint + var vp *bytesI + for k2 := range v { + l = uint(len(mksv)) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 i++ } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.encode(v[k2]) + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.asis(v2[j].v) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[v2[j].i]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } e.encode(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapStringStringR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringStringV(rv2i(rv).(map[string]string), e) + +func (e *Encoder) fastpathEncMapIntfStringR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapIntfStringV(rv2i(rv).(map[interface{}]string), e) } -func (fastpathT) EncMapStringStringV(v map[string]string, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k + var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding + e2 := NewEncoderBytes(&mksv, e.hh) + v2 := make([]bytesI, len(v)) + var i, l uint + var vp *bytesI + for k2 := range v { + l = uint(len(mksv)) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 i++ } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeString(v[k2]) + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.asis(v2[j].v) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[v2[j].i]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeString(v2) + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v2)) + } else { + ee.EncodeStringEnc(cUTF8, v2) + } } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapStringBytesR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringBytesV(rv2i(rv).(map[string][]byte), e) + +func (e *Encoder) fastpathEncMapIntfUintR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapIntfUintV(rv2i(rv).(map[interface{}]uint), e) } -func (fastpathT) EncMapStringBytesV(v map[string][]byte, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k + var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding + e2 := NewEncoderBytes(&mksv, e.hh) + v2 := make([]bytesI, len(v)) + var i, l uint + var vp *bytesI + for k2 := range v { + l = uint(len(mksv)) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 i++ } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v[k2]) + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.asis(v2[j].v) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[v2[j].i]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v2) + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapStringUintR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringUintV(rv2i(rv).(map[string]uint), e) + +func (e *Encoder) fastpathEncMapIntfUint8R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapIntfUint8V(rv2i(rv).(map[interface{}]uint8), e) } -func (fastpathT) EncMapStringUintV(v map[string]uint, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k + var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding + e2 := NewEncoderBytes(&mksv, e.hh) + v2 := make([]bytesI, len(v)) + var i, l uint + var vp *bytesI + for k2 := range v { + l = uint(len(mksv)) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 i++ } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v[k2])) + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.asis(v2[j].v) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[v2[j].i]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapStringUint8R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringUint8V(rv2i(rv).(map[string]uint8), e) + +func (e *Encoder) fastpathEncMapIntfUint16R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapIntfUint16V(rv2i(rv).(map[interface{}]uint16), e) } -func (fastpathT) EncMapStringUint8V(v map[string]uint8, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k + var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding + e2 := NewEncoderBytes(&mksv, e.hh) + v2 := make([]bytesI, len(v)) + var i, l uint + var vp *bytesI + for k2 := range v { + l = uint(len(mksv)) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 i++ } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v[k2])) + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.asis(v2[j].v) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[v2[j].i]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapStringUint64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringUint64V(rv2i(rv).(map[string]uint64), e) + +func (e *Encoder) fastpathEncMapIntfUint32R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapIntfUint32V(rv2i(rv).(map[interface{}]uint32), e) } -func (fastpathT) EncMapStringUint64V(v map[string]uint64, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k + var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding + e2 := NewEncoderBytes(&mksv, e.hh) + v2 := make([]bytesI, len(v)) + var i, l uint + var vp *bytesI + for k2 := range v { + l = uint(len(mksv)) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 i++ } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeUint(v[k2]) + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.asis(v2[j].v) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[v2[j].i]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeUint(v2) + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapStringIntR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringIntV(rv2i(rv).(map[string]int), e) + +func (e *Encoder) fastpathEncMapIntfUint64R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapIntfUint64V(rv2i(rv).(map[interface{}]uint64), e) } -func (fastpathT) EncMapStringIntV(v map[string]int, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k + var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding + e2 := NewEncoderBytes(&mksv, e.hh) + v2 := make([]bytesI, len(v)) + var i, l uint + var vp *bytesI + for k2 := range v { + l = uint(len(mksv)) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 i++ } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeInt(int64(v[k2])) + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.asis(v2[j].v) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[v2[j].i]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeInt(int64(v2)) + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapStringInt64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringInt64V(rv2i(rv).(map[string]int64), e) + +func (e *Encoder) fastpathEncMapIntfUintptrR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapIntfUintptrV(rv2i(rv).(map[interface{}]uintptr), e) } -func (fastpathT) EncMapStringInt64V(v map[string]int64, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k + var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding + e2 := NewEncoderBytes(&mksv, e.hh) + v2 := make([]bytesI, len(v)) + var i, l uint + var vp *bytesI + for k2 := range v { + l = uint(len(mksv)) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 i++ } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeInt(v[k2]) + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.asis(v2[j].v) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[v2[j].i]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeInt(v2) + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapStringFloat32R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringFloat32V(rv2i(rv).(map[string]float32), e) + +func (e *Encoder) fastpathEncMapIntfIntR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapIntfIntV(rv2i(rv).(map[interface{}]int), e) } -func (fastpathT) EncMapStringFloat32V(v map[string]float32, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k + var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding + e2 := NewEncoderBytes(&mksv, e.hh) + v2 := make([]bytesI, len(v)) + var i, l uint + var vp *bytesI + for k2 := range v { + l = uint(len(mksv)) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 i++ } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeFloat32(v[k2]) + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.asis(v2[j].v) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[v2[j].i]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeFloat32(v2) + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapStringFloat64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringFloat64V(rv2i(rv).(map[string]float64), e) + +func (e *Encoder) fastpathEncMapIntfInt8R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapIntfInt8V(rv2i(rv).(map[interface{}]int8), e) } -func (fastpathT) EncMapStringFloat64V(v map[string]float64, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k + var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding + e2 := NewEncoderBytes(&mksv, e.hh) + v2 := make([]bytesI, len(v)) + var i, l uint + var vp *bytesI + for k2 := range v { + l = uint(len(mksv)) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 i++ } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeFloat64(v[k2]) + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.asis(v2[j].v) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[v2[j].i]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeFloat64(v2) + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapStringBoolR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringBoolV(rv2i(rv).(map[string]bool), e) + +func (e *Encoder) fastpathEncMapIntfInt16R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapIntfInt16V(rv2i(rv).(map[interface{}]int16), e) } -func (fastpathT) EncMapStringBoolV(v map[string]bool, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k + var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding + e2 := NewEncoderBytes(&mksv, e.hh) + v2 := make([]bytesI, len(v)) + var i, l uint + var vp *bytesI + for k2 := range v { + l = uint(len(mksv)) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 i++ } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeBool(v[k2]) + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.asis(v2[j].v) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[v2[j].i]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeBool(v2) + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUintIntfR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintIntfV(rv2i(rv).(map[uint]interface{}), e) + +func (e *Encoder) fastpathEncMapIntfInt32R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapIntfInt32V(rv2i(rv).(map[interface{}]int32), e) } -func (fastpathT) EncMapUintIntfV(v map[uint]interface{}, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) + var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding + e2 := NewEncoderBytes(&mksv, e.hh) + v2 := make([]bytesI, len(v)) + var i, l uint + var vp *bytesI + for k2 := range v { + l = uint(len(mksv)) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 i++ } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.encode(v[uint(k2)]) + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.asis(v2[j].v) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[v2[j].i]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.encode(v2) + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUintStringR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintStringV(rv2i(rv).(map[uint]string), e) + +func (e *Encoder) fastpathEncMapIntfInt64R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapIntfInt64V(rv2i(rv).(map[interface{}]int64), e) } -func (fastpathT) EncMapUintStringV(v map[uint]string, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) + var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding + e2 := NewEncoderBytes(&mksv, e.hh) + v2 := make([]bytesI, len(v)) + var i, l uint + var vp *bytesI + for k2 := range v { + l = uint(len(mksv)) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 i++ } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeString(v[uint(k2)]) + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.asis(v2[j].v) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[v2[j].i]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeString(v2) + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUintBytesR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintBytesV(rv2i(rv).(map[uint][]byte), e) + +func (e *Encoder) fastpathEncMapIntfFloat32R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapIntfFloat32V(rv2i(rv).(map[interface{}]float32), e) } -func (fastpathT) EncMapUintBytesV(v map[uint][]byte, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) + var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding + e2 := NewEncoderBytes(&mksv, e.hh) + v2 := make([]bytesI, len(v)) + var i, l uint + var vp *bytesI + for k2 := range v { + l = uint(len(mksv)) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 i++ } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v[uint(k2)]) - } + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.asis(v2[j].v) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[v2[j].i]) + } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v2) + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUintUintR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintUintV(rv2i(rv).(map[uint]uint), e) + +func (e *Encoder) fastpathEncMapIntfFloat64R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapIntfFloat64V(rv2i(rv).(map[interface{}]float64), e) } -func (fastpathT) EncMapUintUintV(v map[uint]uint, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) + var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding + e2 := NewEncoderBytes(&mksv, e.hh) + v2 := make([]bytesI, len(v)) + var i, l uint + var vp *bytesI + for k2 := range v { + l = uint(len(mksv)) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 i++ } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeUint(uint64(v[uint(k2)])) + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.asis(v2[j].v) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[v2[j].i]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUintUint8R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintUint8V(rv2i(rv).(map[uint]uint8), e) + +func (e *Encoder) fastpathEncMapIntfBoolR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapIntfBoolV(rv2i(rv).(map[interface{}]bool), e) } -func (fastpathT) EncMapUintUint8V(v map[uint]uint8, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) + var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding + e2 := NewEncoderBytes(&mksv, e.hh) + v2 := make([]bytesI, len(v)) + var i, l uint + var vp *bytesI + for k2 := range v { + l = uint(len(mksv)) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 i++ } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeUint(uint64(v[uint(k2)])) + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.asis(v2[j].v) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[v2[j].i]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUintUint64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintUint64V(rv2i(rv).(map[uint]uint64), e) + +func (e *Encoder) fastpathEncMapStringIntfR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapStringIntfV(rv2i(rv).(map[string]interface{}), e) } -func (fastpathT) EncMapUintUint64V(v map[uint]uint64, e *Encoder) { - e.mapStart(len(v)) +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)) if e.h.Canonical { - v2 := make([]uint64, len(v)) + v2 := make([]string, len(v)) var i uint for k := range v { - v2[i] = uint64(k) + v2[i] = string(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(stringSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeUint(v[uint(k2)]) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + e.encode(v[string(k2)]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeUint(v2) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUintIntR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintIntV(rv2i(rv).(map[uint]int), e) + +func (e *Encoder) fastpathEncMapStringStringR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapStringStringV(rv2i(rv).(map[string]string), e) } -func (fastpathT) EncMapUintIntV(v map[uint]int, e *Encoder) { - e.mapStart(len(v)) +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)) if e.h.Canonical { - v2 := make([]uint64, len(v)) + v2 := make([]string, len(v)) var i uint for k := range v { - v2[i] = uint64(k) + v2[i] = string(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(stringSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeInt(int64(v[uint(k2)])) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v[string(k2)])) + } else { + ee.EncodeStringEnc(cUTF8, v[string(k2)]) + } } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeInt(int64(v2)) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v2)) + } else { + ee.EncodeStringEnc(cUTF8, v2) + } } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUintInt64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintInt64V(rv2i(rv).(map[uint]int64), e) + +func (e *Encoder) fastpathEncMapStringUintR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapStringUintV(rv2i(rv).(map[string]uint), e) } -func (fastpathT) EncMapUintInt64V(v map[uint]int64, e *Encoder) { - e.mapStart(len(v)) +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)) if e.h.Canonical { - v2 := make([]uint64, len(v)) + v2 := make([]string, len(v)) var i uint for k := range v { - v2[i] = uint64(k) + v2[i] = string(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(stringSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeInt(v[uint(k2)]) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[string(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeInt(v2) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUintFloat32R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintFloat32V(rv2i(rv).(map[uint]float32), e) + +func (e *Encoder) fastpathEncMapStringUint8R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapStringUint8V(rv2i(rv).(map[string]uint8), e) } -func (fastpathT) EncMapUintFloat32V(v map[uint]float32, e *Encoder) { - e.mapStart(len(v)) +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)) if e.h.Canonical { - v2 := make([]uint64, len(v)) + v2 := make([]string, len(v)) var i uint for k := range v { - v2[i] = uint64(k) + v2[i] = string(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(stringSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeFloat32(v[uint(k2)]) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[string(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeFloat32(v2) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUintFloat64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintFloat64V(rv2i(rv).(map[uint]float64), e) + +func (e *Encoder) fastpathEncMapStringUint16R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapStringUint16V(rv2i(rv).(map[string]uint16), e) } -func (fastpathT) EncMapUintFloat64V(v map[uint]float64, e *Encoder) { - e.mapStart(len(v)) +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)) if e.h.Canonical { - v2 := make([]uint64, len(v)) + v2 := make([]string, len(v)) var i uint for k := range v { - v2[i] = uint64(k) + v2[i] = string(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(stringSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeFloat64(v[uint(k2)]) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[string(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeFloat64(v2) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUintBoolR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintBoolV(rv2i(rv).(map[uint]bool), e) + +func (e *Encoder) fastpathEncMapStringUint32R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapStringUint32V(rv2i(rv).(map[string]uint32), e) } -func (fastpathT) EncMapUintBoolV(v map[uint]bool, e *Encoder) { - e.mapStart(len(v)) +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)) if e.h.Canonical { - v2 := make([]uint64, len(v)) + v2 := make([]string, len(v)) var i uint for k := range v { - v2[i] = uint64(k) + v2[i] = string(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(stringSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeBool(v[uint(k2)]) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[string(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeBool(v2) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint8IntfR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8IntfV(rv2i(rv).(map[uint8]interface{}), e) + +func (e *Encoder) fastpathEncMapStringUint64R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapStringUint64V(rv2i(rv).(map[string]uint64), e) } -func (fastpathT) EncMapUint8IntfV(v map[uint8]interface{}, e *Encoder) { - e.mapStart(len(v)) +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)) if e.h.Canonical { - v2 := make([]uint64, len(v)) + v2 := make([]string, len(v)) var i uint for k := range v { - v2[i] = uint64(k) + v2[i] = string(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(stringSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.encode(v[uint8(k2)]) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[string(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.encode(v2) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint8StringR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8StringV(rv2i(rv).(map[uint8]string), e) + +func (e *Encoder) fastpathEncMapStringUintptrR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapStringUintptrV(rv2i(rv).(map[string]uintptr), e) } -func (fastpathT) EncMapUint8StringV(v map[uint8]string, e *Encoder) { - e.mapStart(len(v)) +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)) if e.h.Canonical { - v2 := make([]uint64, len(v)) + v2 := make([]string, len(v)) var i uint for k := range v { - v2[i] = uint64(k) + v2[i] = string(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(stringSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeString(v[uint8(k2)]) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + e.encode(v[string(k2)]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeString(v2) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint8BytesR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8BytesV(rv2i(rv).(map[uint8][]byte), e) + +func (e *Encoder) fastpathEncMapStringIntR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapStringIntV(rv2i(rv).(map[string]int), e) } -func (fastpathT) EncMapUint8BytesV(v map[uint8][]byte, e *Encoder) { - e.mapStart(len(v)) +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)) if e.h.Canonical { - v2 := make([]uint64, len(v)) + v2 := make([]string, len(v)) var i uint for k := range v { - v2[i] = uint64(k) + v2[i] = string(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(stringSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v[uint8(k2)]) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[string(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v2) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint8UintR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8UintV(rv2i(rv).(map[uint8]uint), e) + +func (e *Encoder) fastpathEncMapStringInt8R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapStringInt8V(rv2i(rv).(map[string]int8), e) } -func (fastpathT) EncMapUint8UintV(v map[uint8]uint, e *Encoder) { - e.mapStart(len(v)) +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)) if e.h.Canonical { - v2 := make([]uint64, len(v)) + v2 := make([]string, len(v)) var i uint for k := range v { - v2[i] = uint64(k) + v2[i] = string(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(stringSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeUint(uint64(v[uint8(k2)])) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[string(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint8Uint8R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8Uint8V(rv2i(rv).(map[uint8]uint8), e) + +func (e *Encoder) fastpathEncMapStringInt16R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapStringInt16V(rv2i(rv).(map[string]int16), e) } -func (fastpathT) EncMapUint8Uint8V(v map[uint8]uint8, e *Encoder) { - e.mapStart(len(v)) +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)) if e.h.Canonical { - v2 := make([]uint64, len(v)) + v2 := make([]string, len(v)) var i uint for k := range v { - v2[i] = uint64(k) + v2[i] = string(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(stringSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeUint(uint64(v[uint8(k2)])) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[string(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint8Uint64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8Uint64V(rv2i(rv).(map[uint8]uint64), e) + +func (e *Encoder) fastpathEncMapStringInt32R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapStringInt32V(rv2i(rv).(map[string]int32), e) } -func (fastpathT) EncMapUint8Uint64V(v map[uint8]uint64, e *Encoder) { - e.mapStart(len(v)) +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)) if e.h.Canonical { - v2 := make([]uint64, len(v)) + v2 := make([]string, len(v)) var i uint for k := range v { - v2[i] = uint64(k) + v2[i] = string(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(stringSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeUint(v[uint8(k2)]) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[string(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeUint(v2) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint8IntR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8IntV(rv2i(rv).(map[uint8]int), e) + +func (e *Encoder) fastpathEncMapStringInt64R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapStringInt64V(rv2i(rv).(map[string]int64), e) } -func (fastpathT) EncMapUint8IntV(v map[uint8]int, e *Encoder) { - e.mapStart(len(v)) +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)) if e.h.Canonical { - v2 := make([]uint64, len(v)) + v2 := make([]string, len(v)) var i uint for k := range v { - v2[i] = uint64(k) + v2[i] = string(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(stringSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeInt(int64(v[uint8(k2)])) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[string(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeInt(int64(v2)) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint8Int64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8Int64V(rv2i(rv).(map[uint8]int64), e) + +func (e *Encoder) fastpathEncMapStringFloat32R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapStringFloat32V(rv2i(rv).(map[string]float32), e) } -func (fastpathT) EncMapUint8Int64V(v map[uint8]int64, e *Encoder) { - e.mapStart(len(v)) +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)) if e.h.Canonical { - v2 := make([]uint64, len(v)) + v2 := make([]string, len(v)) var i uint for k := range v { - v2[i] = uint64(k) + v2[i] = string(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(stringSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeInt(v[uint8(k2)]) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v[string(k2)]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeInt(v2) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint8Float32R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8Float32V(rv2i(rv).(map[uint8]float32), e) + +func (e *Encoder) fastpathEncMapStringFloat64R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapStringFloat64V(rv2i(rv).(map[string]float64), e) } -func (fastpathT) EncMapUint8Float32V(v map[uint8]float32, e *Encoder) { - e.mapStart(len(v)) +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)) if e.h.Canonical { - v2 := make([]uint64, len(v)) + v2 := make([]string, len(v)) var i uint for k := range v { - v2[i] = uint64(k) + v2[i] = string(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(stringSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeFloat32(v[uint8(k2)]) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v[string(k2)]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeFloat32(v2) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint8Float64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8Float64V(rv2i(rv).(map[uint8]float64), e) + +func (e *Encoder) fastpathEncMapStringBoolR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapStringBoolV(rv2i(rv).(map[string]bool), e) } -func (fastpathT) EncMapUint8Float64V(v map[uint8]float64, e *Encoder) { - e.mapStart(len(v)) +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)) if e.h.Canonical { - v2 := make([]uint64, len(v)) + v2 := make([]string, len(v)) var i uint for k := range v { - v2[i] = uint64(k) + v2[i] = string(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(stringSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeFloat64(v[uint8(k2)]) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v[string(k2)]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeFloat64(v2) + if esep { + ee.WriteMapElemKey() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(k2)) + } else { + ee.EncodeStringEnc(cUTF8, k2) + } + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint8BoolR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8BoolV(rv2i(rv).(map[uint8]bool), e) + +func (e *Encoder) fastpathEncMapFloat32IntfR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat32IntfV(rv2i(rv).(map[float32]interface{}), e) } -func (fastpathT) EncMapUint8BoolV(v map[uint8]bool, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]uint64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = uint64(k) + v2[i] = float64(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeBool(v[uint8(k2)]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(float32(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[float32(k2)]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeBool(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(k2) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint64IntfR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64IntfV(rv2i(rv).(map[uint64]interface{}), e) + +func (e *Encoder) fastpathEncMapFloat32StringR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat32StringV(rv2i(rv).(map[float32]string), e) } -func (fastpathT) EncMapUint64IntfV(v map[uint64]interface{}, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]uint64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.encode(v[k2]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(float32(k2)) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v[float32(k2)])) + } else { + ee.EncodeStringEnc(cUTF8, v[float32(k2)]) + } } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.encode(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(k2) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v2)) + } else { + ee.EncodeStringEnc(cUTF8, v2) + } } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint64StringR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64StringV(rv2i(rv).(map[uint64]string), e) + +func (e *Encoder) fastpathEncMapFloat32UintR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat32UintV(rv2i(rv).(map[float32]uint), e) } -func (fastpathT) EncMapUint64StringV(v map[uint64]string, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]uint64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeString(v[k2]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(float32(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[float32(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeString(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint64BytesR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64BytesV(rv2i(rv).(map[uint64][]byte), e) + +func (e *Encoder) fastpathEncMapFloat32Uint8R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat32Uint8V(rv2i(rv).(map[float32]uint8), e) } -func (fastpathT) EncMapUint64BytesV(v map[uint64][]byte, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]uint64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v[k2]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(float32(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[float32(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint64UintR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64UintV(rv2i(rv).(map[uint64]uint), e) + +func (e *Encoder) fastpathEncMapFloat32Uint16R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat32Uint16V(rv2i(rv).(map[float32]uint16), e) } -func (fastpathT) EncMapUint64UintV(v map[uint64]uint, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]uint64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v[k2])) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(float32(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[float32(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint64Uint8R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64Uint8V(rv2i(rv).(map[uint64]uint8), e) + +func (e *Encoder) fastpathEncMapFloat32Uint32R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat32Uint32V(rv2i(rv).(map[float32]uint32), e) } -func (fastpathT) EncMapUint64Uint8V(v map[uint64]uint8, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]uint64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v[k2])) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(float32(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[float32(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint64Uint64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64Uint64V(rv2i(rv).(map[uint64]uint64), e) + +func (e *Encoder) fastpathEncMapFloat32Uint64R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat32Uint64V(rv2i(rv).(map[float32]uint64), e) } -func (fastpathT) EncMapUint64Uint64V(v map[uint64]uint64, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]uint64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeUint(v[k2]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(float32(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[float32(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeUint(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint64IntR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64IntV(rv2i(rv).(map[uint64]int), e) + +func (e *Encoder) fastpathEncMapFloat32UintptrR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat32UintptrV(rv2i(rv).(map[float32]uintptr), e) } -func (fastpathT) EncMapUint64IntV(v map[uint64]int, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]uint64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeInt(int64(v[k2])) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(float32(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[float32(k2)]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeInt(int64(v2)) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(k2) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint64Int64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64Int64V(rv2i(rv).(map[uint64]int64), e) + +func (e *Encoder) fastpathEncMapFloat32IntR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat32IntV(rv2i(rv).(map[float32]int), e) } -func (fastpathT) EncMapUint64Int64V(v map[uint64]int64, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]uint64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeInt(v[k2]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(float32(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[float32(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeInt(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint64Float32R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64Float32V(rv2i(rv).(map[uint64]float32), e) + +func (e *Encoder) fastpathEncMapFloat32Int8R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat32Int8V(rv2i(rv).(map[float32]int8), e) } -func (fastpathT) EncMapUint64Float32V(v map[uint64]float32, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]uint64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeFloat32(v[k2]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(float32(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[float32(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeFloat32(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint64Float64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64Float64V(rv2i(rv).(map[uint64]float64), e) + +func (e *Encoder) fastpathEncMapFloat32Int16R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat32Int16V(rv2i(rv).(map[float32]int16), e) } -func (fastpathT) EncMapUint64Float64V(v map[uint64]float64, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]uint64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeFloat64(v[k2]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(float32(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[float32(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeFloat64(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapUint64BoolR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64BoolV(rv2i(rv).(map[uint64]bool), e) + +func (e *Encoder) fastpathEncMapFloat32Int32R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat32Int32V(rv2i(rv).(map[float32]int32), e) } -func (fastpathT) EncMapUint64BoolV(v map[uint64]bool, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]uint64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(uint64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeBool(v[k2]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(float32(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[float32(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeBool(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapIntIntfR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntIntfV(rv2i(rv).(map[int]interface{}), e) + +func (e *Encoder) fastpathEncMapFloat32Int64R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat32Int64V(rv2i(rv).(map[float32]int64), e) } -func (fastpathT) EncMapIntIntfV(v map[int]interface{}, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = int64(k) + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.encode(v[int(k2)]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(float32(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[float32(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.encode(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapIntStringR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntStringV(rv2i(rv).(map[int]string), e) + +func (e *Encoder) fastpathEncMapFloat32Float32R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat32Float32V(rv2i(rv).(map[float32]float32), e) } -func (fastpathT) EncMapIntStringV(v map[int]string, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = int64(k) + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeString(v[int(k2)]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(float32(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v[float32(k2)]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeString(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapIntBytesR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntBytesV(rv2i(rv).(map[int][]byte), e) + +func (e *Encoder) fastpathEncMapFloat32Float64R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat32Float64V(rv2i(rv).(map[float32]float64), e) } -func (fastpathT) EncMapIntBytesV(v map[int][]byte, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = int64(k) + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v[int(k2)]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(float32(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v[float32(k2)]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapIntUintR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntUintV(rv2i(rv).(map[int]uint), e) + +func (e *Encoder) fastpathEncMapFloat32BoolR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat32BoolV(rv2i(rv).(map[float32]bool), e) } -func (fastpathT) EncMapIntUintV(v map[int]uint, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = int64(k) + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeUint(uint64(v[int(k2)])) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(float32(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v[float32(k2)]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat32(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapIntUint8R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntUint8V(rv2i(rv).(map[int]uint8), e) + +func (e *Encoder) fastpathEncMapFloat64IntfR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat64IntfV(rv2i(rv).(map[float64]interface{}), e) } -func (fastpathT) EncMapIntUint8V(v map[int]uint8, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = int64(k) + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeUint(uint64(v[int(k2)])) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(float64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[float64(k2)]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) - } - } - e.mapEnd() + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(k2) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapIntUint64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntUint64V(rv2i(rv).(map[int]uint64), e) + +func (e *Encoder) fastpathEncMapFloat64StringR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat64StringV(rv2i(rv).(map[float64]string), e) } -func (fastpathT) EncMapIntUint64V(v map[int]uint64, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = int64(k) + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeUint(v[int(k2)]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(float64(k2)) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v[float64(k2)])) + } else { + ee.EncodeStringEnc(cUTF8, v[float64(k2)]) + } } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeUint(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(k2) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v2)) + } else { + ee.EncodeStringEnc(cUTF8, v2) + } } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapIntIntR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntIntV(rv2i(rv).(map[int]int), e) + +func (e *Encoder) fastpathEncMapFloat64UintR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat64UintV(rv2i(rv).(map[float64]uint), e) } -func (fastpathT) EncMapIntIntV(v map[int]int, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = int64(k) + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeInt(int64(v[int(k2)])) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(float64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[float64(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeInt(int64(v2)) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapIntInt64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntInt64V(rv2i(rv).(map[int]int64), e) + +func (e *Encoder) fastpathEncMapFloat64Uint8R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat64Uint8V(rv2i(rv).(map[float64]uint8), e) } -func (fastpathT) EncMapIntInt64V(v map[int]int64, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = int64(k) + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeInt(v[int(k2)]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(float64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[float64(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeInt(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapIntFloat32R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntFloat32V(rv2i(rv).(map[int]float32), e) + +func (e *Encoder) fastpathEncMapFloat64Uint16R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat64Uint16V(rv2i(rv).(map[float64]uint16), e) } -func (fastpathT) EncMapIntFloat32V(v map[int]float32, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = int64(k) + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeFloat32(v[int(k2)]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(float64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[float64(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeFloat32(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapIntFloat64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntFloat64V(rv2i(rv).(map[int]float64), e) + +func (e *Encoder) fastpathEncMapFloat64Uint32R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat64Uint32V(rv2i(rv).(map[float64]uint32), e) } -func (fastpathT) EncMapIntFloat64V(v map[int]float64, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = int64(k) + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeFloat64(v[int(k2)]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(float64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[float64(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeFloat64(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapIntBoolR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntBoolV(rv2i(rv).(map[int]bool), e) + +func (e *Encoder) fastpathEncMapFloat64Uint64R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat64Uint64V(rv2i(rv).(map[float64]uint64), e) } -func (fastpathT) EncMapIntBoolV(v map[int]bool, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = int64(k) + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeBool(v[int(k2)]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(float64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[float64(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeBool(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapInt64IntfR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64IntfV(rv2i(rv).(map[int64]interface{}), e) + +func (e *Encoder) fastpathEncMapFloat64UintptrR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat64UintptrV(rv2i(rv).(map[float64]uintptr), e) } -func (fastpathT) EncMapInt64IntfV(v map[int64]interface{}, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.encode(v[k2]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(float64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[float64(k2)]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(k2) + if esep { + ee.WriteMapElemValue() + } e.encode(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapInt64StringR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64StringV(rv2i(rv).(map[int64]string), e) + +func (e *Encoder) fastpathEncMapFloat64IntR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat64IntV(rv2i(rv).(map[float64]int), e) } -func (fastpathT) EncMapInt64StringV(v map[int64]string, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeString(v[k2]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(float64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[float64(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeString(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapInt64BytesR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64BytesV(rv2i(rv).(map[int64][]byte), e) + +func (e *Encoder) fastpathEncMapFloat64Int8R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat64Int8V(rv2i(rv).(map[float64]int8), e) } -func (fastpathT) EncMapInt64BytesV(v map[int64][]byte, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v[k2]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(float64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[float64(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapInt64UintR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64UintV(rv2i(rv).(map[int64]uint), e) + +func (e *Encoder) fastpathEncMapFloat64Int16R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat64Int16V(rv2i(rv).(map[float64]int16), e) } -func (fastpathT) EncMapInt64UintV(v map[int64]uint, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v[k2])) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(float64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[float64(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapInt64Uint8R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64Uint8V(rv2i(rv).(map[int64]uint8), e) + +func (e *Encoder) fastpathEncMapFloat64Int32R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat64Int32V(rv2i(rv).(map[float64]int32), e) } -func (fastpathT) EncMapInt64Uint8V(v map[int64]uint8, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v[k2])) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(float64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[float64(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapInt64Uint64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64Uint64V(rv2i(rv).(map[int64]uint64), e) + +func (e *Encoder) fastpathEncMapFloat64Int64R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat64Int64V(rv2i(rv).(map[float64]int64), e) } -func (fastpathT) EncMapInt64Uint64V(v map[int64]uint64, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeUint(v[k2]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(float64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[float64(k2)])) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeUint(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapInt64IntR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64IntV(rv2i(rv).(map[int64]int), e) + +func (e *Encoder) fastpathEncMapFloat64Float32R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat64Float32V(rv2i(rv).(map[float64]float32), e) } -func (fastpathT) EncMapInt64IntV(v map[int64]int, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeInt(int64(v[k2])) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(float64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v[float64(k2)]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeInt(int64(v2)) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapInt64Int64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64Int64V(rv2i(rv).(map[int64]int64), e) + +func (e *Encoder) fastpathEncMapFloat64Float64R(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat64Float64V(rv2i(rv).(map[float64]float64), e) } -func (fastpathT) EncMapInt64Int64V(v map[int64]int64, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeInt(v[k2]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(float64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v[float64(k2)]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeInt(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapInt64Float32R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64Float32V(rv2i(rv).(map[int64]float32), e) + +func (e *Encoder) fastpathEncMapFloat64BoolR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapFloat64BoolV(rv2i(rv).(map[float64]bool), e) } -func (fastpathT) EncMapInt64Float32V(v map[int64]float32, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]float64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = float64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(floatSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeFloat32(v[k2]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(float64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v[float64(k2)]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeFloat32(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeFloat64(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapInt64Float64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64Float64V(rv2i(rv).(map[int64]float64), e) + +func (e *Encoder) fastpathEncMapUintIntfR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapUintIntfV(rv2i(rv).(map[uint]interface{}), e) } -func (fastpathT) EncMapInt64Float64V(v map[int64]float64, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]uint64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = uint64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(uintSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeFloat64(v[k2]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint(k2))) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[uint(k2)]) } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeFloat64(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) } } - e.mapEnd() + ee.WriteMapEnd() } -func (e *Encoder) fastpathEncMapInt64BoolR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64BoolV(rv2i(rv).(map[int64]bool), e) + +func (e *Encoder) fastpathEncMapUintStringR(f *codecFnInfo, rv reflect.Value) { + fastpathTV.EncMapUintStringV(rv2i(rv).(map[uint]string), e) } -func (fastpathT) EncMapInt64BoolV(v map[int64]bool, e *Encoder) { - e.mapStart(len(v)) +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 { - v2 := make([]int64, len(v)) + v2 := make([]uint64, len(v)) var i uint for k := range v { - v2[i] = k + v2[i] = uint64(k) i++ } - sort.Sort(int64Slice(v2)) + sort.Sort(uintSlice(v2)) for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeBool(v[k2]) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint(k2))) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v[uint(k2)])) + } else { + ee.EncodeStringEnc(cUTF8, v[uint(k2)]) + } } } else { for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeBool(v2) + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v2)) + } else { + ee.EncodeStringEnc(cUTF8, v2) + } } } - e.mapEnd() + ee.WriteMapEnd() } -// -- decode - -// -- -- fast path type switch -func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { - var changed bool - var containerLen int - switch v := iv.(type) { - case []interface{}: - fastpathTV.DecSliceIntfN(v, d) - case *[]interface{}: - var v2 []interface{} - if v2, changed = fastpathTV.DecSliceIntfY(*v, d); changed { - *v = v2 +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ } - case []string: - fastpathTV.DecSliceStringN(v, d) - case *[]string: - var v2 []string - if v2, changed = fastpathTV.DecSliceStringY(*v, d); changed { - *v = v2 + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uint(k2)])) } - case [][]byte: - fastpathTV.DecSliceBytesN(v, d) - case *[][]byte: - var v2 [][]byte - if v2, changed = fastpathTV.DecSliceBytesY(*v, d); changed { - *v = v2 + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } - case []float32: - fastpathTV.DecSliceFloat32N(v, d) - case *[]float32: - var v2 []float32 - if v2, changed = fastpathTV.DecSliceFloat32Y(*v, d); changed { - *v = v2 + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ } - case []float64: - fastpathTV.DecSliceFloat64N(v, d) - case *[]float64: - var v2 []float64 - if v2, changed = fastpathTV.DecSliceFloat64Y(*v, d); changed { - *v = v2 + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uint(k2)])) } - case []uint: - fastpathTV.DecSliceUintN(v, d) - case *[]uint: - var v2 []uint - if v2, changed = fastpathTV.DecSliceUintY(*v, d); changed { - *v = v2 - } - case []uint16: - fastpathTV.DecSliceUint16N(v, d) - case *[]uint16: - var v2 []uint16 - if v2, changed = fastpathTV.DecSliceUint16Y(*v, d); changed { - *v = v2 - } - case []uint32: - fastpathTV.DecSliceUint32N(v, d) - case *[]uint32: - var v2 []uint32 - if v2, changed = fastpathTV.DecSliceUint32Y(*v, d); changed { - *v = v2 - } - case []uint64: - fastpathTV.DecSliceUint64N(v, d) - case *[]uint64: - var v2 []uint64 - if v2, changed = fastpathTV.DecSliceUint64Y(*v, d); changed { - *v = v2 - } - case []int: - fastpathTV.DecSliceIntN(v, d) - case *[]int: - var v2 []int - if v2, changed = fastpathTV.DecSliceIntY(*v, d); changed { - *v = v2 - } - case []int8: - fastpathTV.DecSliceInt8N(v, d) - case *[]int8: - var v2 []int8 - if v2, changed = fastpathTV.DecSliceInt8Y(*v, d); changed { - *v = v2 - } - case []int16: - fastpathTV.DecSliceInt16N(v, d) - case *[]int16: - var v2 []int16 - if v2, changed = fastpathTV.DecSliceInt16Y(*v, d); changed { - *v = v2 - } - case []int32: - fastpathTV.DecSliceInt32N(v, d) - case *[]int32: - var v2 []int32 - if v2, changed = fastpathTV.DecSliceInt32Y(*v, d); changed { - *v = v2 - } - case []int64: - fastpathTV.DecSliceInt64N(v, d) - case *[]int64: - var v2 []int64 - if v2, changed = fastpathTV.DecSliceInt64Y(*v, d); changed { - *v = v2 - } - case []bool: - fastpathTV.DecSliceBoolN(v, d) - case *[]bool: - var v2 []bool - if v2, changed = fastpathTV.DecSliceBoolY(*v, d); changed { - *v = v2 - } - case map[string]interface{}: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringIntfL(v, containerLen, d) - } - d.mapEnd() - } - case *map[string]interface{}: - fastpathTV.DecMapStringIntfX(v, d) - case map[string]string: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringStringL(v, containerLen, d) + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[string]string: - fastpathTV.DecMapStringStringX(v, d) - case map[string][]byte: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringBytesL(v, containerLen, d) + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeUint(uint64(v2)) } - case *map[string][]byte: - fastpathTV.DecMapStringBytesX(v, d) - case map[string]uint: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringUintL(v, containerLen, d) - } - d.mapEnd() + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ } - case *map[string]uint: - fastpathTV.DecMapStringUintX(v, d) - case map[string]uint8: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringUint8L(v, containerLen, d) + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[string]uint8: - fastpathTV.DecMapStringUint8X(v, d) - case map[string]uint64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringUint64L(v, containerLen, d) + ee.EncodeUint(uint64(uint(k2))) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeUint(uint64(v[uint(k2)])) } - case *map[string]uint64: - fastpathTV.DecMapStringUint64X(v, d) - case map[string]int: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringIntL(v, containerLen, d) + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[string]int: - fastpathTV.DecMapStringIntX(v, d) - case map[string]int64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringInt64L(v, containerLen, d) + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeUint(uint64(v2)) } - case *map[string]int64: - fastpathTV.DecMapStringInt64X(v, d) - case map[string]float32: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringFloat32L(v, containerLen, d) - } - d.mapEnd() + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ } - case *map[string]float32: - fastpathTV.DecMapStringFloat32X(v, d) - case map[string]float64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringFloat64L(v, containerLen, d) + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[string]float64: - fastpathTV.DecMapStringFloat64X(v, d) - case map[string]bool: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringBoolL(v, containerLen, d) + ee.EncodeUint(uint64(uint(k2))) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeUint(uint64(v[uint(k2)])) } - case *map[string]bool: - fastpathTV.DecMapStringBoolX(v, d) - case map[uint]interface{}: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintIntfL(v, containerLen, d) + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[uint]interface{}: - fastpathTV.DecMapUintIntfX(v, d) - case map[uint]string: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintStringL(v, containerLen, d) + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeUint(uint64(v2)) } - case *map[uint]string: - fastpathTV.DecMapUintStringX(v, d) - case map[uint][]byte: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintBytesL(v, containerLen, d) - } - d.mapEnd() + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ } - case *map[uint][]byte: - fastpathTV.DecMapUintBytesX(v, d) - case map[uint]uint: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintUintL(v, containerLen, d) + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[uint]uint: - fastpathTV.DecMapUintUintX(v, d) - case map[uint]uint8: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintUint8L(v, containerLen, d) + ee.EncodeUint(uint64(uint(k2))) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeUint(uint64(v[uint(k2)])) } - case *map[uint]uint8: - fastpathTV.DecMapUintUint8X(v, d) - case map[uint]uint64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintUint64L(v, containerLen, d) + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[uint]uint64: - fastpathTV.DecMapUintUint64X(v, d) - case map[uint]int: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintIntL(v, containerLen, d) + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeUint(uint64(v2)) } - case *map[uint]int: - fastpathTV.DecMapUintIntX(v, d) - case map[uint]int64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintInt64L(v, containerLen, d) - } - d.mapEnd() + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ } - case *map[uint]int64: - fastpathTV.DecMapUintInt64X(v, d) - case map[uint]float32: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintFloat32L(v, containerLen, d) + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[uint]float32: - fastpathTV.DecMapUintFloat32X(v, d) - case map[uint]float64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintFloat64L(v, containerLen, d) + ee.EncodeUint(uint64(uint(k2))) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + e.encode(v[uint(k2)]) } - case *map[uint]float64: - fastpathTV.DecMapUintFloat64X(v, d) - case map[uint]bool: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintBoolL(v, containerLen, d) + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[uint]bool: - fastpathTV.DecMapUintBoolX(v, d) - case map[uint8]interface{}: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8IntfL(v, containerLen, d) + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + e.encode(v2) } - case *map[uint8]interface{}: - fastpathTV.DecMapUint8IntfX(v, d) - case map[uint8]string: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8StringL(v, containerLen, d) - } - d.mapEnd() + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ } - case *map[uint8]string: - fastpathTV.DecMapUint8StringX(v, d) - case map[uint8][]byte: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8BytesL(v, containerLen, d) + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[uint8][]byte: - fastpathTV.DecMapUint8BytesX(v, d) - case map[uint8]uint: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8UintL(v, containerLen, d) + ee.EncodeUint(uint64(uint(k2))) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeInt(int64(v[uint(k2)])) } - case *map[uint8]uint: - fastpathTV.DecMapUint8UintX(v, d) - case map[uint8]uint8: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8Uint8L(v, containerLen, d) + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[uint8]uint8: - fastpathTV.DecMapUint8Uint8X(v, d) - case map[uint8]uint64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8Uint64L(v, containerLen, d) + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeInt(int64(v2)) } - case *map[uint8]uint64: - fastpathTV.DecMapUint8Uint64X(v, d) - case map[uint8]int: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8IntL(v, containerLen, d) - } - d.mapEnd() + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ } - case *map[uint8]int: - fastpathTV.DecMapUint8IntX(v, d) - case map[uint8]int64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8Int64L(v, containerLen, d) + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[uint8]int64: - fastpathTV.DecMapUint8Int64X(v, d) - case map[uint8]float32: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8Float32L(v, containerLen, d) + ee.EncodeUint(uint64(uint(k2))) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeInt(int64(v[uint(k2)])) } - case *map[uint8]float32: - fastpathTV.DecMapUint8Float32X(v, d) - case map[uint8]float64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8Float64L(v, containerLen, d) + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[uint8]float64: - fastpathTV.DecMapUint8Float64X(v, d) - case map[uint8]bool: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8BoolL(v, containerLen, d) + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeInt(int64(v2)) } - case *map[uint8]bool: - fastpathTV.DecMapUint8BoolX(v, d) - case map[uint64]interface{}: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64IntfL(v, containerLen, d) - } - d.mapEnd() + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ } - case *map[uint64]interface{}: - fastpathTV.DecMapUint64IntfX(v, d) - case map[uint64]string: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64StringL(v, containerLen, d) + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[uint64]string: - fastpathTV.DecMapUint64StringX(v, d) - case map[uint64][]byte: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64BytesL(v, containerLen, d) + ee.EncodeUint(uint64(uint(k2))) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeInt(int64(v[uint(k2)])) } - case *map[uint64][]byte: - fastpathTV.DecMapUint64BytesX(v, d) - case map[uint64]uint: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64UintL(v, containerLen, d) + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[uint64]uint: - fastpathTV.DecMapUint64UintX(v, d) - case map[uint64]uint8: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64Uint8L(v, containerLen, d) + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeInt(int64(v2)) } - case *map[uint64]uint8: - fastpathTV.DecMapUint64Uint8X(v, d) - case map[uint64]uint64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64Uint64L(v, containerLen, d) - } - d.mapEnd() + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ } - case *map[uint64]uint64: - fastpathTV.DecMapUint64Uint64X(v, d) - case map[uint64]int: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64IntL(v, containerLen, d) + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[uint64]int: - fastpathTV.DecMapUint64IntX(v, d) - case map[uint64]int64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64Int64L(v, containerLen, d) + ee.EncodeUint(uint64(uint(k2))) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeInt(int64(v[uint(k2)])) } - case *map[uint64]int64: - fastpathTV.DecMapUint64Int64X(v, d) - case map[uint64]float32: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64Float32L(v, containerLen, d) + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[uint64]float32: - fastpathTV.DecMapUint64Float32X(v, d) - case map[uint64]float64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64Float64L(v, containerLen, d) + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeInt(int64(v2)) } - case *map[uint64]float64: - fastpathTV.DecMapUint64Float64X(v, d) - case map[uint64]bool: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64BoolL(v, containerLen, d) - } - d.mapEnd() + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ } - case *map[uint64]bool: - fastpathTV.DecMapUint64BoolX(v, d) - case map[int]interface{}: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntIntfL(v, containerLen, d) + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[int]interface{}: - fastpathTV.DecMapIntIntfX(v, d) - case map[int]string: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntStringL(v, containerLen, d) + ee.EncodeUint(uint64(uint(k2))) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeInt(int64(v[uint(k2)])) } - case *map[int]string: - fastpathTV.DecMapIntStringX(v, d) - case map[int][]byte: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntBytesL(v, containerLen, d) + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[int][]byte: - fastpathTV.DecMapIntBytesX(v, d) - case map[int]uint: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntUintL(v, containerLen, d) + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeInt(int64(v2)) } - case *map[int]uint: - fastpathTV.DecMapIntUintX(v, d) - case map[int]uint8: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntUint8L(v, containerLen, d) - } - d.mapEnd() + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ } - case *map[int]uint8: - fastpathTV.DecMapIntUint8X(v, d) - case map[int]uint64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntUint64L(v, containerLen, d) + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() - } - case *map[int]uint64: - fastpathTV.DecMapIntUint64X(v, d) - case map[int]int: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntIntL(v, containerLen, d) + ee.EncodeUint(uint64(uint(k2))) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeFloat32(v[uint(k2)]) } - case *map[int]int: - fastpathTV.DecMapIntIntX(v, d) - case map[int]int64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntInt64L(v, containerLen, d) + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v2) } - case *map[int]int64: - fastpathTV.DecMapIntInt64X(v, d) - case map[int]float32: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntFloat32L(v, containerLen, d) + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint(k2))) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeFloat64(v[uint(k2)]) } - case *map[int]float32: - fastpathTV.DecMapIntFloat32X(v, d) - case map[int]float64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntFloat64L(v, containerLen, d) + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v2) } - case *map[int]float64: - fastpathTV.DecMapIntFloat64X(v, d) - case map[int]bool: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntBoolL(v, containerLen, d) + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint(k2))) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeBool(v[uint(k2)]) } - case *map[int]bool: - fastpathTV.DecMapIntBoolX(v, d) - case map[int64]interface{}: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64IntfL(v, containerLen, d) + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v2) } - case *map[int64]interface{}: - fastpathTV.DecMapInt64IntfX(v, d) - case map[int64]string: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64StringL(v, containerLen, d) + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint8(k2))) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + e.encode(v[uint8(k2)]) } - case *map[int64]string: - fastpathTV.DecMapInt64StringX(v, d) - case map[int64][]byte: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64BytesL(v, containerLen, d) + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) } - case *map[int64][]byte: - fastpathTV.DecMapInt64BytesX(v, d) - case map[int64]uint: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64UintL(v, containerLen, d) + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint8(k2))) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v[uint8(k2)])) + } else { + ee.EncodeStringEnc(cUTF8, v[uint8(k2)]) } - d.mapEnd() } - case *map[int64]uint: - fastpathTV.DecMapInt64UintX(v, d) - case map[int64]uint8: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64Uint8L(v, containerLen, d) + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v2)) + } else { + ee.EncodeStringEnc(cUTF8, v2) } - d.mapEnd() } - case *map[int64]uint8: - fastpathTV.DecMapInt64Uint8X(v, d) - case map[int64]uint64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64Uint64L(v, containerLen, d) + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint8(k2))) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeUint(uint64(v[uint8(k2)])) } - case *map[int64]uint64: - fastpathTV.DecMapInt64Uint64X(v, d) - case map[int64]int: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64IntL(v, containerLen, d) + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } - case *map[int64]int: - fastpathTV.DecMapInt64IntX(v, d) - case map[int64]int64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64Int64L(v, containerLen, d) + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint8(k2))) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeUint(uint64(v[uint8(k2)])) } - case *map[int64]int64: - fastpathTV.DecMapInt64Int64X(v, d) - case map[int64]float32: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64Float32L(v, containerLen, d) + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } - case *map[int64]float32: - fastpathTV.DecMapInt64Float32X(v, d) - case map[int64]float64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64Float64L(v, containerLen, d) + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint8(k2))) + if esep { + ee.WriteMapElemValue() } - d.mapEnd() + ee.EncodeUint(uint64(v[uint8(k2)])) } - case *map[int64]float64: - fastpathTV.DecMapInt64Float64X(v, d) - case map[int64]bool: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64BoolL(v, containerLen, d) + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() } - d.mapEnd() + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) } - case *map[int64]bool: - fastpathTV.DecMapInt64BoolX(v, d) - default: - _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 - return false } - return true + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uint8(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uint8(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint8(k2))) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[uint8(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint8(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint8(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint8(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint8(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint8(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v[uint8(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v[uint8(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v[uint8(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint16(k2))) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[uint16(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint16(k2))) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v[uint16(k2)])) + } else { + ee.EncodeStringEnc(cUTF8, v[uint16(k2)]) + } + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v2)) + } else { + ee.EncodeStringEnc(cUTF8, v2) + } + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uint16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uint16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uint16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uint16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uint16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint16(k2))) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[uint16(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v[uint16(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v[uint16(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v[uint16(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint32(k2))) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[uint32(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint32(k2))) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v[uint32(k2)])) + } else { + ee.EncodeStringEnc(cUTF8, v[uint32(k2)]) + } + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v2)) + } else { + ee.EncodeStringEnc(cUTF8, v2) + } + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uint32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uint32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uint32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uint32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uint32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint32(k2))) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[uint32(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v[uint32(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v[uint32(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v[uint32(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint64(k2))) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[uint64(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint64(k2))) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v[uint64(k2)])) + } else { + ee.EncodeStringEnc(cUTF8, v[uint64(k2)]) + } + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v2)) + } else { + ee.EncodeStringEnc(cUTF8, v2) + } + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uint64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uint64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uint64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uint64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uint64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint64(k2))) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[uint64(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uint64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v[uint64(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v[uint64(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(uint64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v[uint64(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeUint(uint64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.encode(uintptr(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[uintptr(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.encode(uintptr(k2)) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v[uintptr(k2)])) + } else { + ee.EncodeStringEnc(cUTF8, v[uintptr(k2)]) + } + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v2)) + } else { + ee.EncodeStringEnc(cUTF8, v2) + } + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.encode(uintptr(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.encode(uintptr(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.encode(uintptr(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.encode(uintptr(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.encode(uintptr(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.encode(uintptr(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[uintptr(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.encode(uintptr(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.encode(uintptr(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.encode(uintptr(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.encode(uintptr(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.encode(uintptr(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.encode(uintptr(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v[uintptr(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.encode(uintptr(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v[uintptr(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]uint64, len(v)) + var i uint + for k := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + e.encode(uintptr(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v[uintptr(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + e.encode(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int(k2))) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[int(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int(k2))) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v[int(k2)])) + } else { + ee.EncodeStringEnc(cUTF8, v[int(k2)]) + } + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v2)) + } else { + ee.EncodeStringEnc(cUTF8, v2) + } + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int(k2))) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[int(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v[int(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v[int(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v[int(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int8(k2))) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[int8(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int8(k2))) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v[int8(k2)])) + } else { + ee.EncodeStringEnc(cUTF8, v[int8(k2)]) + } + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v2)) + } else { + ee.EncodeStringEnc(cUTF8, v2) + } + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int8(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int8(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int8(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int8(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int8(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int8(k2))) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[int8(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int8(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int8(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int8(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int8(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int8(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v[int8(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v[int8(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int8(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v[int8(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int16(k2))) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[int16(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int16(k2))) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v[int16(k2)])) + } else { + ee.EncodeStringEnc(cUTF8, v[int16(k2)]) + } + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v2)) + } else { + ee.EncodeStringEnc(cUTF8, v2) + } + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int16(k2))) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[int16(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int16(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v[int16(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v[int16(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int16(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v[int16(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int32(k2))) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[int32(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int32(k2))) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v[int32(k2)])) + } else { + ee.EncodeStringEnc(cUTF8, v[int32(k2)]) + } + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v2)) + } else { + ee.EncodeStringEnc(cUTF8, v2) + } + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int32(k2))) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[int32(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int32(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v[int32(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v[int32(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int32(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v[int32(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int64(k2))) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[int64(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int64(k2))) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v[int64(k2)])) + } else { + ee.EncodeStringEnc(cUTF8, v[int64(k2)]) + } + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v2)) + } else { + ee.EncodeStringEnc(cUTF8, v2) + } + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[int64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int64(k2))) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[int64(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[int64(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v[int64(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v[int64(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]int64, len(v)) + var i uint + for k := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(int64(k2))) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v[int64(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeInt(int64(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]bool, len(v)) + var i uint + for k := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(bool(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[bool(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(k2) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]bool, len(v)) + var i uint + for k := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(bool(k2)) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v[bool(k2)])) + } else { + ee.EncodeStringEnc(cUTF8, v[bool(k2)]) + } + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(k2) + if esep { + ee.WriteMapElemValue() + } + if e.h.StringToRaw { + ee.EncodeStringBytesRaw(bytesView(v2)) + } else { + ee.EncodeStringEnc(cUTF8, v2) + } + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]bool, len(v)) + var i uint + for k := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(bool(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[bool(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]bool, len(v)) + var i uint + for k := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(bool(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[bool(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]bool, len(v)) + var i uint + for k := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(bool(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[bool(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]bool, len(v)) + var i uint + for k := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(bool(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[bool(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]bool, len(v)) + var i uint + for k := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(bool(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v[bool(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeUint(uint64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]bool, len(v)) + var i uint + for k := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(bool(k2)) + if esep { + ee.WriteMapElemValue() + } + e.encode(v[bool(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(k2) + if esep { + ee.WriteMapElemValue() + } + e.encode(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]bool, len(v)) + var i uint + for k := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(bool(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[bool(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]bool, len(v)) + var i uint + for k := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(bool(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[bool(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]bool, len(v)) + var i uint + for k := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(bool(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[bool(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]bool, len(v)) + var i uint + for k := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(bool(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[bool(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]bool, len(v)) + var i uint + for k := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(bool(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v[bool(k2)])) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeInt(int64(v2)) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]bool, len(v)) + var i uint + for k := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(bool(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v[bool(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat32(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]bool, len(v)) + var i uint + for k := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(bool(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v[bool(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeFloat64(v2) + } + } + ee.WriteMapEnd() +} + +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 { + v2 := make([]bool, len(v)) + var i uint + for k := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(bool(k2)) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v[bool(k2)]) + } + } else { + for k2, v2 := range v { + if esep { + ee.WriteMapElemKey() + } + ee.EncodeBool(k2) + if esep { + ee.WriteMapElemValue() + } + ee.EncodeBool(v2) + } + } + ee.WriteMapEnd() +} + +// -- decode + +// -- -- fast path type switch +func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { + var changed bool + switch v := iv.(type) { + + case []interface{}: + 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{}: + 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{}: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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{}: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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{}: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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{}: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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{}: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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{}: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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{}: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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{}: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + var v2 map[uint32]bool + v2, changed = fastpathTV.DecMapUint32BoolV(*v, true, d) + if changed { + *v = v2 + } + case map[uint64]interface{}: + fastpathTV.DecMapUint64IntfV(v, false, d) + case *map[uint64]interface{}: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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{}: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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{}: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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{}: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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{}: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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{}: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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{}: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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{}: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + var v2 map[bool]bool + v2, changed = fastpathTV.DecMapBoolBoolV(*v, true, d) + if changed { + *v = v2 + } + default: + _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 + return false + } + return true } func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool { switch v := iv.(type) { + case *[]interface{}: *v = nil - case *[]string: + 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 *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 *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 *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 *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 *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 *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 *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 *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 *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 *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 *[][]byte: + case *map[int8]float64: *v = nil - case *[]float32: + case *map[int8]bool: *v = nil - case *[]float64: + case *map[int16]interface{}: *v = nil - case *[]uint: + case *map[int16]string: *v = nil - case *[]uint16: + case *map[int16]uint: *v = nil - case *[]uint32: + case *map[int16]uint8: *v = nil - case *[]uint64: + case *map[int16]uint16: *v = nil - case *[]int: + case *map[int16]uint32: *v = nil - case *[]int8: + case *map[int16]uint64: *v = nil - case *[]int16: + case *map[int16]uintptr: *v = nil - case *[]int32: + case *map[int16]int: *v = nil - case *[]int64: + case *map[int16]int8: *v = nil - case *[]bool: + 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 *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 *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 *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 // workaround https://github.com/golang/go/issues/12927 seen in go1.4 + return false + } + return true +} + +// -- -- fast path functions + +func (d *Decoder) fastpathDecSliceIntfR(f *codecFnInfo, rv reflect.Value) { + if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*[]interface{}) + v, changed := fastpathTV.DecSliceIntfV(*vp, !array, d) + if changed { + *vp = v + } + } else { + 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) { + 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 { + if v == nil { + v = []interface{}{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + d.depthIncr() + hasLen := containerLenS > 0 + var xlen int + if hasLen && canChange { + if containerLenS > cap(v) { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16) + if xlen <= cap(v) { + v = v[:uint(xlen)] + } else { + v = make([]interface{}, uint(xlen)) + } + changed = true + } else if containerLenS != len(v) { + v = v[:containerLenS] + changed = true + } + } + var j int + for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { + if j == 0 && len(v) == 0 && canChange { + if hasLen { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16) + } else { + xlen = 8 + } + v = make([]interface{}, uint(xlen)) + changed = true + } + // if indefinite, etc, then expand the slice if necessary + var decodeIntoBlank bool + if j >= len(v) { + if canChange { + v = append(v, nil) + changed = true + } else { + d.arrayCannotExpand(len(v), j+1) + decodeIntoBlank = true + } + } + slh.ElemContainerState(j) + if decodeIntoBlank { + d.swallow() + } else if dd.TryDecodeAsNil() { + v[uint(j)] = nil + } else { + d.decode(&v[uint(j)]) + } + } + if canChange { + if j < len(v) { + v = v[:uint(j)] + changed = true + } else if j == 0 && v == nil { + v = make([]interface{}, 0) + changed = true + } + } + slh.End() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecSliceStringR(f *codecFnInfo, rv reflect.Value) { + if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*[]string) + v, changed := fastpathTV.DecSliceStringV(*vp, !array, d) + if changed { + *vp = v + } + } else { + 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) { + 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 { + if v == nil { + v = []string{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + d.depthIncr() + hasLen := containerLenS > 0 + var xlen int + if hasLen && canChange { + if containerLenS > cap(v) { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16) + if xlen <= cap(v) { + v = v[:uint(xlen)] + } else { + v = make([]string, uint(xlen)) + } + changed = true + } else if containerLenS != len(v) { + v = v[:containerLenS] + changed = true + } + } + var j int + for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { + if j == 0 && len(v) == 0 && canChange { + if hasLen { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16) + } else { + xlen = 8 + } + v = make([]string, uint(xlen)) + changed = true + } + // if indefinite, etc, then expand the slice if necessary + var decodeIntoBlank bool + if j >= len(v) { + if canChange { + v = append(v, "") + changed = true + } else { + d.arrayCannotExpand(len(v), j+1) + decodeIntoBlank = true + } + } + slh.ElemContainerState(j) + if decodeIntoBlank { + d.swallow() + } else if dd.TryDecodeAsNil() { + v[uint(j)] = "" + } else { + v[uint(j)] = dd.DecodeString() + } + } + if canChange { + if j < len(v) { + v = v[:uint(j)] + changed = true + } else if j == 0 && v == nil { + v = make([]string, 0) + changed = true + } + } + slh.End() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecSliceFloat32R(f *codecFnInfo, rv reflect.Value) { + if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*[]float32) + v, changed := fastpathTV.DecSliceFloat32V(*vp, !array, d) + if changed { + *vp = v + } + } else { + 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) { + 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 { + if v == nil { + v = []float32{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + d.depthIncr() + hasLen := containerLenS > 0 + var xlen int + if hasLen && canChange { + if containerLenS > cap(v) { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) + if xlen <= cap(v) { + v = v[:uint(xlen)] + } else { + v = make([]float32, uint(xlen)) + } + changed = true + } else if containerLenS != len(v) { + v = v[:containerLenS] + changed = true + } + } + var j int + for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { + if j == 0 && len(v) == 0 && canChange { + if hasLen { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) + } else { + xlen = 8 + } + v = make([]float32, uint(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[uint(j)] = 0 + } else { + v[uint(j)] = float32(chkOvf.Float32V(dd.DecodeFloat64())) + } + } + if canChange { + if j < len(v) { + v = v[:uint(j)] + changed = true + } else if j == 0 && v == nil { + v = make([]float32, 0) + changed = true + } + } + slh.End() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecSliceFloat64R(f *codecFnInfo, rv reflect.Value) { + if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*[]float64) + v, changed := fastpathTV.DecSliceFloat64V(*vp, !array, d) + if changed { + *vp = v + } + } else { + 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) { + 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 { + if v == nil { + v = []float64{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + d.depthIncr() + hasLen := containerLenS > 0 + var xlen int + if hasLen && canChange { + if containerLenS > cap(v) { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) + if xlen <= cap(v) { + v = v[:uint(xlen)] + } else { + v = make([]float64, uint(xlen)) + } + changed = true + } else if containerLenS != len(v) { + v = v[:containerLenS] + changed = true + } + } + var j int + for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { + if j == 0 && len(v) == 0 && canChange { + if hasLen { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) + } else { + xlen = 8 + } + v = make([]float64, uint(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[uint(j)] = 0 + } else { + v[uint(j)] = dd.DecodeFloat64() + } + } + if canChange { + if j < len(v) { + v = v[:uint(j)] + changed = true + } else if j == 0 && v == nil { + v = make([]float64, 0) + changed = true + } + } + slh.End() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecSliceUintR(f *codecFnInfo, rv reflect.Value) { + if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*[]uint) + v, changed := fastpathTV.DecSliceUintV(*vp, !array, d) + if changed { + *vp = v + } + } else { + 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) { + 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 { + if v == nil { + v = []uint{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + d.depthIncr() + hasLen := containerLenS > 0 + var xlen int + if hasLen && canChange { + if containerLenS > cap(v) { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) + if xlen <= cap(v) { + v = v[:uint(xlen)] + } else { + v = make([]uint, uint(xlen)) + } + changed = true + } else if containerLenS != len(v) { + v = v[:containerLenS] + changed = true + } + } + var j int + for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { + if j == 0 && len(v) == 0 && canChange { + if hasLen { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) + } else { + xlen = 8 + } + v = make([]uint, uint(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[uint(j)] = 0 + } else { + v[uint(j)] = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + } + } + if canChange { + if j < len(v) { + v = v[:uint(j)] + changed = true + } else if j == 0 && v == nil { + v = make([]uint, 0) + changed = true + } + } + slh.End() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecSliceUint8R(f *codecFnInfo, rv reflect.Value) { + if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*[]uint8) + v, changed := fastpathTV.DecSliceUint8V(*vp, !array, d) + if changed { + *vp = v + } + } else { + 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 + } + d.depthIncr() + 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[:uint(xlen)] + } else { + v = make([]uint8, uint(xlen)) + } + changed = true + } else if containerLenS != len(v) { + v = v[:containerLenS] + changed = true + } + } + var j int + for j = 0; (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, uint(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[uint(j)] = 0 + } else { + v[uint(j)] = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + } + } + if canChange { + if j < len(v) { + v = v[:uint(j)] + changed = true + } else if j == 0 && v == nil { + v = make([]uint8, 0) + changed = true + } + } + slh.End() + d.depthDecr() + 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) { + 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 { + if v == nil { + v = []uint16{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + d.depthIncr() + hasLen := containerLenS > 0 + var xlen int + if hasLen && canChange { + if containerLenS > cap(v) { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2) + if xlen <= cap(v) { + v = v[:uint(xlen)] + } else { + v = make([]uint16, uint(xlen)) + } + changed = true + } else if containerLenS != len(v) { + v = v[:containerLenS] + changed = true + } + } + var j int + for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { + if j == 0 && len(v) == 0 && canChange { + if hasLen { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2) + } else { + xlen = 8 + } + v = make([]uint16, uint(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[uint(j)] = 0 + } else { + v[uint(j)] = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + } + } + if canChange { + if j < len(v) { + v = v[:uint(j)] + changed = true + } else if j == 0 && v == nil { + v = make([]uint16, 0) + changed = true + } + } + slh.End() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecSliceUint32R(f *codecFnInfo, rv reflect.Value) { + if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*[]uint32) + v, changed := fastpathTV.DecSliceUint32V(*vp, !array, d) + if changed { + *vp = v + } + } else { + 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) { + 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 { + if v == nil { + v = []uint32{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + d.depthIncr() + hasLen := containerLenS > 0 + var xlen int + if hasLen && canChange { + if containerLenS > cap(v) { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) + if xlen <= cap(v) { + v = v[:uint(xlen)] + } else { + v = make([]uint32, uint(xlen)) + } + changed = true + } else if containerLenS != len(v) { + v = v[:containerLenS] + changed = true + } + } + var j int + for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { + if j == 0 && len(v) == 0 && canChange { + if hasLen { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) + } else { + xlen = 8 + } + v = make([]uint32, uint(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[uint(j)] = 0 + } else { + v[uint(j)] = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + } + } + if canChange { + if j < len(v) { + v = v[:uint(j)] + changed = true + } else if j == 0 && v == nil { + v = make([]uint32, 0) + changed = true + } + } + slh.End() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecSliceUint64R(f *codecFnInfo, rv reflect.Value) { + if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*[]uint64) + v, changed := fastpathTV.DecSliceUint64V(*vp, !array, d) + if changed { + *vp = v + } + } else { + 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) { + 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 { + if v == nil { + v = []uint64{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + d.depthIncr() + hasLen := containerLenS > 0 + var xlen int + if hasLen && canChange { + if containerLenS > cap(v) { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) + if xlen <= cap(v) { + v = v[:uint(xlen)] + } else { + v = make([]uint64, uint(xlen)) + } + changed = true + } else if containerLenS != len(v) { + v = v[:containerLenS] + changed = true + } + } + var j int + for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { + if j == 0 && len(v) == 0 && canChange { + if hasLen { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) + } else { + xlen = 8 + } + v = make([]uint64, uint(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[uint(j)] = 0 + } else { + v[uint(j)] = dd.DecodeUint64() + } + } + if canChange { + if j < len(v) { + v = v[:uint(j)] + changed = true + } else if j == 0 && v == nil { + v = make([]uint64, 0) + changed = true + } + } + slh.End() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecSliceUintptrR(f *codecFnInfo, rv reflect.Value) { + if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*[]uintptr) + v, changed := fastpathTV.DecSliceUintptrV(*vp, !array, d) + if changed { + *vp = v + } + } else { + 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) { + 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 { + if v == nil { + v = []uintptr{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + d.depthIncr() + hasLen := containerLenS > 0 + var xlen int + if hasLen && canChange { + if containerLenS > cap(v) { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) + if xlen <= cap(v) { + v = v[:uint(xlen)] + } else { + v = make([]uintptr, uint(xlen)) + } + changed = true + } else if containerLenS != len(v) { + v = v[:containerLenS] + changed = true + } + } + var j int + for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { + if j == 0 && len(v) == 0 && canChange { + if hasLen { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) + } else { + xlen = 8 + } + v = make([]uintptr, uint(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[uint(j)] = 0 + } else { + v[uint(j)] = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + } + } + if canChange { + if j < len(v) { + v = v[:uint(j)] + changed = true + } else if j == 0 && v == nil { + v = make([]uintptr, 0) + changed = true + } + } + slh.End() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecSliceIntR(f *codecFnInfo, rv reflect.Value) { + if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*[]int) + v, changed := fastpathTV.DecSliceIntV(*vp, !array, d) + if changed { + *vp = v + } + } else { + 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) { + 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 { + if v == nil { + v = []int{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + d.depthIncr() + hasLen := containerLenS > 0 + var xlen int + if hasLen && canChange { + if containerLenS > cap(v) { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) + if xlen <= cap(v) { + v = v[:uint(xlen)] + } else { + v = make([]int, uint(xlen)) + } + changed = true + } else if containerLenS != len(v) { + v = v[:containerLenS] + changed = true + } + } + var j int + for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { + if j == 0 && len(v) == 0 && canChange { + if hasLen { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) + } else { + xlen = 8 + } + v = make([]int, uint(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[uint(j)] = 0 + } else { + v[uint(j)] = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + } + } + if canChange { + if j < len(v) { + v = v[:uint(j)] + changed = true + } else if j == 0 && v == nil { + v = make([]int, 0) + changed = true + } + } + slh.End() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecSliceInt8R(f *codecFnInfo, rv reflect.Value) { + if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*[]int8) + v, changed := fastpathTV.DecSliceInt8V(*vp, !array, d) + if changed { + *vp = v + } + } else { + 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) { + 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 { + if v == nil { + v = []int8{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + d.depthIncr() + 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[:uint(xlen)] + } else { + v = make([]int8, uint(xlen)) + } + changed = true + } else if containerLenS != len(v) { + v = v[:containerLenS] + changed = true + } + } + var j int + for j = 0; (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([]int8, uint(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[uint(j)] = 0 + } else { + v[uint(j)] = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + } + } + if canChange { + if j < len(v) { + v = v[:uint(j)] + changed = true + } else if j == 0 && v == nil { + v = make([]int8, 0) + changed = true + } + } + slh.End() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecSliceInt16R(f *codecFnInfo, rv reflect.Value) { + if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*[]int16) + v, changed := fastpathTV.DecSliceInt16V(*vp, !array, d) + if changed { + *vp = v + } + } else { + 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) { + 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 { + if v == nil { + v = []int16{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + d.depthIncr() + hasLen := containerLenS > 0 + var xlen int + if hasLen && canChange { + if containerLenS > cap(v) { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2) + if xlen <= cap(v) { + v = v[:uint(xlen)] + } else { + v = make([]int16, uint(xlen)) + } + changed = true + } else if containerLenS != len(v) { + v = v[:containerLenS] + changed = true + } + } + var j int + for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { + if j == 0 && len(v) == 0 && canChange { + if hasLen { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2) + } else { + xlen = 8 + } + v = make([]int16, uint(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[uint(j)] = 0 + } else { + v[uint(j)] = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + } + } + if canChange { + if j < len(v) { + v = v[:uint(j)] + changed = true + } else if j == 0 && v == nil { + v = make([]int16, 0) + changed = true + } + } + slh.End() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecSliceInt32R(f *codecFnInfo, rv reflect.Value) { + if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*[]int32) + v, changed := fastpathTV.DecSliceInt32V(*vp, !array, d) + if changed { + *vp = v + } + } else { + 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) { + 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 { + if v == nil { + v = []int32{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + d.depthIncr() + hasLen := containerLenS > 0 + var xlen int + if hasLen && canChange { + if containerLenS > cap(v) { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) + if xlen <= cap(v) { + v = v[:uint(xlen)] + } else { + v = make([]int32, uint(xlen)) + } + changed = true + } else if containerLenS != len(v) { + v = v[:containerLenS] + changed = true + } + } + var j int + for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { + if j == 0 && len(v) == 0 && canChange { + if hasLen { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) + } else { + xlen = 8 + } + v = make([]int32, uint(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[uint(j)] = 0 + } else { + v[uint(j)] = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + } + } + if canChange { + if j < len(v) { + v = v[:uint(j)] + changed = true + } else if j == 0 && v == nil { + v = make([]int32, 0) + changed = true + } + } + slh.End() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecSliceInt64R(f *codecFnInfo, rv reflect.Value) { + if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*[]int64) + v, changed := fastpathTV.DecSliceInt64V(*vp, !array, d) + if changed { + *vp = v + } + } else { + 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) { + 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 { + if v == nil { + v = []int64{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + d.depthIncr() + hasLen := containerLenS > 0 + var xlen int + if hasLen && canChange { + if containerLenS > cap(v) { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) + if xlen <= cap(v) { + v = v[:uint(xlen)] + } else { + v = make([]int64, uint(xlen)) + } + changed = true + } else if containerLenS != len(v) { + v = v[:containerLenS] + changed = true + } + } + var j int + for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { + if j == 0 && len(v) == 0 && canChange { + if hasLen { + xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) + } else { + xlen = 8 + } + v = make([]int64, uint(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[uint(j)] = 0 + } else { + v[uint(j)] = dd.DecodeInt64() + } + } + if canChange { + if j < len(v) { + v = v[:uint(j)] + changed = true + } else if j == 0 && v == nil { + v = make([]int64, 0) + changed = true + } + } + slh.End() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecSliceBoolR(f *codecFnInfo, rv reflect.Value) { + if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*[]bool) + v, changed := fastpathTV.DecSliceBoolV(*vp, !array, d) + if changed { + *vp = v + } + } else { + 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) { + 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 { + if v == nil { + v = []bool{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + d.depthIncr() + 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[:uint(xlen)] + } else { + v = make([]bool, uint(xlen)) + } + changed = true + } else if containerLenS != len(v) { + v = v[:containerLenS] + changed = true + } + } + var j int + for j = 0; (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([]bool, uint(xlen)) + changed = true + } + // if indefinite, etc, then expand the slice if necessary + var decodeIntoBlank bool + if j >= len(v) { + if canChange { + v = append(v, false) + changed = true + } else { + d.arrayCannotExpand(len(v), j+1) + decodeIntoBlank = true + } + } + slh.ElemContainerState(j) + if decodeIntoBlank { + d.swallow() + } else if dd.TryDecodeAsNil() { + v[uint(j)] = false + } else { + v[uint(j)] = dd.DecodeBool() + } + } + if canChange { + if j < len(v) { + v = v[:uint(j)] + changed = true + } else if j == 0 && v == nil { + v = make([]bool, 0) + changed = true + } + } + slh.End() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntfIntfR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[interface{}]interface{}) + v, changed := fastpathTV.DecMapIntfIntfV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapIntfIntfV(rv2i(rv).(map[interface{}]interface{}), false, d) + } +} +func (f fastpathT) DecMapIntfIntfX(vp *map[interface{}]interface{}, d *Decoder) { + 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) + v = make(map[interface{}]interface{}, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset + var mk interface{} + var mv interface{} + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = nil + d.decode(&mk) + if bv, bok := mk.([]byte); bok { + mk = d.string(bv) + } + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = nil + } + continue + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } + d.decode(&mv) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntfStringR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[interface{}]string) + v, changed := fastpathTV.DecMapIntfStringV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapIntfStringV(rv2i(rv).(map[interface{}]string), false, d) + } +} +func (f fastpathT) DecMapIntfStringX(vp *map[interface{}]string, d *Decoder) { + 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) + v = make(map[interface{}]string, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk interface{} + var mv string + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = nil + d.decode(&mk) + if bv, bok := mk.([]byte); bok { + mk = d.string(bv) + } + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = "" + } + continue + } + mv = dd.DecodeString() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntfUintR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[interface{}]uint) + v, changed := fastpathTV.DecMapIntfUintV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapIntfUintV(rv2i(rv).(map[interface{}]uint), false, d) + } +} +func (f fastpathT) DecMapIntfUintX(vp *map[interface{}]uint, d *Decoder) { + 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) + v = make(map[interface{}]uint, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk interface{} + var mv uint + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = nil + d.decode(&mk) + if bv, bok := mk.([]byte); bok { + mk = d.string(bv) + } + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntfUint8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[interface{}]uint8) + v, changed := fastpathTV.DecMapIntfUint8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapIntfUint8V(rv2i(rv).(map[interface{}]uint8), false, d) + } +} +func (f fastpathT) DecMapIntfUint8X(vp *map[interface{}]uint8, d *Decoder) { + 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) + v = make(map[interface{}]uint8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk interface{} + var mv uint8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = nil + d.decode(&mk) + if bv, bok := mk.([]byte); bok { + mk = d.string(bv) + } + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntfUint16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[interface{}]uint16) + v, changed := fastpathTV.DecMapIntfUint16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapIntfUint16V(rv2i(rv).(map[interface{}]uint16), false, d) + } +} +func (f fastpathT) DecMapIntfUint16X(vp *map[interface{}]uint16, d *Decoder) { + 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) + v = make(map[interface{}]uint16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk interface{} + var mv uint16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = nil + d.decode(&mk) + if bv, bok := mk.([]byte); bok { + mk = d.string(bv) + } + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntfUint32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[interface{}]uint32) + v, changed := fastpathTV.DecMapIntfUint32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapIntfUint32V(rv2i(rv).(map[interface{}]uint32), false, d) + } +} +func (f fastpathT) DecMapIntfUint32X(vp *map[interface{}]uint32, d *Decoder) { + 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) + v = make(map[interface{}]uint32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk interface{} + var mv uint32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = nil + d.decode(&mk) + if bv, bok := mk.([]byte); bok { + mk = d.string(bv) + } + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntfUint64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[interface{}]uint64) + v, changed := fastpathTV.DecMapIntfUint64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapIntfUint64V(rv2i(rv).(map[interface{}]uint64), false, d) + } +} +func (f fastpathT) DecMapIntfUint64X(vp *map[interface{}]uint64, d *Decoder) { + 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) + v = make(map[interface{}]uint64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk interface{} + var mv uint64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = nil + d.decode(&mk) + if bv, bok := mk.([]byte); bok { + mk = d.string(bv) + } + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeUint64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntfUintptrR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[interface{}]uintptr) + v, changed := fastpathTV.DecMapIntfUintptrV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapIntfUintptrV(rv2i(rv).(map[interface{}]uintptr), false, d) + } +} +func (f fastpathT) DecMapIntfUintptrX(vp *map[interface{}]uintptr, d *Decoder) { + 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) + v = make(map[interface{}]uintptr, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk interface{} + var mv uintptr + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = nil + d.decode(&mk) + if bv, bok := mk.([]byte); bok { + mk = d.string(bv) + } + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntfIntR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[interface{}]int) + v, changed := fastpathTV.DecMapIntfIntV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapIntfIntV(rv2i(rv).(map[interface{}]int), false, d) + } +} +func (f fastpathT) DecMapIntfIntX(vp *map[interface{}]int, d *Decoder) { + 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) + v = make(map[interface{}]int, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk interface{} + var mv int + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = nil + d.decode(&mk) + if bv, bok := mk.([]byte); bok { + mk = d.string(bv) + } + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntfInt8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[interface{}]int8) + v, changed := fastpathTV.DecMapIntfInt8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapIntfInt8V(rv2i(rv).(map[interface{}]int8), false, d) + } +} +func (f fastpathT) DecMapIntfInt8X(vp *map[interface{}]int8, d *Decoder) { + 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) + v = make(map[interface{}]int8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk interface{} + var mv int8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = nil + d.decode(&mk) + if bv, bok := mk.([]byte); bok { + mk = d.string(bv) + } + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntfInt16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[interface{}]int16) + v, changed := fastpathTV.DecMapIntfInt16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapIntfInt16V(rv2i(rv).(map[interface{}]int16), false, d) + } +} +func (f fastpathT) DecMapIntfInt16X(vp *map[interface{}]int16, d *Decoder) { + 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) + v = make(map[interface{}]int16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk interface{} + var mv int16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = nil + d.decode(&mk) + if bv, bok := mk.([]byte); bok { + mk = d.string(bv) + } + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntfInt32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[interface{}]int32) + v, changed := fastpathTV.DecMapIntfInt32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapIntfInt32V(rv2i(rv).(map[interface{}]int32), false, d) + } +} +func (f fastpathT) DecMapIntfInt32X(vp *map[interface{}]int32, d *Decoder) { + 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) + v = make(map[interface{}]int32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk interface{} + var mv int32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = nil + d.decode(&mk) + if bv, bok := mk.([]byte); bok { + mk = d.string(bv) + } + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntfInt64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[interface{}]int64) + v, changed := fastpathTV.DecMapIntfInt64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapIntfInt64V(rv2i(rv).(map[interface{}]int64), false, d) + } +} +func (f fastpathT) DecMapIntfInt64X(vp *map[interface{}]int64, d *Decoder) { + 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) + v = make(map[interface{}]int64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk interface{} + var mv int64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = nil + d.decode(&mk) + if bv, bok := mk.([]byte); bok { + mk = d.string(bv) + } + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeInt64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntfFloat32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[interface{}]float32) + v, changed := fastpathTV.DecMapIntfFloat32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapIntfFloat32V(rv2i(rv).(map[interface{}]float32), false, d) + } +} +func (f fastpathT) DecMapIntfFloat32X(vp *map[interface{}]float32, d *Decoder) { + 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) + v = make(map[interface{}]float32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk interface{} + var mv float32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = nil + d.decode(&mk) + if bv, bok := mk.([]byte); bok { + mk = d.string(bv) + } + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntfFloat64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[interface{}]float64) + v, changed := fastpathTV.DecMapIntfFloat64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapIntfFloat64V(rv2i(rv).(map[interface{}]float64), false, d) + } +} +func (f fastpathT) DecMapIntfFloat64X(vp *map[interface{}]float64, d *Decoder) { + 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) + v = make(map[interface{}]float64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk interface{} + var mv float64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = nil + d.decode(&mk) + if bv, bok := mk.([]byte); bok { + mk = d.string(bv) + } + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeFloat64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntfBoolR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[interface{}]bool) + v, changed := fastpathTV.DecMapIntfBoolV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapIntfBoolV(rv2i(rv).(map[interface{}]bool), false, d) + } +} +func (f fastpathT) DecMapIntfBoolX(vp *map[interface{}]bool, d *Decoder) { + 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) + v = make(map[interface{}]bool, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk interface{} + var mv bool + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = nil + d.decode(&mk) + if bv, bok := mk.([]byte); bok { + mk = d.string(bv) + } + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = false + } + continue + } + mv = dd.DecodeBool() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapStringIntfR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[string]interface{}) + v, changed := fastpathTV.DecMapStringIntfV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapStringIntfV(rv2i(rv).(map[string]interface{}), false, d) + } +} +func (f fastpathT) DecMapStringIntfX(vp *map[string]interface{}, d *Decoder) { + 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) + v = make(map[string]interface{}, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset + var mk string + var mv interface{} + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeString() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = nil + } + continue + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } + d.decode(&mv) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapStringStringR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[string]string) + v, changed := fastpathTV.DecMapStringStringV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapStringStringV(rv2i(rv).(map[string]string), false, d) + } +} +func (f fastpathT) DecMapStringStringX(vp *map[string]string, d *Decoder) { + 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) + v = make(map[string]string, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk string + var mv string + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeString() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = "" + } + continue + } + mv = dd.DecodeString() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapStringUintR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[string]uint) + v, changed := fastpathTV.DecMapStringUintV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapStringUintV(rv2i(rv).(map[string]uint), false, d) + } +} +func (f fastpathT) DecMapStringUintX(vp *map[string]uint, d *Decoder) { + 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) + v = make(map[string]uint, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk string + var mv uint + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeString() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapStringUint8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[string]uint8) + v, changed := fastpathTV.DecMapStringUint8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapStringUint8V(rv2i(rv).(map[string]uint8), false, d) + } +} +func (f fastpathT) DecMapStringUint8X(vp *map[string]uint8, d *Decoder) { + 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) + v = make(map[string]uint8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk string + var mv uint8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeString() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapStringUint16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[string]uint16) + v, changed := fastpathTV.DecMapStringUint16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapStringUint16V(rv2i(rv).(map[string]uint16), false, d) + } +} +func (f fastpathT) DecMapStringUint16X(vp *map[string]uint16, d *Decoder) { + 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) + v = make(map[string]uint16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk string + var mv uint16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeString() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapStringUint32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[string]uint32) + v, changed := fastpathTV.DecMapStringUint32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapStringUint32V(rv2i(rv).(map[string]uint32), false, d) + } +} +func (f fastpathT) DecMapStringUint32X(vp *map[string]uint32, d *Decoder) { + 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) + v = make(map[string]uint32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk string + var mv uint32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeString() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapStringUint64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[string]uint64) + v, changed := fastpathTV.DecMapStringUint64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapStringUint64V(rv2i(rv).(map[string]uint64), false, d) + } +} +func (f fastpathT) DecMapStringUint64X(vp *map[string]uint64, d *Decoder) { + 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) + v = make(map[string]uint64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk string + var mv uint64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeString() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeUint64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapStringUintptrR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[string]uintptr) + v, changed := fastpathTV.DecMapStringUintptrV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapStringUintptrV(rv2i(rv).(map[string]uintptr), false, d) + } +} +func (f fastpathT) DecMapStringUintptrX(vp *map[string]uintptr, d *Decoder) { + 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) + v = make(map[string]uintptr, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk string + var mv uintptr + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeString() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapStringIntR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[string]int) + v, changed := fastpathTV.DecMapStringIntV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapStringIntV(rv2i(rv).(map[string]int), false, d) + } +} +func (f fastpathT) DecMapStringIntX(vp *map[string]int, d *Decoder) { + 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) + v = make(map[string]int, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk string + var mv int + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeString() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapStringInt8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[string]int8) + v, changed := fastpathTV.DecMapStringInt8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapStringInt8V(rv2i(rv).(map[string]int8), false, d) + } +} +func (f fastpathT) DecMapStringInt8X(vp *map[string]int8, d *Decoder) { + 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) + v = make(map[string]int8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk string + var mv int8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeString() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapStringInt16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[string]int16) + v, changed := fastpathTV.DecMapStringInt16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapStringInt16V(rv2i(rv).(map[string]int16), false, d) + } +} +func (f fastpathT) DecMapStringInt16X(vp *map[string]int16, d *Decoder) { + 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) + v = make(map[string]int16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk string + var mv int16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeString() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapStringInt32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[string]int32) + v, changed := fastpathTV.DecMapStringInt32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapStringInt32V(rv2i(rv).(map[string]int32), false, d) + } +} +func (f fastpathT) DecMapStringInt32X(vp *map[string]int32, d *Decoder) { + 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) + v = make(map[string]int32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk string + var mv int32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeString() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapStringInt64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[string]int64) + v, changed := fastpathTV.DecMapStringInt64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapStringInt64V(rv2i(rv).(map[string]int64), false, d) + } +} +func (f fastpathT) DecMapStringInt64X(vp *map[string]int64, d *Decoder) { + 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) + v = make(map[string]int64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk string + var mv int64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeString() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeInt64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapStringFloat32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[string]float32) + v, changed := fastpathTV.DecMapStringFloat32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapStringFloat32V(rv2i(rv).(map[string]float32), false, d) + } +} +func (f fastpathT) DecMapStringFloat32X(vp *map[string]float32, d *Decoder) { + 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) + v = make(map[string]float32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk string + var mv float32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeString() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapStringFloat64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[string]float64) + v, changed := fastpathTV.DecMapStringFloat64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapStringFloat64V(rv2i(rv).(map[string]float64), false, d) + } +} +func (f fastpathT) DecMapStringFloat64X(vp *map[string]float64, d *Decoder) { + 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) + v = make(map[string]float64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk string + var mv float64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeString() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeFloat64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapStringBoolR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[string]bool) + v, changed := fastpathTV.DecMapStringBoolV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapStringBoolV(rv2i(rv).(map[string]bool), false, d) + } +} +func (f fastpathT) DecMapStringBoolX(vp *map[string]bool, d *Decoder) { + 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) + v = make(map[string]bool, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk string + var mv bool + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeString() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = false + } + continue + } + mv = dd.DecodeBool() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat32IntfR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float32]interface{}) + v, changed := fastpathTV.DecMapFloat32IntfV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat32IntfV(rv2i(rv).(map[float32]interface{}), false, d) + } +} +func (f fastpathT) DecMapFloat32IntfX(vp *map[float32]interface{}, d *Decoder) { + 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) + v = make(map[float32]interface{}, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset + var mk float32 + var mv interface{} + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = nil + } + continue + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } + d.decode(&mv) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat32StringR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float32]string) + v, changed := fastpathTV.DecMapFloat32StringV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat32StringV(rv2i(rv).(map[float32]string), false, d) + } +} +func (f fastpathT) DecMapFloat32StringX(vp *map[float32]string, d *Decoder) { + 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) + v = make(map[float32]string, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float32 + var mv string + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = "" + } + continue + } + mv = dd.DecodeString() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat32UintR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float32]uint) + v, changed := fastpathTV.DecMapFloat32UintV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat32UintV(rv2i(rv).(map[float32]uint), false, d) + } +} +func (f fastpathT) DecMapFloat32UintX(vp *map[float32]uint, d *Decoder) { + 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) + v = make(map[float32]uint, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float32 + var mv uint + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat32Uint8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float32]uint8) + v, changed := fastpathTV.DecMapFloat32Uint8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat32Uint8V(rv2i(rv).(map[float32]uint8), false, d) + } +} +func (f fastpathT) DecMapFloat32Uint8X(vp *map[float32]uint8, d *Decoder) { + 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) + v = make(map[float32]uint8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float32 + var mv uint8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat32Uint16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float32]uint16) + v, changed := fastpathTV.DecMapFloat32Uint16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat32Uint16V(rv2i(rv).(map[float32]uint16), false, d) + } +} +func (f fastpathT) DecMapFloat32Uint16X(vp *map[float32]uint16, d *Decoder) { + 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) + v = make(map[float32]uint16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float32 + var mv uint16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat32Uint32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float32]uint32) + v, changed := fastpathTV.DecMapFloat32Uint32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat32Uint32V(rv2i(rv).(map[float32]uint32), false, d) + } +} +func (f fastpathT) DecMapFloat32Uint32X(vp *map[float32]uint32, d *Decoder) { + 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) + v = make(map[float32]uint32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float32 + var mv uint32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat32Uint64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float32]uint64) + v, changed := fastpathTV.DecMapFloat32Uint64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat32Uint64V(rv2i(rv).(map[float32]uint64), false, d) + } +} +func (f fastpathT) DecMapFloat32Uint64X(vp *map[float32]uint64, d *Decoder) { + 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) + v = make(map[float32]uint64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float32 + var mv uint64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeUint64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat32UintptrR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float32]uintptr) + v, changed := fastpathTV.DecMapFloat32UintptrV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat32UintptrV(rv2i(rv).(map[float32]uintptr), false, d) + } +} +func (f fastpathT) DecMapFloat32UintptrX(vp *map[float32]uintptr, d *Decoder) { + 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) + v = make(map[float32]uintptr, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float32 + var mv uintptr + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat32IntR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float32]int) + v, changed := fastpathTV.DecMapFloat32IntV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat32IntV(rv2i(rv).(map[float32]int), false, d) + } +} +func (f fastpathT) DecMapFloat32IntX(vp *map[float32]int, d *Decoder) { + 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) + v = make(map[float32]int, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float32 + var mv int + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat32Int8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float32]int8) + v, changed := fastpathTV.DecMapFloat32Int8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat32Int8V(rv2i(rv).(map[float32]int8), false, d) + } +} +func (f fastpathT) DecMapFloat32Int8X(vp *map[float32]int8, d *Decoder) { + 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) + v = make(map[float32]int8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float32 + var mv int8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat32Int16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float32]int16) + v, changed := fastpathTV.DecMapFloat32Int16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat32Int16V(rv2i(rv).(map[float32]int16), false, d) + } +} +func (f fastpathT) DecMapFloat32Int16X(vp *map[float32]int16, d *Decoder) { + 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) + v = make(map[float32]int16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float32 + var mv int16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat32Int32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float32]int32) + v, changed := fastpathTV.DecMapFloat32Int32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat32Int32V(rv2i(rv).(map[float32]int32), false, d) + } +} +func (f fastpathT) DecMapFloat32Int32X(vp *map[float32]int32, d *Decoder) { + 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) + v = make(map[float32]int32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float32 + var mv int32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat32Int64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float32]int64) + v, changed := fastpathTV.DecMapFloat32Int64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat32Int64V(rv2i(rv).(map[float32]int64), false, d) + } +} +func (f fastpathT) DecMapFloat32Int64X(vp *map[float32]int64, d *Decoder) { + 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) + v = make(map[float32]int64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float32 + var mv int64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeInt64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat32Float32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float32]float32) + v, changed := fastpathTV.DecMapFloat32Float32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat32Float32V(rv2i(rv).(map[float32]float32), false, d) + } +} +func (f fastpathT) DecMapFloat32Float32X(vp *map[float32]float32, d *Decoder) { + 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) + v = make(map[float32]float32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float32 + var mv float32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat32Float64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float32]float64) + v, changed := fastpathTV.DecMapFloat32Float64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat32Float64V(rv2i(rv).(map[float32]float64), false, d) + } +} +func (f fastpathT) DecMapFloat32Float64X(vp *map[float32]float64, d *Decoder) { + 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) + v = make(map[float32]float64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float32 + var mv float64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeFloat64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat32BoolR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float32]bool) + v, changed := fastpathTV.DecMapFloat32BoolV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat32BoolV(rv2i(rv).(map[float32]bool), false, d) + } +} +func (f fastpathT) DecMapFloat32BoolX(vp *map[float32]bool, d *Decoder) { + 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) + v = make(map[float32]bool, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float32 + var mv bool + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = false + } + continue + } + mv = dd.DecodeBool() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat64IntfR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float64]interface{}) + v, changed := fastpathTV.DecMapFloat64IntfV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat64IntfV(rv2i(rv).(map[float64]interface{}), false, d) + } +} +func (f fastpathT) DecMapFloat64IntfX(vp *map[float64]interface{}, d *Decoder) { + 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) + v = make(map[float64]interface{}, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset + var mk float64 + var mv interface{} + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeFloat64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = nil + } + continue + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } + d.decode(&mv) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat64StringR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float64]string) + v, changed := fastpathTV.DecMapFloat64StringV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat64StringV(rv2i(rv).(map[float64]string), false, d) + } +} +func (f fastpathT) DecMapFloat64StringX(vp *map[float64]string, d *Decoder) { + 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) + v = make(map[float64]string, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float64 + var mv string + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeFloat64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = "" + } + continue + } + mv = dd.DecodeString() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat64UintR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float64]uint) + v, changed := fastpathTV.DecMapFloat64UintV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat64UintV(rv2i(rv).(map[float64]uint), false, d) + } +} +func (f fastpathT) DecMapFloat64UintX(vp *map[float64]uint, d *Decoder) { + 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) + v = make(map[float64]uint, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float64 + var mv uint + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeFloat64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat64Uint8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float64]uint8) + v, changed := fastpathTV.DecMapFloat64Uint8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat64Uint8V(rv2i(rv).(map[float64]uint8), false, d) + } +} +func (f fastpathT) DecMapFloat64Uint8X(vp *map[float64]uint8, d *Decoder) { + 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) + v = make(map[float64]uint8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float64 + var mv uint8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeFloat64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat64Uint16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float64]uint16) + v, changed := fastpathTV.DecMapFloat64Uint16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat64Uint16V(rv2i(rv).(map[float64]uint16), false, d) + } +} +func (f fastpathT) DecMapFloat64Uint16X(vp *map[float64]uint16, d *Decoder) { + 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) + v = make(map[float64]uint16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float64 + var mv uint16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeFloat64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat64Uint32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float64]uint32) + v, changed := fastpathTV.DecMapFloat64Uint32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat64Uint32V(rv2i(rv).(map[float64]uint32), false, d) + } +} +func (f fastpathT) DecMapFloat64Uint32X(vp *map[float64]uint32, d *Decoder) { + 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) + v = make(map[float64]uint32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float64 + var mv uint32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeFloat64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat64Uint64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float64]uint64) + v, changed := fastpathTV.DecMapFloat64Uint64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat64Uint64V(rv2i(rv).(map[float64]uint64), false, d) + } +} +func (f fastpathT) DecMapFloat64Uint64X(vp *map[float64]uint64, d *Decoder) { + 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) + v = make(map[float64]uint64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float64 + var mv uint64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeFloat64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeUint64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat64UintptrR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float64]uintptr) + v, changed := fastpathTV.DecMapFloat64UintptrV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat64UintptrV(rv2i(rv).(map[float64]uintptr), false, d) + } +} +func (f fastpathT) DecMapFloat64UintptrX(vp *map[float64]uintptr, d *Decoder) { + 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) + v = make(map[float64]uintptr, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float64 + var mv uintptr + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeFloat64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat64IntR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float64]int) + v, changed := fastpathTV.DecMapFloat64IntV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat64IntV(rv2i(rv).(map[float64]int), false, d) + } +} +func (f fastpathT) DecMapFloat64IntX(vp *map[float64]int, d *Decoder) { + 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) + v = make(map[float64]int, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float64 + var mv int + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeFloat64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat64Int8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float64]int8) + v, changed := fastpathTV.DecMapFloat64Int8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat64Int8V(rv2i(rv).(map[float64]int8), false, d) + } +} +func (f fastpathT) DecMapFloat64Int8X(vp *map[float64]int8, d *Decoder) { + 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) + v = make(map[float64]int8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float64 + var mv int8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeFloat64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat64Int16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float64]int16) + v, changed := fastpathTV.DecMapFloat64Int16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat64Int16V(rv2i(rv).(map[float64]int16), false, d) + } +} +func (f fastpathT) DecMapFloat64Int16X(vp *map[float64]int16, d *Decoder) { + 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) + v = make(map[float64]int16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float64 + var mv int16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeFloat64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat64Int32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float64]int32) + v, changed := fastpathTV.DecMapFloat64Int32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat64Int32V(rv2i(rv).(map[float64]int32), false, d) + } +} +func (f fastpathT) DecMapFloat64Int32X(vp *map[float64]int32, d *Decoder) { + 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) + v = make(map[float64]int32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float64 + var mv int32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeFloat64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat64Int64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float64]int64) + v, changed := fastpathTV.DecMapFloat64Int64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat64Int64V(rv2i(rv).(map[float64]int64), false, d) + } +} +func (f fastpathT) DecMapFloat64Int64X(vp *map[float64]int64, d *Decoder) { + 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) + v = make(map[float64]int64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float64 + var mv int64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeFloat64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeInt64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat64Float32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float64]float32) + v, changed := fastpathTV.DecMapFloat64Float32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat64Float32V(rv2i(rv).(map[float64]float32), false, d) + } +} +func (f fastpathT) DecMapFloat64Float32X(vp *map[float64]float32, d *Decoder) { + 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) + v = make(map[float64]float32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float64 + var mv float32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeFloat64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat64Float64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float64]float64) + v, changed := fastpathTV.DecMapFloat64Float64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat64Float64V(rv2i(rv).(map[float64]float64), false, d) + } +} +func (f fastpathT) DecMapFloat64Float64X(vp *map[float64]float64, d *Decoder) { + 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) + v = make(map[float64]float64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float64 + var mv float64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeFloat64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeFloat64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapFloat64BoolR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[float64]bool) + v, changed := fastpathTV.DecMapFloat64BoolV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapFloat64BoolV(rv2i(rv).(map[float64]bool), false, d) + } +} +func (f fastpathT) DecMapFloat64BoolX(vp *map[float64]bool, d *Decoder) { + 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) + v = make(map[float64]bool, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk float64 + var mv bool + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeFloat64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = false + } + continue + } + mv = dd.DecodeBool() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintIntfR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint]interface{}) + v, changed := fastpathTV.DecMapUintIntfV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintIntfV(rv2i(rv).(map[uint]interface{}), false, d) + } +} +func (f fastpathT) DecMapUintIntfX(vp *map[uint]interface{}, d *Decoder) { + 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) + v = make(map[uint]interface{}, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset + var mk uint + var mv interface{} + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = nil + } + continue + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } + d.decode(&mv) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintStringR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint]string) + v, changed := fastpathTV.DecMapUintStringV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintStringV(rv2i(rv).(map[uint]string), false, d) + } +} +func (f fastpathT) DecMapUintStringX(vp *map[uint]string, d *Decoder) { + 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) + v = make(map[uint]string, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint + var mv string + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = "" + } + continue + } + mv = dd.DecodeString() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintUintR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint]uint) + v, changed := fastpathTV.DecMapUintUintV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintUintV(rv2i(rv).(map[uint]uint), false, d) + } +} +func (f fastpathT) DecMapUintUintX(vp *map[uint]uint, d *Decoder) { + 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) + v = make(map[uint]uint, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint + var mv uint + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintUint8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint]uint8) + v, changed := fastpathTV.DecMapUintUint8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintUint8V(rv2i(rv).(map[uint]uint8), false, d) + } +} +func (f fastpathT) DecMapUintUint8X(vp *map[uint]uint8, d *Decoder) { + 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) + v = make(map[uint]uint8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint + var mv uint8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintUint16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint]uint16) + v, changed := fastpathTV.DecMapUintUint16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintUint16V(rv2i(rv).(map[uint]uint16), false, d) + } +} +func (f fastpathT) DecMapUintUint16X(vp *map[uint]uint16, d *Decoder) { + 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) + v = make(map[uint]uint16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint + var mv uint16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintUint32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint]uint32) + v, changed := fastpathTV.DecMapUintUint32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintUint32V(rv2i(rv).(map[uint]uint32), false, d) + } +} +func (f fastpathT) DecMapUintUint32X(vp *map[uint]uint32, d *Decoder) { + 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) + v = make(map[uint]uint32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint + var mv uint32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintUint64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint]uint64) + v, changed := fastpathTV.DecMapUintUint64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintUint64V(rv2i(rv).(map[uint]uint64), false, d) + } +} +func (f fastpathT) DecMapUintUint64X(vp *map[uint]uint64, d *Decoder) { + 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) + v = make(map[uint]uint64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint + var mv uint64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeUint64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintUintptrR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint]uintptr) + v, changed := fastpathTV.DecMapUintUintptrV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintUintptrV(rv2i(rv).(map[uint]uintptr), false, d) + } +} +func (f fastpathT) DecMapUintUintptrX(vp *map[uint]uintptr, d *Decoder) { + 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) + v = make(map[uint]uintptr, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint + var mv uintptr + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintIntR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint]int) + v, changed := fastpathTV.DecMapUintIntV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintIntV(rv2i(rv).(map[uint]int), false, d) + } +} +func (f fastpathT) DecMapUintIntX(vp *map[uint]int, d *Decoder) { + 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) + v = make(map[uint]int, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint + var mv int + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintInt8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint]int8) + v, changed := fastpathTV.DecMapUintInt8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintInt8V(rv2i(rv).(map[uint]int8), false, d) + } +} +func (f fastpathT) DecMapUintInt8X(vp *map[uint]int8, d *Decoder) { + 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) + v = make(map[uint]int8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint + var mv int8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintInt16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint]int16) + v, changed := fastpathTV.DecMapUintInt16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintInt16V(rv2i(rv).(map[uint]int16), false, d) + } +} +func (f fastpathT) DecMapUintInt16X(vp *map[uint]int16, d *Decoder) { + 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) + v = make(map[uint]int16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint + var mv int16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintInt32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint]int32) + v, changed := fastpathTV.DecMapUintInt32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintInt32V(rv2i(rv).(map[uint]int32), false, d) + } +} +func (f fastpathT) DecMapUintInt32X(vp *map[uint]int32, d *Decoder) { + 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) + v = make(map[uint]int32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint + var mv int32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintInt64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint]int64) + v, changed := fastpathTV.DecMapUintInt64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintInt64V(rv2i(rv).(map[uint]int64), false, d) + } +} +func (f fastpathT) DecMapUintInt64X(vp *map[uint]int64, d *Decoder) { + 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) + v = make(map[uint]int64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint + var mv int64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeInt64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintFloat32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint]float32) + v, changed := fastpathTV.DecMapUintFloat32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintFloat32V(rv2i(rv).(map[uint]float32), false, d) + } +} +func (f fastpathT) DecMapUintFloat32X(vp *map[uint]float32, d *Decoder) { + 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) + v = make(map[uint]float32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint + var mv float32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintFloat64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint]float64) + v, changed := fastpathTV.DecMapUintFloat64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintFloat64V(rv2i(rv).(map[uint]float64), false, d) + } +} +func (f fastpathT) DecMapUintFloat64X(vp *map[uint]float64, d *Decoder) { + 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) + v = make(map[uint]float64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint + var mv float64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeFloat64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintBoolR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint]bool) + v, changed := fastpathTV.DecMapUintBoolV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintBoolV(rv2i(rv).(map[uint]bool), false, d) + } +} +func (f fastpathT) DecMapUintBoolX(vp *map[uint]bool, d *Decoder) { + 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) + v = make(map[uint]bool, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint + var mv bool + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = false + } + continue + } + mv = dd.DecodeBool() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint8IntfR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint8]interface{}) + v, changed := fastpathTV.DecMapUint8IntfV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint8IntfV(rv2i(rv).(map[uint8]interface{}), false, d) + } +} +func (f fastpathT) DecMapUint8IntfX(vp *map[uint8]interface{}, d *Decoder) { + 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) + v = make(map[uint8]interface{}, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset + var mk uint8 + var mv interface{} + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = nil + } + continue + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } + d.decode(&mv) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint8StringR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint8]string) + v, changed := fastpathTV.DecMapUint8StringV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint8StringV(rv2i(rv).(map[uint8]string), false, d) + } +} +func (f fastpathT) DecMapUint8StringX(vp *map[uint8]string, d *Decoder) { + 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) + v = make(map[uint8]string, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint8 + var mv string + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = "" + } + continue + } + mv = dd.DecodeString() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint8UintR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint8]uint) + v, changed := fastpathTV.DecMapUint8UintV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint8UintV(rv2i(rv).(map[uint8]uint), false, d) + } +} +func (f fastpathT) DecMapUint8UintX(vp *map[uint8]uint, d *Decoder) { + 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) + v = make(map[uint8]uint, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint8 + var mv uint + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint8Uint8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint8]uint8) + v, changed := fastpathTV.DecMapUint8Uint8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint8Uint8V(rv2i(rv).(map[uint8]uint8), false, d) + } +} +func (f fastpathT) DecMapUint8Uint8X(vp *map[uint8]uint8, d *Decoder) { + 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) + v = make(map[uint8]uint8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint8 + var mv uint8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint8Uint16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint8]uint16) + v, changed := fastpathTV.DecMapUint8Uint16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint8Uint16V(rv2i(rv).(map[uint8]uint16), false, d) + } +} +func (f fastpathT) DecMapUint8Uint16X(vp *map[uint8]uint16, d *Decoder) { + 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) + v = make(map[uint8]uint16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint8 + var mv uint16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint8Uint32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint8]uint32) + v, changed := fastpathTV.DecMapUint8Uint32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint8Uint32V(rv2i(rv).(map[uint8]uint32), false, d) + } +} +func (f fastpathT) DecMapUint8Uint32X(vp *map[uint8]uint32, d *Decoder) { + 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) + v = make(map[uint8]uint32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint8 + var mv uint32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint8Uint64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint8]uint64) + v, changed := fastpathTV.DecMapUint8Uint64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint8Uint64V(rv2i(rv).(map[uint8]uint64), false, d) + } +} +func (f fastpathT) DecMapUint8Uint64X(vp *map[uint8]uint64, d *Decoder) { + 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) + v = make(map[uint8]uint64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint8 + var mv uint64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeUint64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint8UintptrR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint8]uintptr) + v, changed := fastpathTV.DecMapUint8UintptrV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint8UintptrV(rv2i(rv).(map[uint8]uintptr), false, d) + } +} +func (f fastpathT) DecMapUint8UintptrX(vp *map[uint8]uintptr, d *Decoder) { + 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) + v = make(map[uint8]uintptr, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint8 + var mv uintptr + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint8IntR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint8]int) + v, changed := fastpathTV.DecMapUint8IntV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint8IntV(rv2i(rv).(map[uint8]int), false, d) + } +} +func (f fastpathT) DecMapUint8IntX(vp *map[uint8]int, d *Decoder) { + 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) + v = make(map[uint8]int, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint8 + var mv int + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint8Int8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint8]int8) + v, changed := fastpathTV.DecMapUint8Int8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint8Int8V(rv2i(rv).(map[uint8]int8), false, d) + } +} +func (f fastpathT) DecMapUint8Int8X(vp *map[uint8]int8, d *Decoder) { + 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) + v = make(map[uint8]int8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint8 + var mv int8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint8Int16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint8]int16) + v, changed := fastpathTV.DecMapUint8Int16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint8Int16V(rv2i(rv).(map[uint8]int16), false, d) + } +} +func (f fastpathT) DecMapUint8Int16X(vp *map[uint8]int16, d *Decoder) { + 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) + v = make(map[uint8]int16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint8 + var mv int16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint8Int32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint8]int32) + v, changed := fastpathTV.DecMapUint8Int32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint8Int32V(rv2i(rv).(map[uint8]int32), false, d) + } +} +func (f fastpathT) DecMapUint8Int32X(vp *map[uint8]int32, d *Decoder) { + 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) + v = make(map[uint8]int32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint8 + var mv int32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint8Int64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint8]int64) + v, changed := fastpathTV.DecMapUint8Int64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint8Int64V(rv2i(rv).(map[uint8]int64), false, d) + } +} +func (f fastpathT) DecMapUint8Int64X(vp *map[uint8]int64, d *Decoder) { + 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) + v = make(map[uint8]int64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint8 + var mv int64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeInt64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint8Float32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint8]float32) + v, changed := fastpathTV.DecMapUint8Float32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint8Float32V(rv2i(rv).(map[uint8]float32), false, d) + } +} +func (f fastpathT) DecMapUint8Float32X(vp *map[uint8]float32, d *Decoder) { + 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) + v = make(map[uint8]float32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint8 + var mv float32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint8Float64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint8]float64) + v, changed := fastpathTV.DecMapUint8Float64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint8Float64V(rv2i(rv).(map[uint8]float64), false, d) + } +} +func (f fastpathT) DecMapUint8Float64X(vp *map[uint8]float64, d *Decoder) { + 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) + v = make(map[uint8]float64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint8 + var mv float64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeFloat64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint8BoolR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint8]bool) + v, changed := fastpathTV.DecMapUint8BoolV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint8BoolV(rv2i(rv).(map[uint8]bool), false, d) + } +} +func (f fastpathT) DecMapUint8BoolX(vp *map[uint8]bool, d *Decoder) { + 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) + v = make(map[uint8]bool, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint8 + var mv bool + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = false + } + continue + } + mv = dd.DecodeBool() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint16IntfR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint16]interface{}) + v, changed := fastpathTV.DecMapUint16IntfV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint16IntfV(rv2i(rv).(map[uint16]interface{}), false, d) + } +} +func (f fastpathT) DecMapUint16IntfX(vp *map[uint16]interface{}, d *Decoder) { + 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) + v = make(map[uint16]interface{}, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset + var mk uint16 + var mv interface{} + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = nil + } + continue + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } + d.decode(&mv) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint16StringR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint16]string) + v, changed := fastpathTV.DecMapUint16StringV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint16StringV(rv2i(rv).(map[uint16]string), false, d) + } +} +func (f fastpathT) DecMapUint16StringX(vp *map[uint16]string, d *Decoder) { + 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) + v = make(map[uint16]string, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint16 + var mv string + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = "" + } + continue + } + mv = dd.DecodeString() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint16UintR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint16]uint) + v, changed := fastpathTV.DecMapUint16UintV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint16UintV(rv2i(rv).(map[uint16]uint), false, d) + } +} +func (f fastpathT) DecMapUint16UintX(vp *map[uint16]uint, d *Decoder) { + 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) + v = make(map[uint16]uint, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint16 + var mv uint + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint16Uint8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint16]uint8) + v, changed := fastpathTV.DecMapUint16Uint8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint16Uint8V(rv2i(rv).(map[uint16]uint8), false, d) + } +} +func (f fastpathT) DecMapUint16Uint8X(vp *map[uint16]uint8, d *Decoder) { + 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) + v = make(map[uint16]uint8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint16 + var mv uint8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint16Uint16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint16]uint16) + v, changed := fastpathTV.DecMapUint16Uint16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint16Uint16V(rv2i(rv).(map[uint16]uint16), false, d) + } +} +func (f fastpathT) DecMapUint16Uint16X(vp *map[uint16]uint16, d *Decoder) { + 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) + v = make(map[uint16]uint16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint16 + var mv uint16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint16Uint32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint16]uint32) + v, changed := fastpathTV.DecMapUint16Uint32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint16Uint32V(rv2i(rv).(map[uint16]uint32), false, d) + } +} +func (f fastpathT) DecMapUint16Uint32X(vp *map[uint16]uint32, d *Decoder) { + 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) + v = make(map[uint16]uint32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint16 + var mv uint32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint16Uint64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint16]uint64) + v, changed := fastpathTV.DecMapUint16Uint64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint16Uint64V(rv2i(rv).(map[uint16]uint64), false, d) + } +} +func (f fastpathT) DecMapUint16Uint64X(vp *map[uint16]uint64, d *Decoder) { + 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) + v = make(map[uint16]uint64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint16 + var mv uint64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeUint64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint16UintptrR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint16]uintptr) + v, changed := fastpathTV.DecMapUint16UintptrV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint16UintptrV(rv2i(rv).(map[uint16]uintptr), false, d) + } +} +func (f fastpathT) DecMapUint16UintptrX(vp *map[uint16]uintptr, d *Decoder) { + 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) + v = make(map[uint16]uintptr, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint16 + var mv uintptr + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint16IntR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint16]int) + v, changed := fastpathTV.DecMapUint16IntV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint16IntV(rv2i(rv).(map[uint16]int), false, d) + } +} +func (f fastpathT) DecMapUint16IntX(vp *map[uint16]int, d *Decoder) { + 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) + v = make(map[uint16]int, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint16 + var mv int + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint16Int8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint16]int8) + v, changed := fastpathTV.DecMapUint16Int8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint16Int8V(rv2i(rv).(map[uint16]int8), false, d) + } +} +func (f fastpathT) DecMapUint16Int8X(vp *map[uint16]int8, d *Decoder) { + 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) + v = make(map[uint16]int8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint16 + var mv int8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint16Int16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint16]int16) + v, changed := fastpathTV.DecMapUint16Int16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint16Int16V(rv2i(rv).(map[uint16]int16), false, d) + } +} +func (f fastpathT) DecMapUint16Int16X(vp *map[uint16]int16, d *Decoder) { + 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) + v = make(map[uint16]int16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint16 + var mv int16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint16Int32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint16]int32) + v, changed := fastpathTV.DecMapUint16Int32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint16Int32V(rv2i(rv).(map[uint16]int32), false, d) + } +} +func (f fastpathT) DecMapUint16Int32X(vp *map[uint16]int32, d *Decoder) { + 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) + v = make(map[uint16]int32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint16 + var mv int32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint16Int64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint16]int64) + v, changed := fastpathTV.DecMapUint16Int64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint16Int64V(rv2i(rv).(map[uint16]int64), false, d) + } +} +func (f fastpathT) DecMapUint16Int64X(vp *map[uint16]int64, d *Decoder) { + 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) + v = make(map[uint16]int64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint16 + var mv int64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeInt64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint16Float32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint16]float32) + v, changed := fastpathTV.DecMapUint16Float32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint16Float32V(rv2i(rv).(map[uint16]float32), false, d) + } +} +func (f fastpathT) DecMapUint16Float32X(vp *map[uint16]float32, d *Decoder) { + 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) + v = make(map[uint16]float32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint16 + var mv float32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint16Float64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint16]float64) + v, changed := fastpathTV.DecMapUint16Float64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint16Float64V(rv2i(rv).(map[uint16]float64), false, d) + } +} +func (f fastpathT) DecMapUint16Float64X(vp *map[uint16]float64, d *Decoder) { + 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) + v = make(map[uint16]float64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint16 + var mv float64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeFloat64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint16BoolR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint16]bool) + v, changed := fastpathTV.DecMapUint16BoolV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint16BoolV(rv2i(rv).(map[uint16]bool), false, d) + } +} +func (f fastpathT) DecMapUint16BoolX(vp *map[uint16]bool, d *Decoder) { + 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) + v = make(map[uint16]bool, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint16 + var mv bool + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = false + } + continue + } + mv = dd.DecodeBool() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint32IntfR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint32]interface{}) + v, changed := fastpathTV.DecMapUint32IntfV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint32IntfV(rv2i(rv).(map[uint32]interface{}), false, d) + } +} +func (f fastpathT) DecMapUint32IntfX(vp *map[uint32]interface{}, d *Decoder) { + 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) + v = make(map[uint32]interface{}, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset + var mk uint32 + var mv interface{} + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = nil + } + continue + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } + d.decode(&mv) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint32StringR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint32]string) + v, changed := fastpathTV.DecMapUint32StringV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint32StringV(rv2i(rv).(map[uint32]string), false, d) + } +} +func (f fastpathT) DecMapUint32StringX(vp *map[uint32]string, d *Decoder) { + 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) + v = make(map[uint32]string, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint32 + var mv string + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = "" + } + continue + } + mv = dd.DecodeString() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint32UintR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint32]uint) + v, changed := fastpathTV.DecMapUint32UintV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint32UintV(rv2i(rv).(map[uint32]uint), false, d) + } +} +func (f fastpathT) DecMapUint32UintX(vp *map[uint32]uint, d *Decoder) { + 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) + v = make(map[uint32]uint, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint32 + var mv uint + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint32Uint8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint32]uint8) + v, changed := fastpathTV.DecMapUint32Uint8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint32Uint8V(rv2i(rv).(map[uint32]uint8), false, d) + } +} +func (f fastpathT) DecMapUint32Uint8X(vp *map[uint32]uint8, d *Decoder) { + 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) + v = make(map[uint32]uint8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint32 + var mv uint8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint32Uint16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint32]uint16) + v, changed := fastpathTV.DecMapUint32Uint16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint32Uint16V(rv2i(rv).(map[uint32]uint16), false, d) + } +} +func (f fastpathT) DecMapUint32Uint16X(vp *map[uint32]uint16, d *Decoder) { + 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) + v = make(map[uint32]uint16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint32 + var mv uint16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint32Uint32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint32]uint32) + v, changed := fastpathTV.DecMapUint32Uint32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint32Uint32V(rv2i(rv).(map[uint32]uint32), false, d) + } +} +func (f fastpathT) DecMapUint32Uint32X(vp *map[uint32]uint32, d *Decoder) { + 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) + v = make(map[uint32]uint32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint32 + var mv uint32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint32Uint64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint32]uint64) + v, changed := fastpathTV.DecMapUint32Uint64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint32Uint64V(rv2i(rv).(map[uint32]uint64), false, d) + } +} +func (f fastpathT) DecMapUint32Uint64X(vp *map[uint32]uint64, d *Decoder) { + 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) + v = make(map[uint32]uint64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint32 + var mv uint64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeUint64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint32UintptrR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint32]uintptr) + v, changed := fastpathTV.DecMapUint32UintptrV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint32UintptrV(rv2i(rv).(map[uint32]uintptr), false, d) + } +} +func (f fastpathT) DecMapUint32UintptrX(vp *map[uint32]uintptr, d *Decoder) { + 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) + v = make(map[uint32]uintptr, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint32 + var mv uintptr + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint32IntR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint32]int) + v, changed := fastpathTV.DecMapUint32IntV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint32IntV(rv2i(rv).(map[uint32]int), false, d) + } +} +func (f fastpathT) DecMapUint32IntX(vp *map[uint32]int, d *Decoder) { + 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) + v = make(map[uint32]int, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint32 + var mv int + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint32Int8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint32]int8) + v, changed := fastpathTV.DecMapUint32Int8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint32Int8V(rv2i(rv).(map[uint32]int8), false, d) + } +} +func (f fastpathT) DecMapUint32Int8X(vp *map[uint32]int8, d *Decoder) { + 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) + v = make(map[uint32]int8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint32 + var mv int8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint32Int16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint32]int16) + v, changed := fastpathTV.DecMapUint32Int16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint32Int16V(rv2i(rv).(map[uint32]int16), false, d) + } +} +func (f fastpathT) DecMapUint32Int16X(vp *map[uint32]int16, d *Decoder) { + 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) + v = make(map[uint32]int16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint32 + var mv int16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint32Int32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint32]int32) + v, changed := fastpathTV.DecMapUint32Int32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint32Int32V(rv2i(rv).(map[uint32]int32), false, d) + } +} +func (f fastpathT) DecMapUint32Int32X(vp *map[uint32]int32, d *Decoder) { + 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) + v = make(map[uint32]int32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint32 + var mv int32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint32Int64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint32]int64) + v, changed := fastpathTV.DecMapUint32Int64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint32Int64V(rv2i(rv).(map[uint32]int64), false, d) + } +} +func (f fastpathT) DecMapUint32Int64X(vp *map[uint32]int64, d *Decoder) { + 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) + v = make(map[uint32]int64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint32 + var mv int64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeInt64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint32Float32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint32]float32) + v, changed := fastpathTV.DecMapUint32Float32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint32Float32V(rv2i(rv).(map[uint32]float32), false, d) + } +} +func (f fastpathT) DecMapUint32Float32X(vp *map[uint32]float32, d *Decoder) { + 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) + v = make(map[uint32]float32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint32 + var mv float32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint32Float64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint32]float64) + v, changed := fastpathTV.DecMapUint32Float64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint32Float64V(rv2i(rv).(map[uint32]float64), false, d) + } +} +func (f fastpathT) DecMapUint32Float64X(vp *map[uint32]float64, d *Decoder) { + 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) + v = make(map[uint32]float64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint32 + var mv float64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeFloat64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint32BoolR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint32]bool) + v, changed := fastpathTV.DecMapUint32BoolV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint32BoolV(rv2i(rv).(map[uint32]bool), false, d) + } +} +func (f fastpathT) DecMapUint32BoolX(vp *map[uint32]bool, d *Decoder) { + 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) + v = make(map[uint32]bool, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint32 + var mv bool + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = false + } + continue + } + mv = dd.DecodeBool() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint64IntfR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint64]interface{}) + v, changed := fastpathTV.DecMapUint64IntfV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint64IntfV(rv2i(rv).(map[uint64]interface{}), false, d) + } +} +func (f fastpathT) DecMapUint64IntfX(vp *map[uint64]interface{}, d *Decoder) { + 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) + v = make(map[uint64]interface{}, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset + var mk uint64 + var mv interface{} + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeUint64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = nil + } + continue + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } + d.decode(&mv) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint64StringR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint64]string) + v, changed := fastpathTV.DecMapUint64StringV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint64StringV(rv2i(rv).(map[uint64]string), false, d) + } +} +func (f fastpathT) DecMapUint64StringX(vp *map[uint64]string, d *Decoder) { + 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) + v = make(map[uint64]string, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint64 + var mv string + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeUint64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = "" + } + continue + } + mv = dd.DecodeString() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint64UintR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint64]uint) + v, changed := fastpathTV.DecMapUint64UintV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint64UintV(rv2i(rv).(map[uint64]uint), false, d) + } +} +func (f fastpathT) DecMapUint64UintX(vp *map[uint64]uint, d *Decoder) { + 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) + v = make(map[uint64]uint, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint64 + var mv uint + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeUint64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint64Uint8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint64]uint8) + v, changed := fastpathTV.DecMapUint64Uint8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint64Uint8V(rv2i(rv).(map[uint64]uint8), false, d) + } +} +func (f fastpathT) DecMapUint64Uint8X(vp *map[uint64]uint8, d *Decoder) { + 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) + v = make(map[uint64]uint8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint64 + var mv uint8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeUint64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint64Uint16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint64]uint16) + v, changed := fastpathTV.DecMapUint64Uint16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint64Uint16V(rv2i(rv).(map[uint64]uint16), false, d) + } +} +func (f fastpathT) DecMapUint64Uint16X(vp *map[uint64]uint16, d *Decoder) { + 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) + v = make(map[uint64]uint16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint64 + var mv uint16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeUint64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint64Uint32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint64]uint32) + v, changed := fastpathTV.DecMapUint64Uint32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint64Uint32V(rv2i(rv).(map[uint64]uint32), false, d) + } +} +func (f fastpathT) DecMapUint64Uint32X(vp *map[uint64]uint32, d *Decoder) { + 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) + v = make(map[uint64]uint32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint64 + var mv uint32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeUint64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint64Uint64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint64]uint64) + v, changed := fastpathTV.DecMapUint64Uint64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint64Uint64V(rv2i(rv).(map[uint64]uint64), false, d) + } +} +func (f fastpathT) DecMapUint64Uint64X(vp *map[uint64]uint64, d *Decoder) { + 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) + v = make(map[uint64]uint64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint64 + var mv uint64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeUint64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeUint64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint64UintptrR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint64]uintptr) + v, changed := fastpathTV.DecMapUint64UintptrV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint64UintptrV(rv2i(rv).(map[uint64]uintptr), false, d) + } +} +func (f fastpathT) DecMapUint64UintptrX(vp *map[uint64]uintptr, d *Decoder) { + 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) + v = make(map[uint64]uintptr, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint64 + var mv uintptr + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeUint64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint64IntR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint64]int) + v, changed := fastpathTV.DecMapUint64IntV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint64IntV(rv2i(rv).(map[uint64]int), false, d) + } +} +func (f fastpathT) DecMapUint64IntX(vp *map[uint64]int, d *Decoder) { + 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) + v = make(map[uint64]int, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint64 + var mv int + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeUint64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint64Int8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint64]int8) + v, changed := fastpathTV.DecMapUint64Int8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint64Int8V(rv2i(rv).(map[uint64]int8), false, d) + } +} +func (f fastpathT) DecMapUint64Int8X(vp *map[uint64]int8, d *Decoder) { + 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) + v = make(map[uint64]int8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint64 + var mv int8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeUint64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint64Int16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint64]int16) + v, changed := fastpathTV.DecMapUint64Int16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint64Int16V(rv2i(rv).(map[uint64]int16), false, d) + } +} +func (f fastpathT) DecMapUint64Int16X(vp *map[uint64]int16, d *Decoder) { + 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) + v = make(map[uint64]int16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint64 + var mv int16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeUint64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint64Int32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint64]int32) + v, changed := fastpathTV.DecMapUint64Int32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint64Int32V(rv2i(rv).(map[uint64]int32), false, d) + } +} +func (f fastpathT) DecMapUint64Int32X(vp *map[uint64]int32, d *Decoder) { + 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) + v = make(map[uint64]int32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint64 + var mv int32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeUint64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint64Int64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint64]int64) + v, changed := fastpathTV.DecMapUint64Int64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint64Int64V(rv2i(rv).(map[uint64]int64), false, d) + } +} +func (f fastpathT) DecMapUint64Int64X(vp *map[uint64]int64, d *Decoder) { + 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) + v = make(map[uint64]int64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint64 + var mv int64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeUint64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeInt64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint64Float32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint64]float32) + v, changed := fastpathTV.DecMapUint64Float32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint64Float32V(rv2i(rv).(map[uint64]float32), false, d) + } +} +func (f fastpathT) DecMapUint64Float32X(vp *map[uint64]float32, d *Decoder) { + 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) + v = make(map[uint64]float32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint64 + var mv float32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeUint64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint64Float64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint64]float64) + v, changed := fastpathTV.DecMapUint64Float64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint64Float64V(rv2i(rv).(map[uint64]float64), false, d) + } +} +func (f fastpathT) DecMapUint64Float64X(vp *map[uint64]float64, d *Decoder) { + 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) + v = make(map[uint64]float64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint64 + var mv float64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeUint64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeFloat64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUint64BoolR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uint64]bool) + v, changed := fastpathTV.DecMapUint64BoolV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUint64BoolV(rv2i(rv).(map[uint64]bool), false, d) + } +} +func (f fastpathT) DecMapUint64BoolX(vp *map[uint64]bool, d *Decoder) { + 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) + v = make(map[uint64]bool, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uint64 + var mv bool + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeUint64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = false + } + continue + } + mv = dd.DecodeBool() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintptrIntfR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uintptr]interface{}) + v, changed := fastpathTV.DecMapUintptrIntfV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintptrIntfV(rv2i(rv).(map[uintptr]interface{}), false, d) + } +} +func (f fastpathT) DecMapUintptrIntfX(vp *map[uintptr]interface{}, d *Decoder) { + 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) + v = make(map[uintptr]interface{}, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset + var mk uintptr + var mv interface{} + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = nil + } + continue + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } + d.decode(&mv) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintptrStringR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uintptr]string) + v, changed := fastpathTV.DecMapUintptrStringV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintptrStringV(rv2i(rv).(map[uintptr]string), false, d) + } +} +func (f fastpathT) DecMapUintptrStringX(vp *map[uintptr]string, d *Decoder) { + 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) + v = make(map[uintptr]string, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uintptr + var mv string + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = "" + } + continue + } + mv = dd.DecodeString() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintptrUintR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uintptr]uint) + v, changed := fastpathTV.DecMapUintptrUintV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintptrUintV(rv2i(rv).(map[uintptr]uint), false, d) + } +} +func (f fastpathT) DecMapUintptrUintX(vp *map[uintptr]uint, d *Decoder) { + 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) + v = make(map[uintptr]uint, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uintptr + var mv uint + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintptrUint8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uintptr]uint8) + v, changed := fastpathTV.DecMapUintptrUint8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintptrUint8V(rv2i(rv).(map[uintptr]uint8), false, d) + } +} +func (f fastpathT) DecMapUintptrUint8X(vp *map[uintptr]uint8, d *Decoder) { + 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) + v = make(map[uintptr]uint8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uintptr + var mv uint8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintptrUint16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uintptr]uint16) + v, changed := fastpathTV.DecMapUintptrUint16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintptrUint16V(rv2i(rv).(map[uintptr]uint16), false, d) + } +} +func (f fastpathT) DecMapUintptrUint16X(vp *map[uintptr]uint16, d *Decoder) { + 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) + v = make(map[uintptr]uint16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uintptr + var mv uint16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintptrUint32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uintptr]uint32) + v, changed := fastpathTV.DecMapUintptrUint32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintptrUint32V(rv2i(rv).(map[uintptr]uint32), false, d) + } +} +func (f fastpathT) DecMapUintptrUint32X(vp *map[uintptr]uint32, d *Decoder) { + 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) + v = make(map[uintptr]uint32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uintptr + var mv uint32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} - case *map[string]interface{}: - *v = nil - case *map[string]string: - *v = nil - case *map[string][]byte: - *v = nil - case *map[string]uint: - *v = nil - case *map[string]uint8: - *v = nil - case *map[string]uint64: - *v = nil - case *map[string]int: - *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 *map[uint]interface{}: - *v = nil - case *map[uint]string: - *v = nil - case *map[uint][]byte: - *v = nil - case *map[uint]uint: - *v = nil - case *map[uint]uint8: - *v = nil - case *map[uint]uint64: - *v = nil - case *map[uint]int: - *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][]byte: - *v = nil - case *map[uint8]uint: - *v = nil - case *map[uint8]uint8: - *v = nil - case *map[uint8]uint64: - *v = nil - case *map[uint8]int: - *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 *map[uint64]interface{}: - *v = nil - case *map[uint64]string: - *v = nil - case *map[uint64][]byte: - *v = nil - case *map[uint64]uint: - *v = nil - case *map[uint64]uint8: - *v = nil - case *map[uint64]uint64: - *v = nil - case *map[uint64]int: - *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 *map[int]interface{}: - *v = nil - case *map[int]string: - *v = nil - case *map[int][]byte: - *v = nil - case *map[int]uint: - *v = nil - case *map[int]uint8: - *v = nil - case *map[int]uint64: - *v = nil - case *map[int]int: - *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 *map[int64]interface{}: - *v = nil - case *map[int64]string: - *v = nil - case *map[int64][]byte: - *v = nil - case *map[int64]uint: - *v = nil - case *map[int64]uint8: - *v = nil - case *map[int64]uint64: - *v = nil - case *map[int64]int: - *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 +func (d *Decoder) fastpathDecMapUintptrUint64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uintptr]uint64) + v, changed := fastpathTV.DecMapUintptrUint64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintptrUint64V(rv2i(rv).(map[uintptr]uint64), false, d) + } +} +func (f fastpathT) DecMapUintptrUint64X(vp *map[uintptr]uint64, d *Decoder) { + 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) + v = make(map[uintptr]uint64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uintptr + var mv uint64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeUint64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} - default: - _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 - return false +func (d *Decoder) fastpathDecMapUintptrUintptrR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uintptr]uintptr) + v, changed := fastpathTV.DecMapUintptrUintptrV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintptrUintptrV(rv2i(rv).(map[uintptr]uintptr), false, d) + } +} +func (f fastpathT) DecMapUintptrUintptrX(vp *map[uintptr]uintptr, d *Decoder) { + v, changed := f.DecMapUintptrUintptrV(*vp, true, d) + if changed { + *vp = v } - return true +} +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) + v = make(map[uintptr]uintptr, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uintptr + var mv uintptr + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -// -- -- fast path functions +func (d *Decoder) fastpathDecMapUintptrIntR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uintptr]int) + v, changed := fastpathTV.DecMapUintptrIntV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintptrIntV(rv2i(rv).(map[uintptr]int), false, d) + } +} +func (f fastpathT) DecMapUintptrIntX(vp *map[uintptr]int, d *Decoder) { + 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) + v = make(map[uintptr]int, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uintptr + var mv int + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintptrInt8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uintptr]int8) + v, changed := fastpathTV.DecMapUintptrInt8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintptrInt8V(rv2i(rv).(map[uintptr]int8), false, d) + } +} +func (f fastpathT) DecMapUintptrInt8X(vp *map[uintptr]int8, d *Decoder) { + 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) + v = make(map[uintptr]int8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uintptr + var mv int8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintptrInt16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uintptr]int16) + v, changed := fastpathTV.DecMapUintptrInt16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintptrInt16V(rv2i(rv).(map[uintptr]int16), false, d) + } +} +func (f fastpathT) DecMapUintptrInt16X(vp *map[uintptr]int16, d *Decoder) { + 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) + v = make(map[uintptr]int16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uintptr + var mv int16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} -func (d *Decoder) fastpathDecSliceIntfR(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]interface{}) - if v, changed := fastpathTV.DecSliceIntfY(*vp, d); changed { +func (d *Decoder) fastpathDecMapUintptrInt32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uintptr]int32) + v, changed := fastpathTV.DecMapUintptrInt32V(*vp, true, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceIntfN(rv2i(rv).([]interface{}), d) + fastpathTV.DecMapUintptrInt32V(rv2i(rv).(map[uintptr]int32), false, d) } } -func (f fastpathT) DecSliceIntfX(vp *[]interface{}, d *Decoder) { - if v, changed := f.DecSliceIntfY(*vp, d); changed { +func (f fastpathT) DecMapUintptrInt32X(vp *map[uintptr]int32, d *Decoder) { + v, changed := f.DecMapUintptrInt32V(*vp, true, d) + if changed { *vp = v } } -func (fastpathT) DecSliceIntfY(v []interface{}, d *Decoder) (_ []interface{}, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return +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) + v = make(map[uintptr]int32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uintptr + var mv int32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if v != nil { + v[mk] = mv } - return nil, true } - if containerLenS == 0 { - if v == nil { - v = []interface{}{} - } else if len(v) != 0 { - v = v[:0] + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintptrInt64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uintptr]int64) + v, changed := fastpathTV.DecMapUintptrInt64V(*vp, true, d) + if changed { + *vp = v } - slh.End() - return v, true + } else { + fastpathTV.DecMapUintptrInt64V(rv2i(rv).(map[uintptr]int64), false, d) } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16) - if xlen <= cap(v) { - v = v[:uint(xlen)] +} +func (f fastpathT) DecMapUintptrInt64X(vp *map[uintptr]int64, d *Decoder) { + 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) + v = make(map[uintptr]int64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uintptr + var mv int64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) } else { - v = make([]interface{}, uint(xlen)) + v[mk] = 0 } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + continue + } + mv = dd.DecodeInt64() + if v != nil { + v[mk] = mv } } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16) + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintptrFloat32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uintptr]float32) + v, changed := fastpathTV.DecMapUintptrFloat32V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintptrFloat32V(rv2i(rv).(map[uintptr]float32), false, d) + } +} +func (f fastpathT) DecMapUintptrFloat32X(vp *map[uintptr]float32, d *Decoder) { + 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) + v = make(map[uintptr]float32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uintptr + var mv float32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) } else { - xlen = 8 + v[mk] = 0 } - v = make([]interface{}, uint(xlen)) - changed = true + continue } - if j >= len(v) { - v = append(v, nil) - changed = true + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if v != nil { + v[mk] = mv } - slh.ElemContainerState(j) - d.decode(&v[uint(j)]) } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []interface{}{} + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapUintptrFloat64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uintptr]float64) + v, changed := fastpathTV.DecMapUintptrFloat64V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintptrFloat64V(rv2i(rv).(map[uintptr]float64), false, d) + } +} +func (f fastpathT) DecMapUintptrFloat64X(vp *map[uintptr]float64, d *Decoder) { + 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) + v = make(map[uintptr]float64, xlen) changed = true } - slh.End() + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uintptr + var mv float64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeFloat64() + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() return v, changed } -func (fastpathT) DecSliceIntfN(v []interface{}, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return + +func (d *Decoder) fastpathDecMapUintptrBoolR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[uintptr]bool) + v, changed := fastpathTV.DecMapUintptrBoolV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapUintptrBoolV(rv2i(rv).(map[uintptr]bool), false, d) } - if containerLenS == 0 { - slh.End() - return +} +func (f fastpathT) DecMapUintptrBoolX(vp *map[uintptr]bool, d *Decoder) { + v, changed := f.DecMapUintptrBoolV(*vp, true, d) + if changed { + *vp = v } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return +} +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) + v = make(map[uintptr]bool, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk uintptr + var mv bool + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = false + } + continue + } + mv = dd.DecodeBool() + if v != nil { + v[mk] = mv } - slh.ElemContainerState(j) - d.decode(&v[uint(j)]) } - slh.End() + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecSliceStringR(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]string) - if v, changed := fastpathTV.DecSliceStringY(*vp, d); changed { +func (d *Decoder) fastpathDecMapIntIntfR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int]interface{}) + v, changed := fastpathTV.DecMapIntIntfV(*vp, true, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceStringN(rv2i(rv).([]string), d) + fastpathTV.DecMapIntIntfV(rv2i(rv).(map[int]interface{}), false, d) } } -func (f fastpathT) DecSliceStringX(vp *[]string, d *Decoder) { - if v, changed := f.DecSliceStringY(*vp, d); changed { +func (f fastpathT) DecMapIntIntfX(vp *map[int]interface{}, d *Decoder) { + v, changed := f.DecMapIntIntfV(*vp, true, d) + if changed { *vp = v } } -func (fastpathT) DecSliceStringY(v []string, d *Decoder) (_ []string, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return +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) + v = make(map[int]interface{}, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset + var mk int + var mv interface{} + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = nil + } + continue + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } + d.decode(&mv) + if v != nil { + v[mk] = mv } - return nil, true } - if containerLenS == 0 { - if v == nil { - v = []string{} - } else if len(v) != 0 { - v = v[:0] + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntStringR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int]string) + v, changed := fastpathTV.DecMapIntStringV(*vp, true, d) + if changed { + *vp = v } - slh.End() - return v, true + } else { + fastpathTV.DecMapIntStringV(rv2i(rv).(map[int]string), false, d) } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16) - if xlen <= cap(v) { - v = v[:uint(xlen)] +} +func (f fastpathT) DecMapIntStringX(vp *map[int]string, d *Decoder) { + 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) + v = make(map[int]string, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int + var mv string + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) } else { - v = make([]string, uint(xlen)) + v[mk] = "" } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + continue + } + mv = dd.DecodeString() + if v != nil { + v[mk] = mv } } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16) + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntUintR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int]uint) + v, changed := fastpathTV.DecMapIntUintV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapIntUintV(rv2i(rv).(map[int]uint), false, d) + } +} +func (f fastpathT) DecMapIntUintX(vp *map[int]uint, d *Decoder) { + 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) + v = make(map[int]uint, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int + var mv uint + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) } else { - xlen = 8 + v[mk] = 0 } - v = make([]string, uint(xlen)) - changed = true + continue } - if j >= len(v) { - v = append(v, "") - changed = true + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv } - slh.ElemContainerState(j) - v[uint(j)] = string(d.d.DecodeStringAsBytes()) } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []string{} + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntUint8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int]uint8) + v, changed := fastpathTV.DecMapIntUint8V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapIntUint8V(rv2i(rv).(map[int]uint8), false, d) + } +} +func (f fastpathT) DecMapIntUint8X(vp *map[int]uint8, d *Decoder) { + 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) + v = make(map[int]uint8, xlen) changed = true } - slh.End() + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int + var mv uint8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if v != nil { + v[mk] = mv + } + } + dd.ReadMapEnd() + d.depthDecr() return v, changed } -func (fastpathT) DecSliceStringN(v []string, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return + +func (d *Decoder) fastpathDecMapIntUint16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int]uint16) + v, changed := fastpathTV.DecMapIntUint16V(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapIntUint16V(rv2i(rv).(map[int]uint16), false, d) } - if containerLenS == 0 { - slh.End() - return +} +func (f fastpathT) DecMapIntUint16X(vp *map[int]uint16, d *Decoder) { + v, changed := f.DecMapIntUint16V(*vp, true, d) + if changed { + *vp = v } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return +} +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) + v = make(map[int]uint16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int + var mv uint16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if v != nil { + v[mk] = mv } - slh.ElemContainerState(j) - v[uint(j)] = string(d.d.DecodeStringAsBytes()) } - slh.End() + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecSliceBytesR(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[][]byte) - if v, changed := fastpathTV.DecSliceBytesY(*vp, d); changed { +func (d *Decoder) fastpathDecMapIntUint32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int]uint32) + v, changed := fastpathTV.DecMapIntUint32V(*vp, true, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceBytesN(rv2i(rv).([][]byte), d) + fastpathTV.DecMapIntUint32V(rv2i(rv).(map[int]uint32), false, d) } } -func (f fastpathT) DecSliceBytesX(vp *[][]byte, d *Decoder) { - if v, changed := f.DecSliceBytesY(*vp, d); changed { +func (f fastpathT) DecMapIntUint32X(vp *map[int]uint32, d *Decoder) { + v, changed := f.DecMapIntUint32V(*vp, true, d) + if changed { *vp = v } } -func (fastpathT) DecSliceBytesY(v [][]byte, d *Decoder) (_ [][]byte, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true - } - if containerLenS == 0 { - if v == nil { - v = [][]byte{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true +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) + v = make(map[int]uint32, xlen) + changed = true } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 24) - if xlen <= cap(v) { - v = v[:uint(xlen)] - } else { - v = make([][]byte, uint(xlen)) - } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true - } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 24) + d.depthIncr() + var mk int + var mv uint32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) } else { - xlen = 8 + v[mk] = 0 } - v = make([][]byte, uint(xlen)) - changed = true + continue } - if j >= len(v) { - v = append(v, nil) - changed = true + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if v != nil { + v[mk] = mv } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeBytes(nil, false) - } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = [][]byte{} - changed = true } - slh.End() + dd.ReadMapEnd() + d.depthDecr() return v, changed } -func (fastpathT) DecSliceBytesN(v [][]byte, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return - } - if containerLenS == 0 { - slh.End() - return - } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return - } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeBytes(nil, false) - } - slh.End() -} -func (d *Decoder) fastpathDecSliceFloat32R(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]float32) - if v, changed := fastpathTV.DecSliceFloat32Y(*vp, d); changed { +func (d *Decoder) fastpathDecMapIntUint64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int]uint64) + v, changed := fastpathTV.DecMapIntUint64V(*vp, true, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceFloat32N(rv2i(rv).([]float32), d) + fastpathTV.DecMapIntUint64V(rv2i(rv).(map[int]uint64), false, d) } } -func (f fastpathT) DecSliceFloat32X(vp *[]float32, d *Decoder) { - if v, changed := f.DecSliceFloat32Y(*vp, d); changed { +func (f fastpathT) DecMapIntUint64X(vp *map[int]uint64, d *Decoder) { + v, changed := f.DecMapIntUint64V(*vp, true, d) + if changed { *vp = v } } -func (fastpathT) DecSliceFloat32Y(v []float32, d *Decoder) (_ []float32, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true +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) + v = make(map[int]uint64, xlen) + changed = true } - if containerLenS == 0 { - if v == nil { - v = []float32{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) - if xlen <= cap(v) { - v = v[:uint(xlen)] + d.depthIncr() + var mk int + var mv uint64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) } else { - v = make([]float32, uint(xlen)) + v[mk] = 0 } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + continue } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) - } else { - xlen = 8 - } - v = make([]float32, uint(xlen)) - changed = true + mv = dd.DecodeUint64() + if v != nil { + v[mk] = mv } - if j >= len(v) { - v = append(v, 0) - changed = true + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntUintptrR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int]uintptr) + v, changed := fastpathTV.DecMapIntUintptrV(*vp, true, d) + if changed { + *vp = v } - slh.ElemContainerState(j) - v[uint(j)] = float32(d.decodeFloat32()) + } else { + fastpathTV.DecMapIntUintptrV(rv2i(rv).(map[int]uintptr), false, d) } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []float32{} - changed = true +} +func (f fastpathT) DecMapIntUintptrX(vp *map[int]uintptr, d *Decoder) { + v, changed := f.DecMapIntUintptrV(*vp, true, d) + if changed { + *vp = v } - slh.End() - return v, changed } -func (fastpathT) DecSliceFloat32N(v []float32, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return +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) + v = make(map[int]uintptr, xlen) + changed = true } - if containerLenS == 0 { - slh.End() - return + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return + d.depthIncr() + var mk int + var mv uintptr + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv } - slh.ElemContainerState(j) - v[uint(j)] = float32(d.decodeFloat32()) } - slh.End() + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecSliceFloat64R(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]float64) - if v, changed := fastpathTV.DecSliceFloat64Y(*vp, d); changed { +func (d *Decoder) fastpathDecMapIntIntR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int]int) + v, changed := fastpathTV.DecMapIntIntV(*vp, true, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceFloat64N(rv2i(rv).([]float64), d) + fastpathTV.DecMapIntIntV(rv2i(rv).(map[int]int), false, d) } } -func (f fastpathT) DecSliceFloat64X(vp *[]float64, d *Decoder) { - if v, changed := f.DecSliceFloat64Y(*vp, d); changed { +func (f fastpathT) DecMapIntIntX(vp *map[int]int, d *Decoder) { + v, changed := f.DecMapIntIntV(*vp, true, d) + if changed { *vp = v } } -func (fastpathT) DecSliceFloat64Y(v []float64, d *Decoder) (_ []float64, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true +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) + v = make(map[int]int, xlen) + changed = true } - if containerLenS == 0 { - if v == nil { - v = []float64{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - if xlen <= cap(v) { - v = v[:uint(xlen)] + d.depthIncr() + var mk int + var mv int + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) } else { - v = make([]float64, uint(xlen)) + v[mk] = 0 } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + continue } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - } else { - xlen = 8 - } - v = make([]float64, uint(xlen)) - changed = true + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if v != nil { + v[mk] = mv } - if j >= len(v) { - v = append(v, 0) - changed = true + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntInt8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int]int8) + v, changed := fastpathTV.DecMapIntInt8V(*vp, true, d) + if changed { + *vp = v } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeFloat64() + } else { + fastpathTV.DecMapIntInt8V(rv2i(rv).(map[int]int8), false, d) } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []float64{} - changed = true +} +func (f fastpathT) DecMapIntInt8X(vp *map[int]int8, d *Decoder) { + v, changed := f.DecMapIntInt8V(*vp, true, d) + if changed { + *vp = v } - slh.End() - return v, changed } -func (fastpathT) DecSliceFloat64N(v []float64, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return +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) + v = make(map[int]int8, xlen) + changed = true } - if containerLenS == 0 { - slh.End() - return + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return + d.depthIncr() + var mk int + var mv int8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if v != nil { + v[mk] = mv } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeFloat64() } - slh.End() + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecSliceUintR(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]uint) - if v, changed := fastpathTV.DecSliceUintY(*vp, d); changed { +func (d *Decoder) fastpathDecMapIntInt16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int]int16) + v, changed := fastpathTV.DecMapIntInt16V(*vp, true, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceUintN(rv2i(rv).([]uint), d) + fastpathTV.DecMapIntInt16V(rv2i(rv).(map[int]int16), false, d) } } -func (f fastpathT) DecSliceUintX(vp *[]uint, d *Decoder) { - if v, changed := f.DecSliceUintY(*vp, d); changed { +func (f fastpathT) DecMapIntInt16X(vp *map[int]int16, d *Decoder) { + v, changed := f.DecMapIntInt16V(*vp, true, d) + if changed { *vp = v } } -func (fastpathT) DecSliceUintY(v []uint, d *Decoder) (_ []uint, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true +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) + v = make(map[int]int16, xlen) + changed = true } - if containerLenS == 0 { - if v == nil { - v = []uint{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - if xlen <= cap(v) { - v = v[:uint(xlen)] + d.depthIncr() + var mk int + var mv int16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) } else { - v = make([]uint, uint(xlen)) + v[mk] = 0 } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + continue } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - } else { - xlen = 8 - } - v = make([]uint, uint(xlen)) - changed = true + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if v != nil { + v[mk] = mv } - if j >= len(v) { - v = append(v, 0) - changed = true + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntInt32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int]int32) + v, changed := fastpathTV.DecMapIntInt32V(*vp, true, d) + if changed { + *vp = v } - slh.ElemContainerState(j) - v[uint(j)] = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) + } else { + fastpathTV.DecMapIntInt32V(rv2i(rv).(map[int]int32), false, d) } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []uint{} - changed = true +} +func (f fastpathT) DecMapIntInt32X(vp *map[int]int32, d *Decoder) { + v, changed := f.DecMapIntInt32V(*vp, true, d) + if changed { + *vp = v } - slh.End() - return v, changed } -func (fastpathT) DecSliceUintN(v []uint, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return +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) + v = make(map[int]int32, xlen) + changed = true } - if containerLenS == 0 { - slh.End() - return + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return + d.depthIncr() + var mk int + var mv int32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if v != nil { + v[mk] = mv } - slh.ElemContainerState(j) - v[uint(j)] = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) } - slh.End() + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecSliceUint16R(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]uint16) - if v, changed := fastpathTV.DecSliceUint16Y(*vp, d); changed { +func (d *Decoder) fastpathDecMapIntInt64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int]int64) + v, changed := fastpathTV.DecMapIntInt64V(*vp, true, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceUint16N(rv2i(rv).([]uint16), d) + fastpathTV.DecMapIntInt64V(rv2i(rv).(map[int]int64), false, d) } } -func (f fastpathT) DecSliceUint16X(vp *[]uint16, d *Decoder) { - if v, changed := f.DecSliceUint16Y(*vp, d); changed { +func (f fastpathT) DecMapIntInt64X(vp *map[int]int64, d *Decoder) { + v, changed := f.DecMapIntInt64V(*vp, true, d) + if changed { *vp = v } } -func (fastpathT) DecSliceUint16Y(v []uint16, d *Decoder) (_ []uint16, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true +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) + v = make(map[int]int64, xlen) + changed = true } - if containerLenS == 0 { - if v == nil { - v = []uint16{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2) - if xlen <= cap(v) { - v = v[:uint(xlen)] + d.depthIncr() + var mk int + var mv int64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) } else { - v = make([]uint16, uint(xlen)) + v[mk] = 0 } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + continue } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2) - } else { - xlen = 8 - } - v = make([]uint16, uint(xlen)) - changed = true + mv = dd.DecodeInt64() + if v != nil { + v[mk] = mv } - if j >= len(v) { - v = append(v, 0) - changed = true + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntFloat32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int]float32) + v, changed := fastpathTV.DecMapIntFloat32V(*vp, true, d) + if changed { + *vp = v } - slh.ElemContainerState(j) - v[uint(j)] = uint16(chkOvf.UintV(d.d.DecodeUint64(), 16)) + } else { + fastpathTV.DecMapIntFloat32V(rv2i(rv).(map[int]float32), false, d) } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []uint16{} - changed = true +} +func (f fastpathT) DecMapIntFloat32X(vp *map[int]float32, d *Decoder) { + v, changed := f.DecMapIntFloat32V(*vp, true, d) + if changed { + *vp = v } - slh.End() - return v, changed } -func (fastpathT) DecSliceUint16N(v []uint16, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return +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) + v = make(map[int]float32, xlen) + changed = true } - if containerLenS == 0 { - slh.End() - return + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return + d.depthIncr() + var mk int + var mv float32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if v != nil { + v[mk] = mv } - slh.ElemContainerState(j) - v[uint(j)] = uint16(chkOvf.UintV(d.d.DecodeUint64(), 16)) } - slh.End() + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecSliceUint32R(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]uint32) - if v, changed := fastpathTV.DecSliceUint32Y(*vp, d); changed { +func (d *Decoder) fastpathDecMapIntFloat64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int]float64) + v, changed := fastpathTV.DecMapIntFloat64V(*vp, true, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceUint32N(rv2i(rv).([]uint32), d) + fastpathTV.DecMapIntFloat64V(rv2i(rv).(map[int]float64), false, d) } } -func (f fastpathT) DecSliceUint32X(vp *[]uint32, d *Decoder) { - if v, changed := f.DecSliceUint32Y(*vp, d); changed { +func (f fastpathT) DecMapIntFloat64X(vp *map[int]float64, d *Decoder) { + v, changed := f.DecMapIntFloat64V(*vp, true, d) + if changed { *vp = v } } -func (fastpathT) DecSliceUint32Y(v []uint32, d *Decoder) (_ []uint32, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true +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) + v = make(map[int]float64, xlen) + changed = true } - if containerLenS == 0 { - if v == nil { - v = []uint32{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) - if xlen <= cap(v) { - v = v[:uint(xlen)] + d.depthIncr() + var mk int + var mv float64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) } else { - v = make([]uint32, uint(xlen)) + v[mk] = 0 } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + continue } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) - } else { - xlen = 8 - } - v = make([]uint32, uint(xlen)) - changed = true + mv = dd.DecodeFloat64() + if v != nil { + v[mk] = mv } - if j >= len(v) { - v = append(v, 0) - changed = true + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapIntBoolR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int]bool) + v, changed := fastpathTV.DecMapIntBoolV(*vp, true, d) + if changed { + *vp = v } - slh.ElemContainerState(j) - v[uint(j)] = uint32(chkOvf.UintV(d.d.DecodeUint64(), 32)) + } else { + fastpathTV.DecMapIntBoolV(rv2i(rv).(map[int]bool), false, d) } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []uint32{} - changed = true +} +func (f fastpathT) DecMapIntBoolX(vp *map[int]bool, d *Decoder) { + v, changed := f.DecMapIntBoolV(*vp, true, d) + if changed { + *vp = v } - slh.End() - return v, changed } -func (fastpathT) DecSliceUint32N(v []uint32, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return +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) + v = make(map[int]bool, xlen) + changed = true } - if containerLenS == 0 { - slh.End() - return + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return + d.depthIncr() + var mk int + var mv bool + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = false + } + continue + } + mv = dd.DecodeBool() + if v != nil { + v[mk] = mv } - slh.ElemContainerState(j) - v[uint(j)] = uint32(chkOvf.UintV(d.d.DecodeUint64(), 32)) } - slh.End() + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecSliceUint64R(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]uint64) - if v, changed := fastpathTV.DecSliceUint64Y(*vp, d); changed { +func (d *Decoder) fastpathDecMapInt8IntfR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int8]interface{}) + v, changed := fastpathTV.DecMapInt8IntfV(*vp, true, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceUint64N(rv2i(rv).([]uint64), d) + fastpathTV.DecMapInt8IntfV(rv2i(rv).(map[int8]interface{}), false, d) } } -func (f fastpathT) DecSliceUint64X(vp *[]uint64, d *Decoder) { - if v, changed := f.DecSliceUint64Y(*vp, d); changed { +func (f fastpathT) DecMapInt8IntfX(vp *map[int8]interface{}, d *Decoder) { + v, changed := f.DecMapInt8IntfV(*vp, true, d) + if changed { *vp = v } } -func (fastpathT) DecSliceUint64Y(v []uint64, d *Decoder) (_ []uint64, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true +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) + v = make(map[int8]interface{}, xlen) + changed = true } - if containerLenS == 0 { - if v == nil { - v = []uint64{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - if xlen <= cap(v) { - v = v[:uint(xlen)] + d.depthIncr() + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset + var mk int8 + var mv interface{} + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) } else { - v = make([]uint64, uint(xlen)) + v[mk] = nil } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + continue } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - } else { - xlen = 8 - } - v = make([]uint64, uint(xlen)) - changed = true + if mapGet { + mv = v[mk] + } else { + mv = nil } - if j >= len(v) { - v = append(v, 0) - changed = true + d.decode(&mv) + if v != nil { + v[mk] = mv } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeUint64() - } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []uint64{} - changed = true } - slh.End() + dd.ReadMapEnd() + d.depthDecr() return v, changed } -func (fastpathT) DecSliceUint64N(v []uint64, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return + +func (d *Decoder) fastpathDecMapInt8StringR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int8]string) + v, changed := fastpathTV.DecMapInt8StringV(*vp, true, d) + if changed { + *vp = v + } + } else { + fastpathTV.DecMapInt8StringV(rv2i(rv).(map[int8]string), false, d) } - if containerLenS == 0 { - slh.End() - return +} +func (f fastpathT) DecMapInt8StringX(vp *map[int8]string, d *Decoder) { + v, changed := f.DecMapInt8StringV(*vp, true, d) + if changed { + *vp = v } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return +} +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) + v = make(map[int8]string, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int8 + var mv string + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = "" + } + continue + } + mv = dd.DecodeString() + if v != nil { + v[mk] = mv } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeUint64() } - slh.End() + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecSliceIntR(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]int) - if v, changed := fastpathTV.DecSliceIntY(*vp, d); changed { +func (d *Decoder) fastpathDecMapInt8UintR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int8]uint) + v, changed := fastpathTV.DecMapInt8UintV(*vp, true, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceIntN(rv2i(rv).([]int), d) + fastpathTV.DecMapInt8UintV(rv2i(rv).(map[int8]uint), false, d) } } -func (f fastpathT) DecSliceIntX(vp *[]int, d *Decoder) { - if v, changed := f.DecSliceIntY(*vp, d); changed { +func (f fastpathT) DecMapInt8UintX(vp *map[int8]uint, d *Decoder) { + v, changed := f.DecMapInt8UintV(*vp, true, d) + if changed { *vp = v } } -func (fastpathT) DecSliceIntY(v []int, d *Decoder) (_ []int, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true +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) + v = make(map[int8]uint, xlen) + changed = true } - if containerLenS == 0 { - if v == nil { - v = []int{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - if xlen <= cap(v) { - v = v[:uint(xlen)] + d.depthIncr() + var mk int8 + var mv uint + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) } else { - v = make([]int, uint(xlen)) + v[mk] = 0 } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + continue } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - } else { - xlen = 8 - } - v = make([]int, uint(xlen)) - changed = true + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv } - if j >= len(v) { - v = append(v, 0) - changed = true + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapInt8Uint8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int8]uint8) + v, changed := fastpathTV.DecMapInt8Uint8V(*vp, true, d) + if changed { + *vp = v } - slh.ElemContainerState(j) - v[uint(j)] = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) + } else { + fastpathTV.DecMapInt8Uint8V(rv2i(rv).(map[int8]uint8), false, d) } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []int{} - changed = true +} +func (f fastpathT) DecMapInt8Uint8X(vp *map[int8]uint8, d *Decoder) { + v, changed := f.DecMapInt8Uint8V(*vp, true, d) + if changed { + *vp = v } - slh.End() - return v, changed } -func (fastpathT) DecSliceIntN(v []int, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return +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) + v = make(map[int8]uint8, xlen) + changed = true } - if containerLenS == 0 { - slh.End() - return + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return + d.depthIncr() + var mk int8 + var mv uint8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) + if v != nil { + v[mk] = mv } - slh.ElemContainerState(j) - v[uint(j)] = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) } - slh.End() + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecSliceInt8R(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]int8) - if v, changed := fastpathTV.DecSliceInt8Y(*vp, d); changed { +func (d *Decoder) fastpathDecMapInt8Uint16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int8]uint16) + v, changed := fastpathTV.DecMapInt8Uint16V(*vp, true, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceInt8N(rv2i(rv).([]int8), d) + fastpathTV.DecMapInt8Uint16V(rv2i(rv).(map[int8]uint16), false, d) } } -func (f fastpathT) DecSliceInt8X(vp *[]int8, d *Decoder) { - if v, changed := f.DecSliceInt8Y(*vp, d); changed { +func (f fastpathT) DecMapInt8Uint16X(vp *map[int8]uint16, d *Decoder) { + v, changed := f.DecMapInt8Uint16V(*vp, true, d) + if changed { *vp = v } } -func (fastpathT) DecSliceInt8Y(v []int8, d *Decoder) (_ []int8, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true +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) + v = make(map[int8]uint16, xlen) + changed = true } - if containerLenS == 0 { - if v == nil { - v = []int8{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1) - if xlen <= cap(v) { - v = v[:uint(xlen)] + d.depthIncr() + var mk int8 + var mv uint16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) } else { - v = make([]int8, uint(xlen)) + v[mk] = 0 } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + continue } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1) - } else { - xlen = 8 - } - v = make([]int8, uint(xlen)) - changed = true + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) + if v != nil { + v[mk] = mv } - if j >= len(v) { - v = append(v, 0) - changed = true + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapInt8Uint32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int8]uint32) + v, changed := fastpathTV.DecMapInt8Uint32V(*vp, true, d) + if changed { + *vp = v } - slh.ElemContainerState(j) - v[uint(j)] = int8(chkOvf.IntV(d.d.DecodeInt64(), 8)) + } else { + fastpathTV.DecMapInt8Uint32V(rv2i(rv).(map[int8]uint32), false, d) } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []int8{} - changed = true +} +func (f fastpathT) DecMapInt8Uint32X(vp *map[int8]uint32, d *Decoder) { + v, changed := f.DecMapInt8Uint32V(*vp, true, d) + if changed { + *vp = v } - slh.End() - return v, changed } -func (fastpathT) DecSliceInt8N(v []int8, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return +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) + v = make(map[int8]uint32, xlen) + changed = true } - if containerLenS == 0 { - slh.End() - return + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return + d.depthIncr() + var mk int8 + var mv uint32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) + if v != nil { + v[mk] = mv } - slh.ElemContainerState(j) - v[uint(j)] = int8(chkOvf.IntV(d.d.DecodeInt64(), 8)) } - slh.End() + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecSliceInt16R(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]int16) - if v, changed := fastpathTV.DecSliceInt16Y(*vp, d); changed { +func (d *Decoder) fastpathDecMapInt8Uint64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int8]uint64) + v, changed := fastpathTV.DecMapInt8Uint64V(*vp, true, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceInt16N(rv2i(rv).([]int16), d) + fastpathTV.DecMapInt8Uint64V(rv2i(rv).(map[int8]uint64), false, d) } } -func (f fastpathT) DecSliceInt16X(vp *[]int16, d *Decoder) { - if v, changed := f.DecSliceInt16Y(*vp, d); changed { +func (f fastpathT) DecMapInt8Uint64X(vp *map[int8]uint64, d *Decoder) { + v, changed := f.DecMapInt8Uint64V(*vp, true, d) + if changed { *vp = v } } -func (fastpathT) DecSliceInt16Y(v []int16, d *Decoder) (_ []int16, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true +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) + v = make(map[int8]uint64, xlen) + changed = true } - if containerLenS == 0 { - if v == nil { - v = []int16{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2) - if xlen <= cap(v) { - v = v[:uint(xlen)] + d.depthIncr() + var mk int8 + var mv uint64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) } else { - v = make([]int16, uint(xlen)) + v[mk] = 0 } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + continue } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2) - } else { - xlen = 8 - } - v = make([]int16, uint(xlen)) - changed = true + mv = dd.DecodeUint64() + if v != nil { + v[mk] = mv } - if j >= len(v) { - v = append(v, 0) - changed = true + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapInt8UintptrR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int8]uintptr) + v, changed := fastpathTV.DecMapInt8UintptrV(*vp, true, d) + if changed { + *vp = v } - slh.ElemContainerState(j) - v[uint(j)] = int16(chkOvf.IntV(d.d.DecodeInt64(), 16)) + } else { + fastpathTV.DecMapInt8UintptrV(rv2i(rv).(map[int8]uintptr), false, d) } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []int16{} - changed = true +} +func (f fastpathT) DecMapInt8UintptrX(vp *map[int8]uintptr, d *Decoder) { + v, changed := f.DecMapInt8UintptrV(*vp, true, d) + if changed { + *vp = v } - slh.End() - return v, changed } -func (fastpathT) DecSliceInt16N(v []int16, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return +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) + v = make(map[int8]uintptr, xlen) + changed = true } - if containerLenS == 0 { - slh.End() - return + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return + d.depthIncr() + var mk int8 + var mv uintptr + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) + if v != nil { + v[mk] = mv } - slh.ElemContainerState(j) - v[uint(j)] = int16(chkOvf.IntV(d.d.DecodeInt64(), 16)) } - slh.End() + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecSliceInt32R(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]int32) - if v, changed := fastpathTV.DecSliceInt32Y(*vp, d); changed { +func (d *Decoder) fastpathDecMapInt8IntR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int8]int) + v, changed := fastpathTV.DecMapInt8IntV(*vp, true, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceInt32N(rv2i(rv).([]int32), d) + fastpathTV.DecMapInt8IntV(rv2i(rv).(map[int8]int), false, d) } } -func (f fastpathT) DecSliceInt32X(vp *[]int32, d *Decoder) { - if v, changed := f.DecSliceInt32Y(*vp, d); changed { +func (f fastpathT) DecMapInt8IntX(vp *map[int8]int, d *Decoder) { + v, changed := f.DecMapInt8IntV(*vp, true, d) + if changed { *vp = v } } -func (fastpathT) DecSliceInt32Y(v []int32, d *Decoder) (_ []int32, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true +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) + v = make(map[int8]int, xlen) + changed = true } - if containerLenS == 0 { - if v == nil { - v = []int32{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) - if xlen <= cap(v) { - v = v[:uint(xlen)] + d.depthIncr() + var mk int8 + var mv int + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) } else { - v = make([]int32, uint(xlen)) + v[mk] = 0 } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + continue } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) - } else { - xlen = 8 - } - v = make([]int32, uint(xlen)) - changed = true + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) + if v != nil { + v[mk] = mv } - if j >= len(v) { - v = append(v, 0) - changed = true + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapInt8Int8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int8]int8) + v, changed := fastpathTV.DecMapInt8Int8V(*vp, true, d) + if changed { + *vp = v } - slh.ElemContainerState(j) - v[uint(j)] = int32(chkOvf.IntV(d.d.DecodeInt64(), 32)) + } else { + fastpathTV.DecMapInt8Int8V(rv2i(rv).(map[int8]int8), false, d) } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []int32{} - changed = true +} +func (f fastpathT) DecMapInt8Int8X(vp *map[int8]int8, d *Decoder) { + v, changed := f.DecMapInt8Int8V(*vp, true, d) + if changed { + *vp = v } - slh.End() - return v, changed } -func (fastpathT) DecSliceInt32N(v []int32, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return +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) + v = make(map[int8]int8, xlen) + changed = true } - if containerLenS == 0 { - slh.End() - return + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return + d.depthIncr() + var mk int8 + var mv int8 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if v != nil { + v[mk] = mv } - slh.ElemContainerState(j) - v[uint(j)] = int32(chkOvf.IntV(d.d.DecodeInt64(), 32)) } - slh.End() + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecSliceInt64R(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]int64) - if v, changed := fastpathTV.DecSliceInt64Y(*vp, d); changed { +func (d *Decoder) fastpathDecMapInt8Int16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int8]int16) + v, changed := fastpathTV.DecMapInt8Int16V(*vp, true, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceInt64N(rv2i(rv).([]int64), d) + fastpathTV.DecMapInt8Int16V(rv2i(rv).(map[int8]int16), false, d) } } -func (f fastpathT) DecSliceInt64X(vp *[]int64, d *Decoder) { - if v, changed := f.DecSliceInt64Y(*vp, d); changed { +func (f fastpathT) DecMapInt8Int16X(vp *map[int8]int16, d *Decoder) { + v, changed := f.DecMapInt8Int16V(*vp, true, d) + if changed { *vp = v } } -func (fastpathT) DecSliceInt64Y(v []int64, d *Decoder) (_ []int64, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true +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) + v = make(map[int8]int16, xlen) + changed = true } - if containerLenS == 0 { - if v == nil { - v = []int64{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - if xlen <= cap(v) { - v = v[:uint(xlen)] + d.depthIncr() + var mk int8 + var mv int16 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) } else { - v = make([]int64, uint(xlen)) + v[mk] = 0 } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + continue } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - } else { - xlen = 8 - } - v = make([]int64, uint(xlen)) - changed = true + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if v != nil { + v[mk] = mv } - if j >= len(v) { - v = append(v, 0) - changed = true + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapInt8Int32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int8]int32) + v, changed := fastpathTV.DecMapInt8Int32V(*vp, true, d) + if changed { + *vp = v } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeInt64() + } else { + fastpathTV.DecMapInt8Int32V(rv2i(rv).(map[int8]int32), false, d) } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []int64{} - changed = true +} +func (f fastpathT) DecMapInt8Int32X(vp *map[int8]int32, d *Decoder) { + v, changed := f.DecMapInt8Int32V(*vp, true, d) + if changed { + *vp = v } - slh.End() - return v, changed } -func (fastpathT) DecSliceInt64N(v []int64, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return +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) + v = make(map[int8]int32, xlen) + changed = true } - if containerLenS == 0 { - slh.End() - return + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return + d.depthIncr() + var mk int8 + var mv int32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if v != nil { + v[mk] = mv } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeInt64() } - slh.End() + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecSliceBoolR(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]bool) - if v, changed := fastpathTV.DecSliceBoolY(*vp, d); changed { +func (d *Decoder) fastpathDecMapInt8Int64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int8]int64) + v, changed := fastpathTV.DecMapInt8Int64V(*vp, true, d) + if changed { *vp = v } } else { - fastpathTV.DecSliceBoolN(rv2i(rv).([]bool), d) + fastpathTV.DecMapInt8Int64V(rv2i(rv).(map[int8]int64), false, d) } } -func (f fastpathT) DecSliceBoolX(vp *[]bool, d *Decoder) { - if v, changed := f.DecSliceBoolY(*vp, d); changed { +func (f fastpathT) DecMapInt8Int64X(vp *map[int8]int64, d *Decoder) { + v, changed := f.DecMapInt8Int64V(*vp, true, d) + if changed { *vp = v } } -func (fastpathT) DecSliceBoolY(v []bool, d *Decoder) (_ []bool, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true +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) + v = make(map[int8]int64, xlen) + changed = true } - if containerLenS == 0 { - if v == nil { - v = []bool{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1) - if xlen <= cap(v) { - v = v[:uint(xlen)] + d.depthIncr() + var mk int8 + var mv int64 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) } else { - v = make([]bool, uint(xlen)) + v[mk] = 0 } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + continue } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1) - } else { - xlen = 8 - } - v = make([]bool, uint(xlen)) - changed = true + mv = dd.DecodeInt64() + if v != nil { + v[mk] = mv } - if j >= len(v) { - v = append(v, false) - changed = true + } + dd.ReadMapEnd() + d.depthDecr() + return v, changed +} + +func (d *Decoder) fastpathDecMapInt8Float32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int8]float32) + v, changed := fastpathTV.DecMapInt8Float32V(*vp, true, d) + if changed { + *vp = v } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeBool() + } else { + fastpathTV.DecMapInt8Float32V(rv2i(rv).(map[int8]float32), false, d) } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []bool{} - changed = true +} +func (f fastpathT) DecMapInt8Float32X(vp *map[int8]float32, d *Decoder) { + v, changed := f.DecMapInt8Float32V(*vp, true, d) + if changed { + *vp = v } - slh.End() - return v, changed } -func (fastpathT) DecSliceBoolN(v []bool, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return +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) + v = make(map[int8]float32, xlen) + changed = true } - if containerLenS == 0 { - slh.End() - return + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return + d.depthIncr() + var mk int8 + var mv float32 + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) + if v != nil { + v[mk] = mv } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeBool() - } - slh.End() -} -func fastpathDecArrayCannotExpand(slh decSliceHelper, hasLen bool, lenv, j, containerLenS int) { - slh.d.arrayCannotExpand(lenv, j+1) - slh.ElemContainerState(j) - slh.d.swallow() - j++ - for ; (hasLen && j < containerLenS) || !(hasLen || slh.d.checkBreak()); j++ { - slh.ElemContainerState(j) - slh.d.swallow() } - slh.End() + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapStringIntfR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]interface{})) = nil +func (d *Decoder) fastpathDecMapInt8Float64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int8]float64) + v, changed := fastpathTV.DecMapInt8Float64V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]interface{}) - if *vp == nil { - *vp = make(map[string]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - fastpathTV.DecMapStringIntfL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringIntfL(rv2i(rv).(map[string]interface{}), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt8Float64V(rv2i(rv).(map[int8]float64), false, d) } } -func (f fastpathT) DecMapStringIntfX(vp *map[string]interface{}, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - f.DecMapStringIntfL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt8Float64X(vp *map[int8]float64, d *Decoder) { + v, changed := f.DecMapInt8Float64V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapStringIntfL(v map[string]interface{}, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset - var mk string - var mv interface{} +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) + v = make(map[int8]float64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int8 + var mv float64 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue } - d.decode(&mv) + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapStringStringR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]string)) = nil + +func (d *Decoder) fastpathDecMapInt8BoolR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int8]bool) + v, changed := fastpathTV.DecMapInt8BoolV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]string) - if *vp == nil { - *vp = make(map[string]string, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - fastpathTV.DecMapStringStringL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringStringL(rv2i(rv).(map[string]string), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt8BoolV(rv2i(rv).(map[int8]bool), false, d) } } -func (f fastpathT) DecMapStringStringX(vp *map[string]string, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]string, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - f.DecMapStringStringL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt8BoolX(vp *map[int8]bool, d *Decoder) { + v, changed := f.DecMapInt8BoolV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapStringStringL(v map[string]string, containerLen int, d *Decoder) { - var mk string - var mv string +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) + v = make(map[int8]bool, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int8 + var mv bool hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - mv = string(d.d.DecodeStringAsBytes()) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = false + } + continue + } + mv = dd.DecodeBool() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapStringBytesR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string][]byte)) = nil + +func (d *Decoder) fastpathDecMapInt16IntfR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int16]interface{}) + v, changed := fastpathTV.DecMapInt16IntfV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string][]byte) - if *vp == nil { - *vp = make(map[string][]byte, decInferLen(containerLen, d.h.MaxInitLen, 40)) - } - if containerLen != 0 { - fastpathTV.DecMapStringBytesL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringBytesL(rv2i(rv).(map[string][]byte), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt16IntfV(rv2i(rv).(map[int16]interface{}), false, d) } } -func (f fastpathT) DecMapStringBytesX(vp *map[string][]byte, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string][]byte, decInferLen(containerLen, d.h.MaxInitLen, 40)) - } - if containerLen != 0 { - f.DecMapStringBytesL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt16IntfX(vp *map[int16]interface{}, d *Decoder) { + v, changed := f.DecMapInt16IntfV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapStringBytesL(v map[string][]byte, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset - var mk string - var mv []byte +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) + v = make(map[int16]interface{}, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset + var mk int16 + var mv interface{} hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = nil + } + continue + } if mapGet { mv = v[mk] } else { mv = nil } - mv = d.d.DecodeBytes(mv, false) + d.decode(&mv) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapStringUintR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]uint)) = nil + +func (d *Decoder) fastpathDecMapInt16StringR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int16]string) + v, changed := fastpathTV.DecMapInt16StringV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]uint) - if *vp == nil { - *vp = make(map[string]uint, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapStringUintL(*vp, containerLen, d) + fastpathTV.DecMapInt16StringV(rv2i(rv).(map[int16]string), false, d) + } +} +func (f fastpathT) DecMapInt16StringX(vp *map[int16]string, d *Decoder) { + 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) + v = make(map[int16]string, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int16 + var mv string + hasLen := containerLen > 0 + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = "" } - } else if containerLen != 0 { - fastpathTV.DecMapStringUintL(rv2i(rv).(map[string]uint), containerLen, d) + continue + } + mv = dd.DecodeString() + if v != nil { + v[mk] = mv } - d.mapEnd() } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (f fastpathT) DecMapStringUintX(vp *map[string]uint, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]uint, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapStringUintL(*vp, containerLen, d) + +func (d *Decoder) fastpathDecMapInt16UintR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int16]uint) + v, changed := fastpathTV.DecMapInt16UintV(*vp, true, d) + if changed { + *vp = v } - d.mapEnd() + } else { + fastpathTV.DecMapInt16UintV(rv2i(rv).(map[int16]uint), false, d) } } -func (fastpathT) DecMapStringUintL(v map[string]uint, containerLen int, d *Decoder) { - var mk string +func (f fastpathT) DecMapInt16UintX(vp *map[int16]uint, d *Decoder) { + 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) + v = make(map[int16]uint, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int16 var mv uint hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - mv = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapStringUint8R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]uint8)) = nil + +func (d *Decoder) fastpathDecMapInt16Uint8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int16]uint8) + v, changed := fastpathTV.DecMapInt16Uint8V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]uint8) - if *vp == nil { - *vp = make(map[string]uint8, decInferLen(containerLen, d.h.MaxInitLen, 17)) - } - if containerLen != 0 { - fastpathTV.DecMapStringUint8L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringUint8L(rv2i(rv).(map[string]uint8), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt16Uint8V(rv2i(rv).(map[int16]uint8), false, d) } } -func (f fastpathT) DecMapStringUint8X(vp *map[string]uint8, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]uint8, decInferLen(containerLen, d.h.MaxInitLen, 17)) - } - if containerLen != 0 { - f.DecMapStringUint8L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt16Uint8X(vp *map[int16]uint8, d *Decoder) { + v, changed := f.DecMapInt16Uint8V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapStringUint8L(v map[string]uint8, containerLen int, d *Decoder) { - var mk string +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) + v = make(map[int16]uint8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int16 var mv uint8 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - mv = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapStringUint64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]uint64)) = nil + +func (d *Decoder) fastpathDecMapInt16Uint16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int16]uint16) + v, changed := fastpathTV.DecMapInt16Uint16V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]uint64) - if *vp == nil { - *vp = make(map[string]uint64, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapStringUint64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringUint64L(rv2i(rv).(map[string]uint64), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt16Uint16V(rv2i(rv).(map[int16]uint16), false, d) } } -func (f fastpathT) DecMapStringUint64X(vp *map[string]uint64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]uint64, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapStringUint64L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt16Uint16X(vp *map[int16]uint16, d *Decoder) { + v, changed := f.DecMapInt16Uint16V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapStringUint64L(v map[string]uint64, containerLen int, d *Decoder) { - var mk string - var mv uint64 +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) + v = make(map[int16]uint16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int16 + var mv uint16 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - mv = d.d.DecodeUint64() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapStringIntR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]int)) = nil + +func (d *Decoder) fastpathDecMapInt16Uint32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int16]uint32) + v, changed := fastpathTV.DecMapInt16Uint32V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]int) - if *vp == nil { - *vp = make(map[string]int, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapStringIntL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringIntL(rv2i(rv).(map[string]int), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt16Uint32V(rv2i(rv).(map[int16]uint32), false, d) } } -func (f fastpathT) DecMapStringIntX(vp *map[string]int, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]int, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapStringIntL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt16Uint32X(vp *map[int16]uint32, d *Decoder) { + v, changed := f.DecMapInt16Uint32V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapStringIntL(v map[string]int, containerLen int, d *Decoder) { - var mk string - var mv int +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) + v = make(map[int16]uint32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int16 + var mv uint32 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - mv = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapStringInt64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]int64)) = nil + +func (d *Decoder) fastpathDecMapInt16Uint64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int16]uint64) + v, changed := fastpathTV.DecMapInt16Uint64V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]int64) - if *vp == nil { - *vp = make(map[string]int64, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapStringInt64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringInt64L(rv2i(rv).(map[string]int64), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt16Uint64V(rv2i(rv).(map[int16]uint64), false, d) } } -func (f fastpathT) DecMapStringInt64X(vp *map[string]int64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]int64, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapStringInt64L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt16Uint64X(vp *map[int16]uint64, d *Decoder) { + v, changed := f.DecMapInt16Uint64V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapStringInt64L(v map[string]int64, containerLen int, d *Decoder) { - var mk string - var mv int64 +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) + v = make(map[int16]uint64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int16 + var mv uint64 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - mv = d.d.DecodeInt64() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapStringFloat32R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]float32)) = nil + +func (d *Decoder) fastpathDecMapInt16UintptrR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int16]uintptr) + v, changed := fastpathTV.DecMapInt16UintptrV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]float32) - if *vp == nil { - *vp = make(map[string]float32, decInferLen(containerLen, d.h.MaxInitLen, 20)) - } - if containerLen != 0 { - fastpathTV.DecMapStringFloat32L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringFloat32L(rv2i(rv).(map[string]float32), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt16UintptrV(rv2i(rv).(map[int16]uintptr), false, d) } } -func (f fastpathT) DecMapStringFloat32X(vp *map[string]float32, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]float32, decInferLen(containerLen, d.h.MaxInitLen, 20)) - } - if containerLen != 0 { - f.DecMapStringFloat32L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt16UintptrX(vp *map[int16]uintptr, d *Decoder) { + v, changed := f.DecMapInt16UintptrV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapStringFloat32L(v map[string]float32, containerLen int, d *Decoder) { - var mk string - var mv float32 +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) + v = make(map[int16]uintptr, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int16 + var mv uintptr hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - mv = float32(d.decodeFloat32()) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapStringFloat64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]float64)) = nil + +func (d *Decoder) fastpathDecMapInt16IntR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int16]int) + v, changed := fastpathTV.DecMapInt16IntV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]float64) - if *vp == nil { - *vp = make(map[string]float64, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapStringFloat64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringFloat64L(rv2i(rv).(map[string]float64), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt16IntV(rv2i(rv).(map[int16]int), false, d) } } -func (f fastpathT) DecMapStringFloat64X(vp *map[string]float64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]float64, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapStringFloat64L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt16IntX(vp *map[int16]int, d *Decoder) { + v, changed := f.DecMapInt16IntV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapStringFloat64L(v map[string]float64, containerLen int, d *Decoder) { - var mk string - var mv float64 +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) + v = make(map[int16]int, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int16 + var mv int hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - mv = d.d.DecodeFloat64() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapStringBoolR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]bool)) = nil + +func (d *Decoder) fastpathDecMapInt16Int8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int16]int8) + v, changed := fastpathTV.DecMapInt16Int8V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]bool) - if *vp == nil { - *vp = make(map[string]bool, decInferLen(containerLen, d.h.MaxInitLen, 17)) - } - if containerLen != 0 { - fastpathTV.DecMapStringBoolL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringBoolL(rv2i(rv).(map[string]bool), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt16Int8V(rv2i(rv).(map[int16]int8), false, d) } } -func (f fastpathT) DecMapStringBoolX(vp *map[string]bool, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]bool, decInferLen(containerLen, d.h.MaxInitLen, 17)) - } - if containerLen != 0 { - f.DecMapStringBoolL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt16Int8X(vp *map[int16]int8, d *Decoder) { + v, changed := f.DecMapInt16Int8V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapStringBoolL(v map[string]bool, containerLen int, d *Decoder) { - var mk string - var mv bool +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) + v = make(map[int16]int8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int16 + var mv int8 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - mv = d.d.DecodeBool() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUintIntfR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]interface{})) = nil + +func (d *Decoder) fastpathDecMapInt16Int16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int16]int16) + v, changed := fastpathTV.DecMapInt16Int16V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]interface{}) - if *vp == nil { - *vp = make(map[uint]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapUintIntfL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintIntfL(rv2i(rv).(map[uint]interface{}), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt16Int16V(rv2i(rv).(map[int16]int16), false, d) } } -func (f fastpathT) DecMapUintIntfX(vp *map[uint]interface{}, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapUintIntfL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt16Int16X(vp *map[int16]int16, d *Decoder) { + v, changed := f.DecMapInt16Int16V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUintIntfL(v map[uint]interface{}, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset - var mk uint - var mv interface{} +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) + v = make(map[int16]int16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int16 + var mv int16 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue } - d.decode(&mv) + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUintStringR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]string)) = nil + +func (d *Decoder) fastpathDecMapInt16Int32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int16]int32) + v, changed := fastpathTV.DecMapInt16Int32V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]string) - if *vp == nil { - *vp = make(map[uint]string, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapUintStringL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintStringL(rv2i(rv).(map[uint]string), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt16Int32V(rv2i(rv).(map[int16]int32), false, d) } } -func (f fastpathT) DecMapUintStringX(vp *map[uint]string, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]string, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapUintStringL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt16Int32X(vp *map[int16]int32, d *Decoder) { + v, changed := f.DecMapInt16Int32V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUintStringL(v map[uint]string, containerLen int, d *Decoder) { - var mk uint - var mv string +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) + v = make(map[int16]int32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int16 + var mv int32 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - mv = string(d.d.DecodeStringAsBytes()) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUintBytesR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint][]byte)) = nil + +func (d *Decoder) fastpathDecMapInt16Int64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int16]int64) + v, changed := fastpathTV.DecMapInt16Int64V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint][]byte) - if *vp == nil { - *vp = make(map[uint][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - fastpathTV.DecMapUintBytesL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintBytesL(rv2i(rv).(map[uint][]byte), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt16Int64V(rv2i(rv).(map[int16]int64), false, d) } } -func (f fastpathT) DecMapUintBytesX(vp *map[uint][]byte, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - f.DecMapUintBytesL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt16Int64X(vp *map[int16]int64, d *Decoder) { + v, changed := f.DecMapInt16Int64V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUintBytesL(v map[uint][]byte, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset - var mk uint - var mv []byte +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) + v = make(map[int16]int64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int16 + var mv int64 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue } - mv = d.d.DecodeBytes(mv, false) + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUintUintR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]uint)) = nil + +func (d *Decoder) fastpathDecMapInt16Float32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int16]float32) + v, changed := fastpathTV.DecMapInt16Float32V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]uint) - if *vp == nil { - *vp = make(map[uint]uint, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUintUintL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintUintL(rv2i(rv).(map[uint]uint), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt16Float32V(rv2i(rv).(map[int16]float32), false, d) } } -func (f fastpathT) DecMapUintUintX(vp *map[uint]uint, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]uint, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUintUintL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt16Float32X(vp *map[int16]float32, d *Decoder) { + v, changed := f.DecMapInt16Float32V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUintUintL(v map[uint]uint, containerLen int, d *Decoder) { - var mk uint - var mv uint +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) + v = make(map[int16]float32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int16 + var mv float32 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - mv = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUintUint8R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]uint8)) = nil + +func (d *Decoder) fastpathDecMapInt16Float64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int16]float64) + v, changed := fastpathTV.DecMapInt16Float64V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]uint8) - if *vp == nil { - *vp = make(map[uint]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapUintUint8L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintUint8L(rv2i(rv).(map[uint]uint8), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt16Float64V(rv2i(rv).(map[int16]float64), false, d) } } -func (f fastpathT) DecMapUintUint8X(vp *map[uint]uint8, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapUintUint8L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt16Float64X(vp *map[int16]float64, d *Decoder) { + v, changed := f.DecMapInt16Float64V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUintUint8L(v map[uint]uint8, containerLen int, d *Decoder) { - var mk uint - var mv uint8 +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) + v = make(map[int16]float64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int16 + var mv float64 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - mv = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUintUint64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]uint64)) = nil + +func (d *Decoder) fastpathDecMapInt16BoolR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int16]bool) + v, changed := fastpathTV.DecMapInt16BoolV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]uint64) - if *vp == nil { - *vp = make(map[uint]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUintUint64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintUint64L(rv2i(rv).(map[uint]uint64), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt16BoolV(rv2i(rv).(map[int16]bool), false, d) } } -func (f fastpathT) DecMapUintUint64X(vp *map[uint]uint64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUintUint64L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt16BoolX(vp *map[int16]bool, d *Decoder) { + v, changed := f.DecMapInt16BoolV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUintUint64L(v map[uint]uint64, containerLen int, d *Decoder) { - var mk uint - var mv uint64 +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) + v = make(map[int16]bool, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int16 + var mv bool hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - mv = d.d.DecodeUint64() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = false + } + continue + } + mv = dd.DecodeBool() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUintIntR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]int)) = nil + +func (d *Decoder) fastpathDecMapInt32IntfR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int32]interface{}) + v, changed := fastpathTV.DecMapInt32IntfV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]int) - if *vp == nil { - *vp = make(map[uint]int, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUintIntL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintIntL(rv2i(rv).(map[uint]int), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt32IntfV(rv2i(rv).(map[int32]interface{}), false, d) } } -func (f fastpathT) DecMapUintIntX(vp *map[uint]int, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]int, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUintIntL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt32IntfX(vp *map[int32]interface{}, d *Decoder) { + v, changed := f.DecMapInt32IntfV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUintIntL(v map[uint]int, containerLen int, d *Decoder) { - var mk uint - var mv int +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) + v = make(map[int32]interface{}, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset + var mk int32 + var mv interface{} hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - mv = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - if v != nil { - v[mk] = mv + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = nil + } + continue } - } -} -func (d *Decoder) fastpathDecMapUintInt64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]int64)) = nil + if mapGet { + mv = v[mk] + } else { + mv = nil } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]int64) - if *vp == nil { - *vp = make(map[uint]int64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUintInt64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintInt64L(rv2i(rv).(map[uint]int64), containerLen, d) + d.decode(&mv) + if v != nil { + v[mk] = mv } - d.mapEnd() } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (f fastpathT) DecMapUintInt64X(vp *map[uint]int64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]int64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUintInt64L(*vp, containerLen, d) + +func (d *Decoder) fastpathDecMapInt32StringR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int32]string) + v, changed := fastpathTV.DecMapInt32StringV(*vp, true, d) + if changed { + *vp = v } - d.mapEnd() + } else { + fastpathTV.DecMapInt32StringV(rv2i(rv).(map[int32]string), false, d) } } -func (fastpathT) DecMapUintInt64L(v map[uint]int64, containerLen int, d *Decoder) { - var mk uint - var mv int64 +func (f fastpathT) DecMapInt32StringX(vp *map[int32]string, d *Decoder) { + 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) + v = make(map[int32]string, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int32 + var mv string hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - mv = d.d.DecodeInt64() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = "" + } + continue + } + mv = dd.DecodeString() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUintFloat32R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]float32)) = nil + +func (d *Decoder) fastpathDecMapInt32UintR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int32]uint) + v, changed := fastpathTV.DecMapInt32UintV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]float32) - if *vp == nil { - *vp = make(map[uint]float32, decInferLen(containerLen, d.h.MaxInitLen, 12)) - } - if containerLen != 0 { - fastpathTV.DecMapUintFloat32L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintFloat32L(rv2i(rv).(map[uint]float32), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt32UintV(rv2i(rv).(map[int32]uint), false, d) } } -func (f fastpathT) DecMapUintFloat32X(vp *map[uint]float32, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]float32, decInferLen(containerLen, d.h.MaxInitLen, 12)) - } - if containerLen != 0 { - f.DecMapUintFloat32L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt32UintX(vp *map[int32]uint, d *Decoder) { + v, changed := f.DecMapInt32UintV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUintFloat32L(v map[uint]float32, containerLen int, d *Decoder) { - var mk uint - var mv float32 +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) + v = make(map[int32]uint, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int32 + var mv uint hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - mv = float32(d.decodeFloat32()) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUintFloat64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]float64)) = nil + +func (d *Decoder) fastpathDecMapInt32Uint8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int32]uint8) + v, changed := fastpathTV.DecMapInt32Uint8V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]float64) - if *vp == nil { - *vp = make(map[uint]float64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUintFloat64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintFloat64L(rv2i(rv).(map[uint]float64), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt32Uint8V(rv2i(rv).(map[int32]uint8), false, d) } } -func (f fastpathT) DecMapUintFloat64X(vp *map[uint]float64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]float64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUintFloat64L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt32Uint8X(vp *map[int32]uint8, d *Decoder) { + v, changed := f.DecMapInt32Uint8V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUintFloat64L(v map[uint]float64, containerLen int, d *Decoder) { - var mk uint - var mv float64 +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) + v = make(map[int32]uint8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int32 + var mv uint8 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - mv = d.d.DecodeFloat64() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUintBoolR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]bool)) = nil + +func (d *Decoder) fastpathDecMapInt32Uint16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int32]uint16) + v, changed := fastpathTV.DecMapInt32Uint16V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]bool) - if *vp == nil { - *vp = make(map[uint]bool, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapUintBoolL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintBoolL(rv2i(rv).(map[uint]bool), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt32Uint16V(rv2i(rv).(map[int32]uint16), false, d) } } -func (f fastpathT) DecMapUintBoolX(vp *map[uint]bool, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]bool, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapUintBoolL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt32Uint16X(vp *map[int32]uint16, d *Decoder) { + v, changed := f.DecMapInt32Uint16V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUintBoolL(v map[uint]bool, containerLen int, d *Decoder) { - var mk uint - var mv bool +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) + v = make(map[int32]uint16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int32 + var mv uint16 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - mv = d.d.DecodeBool() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint8IntfR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]interface{})) = nil + +func (d *Decoder) fastpathDecMapInt32Uint32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int32]uint32) + v, changed := fastpathTV.DecMapInt32Uint32V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]interface{}) - if *vp == nil { - *vp = make(map[uint8]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 17)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8IntfL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8IntfL(rv2i(rv).(map[uint8]interface{}), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt32Uint32V(rv2i(rv).(map[int32]uint32), false, d) } } -func (f fastpathT) DecMapUint8IntfX(vp *map[uint8]interface{}, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 17)) - } - if containerLen != 0 { - f.DecMapUint8IntfL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt32Uint32X(vp *map[int32]uint32, d *Decoder) { + v, changed := f.DecMapInt32Uint32V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUint8IntfL(v map[uint8]interface{}, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset - var mk uint8 - var mv interface{} +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) + v = make(map[int32]uint32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int32 + var mv uint32 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue } - d.decode(&mv) + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint8StringR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]string)) = nil + +func (d *Decoder) fastpathDecMapInt32Uint64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int32]uint64) + v, changed := fastpathTV.DecMapInt32Uint64V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]string) - if *vp == nil { - *vp = make(map[uint8]string, decInferLen(containerLen, d.h.MaxInitLen, 17)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8StringL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8StringL(rv2i(rv).(map[uint8]string), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt32Uint64V(rv2i(rv).(map[int32]uint64), false, d) } } -func (f fastpathT) DecMapUint8StringX(vp *map[uint8]string, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]string, decInferLen(containerLen, d.h.MaxInitLen, 17)) - } - if containerLen != 0 { - f.DecMapUint8StringL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt32Uint64X(vp *map[int32]uint64, d *Decoder) { + v, changed := f.DecMapInt32Uint64V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUint8StringL(v map[uint8]string, containerLen int, d *Decoder) { - var mk uint8 - var mv string +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) + v = make(map[int32]uint64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int32 + var mv uint64 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - mv = string(d.d.DecodeStringAsBytes()) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint8BytesR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8][]byte)) = nil + +func (d *Decoder) fastpathDecMapInt32UintptrR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int32]uintptr) + v, changed := fastpathTV.DecMapInt32UintptrV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8][]byte) - if *vp == nil { - *vp = make(map[uint8][]byte, decInferLen(containerLen, d.h.MaxInitLen, 25)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8BytesL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8BytesL(rv2i(rv).(map[uint8][]byte), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt32UintptrV(rv2i(rv).(map[int32]uintptr), false, d) } } -func (f fastpathT) DecMapUint8BytesX(vp *map[uint8][]byte, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8][]byte, decInferLen(containerLen, d.h.MaxInitLen, 25)) - } - if containerLen != 0 { - f.DecMapUint8BytesL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt32UintptrX(vp *map[int32]uintptr, d *Decoder) { + v, changed := f.DecMapInt32UintptrV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUint8BytesL(v map[uint8][]byte, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset - var mk uint8 - var mv []byte +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) + v = make(map[int32]uintptr, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int32 + var mv uintptr hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue } - mv = d.d.DecodeBytes(mv, false) + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint8UintR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]uint)) = nil + +func (d *Decoder) fastpathDecMapInt32IntR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int32]int) + v, changed := fastpathTV.DecMapInt32IntV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]uint) - if *vp == nil { - *vp = make(map[uint8]uint, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8UintL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8UintL(rv2i(rv).(map[uint8]uint), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt32IntV(rv2i(rv).(map[int32]int), false, d) } } -func (f fastpathT) DecMapUint8UintX(vp *map[uint8]uint, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]uint, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapUint8UintL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt32IntX(vp *map[int32]int, d *Decoder) { + v, changed := f.DecMapInt32IntV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUint8UintL(v map[uint8]uint, containerLen int, d *Decoder) { - var mk uint8 - var mv uint +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) + v = make(map[int32]int, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int32 + var mv int hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - mv = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint8Uint8R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]uint8)) = nil + +func (d *Decoder) fastpathDecMapInt32Int8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int32]int8) + v, changed := fastpathTV.DecMapInt32Int8V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]uint8) - if *vp == nil { - *vp = make(map[uint8]uint8, decInferLen(containerLen, d.h.MaxInitLen, 2)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8Uint8L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8Uint8L(rv2i(rv).(map[uint8]uint8), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt32Int8V(rv2i(rv).(map[int32]int8), false, d) } } -func (f fastpathT) DecMapUint8Uint8X(vp *map[uint8]uint8, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]uint8, decInferLen(containerLen, d.h.MaxInitLen, 2)) - } - if containerLen != 0 { - f.DecMapUint8Uint8L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt32Int8X(vp *map[int32]int8, d *Decoder) { + v, changed := f.DecMapInt32Int8V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUint8Uint8L(v map[uint8]uint8, containerLen int, d *Decoder) { - var mk uint8 - var mv uint8 +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) + v = make(map[int32]int8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int32 + var mv int8 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - mv = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint8Uint64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]uint64)) = nil + +func (d *Decoder) fastpathDecMapInt32Int16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int32]int16) + v, changed := fastpathTV.DecMapInt32Int16V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]uint64) - if *vp == nil { - *vp = make(map[uint8]uint64, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8Uint64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8Uint64L(rv2i(rv).(map[uint8]uint64), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt32Int16V(rv2i(rv).(map[int32]int16), false, d) } } -func (f fastpathT) DecMapUint8Uint64X(vp *map[uint8]uint64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]uint64, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapUint8Uint64L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt32Int16X(vp *map[int32]int16, d *Decoder) { + v, changed := f.DecMapInt32Int16V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUint8Uint64L(v map[uint8]uint64, containerLen int, d *Decoder) { - var mk uint8 - var mv uint64 +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) + v = make(map[int32]int16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int32 + var mv int16 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - mv = d.d.DecodeUint64() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint8IntR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]int)) = nil + +func (d *Decoder) fastpathDecMapInt32Int32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int32]int32) + v, changed := fastpathTV.DecMapInt32Int32V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]int) - if *vp == nil { - *vp = make(map[uint8]int, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8IntL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8IntL(rv2i(rv).(map[uint8]int), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt32Int32V(rv2i(rv).(map[int32]int32), false, d) } } -func (f fastpathT) DecMapUint8IntX(vp *map[uint8]int, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]int, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapUint8IntL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt32Int32X(vp *map[int32]int32, d *Decoder) { + v, changed := f.DecMapInt32Int32V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUint8IntL(v map[uint8]int, containerLen int, d *Decoder) { - var mk uint8 - var mv int +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) + v = make(map[int32]int32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int32 + var mv int32 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - mv = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint8Int64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]int64)) = nil + +func (d *Decoder) fastpathDecMapInt32Int64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int32]int64) + v, changed := fastpathTV.DecMapInt32Int64V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]int64) - if *vp == nil { - *vp = make(map[uint8]int64, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8Int64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8Int64L(rv2i(rv).(map[uint8]int64), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt32Int64V(rv2i(rv).(map[int32]int64), false, d) } } -func (f fastpathT) DecMapUint8Int64X(vp *map[uint8]int64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]int64, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapUint8Int64L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt32Int64X(vp *map[int32]int64, d *Decoder) { + v, changed := f.DecMapInt32Int64V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUint8Int64L(v map[uint8]int64, containerLen int, d *Decoder) { - var mk uint8 +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) + v = make(map[int32]int64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int32 var mv int64 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - mv = d.d.DecodeInt64() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint8Float32R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]float32)) = nil + +func (d *Decoder) fastpathDecMapInt32Float32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int32]float32) + v, changed := fastpathTV.DecMapInt32Float32V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]float32) - if *vp == nil { - *vp = make(map[uint8]float32, decInferLen(containerLen, d.h.MaxInitLen, 5)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8Float32L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8Float32L(rv2i(rv).(map[uint8]float32), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt32Float32V(rv2i(rv).(map[int32]float32), false, d) } } -func (f fastpathT) DecMapUint8Float32X(vp *map[uint8]float32, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]float32, decInferLen(containerLen, d.h.MaxInitLen, 5)) - } - if containerLen != 0 { - f.DecMapUint8Float32L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt32Float32X(vp *map[int32]float32, d *Decoder) { + 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) + v = make(map[int32]float32, xlen) + changed = true } -} -func (fastpathT) DecMapUint8Float32L(v map[uint8]float32, containerLen int, d *Decoder) { - var mk uint8 + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int32 var mv float32 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - mv = float32(d.decodeFloat32()) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint8Float64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]float64)) = nil + +func (d *Decoder) fastpathDecMapInt32Float64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int32]float64) + v, changed := fastpathTV.DecMapInt32Float64V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]float64) - if *vp == nil { - *vp = make(map[uint8]float64, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8Float64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8Float64L(rv2i(rv).(map[uint8]float64), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt32Float64V(rv2i(rv).(map[int32]float64), false, d) } } -func (f fastpathT) DecMapUint8Float64X(vp *map[uint8]float64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]float64, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapUint8Float64L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt32Float64X(vp *map[int32]float64, d *Decoder) { + v, changed := f.DecMapInt32Float64V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUint8Float64L(v map[uint8]float64, containerLen int, d *Decoder) { - var mk uint8 +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) + v = make(map[int32]float64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int32 var mv float64 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - mv = d.d.DecodeFloat64() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint8BoolR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]bool)) = nil + +func (d *Decoder) fastpathDecMapInt32BoolR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int32]bool) + v, changed := fastpathTV.DecMapInt32BoolV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]bool) - if *vp == nil { - *vp = make(map[uint8]bool, decInferLen(containerLen, d.h.MaxInitLen, 2)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8BoolL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8BoolL(rv2i(rv).(map[uint8]bool), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt32BoolV(rv2i(rv).(map[int32]bool), false, d) } } -func (f fastpathT) DecMapUint8BoolX(vp *map[uint8]bool, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]bool, decInferLen(containerLen, d.h.MaxInitLen, 2)) - } - if containerLen != 0 { - f.DecMapUint8BoolL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt32BoolX(vp *map[int32]bool, d *Decoder) { + v, changed := f.DecMapInt32BoolV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUint8BoolL(v map[uint8]bool, containerLen int, d *Decoder) { - var mk uint8 +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) + v = make(map[int32]bool, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int32 var mv bool hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - mv = d.d.DecodeBool() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = false + } + continue + } + mv = dd.DecodeBool() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint64IntfR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]interface{})) = nil + +func (d *Decoder) fastpathDecMapInt64IntfR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int64]interface{}) + v, changed := fastpathTV.DecMapInt64IntfV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]interface{}) - if *vp == nil { - *vp = make(map[uint64]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64IntfL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64IntfL(rv2i(rv).(map[uint64]interface{}), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt64IntfV(rv2i(rv).(map[int64]interface{}), false, d) } } -func (f fastpathT) DecMapUint64IntfX(vp *map[uint64]interface{}, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapUint64IntfL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt64IntfX(vp *map[int64]interface{}, d *Decoder) { + v, changed := f.DecMapInt64IntfV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUint64IntfL(v map[uint64]interface{}, containerLen int, d *Decoder) { +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) + v = make(map[int64]interface{}, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset - var mk uint64 + var mk int64 var mv interface{} hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeInt64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = nil + } + continue + } if mapGet { mv = v[mk] } else { @@ -7349,1602 +31765,1904 @@ func (fastpathT) DecMapUint64IntfL(v map[uint64]interface{}, containerLen int, d v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint64StringR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]string)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]string) - if *vp == nil { - *vp = make(map[uint64]string, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64StringL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64StringL(rv2i(rv).(map[uint64]string), containerLen, d) + +func (d *Decoder) fastpathDecMapInt64StringR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int64]string) + v, changed := fastpathTV.DecMapInt64StringV(*vp, true, d) + if changed { + *vp = v } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint64StringX(vp *map[uint64]string, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil } else { - if *vp == nil { - *vp = make(map[uint64]string, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapUint64StringL(*vp, containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt64StringV(rv2i(rv).(map[int64]string), false, d) } } -func (fastpathT) DecMapUint64StringL(v map[uint64]string, containerLen int, d *Decoder) { - var mk uint64 - var mv string - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - mv = string(d.d.DecodeStringAsBytes()) - if v != nil { - v[mk] = mv - } +func (f fastpathT) DecMapInt64StringX(vp *map[int64]string, d *Decoder) { + v, changed := f.DecMapInt64StringV(*vp, true, d) + if changed { + *vp = v } } -func (d *Decoder) fastpathDecMapUint64BytesR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64][]byte)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64][]byte) - if *vp == nil { - *vp = make(map[uint64][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64BytesL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64BytesL(rv2i(rv).(map[uint64][]byte), containerLen, d) - } - d.mapEnd() +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) + v = make(map[int64]string, xlen) + changed = true } -} -func (f fastpathT) DecMapUint64BytesX(vp *map[uint64][]byte, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - f.DecMapUint64BytesL(*vp, containerLen, d) - } - d.mapEnd() + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed } -} -func (fastpathT) DecMapUint64BytesL(v map[uint64][]byte, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset - var mk uint64 - var mv []byte + d.depthIncr() + var mk int64 + var mv string hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeInt64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = "" + } + continue } - mv = d.d.DecodeBytes(mv, false) + mv = dd.DecodeString() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint64UintR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]uint)) = nil + +func (d *Decoder) fastpathDecMapInt64UintR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int64]uint) + v, changed := fastpathTV.DecMapInt64UintV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]uint) - if *vp == nil { - *vp = make(map[uint64]uint, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64UintL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64UintL(rv2i(rv).(map[uint64]uint), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt64UintV(rv2i(rv).(map[int64]uint), false, d) } } -func (f fastpathT) DecMapUint64UintX(vp *map[uint64]uint, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64]uint, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUint64UintL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt64UintX(vp *map[int64]uint, d *Decoder) { + v, changed := f.DecMapInt64UintV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUint64UintL(v map[uint64]uint, containerLen int, d *Decoder) { - var mk uint64 +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) + v = make(map[int64]uint, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int64 var mv uint hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - mv = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeInt64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint64Uint8R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]uint8)) = nil + +func (d *Decoder) fastpathDecMapInt64Uint8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int64]uint8) + v, changed := fastpathTV.DecMapInt64Uint8V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]uint8) - if *vp == nil { - *vp = make(map[uint64]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64Uint8L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64Uint8L(rv2i(rv).(map[uint64]uint8), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt64Uint8V(rv2i(rv).(map[int64]uint8), false, d) } } -func (f fastpathT) DecMapUint64Uint8X(vp *map[uint64]uint8, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapUint64Uint8L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt64Uint8X(vp *map[int64]uint8, d *Decoder) { + v, changed := f.DecMapInt64Uint8V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUint64Uint8L(v map[uint64]uint8, containerLen int, d *Decoder) { - var mk uint64 +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) + v = make(map[int64]uint8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int64 var mv uint8 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - mv = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeInt64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint64Uint64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]uint64)) = nil + +func (d *Decoder) fastpathDecMapInt64Uint16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int64]uint16) + v, changed := fastpathTV.DecMapInt64Uint16V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]uint64) - if *vp == nil { - *vp = make(map[uint64]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64Uint64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64Uint64L(rv2i(rv).(map[uint64]uint64), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt64Uint16V(rv2i(rv).(map[int64]uint16), false, d) } } -func (f fastpathT) DecMapUint64Uint64X(vp *map[uint64]uint64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUint64Uint64L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt64Uint16X(vp *map[int64]uint16, d *Decoder) { + v, changed := f.DecMapInt64Uint16V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUint64Uint64L(v map[uint64]uint64, containerLen int, d *Decoder) { - var mk uint64 - var mv uint64 +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) + v = make(map[int64]uint16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int64 + var mv uint16 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - mv = d.d.DecodeUint64() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeInt64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint64IntR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]int)) = nil + +func (d *Decoder) fastpathDecMapInt64Uint32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int64]uint32) + v, changed := fastpathTV.DecMapInt64Uint32V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]int) - if *vp == nil { - *vp = make(map[uint64]int, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64IntL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64IntL(rv2i(rv).(map[uint64]int), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt64Uint32V(rv2i(rv).(map[int64]uint32), false, d) } } -func (f fastpathT) DecMapUint64IntX(vp *map[uint64]int, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64]int, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUint64IntL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt64Uint32X(vp *map[int64]uint32, d *Decoder) { + v, changed := f.DecMapInt64Uint32V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUint64IntL(v map[uint64]int, containerLen int, d *Decoder) { - var mk uint64 - var mv int +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) + v = make(map[int64]uint32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int64 + var mv uint32 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - mv = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeInt64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint64Int64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]int64)) = nil + +func (d *Decoder) fastpathDecMapInt64Uint64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int64]uint64) + v, changed := fastpathTV.DecMapInt64Uint64V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]int64) - if *vp == nil { - *vp = make(map[uint64]int64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64Int64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64Int64L(rv2i(rv).(map[uint64]int64), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt64Uint64V(rv2i(rv).(map[int64]uint64), false, d) } } -func (f fastpathT) DecMapUint64Int64X(vp *map[uint64]int64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64]int64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUint64Int64L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt64Uint64X(vp *map[int64]uint64, d *Decoder) { + v, changed := f.DecMapInt64Uint64V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUint64Int64L(v map[uint64]int64, containerLen int, d *Decoder) { - var mk uint64 - var mv int64 +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) + v = make(map[int64]uint64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int64 + var mv uint64 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - mv = d.d.DecodeInt64() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeInt64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint64Float32R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]float32)) = nil + +func (d *Decoder) fastpathDecMapInt64UintptrR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int64]uintptr) + v, changed := fastpathTV.DecMapInt64UintptrV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]float32) - if *vp == nil { - *vp = make(map[uint64]float32, decInferLen(containerLen, d.h.MaxInitLen, 12)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64Float32L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64Float32L(rv2i(rv).(map[uint64]float32), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt64UintptrV(rv2i(rv).(map[int64]uintptr), false, d) } } -func (f fastpathT) DecMapUint64Float32X(vp *map[uint64]float32, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64]float32, decInferLen(containerLen, d.h.MaxInitLen, 12)) - } - if containerLen != 0 { - f.DecMapUint64Float32L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt64UintptrX(vp *map[int64]uintptr, d *Decoder) { + v, changed := f.DecMapInt64UintptrV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUint64Float32L(v map[uint64]float32, containerLen int, d *Decoder) { - var mk uint64 - var mv float32 +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) + v = make(map[int64]uintptr, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int64 + var mv uintptr hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - mv = float32(d.decodeFloat32()) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeInt64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint64Float64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]float64)) = nil + +func (d *Decoder) fastpathDecMapInt64IntR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int64]int) + v, changed := fastpathTV.DecMapInt64IntV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]float64) - if *vp == nil { - *vp = make(map[uint64]float64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64Float64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64Float64L(rv2i(rv).(map[uint64]float64), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt64IntV(rv2i(rv).(map[int64]int), false, d) } } -func (f fastpathT) DecMapUint64Float64X(vp *map[uint64]float64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64]float64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUint64Float64L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt64IntX(vp *map[int64]int, d *Decoder) { + 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) + v = make(map[int64]int, xlen) + changed = true } -} -func (fastpathT) DecMapUint64Float64L(v map[uint64]float64, containerLen int, d *Decoder) { - var mk uint64 - var mv float64 + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int64 + var mv int hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - mv = d.d.DecodeFloat64() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeInt64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapUint64BoolR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]bool)) = nil + +func (d *Decoder) fastpathDecMapInt64Int8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int64]int8) + v, changed := fastpathTV.DecMapInt64Int8V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]bool) - if *vp == nil { - *vp = make(map[uint64]bool, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64BoolL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64BoolL(rv2i(rv).(map[uint64]bool), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt64Int8V(rv2i(rv).(map[int64]int8), false, d) } } -func (f fastpathT) DecMapUint64BoolX(vp *map[uint64]bool, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64]bool, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapUint64BoolL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt64Int8X(vp *map[int64]int8, d *Decoder) { + v, changed := f.DecMapInt64Int8V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapUint64BoolL(v map[uint64]bool, containerLen int, d *Decoder) { - var mk uint64 - var mv bool +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) + v = make(map[int64]int8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int64 + var mv int8 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - mv = d.d.DecodeBool() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeInt64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapIntIntfR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]interface{})) = nil + +func (d *Decoder) fastpathDecMapInt64Int16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int64]int16) + v, changed := fastpathTV.DecMapInt64Int16V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]interface{}) - if *vp == nil { - *vp = make(map[int]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapIntIntfL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntIntfL(rv2i(rv).(map[int]interface{}), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt64Int16V(rv2i(rv).(map[int64]int16), false, d) } } -func (f fastpathT) DecMapIntIntfX(vp *map[int]interface{}, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapIntIntfL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt64Int16X(vp *map[int64]int16, d *Decoder) { + v, changed := f.DecMapInt64Int16V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapIntIntfL(v map[int]interface{}, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset - var mk int - var mv interface{} +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) + v = make(map[int64]int16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int64 + var mv int16 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeInt64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue } - d.decode(&mv) + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapIntStringR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]string)) = nil + +func (d *Decoder) fastpathDecMapInt64Int32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int64]int32) + v, changed := fastpathTV.DecMapInt64Int32V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]string) - if *vp == nil { - *vp = make(map[int]string, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapIntStringL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntStringL(rv2i(rv).(map[int]string), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt64Int32V(rv2i(rv).(map[int64]int32), false, d) } } -func (f fastpathT) DecMapIntStringX(vp *map[int]string, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int]string, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapIntStringL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt64Int32X(vp *map[int64]int32, d *Decoder) { + v, changed := f.DecMapInt64Int32V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapIntStringL(v map[int]string, containerLen int, d *Decoder) { - var mk int - var mv string +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) + v = make(map[int64]int32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int64 + var mv int32 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - mv = string(d.d.DecodeStringAsBytes()) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeInt64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapIntBytesR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int][]byte)) = nil + +func (d *Decoder) fastpathDecMapInt64Int64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int64]int64) + v, changed := fastpathTV.DecMapInt64Int64V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int][]byte) - if *vp == nil { - *vp = make(map[int][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - fastpathTV.DecMapIntBytesL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntBytesL(rv2i(rv).(map[int][]byte), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt64Int64V(rv2i(rv).(map[int64]int64), false, d) } } -func (f fastpathT) DecMapIntBytesX(vp *map[int][]byte, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - f.DecMapIntBytesL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt64Int64X(vp *map[int64]int64, d *Decoder) { + v, changed := f.DecMapInt64Int64V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapIntBytesL(v map[int][]byte, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset - var mk int - var mv []byte +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) + v = make(map[int64]int64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int64 + var mv int64 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeInt64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue } - mv = d.d.DecodeBytes(mv, false) + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapIntUintR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]uint)) = nil + +func (d *Decoder) fastpathDecMapInt64Float32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int64]float32) + v, changed := fastpathTV.DecMapInt64Float32V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]uint) - if *vp == nil { - *vp = make(map[int]uint, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapIntUintL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntUintL(rv2i(rv).(map[int]uint), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt64Float32V(rv2i(rv).(map[int64]float32), false, d) } } -func (f fastpathT) DecMapIntUintX(vp *map[int]uint, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int]uint, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapIntUintL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt64Float32X(vp *map[int64]float32, d *Decoder) { + v, changed := f.DecMapInt64Float32V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapIntUintL(v map[int]uint, containerLen int, d *Decoder) { - var mk int - var mv uint +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) + v = make(map[int64]float32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int64 + var mv float32 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - mv = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeInt64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapIntUint8R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]uint8)) = nil + +func (d *Decoder) fastpathDecMapInt64Float64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int64]float64) + v, changed := fastpathTV.DecMapInt64Float64V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]uint8) - if *vp == nil { - *vp = make(map[int]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapIntUint8L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntUint8L(rv2i(rv).(map[int]uint8), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt64Float64V(rv2i(rv).(map[int64]float64), false, d) } } -func (f fastpathT) DecMapIntUint8X(vp *map[int]uint8, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapIntUint8L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt64Float64X(vp *map[int64]float64, d *Decoder) { + v, changed := f.DecMapInt64Float64V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapIntUint8L(v map[int]uint8, containerLen int, d *Decoder) { - var mk int - var mv uint8 +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) + v = make(map[int64]float64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int64 + var mv float64 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - mv = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeInt64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapIntUint64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]uint64)) = nil + +func (d *Decoder) fastpathDecMapInt64BoolR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[int64]bool) + v, changed := fastpathTV.DecMapInt64BoolV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]uint64) - if *vp == nil { - *vp = make(map[int]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapIntUint64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntUint64L(rv2i(rv).(map[int]uint64), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapInt64BoolV(rv2i(rv).(map[int64]bool), false, d) } } -func (f fastpathT) DecMapIntUint64X(vp *map[int]uint64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapIntUint64L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapInt64BoolX(vp *map[int64]bool, d *Decoder) { + v, changed := f.DecMapInt64BoolV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapIntUint64L(v map[int]uint64, containerLen int, d *Decoder) { - var mk int - var mv uint64 +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) + v = make(map[int64]bool, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk int64 + var mv bool hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - mv = d.d.DecodeUint64() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeInt64() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = false + } + continue + } + mv = dd.DecodeBool() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapIntIntR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]int)) = nil + +func (d *Decoder) fastpathDecMapBoolIntfR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[bool]interface{}) + v, changed := fastpathTV.DecMapBoolIntfV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]int) - if *vp == nil { - *vp = make(map[int]int, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapIntIntL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntIntL(rv2i(rv).(map[int]int), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapBoolIntfV(rv2i(rv).(map[bool]interface{}), false, d) } } -func (f fastpathT) DecMapIntIntX(vp *map[int]int, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int]int, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapIntIntL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapBoolIntfX(vp *map[bool]interface{}, d *Decoder) { + v, changed := f.DecMapBoolIntfV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapIntIntL(v map[int]int, containerLen int, d *Decoder) { - var mk int - var mv int +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) + v = make(map[bool]interface{}, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset + var mk bool + var mv interface{} hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - mv = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeBool() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = nil + } + continue + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } + d.decode(&mv) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapIntInt64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]int64)) = nil + +func (d *Decoder) fastpathDecMapBoolStringR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[bool]string) + v, changed := fastpathTV.DecMapBoolStringV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]int64) - if *vp == nil { - *vp = make(map[int]int64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapIntInt64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntInt64L(rv2i(rv).(map[int]int64), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapBoolStringV(rv2i(rv).(map[bool]string), false, d) } } -func (f fastpathT) DecMapIntInt64X(vp *map[int]int64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int]int64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapIntInt64L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapBoolStringX(vp *map[bool]string, d *Decoder) { + v, changed := f.DecMapBoolStringV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapIntInt64L(v map[int]int64, containerLen int, d *Decoder) { - var mk int - var mv int64 +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) + v = make(map[bool]string, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk bool + var mv string hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - mv = d.d.DecodeInt64() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeBool() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = "" + } + continue + } + mv = dd.DecodeString() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapIntFloat32R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]float32)) = nil + +func (d *Decoder) fastpathDecMapBoolUintR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[bool]uint) + v, changed := fastpathTV.DecMapBoolUintV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]float32) - if *vp == nil { - *vp = make(map[int]float32, decInferLen(containerLen, d.h.MaxInitLen, 12)) - } - if containerLen != 0 { - fastpathTV.DecMapIntFloat32L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntFloat32L(rv2i(rv).(map[int]float32), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapBoolUintV(rv2i(rv).(map[bool]uint), false, d) } } -func (f fastpathT) DecMapIntFloat32X(vp *map[int]float32, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int]float32, decInferLen(containerLen, d.h.MaxInitLen, 12)) - } - if containerLen != 0 { - f.DecMapIntFloat32L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapBoolUintX(vp *map[bool]uint, d *Decoder) { + v, changed := f.DecMapBoolUintV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapIntFloat32L(v map[int]float32, containerLen int, d *Decoder) { - var mk int - var mv float32 +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) + v = make(map[bool]uint, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk bool + var mv uint hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - mv = float32(d.decodeFloat32()) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeBool() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapIntFloat64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]float64)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]float64) - if *vp == nil { - *vp = make(map[int]float64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapIntFloat64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntFloat64L(rv2i(rv).(map[int]float64), containerLen, d) + +func (d *Decoder) fastpathDecMapBoolUint8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[bool]uint8) + v, changed := fastpathTV.DecMapBoolUint8V(*vp, true, d) + if changed { + *vp = v } - d.mapEnd() - } -} -func (f fastpathT) DecMapIntFloat64X(vp *map[int]float64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil } else { - if *vp == nil { - *vp = make(map[int]float64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapIntFloat64L(*vp, containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapBoolUint8V(rv2i(rv).(map[bool]uint8), false, d) } } -func (fastpathT) DecMapIntFloat64L(v map[int]float64, containerLen int, d *Decoder) { - var mk int - var mv float64 +func (f fastpathT) DecMapBoolUint8X(vp *map[bool]uint8, d *Decoder) { + 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) + v = make(map[bool]uint8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk bool + var mv uint8 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - mv = d.d.DecodeFloat64() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeBool() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapIntBoolR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]bool)) = nil + +func (d *Decoder) fastpathDecMapBoolUint16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[bool]uint16) + v, changed := fastpathTV.DecMapBoolUint16V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]bool) - if *vp == nil { - *vp = make(map[int]bool, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapIntBoolL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntBoolL(rv2i(rv).(map[int]bool), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapBoolUint16V(rv2i(rv).(map[bool]uint16), false, d) } } -func (f fastpathT) DecMapIntBoolX(vp *map[int]bool, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int]bool, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapIntBoolL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapBoolUint16X(vp *map[bool]uint16, d *Decoder) { + v, changed := f.DecMapBoolUint16V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapIntBoolL(v map[int]bool, containerLen int, d *Decoder) { - var mk int - var mv bool +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) + v = make(map[bool]uint16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk bool + var mv uint16 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - mv = d.d.DecodeBool() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeBool() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapInt64IntfR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]interface{})) = nil + +func (d *Decoder) fastpathDecMapBoolUint32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[bool]uint32) + v, changed := fastpathTV.DecMapBoolUint32V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]interface{}) - if *vp == nil { - *vp = make(map[int64]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64IntfL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64IntfL(rv2i(rv).(map[int64]interface{}), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapBoolUint32V(rv2i(rv).(map[bool]uint32), false, d) } } -func (f fastpathT) DecMapInt64IntfX(vp *map[int64]interface{}, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapInt64IntfL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapBoolUint32X(vp *map[bool]uint32, d *Decoder) { + v, changed := f.DecMapBoolUint32V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapInt64IntfL(v map[int64]interface{}, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset - var mk int64 - var mv interface{} +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) + v = make(map[bool]uint32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk bool + var mv uint32 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeBool() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue } - d.decode(&mv) + mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapInt64StringR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]string)) = nil + +func (d *Decoder) fastpathDecMapBoolUint64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[bool]uint64) + v, changed := fastpathTV.DecMapBoolUint64V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]string) - if *vp == nil { - *vp = make(map[int64]string, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64StringL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64StringL(rv2i(rv).(map[int64]string), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapBoolUint64V(rv2i(rv).(map[bool]uint64), false, d) } } -func (f fastpathT) DecMapInt64StringX(vp *map[int64]string, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]string, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapInt64StringL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapBoolUint64X(vp *map[bool]uint64, d *Decoder) { + v, changed := f.DecMapBoolUint64V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapInt64StringL(v map[int64]string, containerLen int, d *Decoder) { - var mk int64 - var mv string +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) + v = make(map[bool]uint64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk bool + var mv uint64 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - mv = string(d.d.DecodeStringAsBytes()) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeBool() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeUint64() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapInt64BytesR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64][]byte)) = nil + +func (d *Decoder) fastpathDecMapBoolUintptrR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[bool]uintptr) + v, changed := fastpathTV.DecMapBoolUintptrV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64][]byte) - if *vp == nil { - *vp = make(map[int64][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64BytesL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64BytesL(rv2i(rv).(map[int64][]byte), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapBoolUintptrV(rv2i(rv).(map[bool]uintptr), false, d) } } -func (f fastpathT) DecMapInt64BytesX(vp *map[int64][]byte, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - f.DecMapInt64BytesL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapBoolUintptrX(vp *map[bool]uintptr, d *Decoder) { + v, changed := f.DecMapBoolUintptrV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapInt64BytesL(v map[int64][]byte, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset - var mk int64 - var mv []byte +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) + v = make(map[bool]uintptr, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk bool + var mv uintptr hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeBool() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue } - mv = d.d.DecodeBytes(mv, false) + mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapInt64UintR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]uint)) = nil + +func (d *Decoder) fastpathDecMapBoolIntR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[bool]int) + v, changed := fastpathTV.DecMapBoolIntV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]uint) - if *vp == nil { - *vp = make(map[int64]uint, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64UintL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64UintL(rv2i(rv).(map[int64]uint), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapBoolIntV(rv2i(rv).(map[bool]int), false, d) } } -func (f fastpathT) DecMapInt64UintX(vp *map[int64]uint, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]uint, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapInt64UintL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapBoolIntX(vp *map[bool]int, d *Decoder) { + v, changed := f.DecMapBoolIntV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapInt64UintL(v map[int64]uint, containerLen int, d *Decoder) { - var mk int64 - var mv uint +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) + v = make(map[bool]int, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk bool + var mv int hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - mv = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeBool() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapInt64Uint8R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]uint8)) = nil + +func (d *Decoder) fastpathDecMapBoolInt8R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[bool]int8) + v, changed := fastpathTV.DecMapBoolInt8V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]uint8) - if *vp == nil { - *vp = make(map[int64]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64Uint8L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64Uint8L(rv2i(rv).(map[int64]uint8), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapBoolInt8V(rv2i(rv).(map[bool]int8), false, d) } } -func (f fastpathT) DecMapInt64Uint8X(vp *map[int64]uint8, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapInt64Uint8L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapBoolInt8X(vp *map[bool]int8, d *Decoder) { + v, changed := f.DecMapBoolInt8V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapInt64Uint8L(v map[int64]uint8, containerLen int, d *Decoder) { - var mk int64 - var mv uint8 +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) + v = make(map[bool]int8, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk bool + var mv int8 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - mv = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeBool() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapInt64Uint64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]uint64)) = nil + +func (d *Decoder) fastpathDecMapBoolInt16R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[bool]int16) + v, changed := fastpathTV.DecMapBoolInt16V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]uint64) - if *vp == nil { - *vp = make(map[int64]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64Uint64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64Uint64L(rv2i(rv).(map[int64]uint64), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapBoolInt16V(rv2i(rv).(map[bool]int16), false, d) } } -func (f fastpathT) DecMapInt64Uint64X(vp *map[int64]uint64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapInt64Uint64L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapBoolInt16X(vp *map[bool]int16, d *Decoder) { + v, changed := f.DecMapBoolInt16V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapInt64Uint64L(v map[int64]uint64, containerLen int, d *Decoder) { - var mk int64 - var mv uint64 +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) + v = make(map[bool]int16, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk bool + var mv int16 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - mv = d.d.DecodeUint64() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeBool() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapInt64IntR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]int)) = nil + +func (d *Decoder) fastpathDecMapBoolInt32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[bool]int32) + v, changed := fastpathTV.DecMapBoolInt32V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]int) - if *vp == nil { - *vp = make(map[int64]int, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64IntL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64IntL(rv2i(rv).(map[int64]int), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapBoolInt32V(rv2i(rv).(map[bool]int32), false, d) } } -func (f fastpathT) DecMapInt64IntX(vp *map[int64]int, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]int, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapInt64IntL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapBoolInt32X(vp *map[bool]int32, d *Decoder) { + v, changed := f.DecMapBoolInt32V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapInt64IntL(v map[int64]int, containerLen int, d *Decoder) { - var mk int64 - var mv int +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) + v = make(map[bool]int32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk bool + var mv int32 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - mv = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeBool() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32)) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapInt64Int64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]int64)) = nil + +func (d *Decoder) fastpathDecMapBoolInt64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[bool]int64) + v, changed := fastpathTV.DecMapBoolInt64V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]int64) - if *vp == nil { - *vp = make(map[int64]int64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64Int64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64Int64L(rv2i(rv).(map[int64]int64), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapBoolInt64V(rv2i(rv).(map[bool]int64), false, d) } } -func (f fastpathT) DecMapInt64Int64X(vp *map[int64]int64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]int64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapInt64Int64L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapBoolInt64X(vp *map[bool]int64, d *Decoder) { + v, changed := f.DecMapBoolInt64V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapInt64Int64L(v map[int64]int64, containerLen int, d *Decoder) { - var mk int64 +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) + v = make(map[bool]int64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk bool var mv int64 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - mv = d.d.DecodeInt64() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeBool() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeInt64() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapInt64Float32R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]float32)) = nil + +func (d *Decoder) fastpathDecMapBoolFloat32R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[bool]float32) + v, changed := fastpathTV.DecMapBoolFloat32V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]float32) - if *vp == nil { - *vp = make(map[int64]float32, decInferLen(containerLen, d.h.MaxInitLen, 12)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64Float32L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64Float32L(rv2i(rv).(map[int64]float32), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapBoolFloat32V(rv2i(rv).(map[bool]float32), false, d) } } -func (f fastpathT) DecMapInt64Float32X(vp *map[int64]float32, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]float32, decInferLen(containerLen, d.h.MaxInitLen, 12)) - } - if containerLen != 0 { - f.DecMapInt64Float32L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapBoolFloat32X(vp *map[bool]float32, d *Decoder) { + v, changed := f.DecMapBoolFloat32V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapInt64Float32L(v map[int64]float32, containerLen int, d *Decoder) { - var mk int64 +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) + v = make(map[bool]float32, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk bool var mv float32 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - mv = float32(d.decodeFloat32()) + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeBool() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = float32(chkOvf.Float32V(dd.DecodeFloat64())) if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapInt64Float64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]float64)) = nil + +func (d *Decoder) fastpathDecMapBoolFloat64R(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[bool]float64) + v, changed := fastpathTV.DecMapBoolFloat64V(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]float64) - if *vp == nil { - *vp = make(map[int64]float64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64Float64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64Float64L(rv2i(rv).(map[int64]float64), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapBoolFloat64V(rv2i(rv).(map[bool]float64), false, d) } } -func (f fastpathT) DecMapInt64Float64X(vp *map[int64]float64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]float64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapInt64Float64L(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapBoolFloat64X(vp *map[bool]float64, d *Decoder) { + v, changed := f.DecMapBoolFloat64V(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapInt64Float64L(v map[int64]float64, containerLen int, d *Decoder) { - var mk int64 +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) + v = make(map[bool]float64, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk bool var mv float64 hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - mv = d.d.DecodeFloat64() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeBool() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = 0 + } + continue + } + mv = dd.DecodeFloat64() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } -func (d *Decoder) fastpathDecMapInt64BoolR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]bool)) = nil + +func (d *Decoder) fastpathDecMapBoolBoolR(f *codecFnInfo, rv reflect.Value) { + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[bool]bool) + v, changed := fastpathTV.DecMapBoolBoolV(*vp, true, d) + if changed { + *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]bool) - if *vp == nil { - *vp = make(map[int64]bool, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64BoolL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64BoolL(rv2i(rv).(map[int64]bool), containerLen, d) - } - d.mapEnd() + fastpathTV.DecMapBoolBoolV(rv2i(rv).(map[bool]bool), false, d) } } -func (f fastpathT) DecMapInt64BoolX(vp *map[int64]bool, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]bool, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapInt64BoolL(*vp, containerLen, d) - } - d.mapEnd() +func (f fastpathT) DecMapBoolBoolX(vp *map[bool]bool, d *Decoder) { + v, changed := f.DecMapBoolBoolV(*vp, true, d) + if changed { + *vp = v } } -func (fastpathT) DecMapInt64BoolL(v map[int64]bool, containerLen int, d *Decoder) { - var mk int64 +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) + v = make(map[bool]bool, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + var mk bool var mv bool hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - mv = d.d.DecodeBool() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { + dd.ReadMapElemKey() + } + mk = dd.DecodeBool() + if esep { + dd.ReadMapElemValue() + } + if dd.TryDecodeAsNil() { + if v == nil { + } else if d.h.DeleteOnNilMapValue { + delete(v, mk) + } else { + v[mk] = false + } + continue + } + mv = dd.DecodeBool() if v != nil { v[mk] = mv } } + dd.ReadMapEnd() + d.depthDecr() + return v, changed } 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 537f069d60af..7617c4350642 100644 --- a/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl +++ b/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl @@ -10,7 +10,7 @@ package codec // Fast path functions try to create a fast path encode or decode implementation // for common maps and slices. // -// We define the functions and register them in this single file +// We define the functions and register then in this single file // so as not to pollute the encode.go and decode.go, and create a dependency in there. // This file can be omitted without causing a build failure. // @@ -18,10 +18,9 @@ package codec // - Many calls bypass reflection altogether // // Currently support -// - slice of all builtin types (numeric, bool, string, []byte) -// - maps of builtin types to builtin or interface{} type, EXCEPT FOR -// keys of type uintptr, int8/16/32, uint16/32, float32/64, bool, interface{} -// AND values of type type int8/16/32, uint16/32 +// - 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. @@ -31,24 +30,6 @@ package codec // // decoding into p2 will bomb if fast track functions do not treat like unaddressable. // -{{/* -fastpathEncMapStringUint64R (called by fastpath...switch) -EncMapStringUint64V (called by codecgen) - -fastpathEncSliceBoolR: (called by fastpath...switch) (checks f.ti.mbs and calls one of them below) -EncSliceBoolV (also called by codecgen) -EncAsMapSliceBoolV (delegate when mapbyslice=true) - -fastpathDecSliceIntfR (called by fastpath...switch) (calls Y or N below depending on if it can be updated) -DecSliceIntfX (called by codecgen) (calls Y below) -DecSliceIntfY (delegate when slice CAN be updated) -DecSliceIntfN (delegate when slice CANNOT be updated e.g. from array or non-addressable slice) - -fastpathDecMap...R (called by fastpath...switch) (calls L or X? below) -DecMap...X (called by codecgen) -DecMap...L (delegated to by both above) -*/ -}} - import ( "reflect" "sort" @@ -113,13 +94,11 @@ func init() { i++ } {{/* 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 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}} + {{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}} sort.Sort(fastpathAslice(fastpathAV[:])) } @@ -129,28 +108,60 @@ 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 }}{{if ne .Elem "uint8" -}} + +{{range .Values}}{{if not .Primitive}}{{if not .MapKey }}{{if ne .Elem "uint8"}} case []{{ .Elem }}: fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, e) case *[]{{ .Elem }}: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e) - } -{{end}}{{end}}{{end}}{{end -}} + fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e){{/* +*/}}{{end}}{{end}}{{end}}{{end}} -{{range .Values}}{{if not .Primitive}}{{if .MapKey -}} +{{range .Values}}{{if not .Primitive}}{{if .MapKey }} case map[{{ .MapKey }}]{{ .Elem }}: fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, e) case *map[{{ .MapKey }}]{{ .Elem }}: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e) - } -{{end}}{{end}}{{end -}} + fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e){{/* +*/}}{{end}}{{end}}{{end}} + + default: + _ = 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 }} + case []{{ .Elem }}: + fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, e) + case *[]{{ .Elem }}: + fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e) +{{end}}{{end}}{{end}} + default: + _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 + return false + } + return true +} +func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { + switch v := iv.(type) { +{{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 // workaround https://github.com/golang/go/issues/12927 seen in go1.4 return false @@ -158,8 +169,17 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { 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 -}} +{{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) @@ -167,48 +187,52 @@ func (e *Encoder) {{ .MethodNamePfx "fastpathEnc" false }}R(f *codecFnInfo, rv r fastpathTV.{{ .MethodNamePfx "Enc" false }}V(rv2i(rv).([]{{ .Elem }}), e) } } -func (fastpathT) {{ .MethodNamePfx "Enc" false }}V(v []{{ .Elem }}, e *Encoder) { - {{/* if v == nil { e.e.EncodeNil(); return } */ -}} - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - {{ encmd .Elem "v[j]"}} +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)) + for _, v2 := range v { + if esep { ee.WriteArrayElem() } + {{ encmd .Elem "v2"}} } - e.arrayEnd() + ee.WriteArrayEnd() } -func (fastpathT) {{ .MethodNamePfx "EncAsMap" false }}V(v []{{ .Elem }}, e *Encoder) { - {{/* if v == nil { e.e.EncodeNil() } else */ -}} +func (_ fastpathT) {{ .MethodNamePfx "EncAsMap" false }}V(v []{{ .Elem }}, e *Encoder) { + ee, esep := e.e, e.hh.hasElemSeparators() if len(v)%2 == 1 { e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { + return + } + ee.WriteMapStart(len(v) / 2) + for j, v2 := range v { + if esep { if j%2 == 0 { - e.mapElemKey() + ee.WriteMapElemKey() } else { - e.mapElemValue() + ee.WriteMapElemValue() } - {{ encmd .Elem "v[j]"}} - } - e.mapEnd() + } + {{ encmd .Elem "v2"}} } + ee.WriteMapEnd() } -{{end}}{{end}}{{end -}} +{{end}}{{end}}{{end}} -{{range .Values}}{{if not .Primitive}}{{if .MapKey -}} +{{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 } */ -}} - e.mapStart(len(v)) - if e.h.Canonical { {{/* need to figure out .NoCanonical */}} - {{if eq .MapKey "interface{}"}}{{/* out of band */ -}} - var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding +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 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) - v2 := make([]bytesIntf, len(v)) - var i, l uint {{/* put loop variables outside. seems currently needed for better perf */}} - var vp *bytesIntf + v2 := make([]bytesI, len(v)) + var i, l uint + var vp *bytesI {{/* put loop variables outside. seems currently needed for better perf */}} for k2 := range v { l = uint(len(mksv)) e2.MustEncode(k2) @@ -217,81 +241,69 @@ func (fastpathT) {{ .MethodNamePfx "Enc" false }}V(v map[{{ .MapKey }}]{{ .Elem vp.i = k2 i++ } - sort.Sort(bytesIntfSlice(v2)) + sort.Sort(bytesISlice(v2)) for j := range v2 { - e.mapElemKey() + if esep { ee.WriteMapElemKey() } e.asis(v2[j].v) - e.mapElemValue() + if esep { ee.WriteMapElemValue() } e.encode(v[v2[j].i]) } {{else}}{{ $x := sorttype .MapKey true}}v2 := make([]{{ $x }}, len(v)) var i uint for k := range v { - v2[i] = {{if eq $x .MapKey}}k{{else}}{{ $x }}(k){{end}} + v2[i] = {{ $x }}(k) i++ } sort.Sort({{ sorttype .MapKey false}}(v2)) for _, k2 := range v2 { - e.mapElemKey() - {{if eq .MapKey "string"}} e.e.EncodeString(k2) {{else}}{{ $y := printf "%s(k2)" .MapKey }}{{if eq $x .MapKey }}{{ $y = "k2" }}{{end}}{{ encmd .MapKey $y }}{{end}} - e.mapElemValue() - {{ $y := printf "v[%s(k2)]" .MapKey }}{{if eq $x .MapKey }}{{ $y = "v[k2]" }}{{end}}{{ encmd .Elem $y }} + if esep { ee.WriteMapElemKey() } + {{if eq .MapKey "string"}} if e.h.StringToRaw {ee.EncodeStringBytesRaw(bytesView(k2))} else {ee.EncodeStringEnc(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}} - } else { + } else { for k2, v2 := range v { - e.mapElemKey() - {{if eq .MapKey "string"}} e.e.EncodeString(k2) {{else}}{{ encmd .MapKey "k2"}}{{end}} - e.mapElemValue() + if esep { ee.WriteMapElemKey() } + {{if eq .MapKey "string"}} if e.h.StringToRaw {ee.EncodeStringBytesRaw(bytesView(k2))} else {ee.EncodeStringEnc(cUTF8, k2)} {{else}}{{ encmd .MapKey "k2"}}{{end}} + if esep { ee.WriteMapElemValue() } {{ encmd .Elem "v2"}} } } - e.mapEnd() + ee.WriteMapEnd() } -{{end}}{{end}}{{end -}} +{{end}}{{end}}{{end}} // -- decode // -- -- fast path type switch func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { - var changed bool - var containerLen int + var changed bool switch v := iv.(type) { -{{range .Values}}{{if not .Primitive}}{{if not .MapKey }}{{if ne .Elem "uint8" -}} +{{range .Values}}{{if not .Primitive}}{{if not .MapKey }}{{if ne .Elem "uint8"}} case []{{ .Elem }}: - fastpathTV.{{ .MethodNamePfx "Dec" false }}N(v, d) - case *[]{{ .Elem }}: var v2 []{{ .Elem }} - if v2, changed = fastpathTV.{{ .MethodNamePfx "Dec" false }}Y(*v, d); changed { - *v = v2 + 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}}{{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 }}: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.{{ .MethodNamePfx "Dec" false }}L(v, containerLen, d) - } - d.mapEnd() - } + fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, false, d) case *map[{{ .MapKey }}]{{ .Elem }}: - {{/* - containerLen = d.mapStart() - if containerLen == 0 { - d.mapEnd() - } else if containerLen == decContainerLenNil { - *v = nil - } else { - if *v == nil { - *v = make(map[{{ .MapKey }}]{{ .Elem }}, decInferLen(containerLen, d.h.MaxInitLen, {{ .Size }})) - } - fastpathTV.{{ .MethodNamePfx "Dec" false }}L(*v, containerLen, d) - } - // consider delegating fully to X - encoding *map is uncommon, so ok to pay small function call cost - */ -}} - fastpathTV.{{ .MethodNamePfx "Dec" false }}X(v, d) -{{end}}{{end}}{{end -}} + var v2 map[{{ .MapKey }}]{{ .Elem }} + v2, changed = fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*v, true, d) + if changed { + *v = v2 + }{{/* +*/}}{{end}}{{end}}{{end}} default: _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 return false @@ -301,14 +313,14 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool { switch v := iv.(type) { -{{range .Values}}{{if not .Primitive}}{{if not .MapKey -}} +{{range .Values}}{{if not .Primitive}}{{if not .MapKey }} case *[]{{ .Elem }}: - *v = nil -{{end}}{{end}}{{end}} -{{range .Values}}{{if not .Primitive}}{{if .MapKey -}} + *v = nil {{/* +*/}}{{end}}{{end}}{{end}} +{{range .Values}}{{if not .Primitive}}{{if .MapKey }} case *map[{{ .MapKey }}]{{ .Elem }}: - *v = nil -{{end}}{{end}}{{end}} + *v = nil {{/* +*/}}{{end}}{{end}}{{end}} default: _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 return false @@ -317,38 +329,47 @@ func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool { } // -- -- fast path functions -{{range .Values}}{{if not .Primitive}}{{if not .MapKey -}} +{{range .Values}}{{if not .Primitive}}{{if not .MapKey }} {{/* -Slices can change if they +Slices can change if they - did not come from an array - 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) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { + if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr { vp := rv2i(rv).(*[]{{ .Elem }}) - if v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}Y(*vp, d); changed { *vp = v } + v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*vp, !array, d) + if changed { *vp = v } } else { - fastpathTV.{{ .MethodNamePfx "Dec" false }}N(rv2i(rv).([]{{ .Elem }}), 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 }}Y(*vp, d); changed { *vp = v } + v, changed := f.{{ .MethodNamePfx "Dec" false }}V(*vp, true, d) + if changed { *vp = v } } -func (fastpathT) {{ .MethodNamePfx "Dec" false }}Y(v []{{ .Elem }}, d *Decoder) (_ []{{ .Elem }}, changed bool) { +func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v []{{ .Elem }}, canChange bool, d *Decoder) (_ []{{ .Elem }}, changed bool) { + dd := d.d{{/* + // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() + */}} slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { return } - return nil, true - } if containerLenS == 0 { - if v == nil { v = []{{ .Elem }}{} } else if len(v) != 0 { v = v[:0] } + if canChange { + if v == nil { v = []{{ .Elem }}{} } else if len(v) != 0 { v = v[:0] } + changed = true + } slh.End() - return v, true + return v, changed } + d.depthIncr() hasLen := containerLenS > 0 var xlen int - if hasLen { + if hasLen && canChange { if containerLenS > cap(v) { xlen = decInferLen(containerLenS, d.h.MaxInitLen, {{ .Size }}) if xlen <= cap(v) { @@ -363,8 +384,8 @@ func (fastpathT) {{ .MethodNamePfx "Dec" false }}Y(v []{{ .Elem }}, d *Decoder) } } var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { + for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { + if j == 0 && len(v) == 0 && canChange { if hasLen { xlen = decInferLen(containerLenS, d.h.MaxInitLen, {{ .Size }}) } else { @@ -373,131 +394,98 @@ func (fastpathT) {{ .MethodNamePfx "Dec" false }}Y(v []{{ .Elem }}, d *Decoder) v = make([]{{ .Elem }}, uint(xlen)) changed = true } - {{/* // if indefinite, etc, then expand the slice if necessary */ -}} + // if indefinite, etc, then expand the slice if necessary + var decodeIntoBlank bool if j >= len(v) { - v = append(v, {{ zerocmd .Elem }}) - changed = true + if canChange { + v = append(v, {{ zerocmd .Elem }}) + changed = true + } else { + d.arrayCannotExpand(len(v), j+1) + decodeIntoBlank = true + } } slh.ElemContainerState(j) - {{ if eq .Elem "interface{}" }}d.decode(&v[uint(j)]){{ else }}v[uint(j)] = {{ decmd .Elem }}{{ end }} + if decodeIntoBlank { + d.swallow() + } else if dd.TryDecodeAsNil() { + v[uint(j)] = {{ zerocmd .Elem }} + } else { + {{ if eq .Elem "interface{}" }}d.decode(&v[uint(j)]){{ else }}v[uint(j)] = {{ decmd .Elem }}{{ end }} + } } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []{{ .Elem }}{} - changed = true + if canChange { + if j < len(v) { + v = v[:uint(j)] + changed = true + } else if j == 0 && v == nil { + v = make([]{{ .Elem }}, 0) + changed = true + } } slh.End() + d.depthDecr() return v, changed } -func (fastpathT) {{ .MethodNamePfx "Dec" false }}N(v []{{ .Elem }}, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return - } - if containerLenS == 0 { - slh.End() - return - } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - {{/* // if indefinite, etc, then expand the slice if necessary */ -}} - if j >= len(v) { - fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return - } - slh.ElemContainerState(j) - {{ if eq .Elem "interface{}" -}} - d.decode(&v[uint(j)]) - {{- else -}} - v[uint(j)] = {{ decmd .Elem }} - {{- end }} - } - slh.End() -} -{{end}}{{end}}{{end -}} - -func fastpathDecArrayCannotExpand(slh decSliceHelper, hasLen bool, lenv, j, containerLenS int) { - slh.d.arrayCannotExpand(lenv, j+1) - slh.ElemContainerState(j) - slh.d.swallow() - j++ - for ; (hasLen && j < containerLenS) || !(hasLen || slh.d.checkBreak()); j++ { - slh.ElemContainerState(j) - slh.d.swallow() - } - slh.End() -} +{{end}}{{end}}{{end}} -{{range .Values}}{{if not .Primitive}}{{if .MapKey -}} +{{range .Values}}{{if not .Primitive}}{{if .MapKey }} {{/* Maps can change if they are - addressable (from a ptr) - settable (e.g. contained in an interface{}) -*/ -}} +*/}} func (d *Decoder) {{ .MethodNamePfx "fastpathDec" false }}R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[{{ .MapKey }}]{{ .Elem }})) = nil - } + if rv.Kind() == reflect.Ptr { + vp := rv2i(rv).(*map[{{ .MapKey }}]{{ .Elem }}) + v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*vp, true, d); + if changed { *vp = v } } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[{{ .MapKey }}]{{ .Elem }}) - if *vp == nil { - *vp = make(map[{{ .MapKey }}]{{ .Elem }}, decInferLen(containerLen, d.h.MaxInitLen, {{ .Size }})) - } - if containerLen != 0 { - fastpathTV.{{ .MethodNamePfx "Dec" false }}L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.{{ .MethodNamePfx "Dec" false }}L(rv2i(rv).(map[{{ .MapKey }}]{{ .Elem }}), containerLen, d) - } - d.mapEnd() + 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) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[{{ .MapKey }}]{{ .Elem }}, decInferLen(containerLen, d.h.MaxInitLen, {{ .Size }})) - } - if containerLen != 0 { - f.{{ .MethodNamePfx "Dec" false }}L(*vp, containerLen, d) - } - d.mapEnd() - } + v, changed := f.{{ .MethodNamePfx "Dec" false }}V(*vp, true, d) + if changed { *vp = v } } -func (fastpathT) {{ .MethodNamePfx "Dec" false }}L(v map[{{ .MapKey }}]{{ .Elem }}, containerLen int, d *Decoder) { - {{/* No need to check if containerLen == decContainerLenNil, as that is checked by R and L above */ -}} - {{if eq .Elem "interface{}" }}mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset - {{else if eq .Elem "bytes" "[]byte" }}mapGet := v != nil && !d.h.MapValueReset - {{end -}} - var mk {{ .MapKey }} +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() + */}} + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen := decInferLen(containerLen, d.h.MaxInitLen, {{ .Size }}) + v = make(map[{{ .MapKey }}]{{ .Elem }}, xlen) + changed = true + } + if containerLen == 0 { + dd.ReadMapEnd() + return v, changed + } + d.depthIncr() + {{ 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 || d.checkBreak()); j++ { - d.mapElemKey() + for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { + if esep { dd.ReadMapElemKey() } {{ if eq .MapKey "interface{}" }}mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { mk = d.string(bv) {{/* // maps cannot have []byte as key. switch to string. */}} }{{ else }}mk = {{ decmd .MapKey }}{{ end }} - d.mapElemValue() - {{ if eq .Elem "interface{}" "[]byte" "bytes" -}} - if mapGet { mv = v[mk] } else { mv = nil } - {{ end -}} - {{ if eq .Elem "interface{}" -}} - d.decode(&mv) - {{ else if eq .Elem "[]byte" "bytes" -}} - mv = d.d.DecodeBytes(mv, false) - {{ else -}} - mv = {{ decmd .Elem }} - {{ end -}} + if esep { dd.ReadMapElemValue() } + if dd.TryDecodeAsNil() { + 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 } } + dd.ReadMapEnd() + d.depthDecr() + 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 6b6ac1ff2956..cf97db0f27c1 100644 --- a/vendor/github.com/ugorji/go/codec/fast-path.not.go +++ b/vendor/github.com/ugorji/go/codec/fast-path.not.go @@ -34,6 +34,12 @@ 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.h.fn(uint8SliceTyp, true, true) + d.kSlice(&fn.i, reflect.ValueOf(&v).Elem()) + return v, true +} + var fastpathAV fastpathA var fastpathTV fastpathT diff --git a/vendor/github.com/ugorji/go/codec/float.go b/vendor/github.com/ugorji/go/codec/float.go deleted file mode 100644 index cfe3a9ec7f04..000000000000 --- a/vendor/github.com/ugorji/go/codec/float.go +++ /dev/null @@ -1,313 +0,0 @@ -// 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 - -import "strconv" - -// func parseFloat(b []byte, bitsize int) (f float64, err error) { -// if bitsize == 32 { -// return parseFloat32(b) -// } else { -// return parseFloat64(b) -// } -// } - -func parseFloat32(b []byte) (f float32, err error) { - return parseFloat32_custom(b) - // return parseFloat32_strconv(b) -} - -func parseFloat64(b []byte) (f float64, err error) { - return parseFloat64_custom(b) - // return parseFloat64_strconv(b) -} - -func parseFloat32_strconv(b []byte) (f float32, err error) { - f64, err := strconv.ParseFloat(stringView(b), 32) - f = float32(f64) - return -} - -func parseFloat64_strconv(b []byte) (f float64, err error) { - return strconv.ParseFloat(stringView(b), 64) -} - -// ------ parseFloat custom below -------- - -// We assume that a lot of floating point numbers in json files will be -// those that are handwritten, and with defined precision (in terms of number -// of digits after decimal point), etc. -// -// We further assume that this ones can be written in exact format. -// -// strconv.ParseFloat has some unnecessary overhead which we can do without -// for the common case: -// -// - expensive char-by-char check to see if underscores are in right place -// - testing for and skipping underscores -// - check if the string matches ignorecase +/- inf, +/- infinity, nan -// - support for base 16 (0xFFFF...) -// -// The functions below will try a fast-path for floats which can be decoded -// without any loss of precision, meaning they: -// -// - fits within the significand bits of the 32-bits or 64-bits -// - exponent fits within the exponent value -// - there is no truncation (any extra numbers are all trailing zeros) -// -// To figure out what the values are for maxMantDigits, use this idea below: -// -// 2^23 = 838 8608 (between 10^ 6 and 10^ 7) (significand bits of uint32) -// 2^32 = 42 9496 7296 (between 10^ 9 and 10^10) (full uint32) -// 2^52 = 4503 5996 2737 0496 (between 10^15 and 10^16) (significand bits of uint64) -// 2^64 = 1844 6744 0737 0955 1616 (between 10^19 and 10^20) (full uint64) -// -// Since we only allow for up to what can comfortably fit into the significand -// ignoring the exponent, and we only try to parse iff significand fits into the - -// Exact powers of 10. -var float64pow10 = [...]float64{ - 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, - 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, - 1e20, 1e21, 1e22, -} -var float32pow10 = [...]float32{1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10} - -type floatinfo struct { - mantbits uint8 - expbits uint8 - bias int16 - - exactPow10 int8 // Exact powers of ten are <= 10^N (32: 10, 64: 22) - exactInts int8 // Exact integers are <= 10^N - - maxMantDigits int8 // 10^19 fits in uint64, while 10^9 fits in uint32 -} - -var fi32 = floatinfo{23, 8, -127, 10, 7, 9} // maxMantDigits = 9 -var fi64 = floatinfo{52, 11, -1023, 22, 15, 19} // maxMantDigits = 19 - -const fMax64 = 1e15 -const fMax32 = 1e7 - -const fBase = 10 - -func parseFloatErr(b []byte) error { - return &strconv.NumError{ - Func: "ParseFloat", - Err: strconv.ErrSyntax, - Num: string(b), - } -} - -func parseFloat32_custom(b []byte) (f float32, err error) { - mantissa, exp, neg, trunc, bad, ok := readFloat(b, fi32) - _ = trunc - if bad { - return 0, parseFloatErr(b) - } - if ok { - // parseFloatDebug(b, 32, false, exp, trunc, ok) - f = float32(mantissa) - if neg { - f = -f - } - if exp != 0 { - indx := fExpIndx(exp) - if exp < 0 { // int / 10^k - f /= float32pow10[indx] - } else { // exp > 0 - if exp > fi32.exactPow10 { - f *= float32pow10[exp-fi32.exactPow10] - if f < -fMax32 || f > fMax32 { // exponent too large - outside range - goto FALLBACK - } - indx = uint8(fi32.exactPow10) - } - f *= float32pow10[indx] - } - } - return - } -FALLBACK: - // parseFloatDebug(b, 32, true, exp, trunc, ok) - return parseFloat32_strconv(b) -} - -func parseFloat64_custom(b []byte) (f float64, err error) { - mantissa, exp, neg, trunc, bad, ok := readFloat(b, fi64) - _ = trunc - if bad { - return 0, parseFloatErr(b) - } - if ok { - f = float64(mantissa) - if neg { - f = -f - } - if exp != 0 { - indx := fExpIndx(exp) - if exp < 0 { // int / 10^k - f /= float64pow10[indx] - } else { // exp > 0 - if exp > fi64.exactPow10 { - f *= float64pow10[exp-fi64.exactPow10] - if f < -fMax64 || f > fMax64 { // exponent too large - outside range - goto FALLBACK - } - indx = uint8(fi64.exactPow10) - } - f *= float64pow10[indx] - } - } - return - } -FALLBACK: - return parseFloat64_strconv(b) -} - -func fExpIndx(v int8) uint8 { - if v < 0 { - return uint8(-v) - } - return uint8(v) -} - -func readFloat(s []byte, y floatinfo) (mantissa uint64, exp int8, neg, trunc, bad, ok bool) { - var i uint // make it uint, so that we eliminate bounds checking - var slen = uint(len(s)) - if slen == 0 { - bad = true - return - } - switch s[0] { - case '+': - i++ - case '-': - neg = true - i++ - } - - // we considered punting early if string has length > maxMantDigits, but this doesn't account - // for trailing 0's e.g. 700000000000000000000 can be encoded exactly as it is 7e20 - - // var sawdot, sawdigits, sawexp bool - var sawdot, sawexp bool - var nd, ndMant, dp int8 -L: - for ; i < slen; i++ { - switch s[i] { - case '.': - if sawdot { - bad = true - return - } - sawdot = true - dp = nd - case '0': - if nd == 0 { // ignore leading zeros - dp-- - continue - } - nd++ - if ndMant < y.maxMantDigits { - // mantissa = (mantissa << 1) + (mantissa << 3) - mantissa *= fBase - ndMant++ - } - case '1', '2', '3', '4', '5', '6', '7', '8', '9': - // sawdigits = true - nd++ - if ndMant < y.maxMantDigits { - // mantissa = (mantissa << 1) + (mantissa << 3) + uint64(s[i]-'0') - mantissa = mantissa*fBase + uint64(s[i]-'0') - // mantissa *= fBase - // mantissa += uint64(s[i] - '0') - ndMant++ - } else { - trunc = true - return // break L - } - case 'e', 'E': - sawexp = true - break L - default: - bad = true - return - } - } - // if !sawdigits { - // bad = true - // return - // } - if !sawdot { - dp = nd - } - - if sawexp { - i++ - if i < slen { - var eneg bool - if s[i] == '+' { - i++ - } else if s[i] == '-' { - i++ - eneg = true - } - if i < slen { - // for exact match, exponent is 1 or 2 digits (float64: -22 to 37, float32: -1 to 17). - // exit quick if exponent is more than 2 digits. - if i+2 < slen { - return - } - - var e int8 - - if s[i] < '0' || s[i] > '9' { - bad = true - return - } - e = e*fBase + int8(s[i]-'0') // (e << 1) + (e << 3) + int8(s[i]-'0') - i++ - - if i < slen { - if s[i] < '0' || s[i] > '9' { - bad = true - return - } - e = e*fBase + int8(s[i]-'0') // (e << 1) + (e << 3) + int8(s[i]-'0') - i++ - } - - if eneg { - dp -= e - } else { - dp += e - } - } - } - } - - if mantissa != 0 { - if mantissa>>y.mantbits != 0 { - return - } - exp = dp - ndMant - if exp < -y.exactPow10 || exp > y.exactInts+y.exactPow10 { // cannot handle it - return - } - } - ok = true // && !trunc // if trunc=true, we return early (so here trunc=false) - return -} - -// fMul10ShiftU64 - -// func parseFloatDebug(b []byte, bitsize int, strconv bool, exp int8, trunc, ok bool) { -// if strconv { -// xdebugf("parseFloat%d: delegating: %s, exp: %d, trunc: %v, ok: %v", bitsize, b, exp, trunc, ok) -// } else { -// xdebug2f("parseFloat%d: attempting: %s, exp: %d, trunc: %v, ok: %v", bitsize, b, exp, trunc, ok) -// } -// } 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 d2caa0b667fa..790e914e13cb 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 @@ -1,17 +1,9 @@ {{var "v"}} := {{if not isArray}}*{{end}}{{ .Varname }} -{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}} -{{if not isArray -}} +{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}}{{if not isArray}} var {{var "c"}} bool {{/* // changed */}} -_ = {{var "c"}} -if {{var "h"}}.IsNil { - if {{var "v"}} != nil { - {{var "v"}} = nil - {{var "c"}} = true - } -} else {{end -}} +_ = {{var "c"}}{{end}} if {{var "l"}} == 0 { - {{if isSlice -}} - if {{var "v"}} == nil { + {{if isSlice }}if {{var "v"}} == nil { {{var "v"}} = []{{ .Typ }}{} {{var "c"}} = true } else if len({{var "v"}}) != 0 { @@ -20,8 +12,7 @@ if {{var "l"}} == 0 { } {{else if isChan }}if {{var "v"}} == nil { {{var "v"}} = make({{ .CTyp }}, 0) {{var "c"}} = true - } - {{end -}} + } {{end}} } else { {{var "hl"}} := {{var "l"}} > 0 var {{var "rl"}} int @@ -39,11 +30,10 @@ if {{var "l"}} == 0 { {{var "v"}} = {{var "v"}}[:{{var "l"}}] {{var "c"}} = true } - } - {{end -}} + } {{end}} var {{var "j"}} int - {{/* // var {{var "dn"}} bool */ -}} - for {{var "j"}} = 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ { // bounds-check-elimination + // var {{var "dn"}} bool + for {{var "j"}} = 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || r.CheckBreak()); {{var "j"}}++ { // bounds-check-elimination {{if not isArray}} if {{var "j"}} == 0 && {{var "v"}} == nil { if {{var "hl"}} { {{var "rl"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }}) @@ -52,27 +42,27 @@ if {{var "l"}} == 0 { } {{var "v"}} = make({{if isSlice}}[]{{ .Typ }}{{else if isChan}}{{.CTyp}}{{end}}, {{var "rl"}}) {{var "c"}} = true - } - {{end -}} + }{{end}} {{var "h"}}.ElemContainerState({{var "j"}}) - {{/* {{var "dn"}} = r.TryDecodeAsNil() */}}{{/* commented out, as decLineVar handles this already each time */ -}} + {{/* {{var "dn"}} = r.TryDecodeAsNil() */}}{{/* commented out, as decLineVar handles this already each time */}} {{if isChan}}{{ $x := printf "%[1]vvcx%[2]v" .TempVar .Rand }}var {{$x}} {{ .Typ }} - {{ decLineVar $x -}} + {{ decLineVar $x }} {{var "v"}} <- {{ $x }} - {{else}}{{/* // if indefinite, etc, then expand the slice if necessary */ -}} + // println(">>>> sending ", {{ $x }}, " into ", {{var "v"}}) // TODO: remove this + {{else}}{{/* // if indefinite, etc, then expand the slice if necessary */}} var {{var "db"}} bool if {{var "j"}} >= len({{var "v"}}) { {{if isSlice }} {{var "v"}} = append({{var "v"}}, {{ zero }}) {{var "c"}} = true {{else}} z.DecArrayCannotExpand(len(v), {{var "j"}}+1); {{var "db"}} = true - {{end -}} + {{end}} } if {{var "db"}} { z.DecSwallow() } else { - {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x -}} + {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }} } - {{end -}} + {{end}} } {{if isSlice}} if {{var "j"}} < len({{var "v"}}) { {{var "v"}} = {{var "v"}}[:{{var "j"}}] @@ -80,11 +70,9 @@ if {{var "l"}} == 0 { } else if {{var "j"}} == 0 && {{var "v"}} == nil { {{var "v"}} = make([]{{ .Typ }}, 0) {{var "c"}} = true - } - {{end -}} + } {{end}} } {{var "h"}}.End() {{if not isArray }}if {{var "c"}} { *{{ .Varname }} = {{var "v"}} -} -{{end -}} +}{{end}} diff --git a/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl b/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl index 35bda4a1609c..8323b54940d0 100644 --- a/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl +++ b/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl @@ -1,53 +1,42 @@ {{var "v"}} := *{{ .Varname }} -{{var "l"}} := z.DecReadMapStart() -if {{var "l"}} == codecSelferDecContainerLenNil{{xs}} { - *{{ .Varname }} = nil -} else { +{{var "l"}} := r.ReadMapStart() +{{var "bh"}} := z.DecBasicHandle() if {{var "v"}} == nil { - {{var "rl"}} := z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }}) + {{var "rl"}} := z.DecInferLen({{var "l"}}, {{var "bh"}}.MaxInitLen, {{ .Size }}) {{var "v"}} = make(map[{{ .KTyp }}]{{ .Typ }}, {{var "rl"}}) *{{ .Varname }} = {{var "v"}} } var {{var "mk"}} {{ .KTyp }} var {{var "mv"}} {{ .Typ }} var {{var "mg"}}, {{var "mdn"}} {{if decElemKindPtr}}, {{var "ms"}}, {{var "mok"}}{{end}} bool -if z.DecBasicHandle().MapValueReset { +if {{var "bh"}}.MapValueReset { {{if decElemKindPtr}}{{var "mg"}} = true - {{else if decElemKindIntf}}if !z.DecBasicHandle().InterfaceReset { {{var "mg"}} = true } + {{else if decElemKindIntf}}if !{{var "bh"}}.InterfaceReset { {{var "mg"}} = true } {{else if not decElemKindImmutable}}{{var "mg"}} = true {{end}} } if {{var "l"}} != 0 { - {{var "hl"}} := {{var "l"}} > 0 - for {{var "j"}} := 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ { - z.DecReadMapElemKey() - {{ $x := printf "%vmk%v" .TempVar .Rand }}{{ decLineVarK $x -}} - {{ if eq .KTyp "interface{}" }}{{/* // special case if a byte array. */ -}} - if {{var "bv"}}, {{var "bok"}} := {{var "mk"}}.([]byte); {{var "bok"}} { +{{var "hl"}} := {{var "l"}} > 0 + for {{var "j"}} := 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || r.CheckBreak()); {{var "j"}}++ { + r.ReadMapElemKey() {{/* z.DecSendContainerState(codecSelfer_containerMapKey{{ .Sfx }}) */}} + {{ $x := printf "%vmk%v" .TempVar .Rand }}{{ decLineVarK $x }} +{{ if eq .KTyp "interface{}" }}{{/* // special case if a byte array. */}}if {{var "bv"}}, {{var "bok"}} := {{var "mk"}}.([]byte); {{var "bok"}} { {{var "mk"}} = string({{var "bv"}}) - } - {{ end -}} - {{if decElemKindPtr -}} - {{var "ms"}} = true - {{end -}} + }{{ end }}{{if decElemKindPtr}} + {{var "ms"}} = true{{end}} if {{var "mg"}} { - {{if decElemKindPtr -}} - {{var "mv"}}, {{var "mok"}} = {{var "v"}}[{{var "mk"}}] + {{if decElemKindPtr}}{{var "mv"}}, {{var "mok"}} = {{var "v"}}[{{var "mk"}}] if {{var "mok"}} { {{var "ms"}} = false - } - {{else -}} - {{var "mv"}} = {{var "v"}}[{{var "mk"}}] - {{end -}} + } {{else}}{{var "mv"}} = {{var "v"}}[{{var "mk"}}] {{end}} } {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}} - z.DecReadMapElemValue() + r.ReadMapElemValue() {{/* z.DecSendContainerState(codecSelfer_containerMapValue{{ .Sfx }}) */}} {{var "mdn"}} = false - {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ $y := printf "%vmdn%v" .TempVar .Rand }}{{ decLineVar $x $y -}} + {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ $y := printf "%vmdn%v" .TempVar .Rand }}{{ decLineVar $x $y }} if {{var "mdn"}} { - if z.DecBasicHandle().DeleteOnNilMapValue { delete({{var "v"}}, {{var "mk"}}) } else { {{var "v"}}[{{var "mk"}}] = {{decElemZero}} } + if {{ var "bh" }}.DeleteOnNilMapValue { delete({{var "v"}}, {{var "mk"}}) } else { {{var "v"}}[{{var "mk"}}] = {{decElemZero}} } } else if {{if decElemKindPtr}} {{var "ms"}} && {{end}} {{var "v"}} != nil { {{var "v"}}[{{var "mk"}}] = {{var "mv"}} } } } // else len==0: TODO: Should we clear map entries? -z.DecReadMapEnd() -} +r.ReadMapEnd() {{/* z.DecSendContainerState(codecSelfer_containerMapEnd{{ .Sfx }}) */}} 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 d86d3af49c73..2a7d1aab70b3 100644 --- a/vendor/github.com/ugorji/go/codec/gen-helper.generated.go +++ b/vendor/github.com/ugorji/go/codec/gen-helper.generated.go @@ -7,14 +7,23 @@ package codec -import "encoding" +import ( + "encoding" + "reflect" +) // GenVersion is the current version of codecgen. -const GenVersion = 16 +const GenVersion = 10 // 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. // @@ -38,22 +47,56 @@ type genHelperEncDriver struct { encDriver } +func (x genHelperEncDriver) EncodeBuiltin(rt uintptr, v interface{}) {} +func (x genHelperEncDriver) EncStructFieldKey(keyType valueType, s string) { + encStructFieldKey(s, x.encDriver, nil, keyType, false, false) +} +func (x genHelperEncDriver) EncodeSymbol(s string) { + x.encDriver.EncodeStringEnc(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 - F fastpathT e *Encoder + F fastpathT } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* type genHelperDecoder struct { C checkOverflow - F fastpathT d *Decoder + F fastpathT } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* @@ -73,8 +116,9 @@ func (f genHelperEncoder) IsJSONHandle() bool { // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) EncFallback(iv interface{}) { + // println(">>>>>>>>> EncFallback") // f.e.encodeI(iv, false, false) - f.e.encodeValue(rv4i(iv), nil) + f.e.encodeValue(reflect.ValueOf(iv), nil, false) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* @@ -98,6 +142,18 @@ func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) { // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* 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) @@ -105,42 +161,41 @@ func (f genHelperEncoder) I2Rtid(v interface{}) uintptr { // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) Extension(rtid uintptr) (xfn *extTypeTagFn) { - return f.e.h.getExt(rtid, true) + return f.e.h.getExt(rtid) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) EncExtension(v interface{}, xfFn *extTypeTagFn) { - f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext) + f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext, f.e) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) WriteStr(s string) { - f.e.w().writestr(s) + f.e.w.writestr(s) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) BytesView(v string) []byte { return bytesView(v) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteMapStart(length int) { f.e.mapStart(length) } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteMapEnd() { f.e.mapEnd() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteArrayStart(length int) { f.e.arrayStart(length) } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteArrayEnd() { f.e.arrayEnd() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteArrayElem() { f.e.arrayElem() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteMapElemKey() { f.e.mapElemKey() } +// +// 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* -func (f genHelperEncoder) EncWriteMapElemValue() { f.e.mapElemValue() } +// +// 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) { + 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 +} // ---------------- DECODER FOLLOWS ----------------- @@ -169,11 +224,13 @@ func (f genHelperDecoder) DecScratchArrayBuffer() *[decScratchByteArrayLen]byte // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecFallback(iv interface{}, chkPtr bool) { - rv := rv4i(iv) + // println(">>>>>>>>> DecFallback") + rv := reflect.ValueOf(iv) if chkPtr { - f.d.ensureDecodeable(rv) + rv = f.d.ensureDecodeable(rv) } - f.d.decodeValue(rv, nil) + f.d.decodeValue(rv, nil, false) + // f.d.decodeValueFallback(rv) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* @@ -193,7 +250,8 @@ func (f genHelperDecoder) DecArrayCannotExpand(sliceLen, streamLen int) { // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecTextUnmarshal(tm encoding.TextUnmarshaler) { - if fnerr := tm.UnmarshalText(f.d.d.DecodeStringAsBytes()); fnerr != nil { + fnerr := tm.UnmarshalText(f.d.d.DecodeStringAsBytes()) + if fnerr != nil { panic(fnerr) } } @@ -202,14 +260,16 @@ func (f genHelperDecoder) DecTextUnmarshal(tm encoding.TextUnmarshaler) { func (f genHelperDecoder) DecJSONUnmarshal(tm jsonUnmarshaler) { // bs := f.dd.DecodeStringAsBytes() // grab the bytes to be read, as UnmarshalJSON needs the full JSON so as to unmarshal it itself. - if fnerr := tm.UnmarshalJSON(f.d.nextValueBytes()); fnerr != nil { + fnerr := tm.UnmarshalJSON(f.d.nextValueBytes()) + if fnerr != nil { panic(fnerr) } } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecBinaryUnmarshal(bm encoding.BinaryUnmarshaler) { - if fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, true)); fnerr != nil { + fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, true)) + if fnerr != nil { panic(fnerr) } } @@ -217,6 +277,20 @@ 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() } +// 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 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 @@ -229,7 +303,7 @@ func (f genHelperDecoder) I2Rtid(v interface{}) uintptr { // 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, true) + return f.d.h.getExt(rtid) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* @@ -238,36 +312,32 @@ func (f genHelperDecoder) DecExtension(v interface{}, xfFn *extTypeTagFn) { } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecInferLen(clen, maxlen, unit int) (rvlen int) { - return decInferLen(clen, maxlen, unit) +// +// 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* -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) DecReadMapStart() int { return f.d.mapStart() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadMapEnd() { f.d.mapEnd() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadArrayStart() int { return f.d.arrayStart() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadArrayEnd() { f.d.arrayEnd() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadArrayElem() { f.d.arrayElem() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadMapElemKey() { f.d.mapElemKey() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadMapElemValue() { f.d.mapElemValue() } +// +// 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) { + if xfFn := f.d.h.getExt(i2rtid(v)); xfFn != nil { + f.d.d.DecodeExt(v, xfFn.tag, xfFn.ext) + return true + } + return false +} // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecDecodeFloat32() float32 { return f.d.decodeFloat32() } +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) DecCheckBreak() bool { return f.d.checkBreak() } +// +// 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 446523316ced..f5d0634e6a1c 100644 --- a/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl +++ b/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl @@ -7,7 +7,10 @@ package codec -import "encoding" +import ( + "encoding" + "reflect" +) // GenVersion is the current version of codecgen. const GenVersion = {{ .Version }} @@ -15,14 +18,12 @@ 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. // @@ -46,22 +47,56 @@ type genHelperEncDriver struct { encDriver } +func (x genHelperEncDriver) EncodeBuiltin(rt uintptr, v interface{}) {} +func (x genHelperEncDriver) EncStructFieldKey(keyType valueType, s string) { + encStructFieldKey(s, x.encDriver, nil, keyType, false, false) +} +func (x genHelperEncDriver) EncodeSymbol(s string) { + x.encDriver.EncodeStringEnc(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 - F fastpathT e *Encoder + F fastpathT } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* type genHelperDecoder struct { C checkOverflow - F fastpathT d *Decoder + F fastpathT } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* @@ -78,8 +113,9 @@ func (f genHelperEncoder) IsJSONHandle() bool { } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) EncFallback(iv interface{}) { + // println(">>>>>>>>> EncFallback") // f.e.encodeI(iv, false, false) - f.e.encodeValue(rv4i(iv), nil) + f.e.encodeValue(reflect.ValueOf(iv), nil, false) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) EncTextMarshal(iv encoding.TextMarshaler) { @@ -98,6 +134,16 @@ func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) { } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* 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 { @@ -105,33 +151,36 @@ func (f genHelperEncoder) I2Rtid(v interface{}) uintptr { } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) Extension(rtid uintptr) (xfn *extTypeTagFn) { - return f.e.h.getExt(rtid, true) + return f.e.h.getExt(rtid) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) EncExtension(v interface{}, xfFn *extTypeTagFn) { - f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext) + f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext, f.e) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) WriteStr(s string) { - f.e.w().writestr(s) + f.e.w.writestr(s) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) BytesView(v string) []byte { return bytesView(v) } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteMapStart(length int) { f.e.mapStart(length) } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteMapEnd() { f.e.mapEnd() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteArrayStart(length int) { f.e.arrayStart(length) } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteArrayEnd() { f.e.arrayEnd() } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteArrayElem() { f.e.arrayElem() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteMapElemKey() { f.e.mapElemKey() } +// +// 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* -func (f genHelperEncoder) EncWriteMapElemValue() { f.e.mapElemValue() } +// +// 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) { + 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 +} // ---------------- DECODER FOLLOWS ----------------- @@ -155,11 +204,13 @@ func (f genHelperDecoder) DecScratchArrayBuffer() *[decScratchByteArrayLen]byte } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecFallback(iv interface{}, chkPtr bool) { - rv := rv4i(iv) + // println(">>>>>>>>> DecFallback") + rv := reflect.ValueOf(iv) if chkPtr { - f.d.ensureDecodeable(rv) + rv = f.d.ensureDecodeable(rv) } - f.d.decodeValue(rv, nil) + f.d.decodeValue(rv, nil, false) + // f.d.decodeValueFallback(rv) } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecSliceHelperStart() (decSliceHelper, int) { @@ -175,7 +226,8 @@ func (f genHelperDecoder) DecArrayCannotExpand(sliceLen, streamLen int) { } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecTextUnmarshal(tm encoding.TextUnmarshaler) { - if fnerr := tm.UnmarshalText(f.d.d.DecodeStringAsBytes()); fnerr != nil { + fnerr := tm.UnmarshalText(f.d.d.DecodeStringAsBytes()) + if fnerr != nil { panic(fnerr) } } @@ -183,18 +235,32 @@ func (f genHelperDecoder) DecTextUnmarshal(tm encoding.TextUnmarshaler) { func (f genHelperDecoder) DecJSONUnmarshal(tm jsonUnmarshaler) { // bs := f.dd.DecodeStringAsBytes() // grab the bytes to be read, as UnmarshalJSON needs the full JSON so as to unmarshal it itself. - if fnerr := tm.UnmarshalJSON(f.d.nextValueBytes()); fnerr != nil { + fnerr := tm.UnmarshalJSON(f.d.nextValueBytes()) + if fnerr != nil { panic(fnerr) } } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecBinaryUnmarshal(bm encoding.BinaryUnmarshaler) { - if fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, true)); fnerr != nil { + fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, true)) + if fnerr != nil { panic(fnerr) } } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecRaw() []byte { return f.d.rawBytes() } +// 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 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 { @@ -206,36 +272,37 @@ func (f genHelperDecoder) I2Rtid(v interface{}) uintptr { } // 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, true) + 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) { + if xfFn := f.d.h.getExt(i2rtid(v)); xfFn != nil { + f.d.d.DecodeExt(v, xfFn.tag, xfFn.ext) + return true + } + return false +} +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* 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* +// +// 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 genHelperDecoder) DecReadMapStart() int { return f.d.mapStart() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadMapEnd() { f.d.mapEnd() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadArrayStart() int { return f.d.arrayStart() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadArrayEnd() { f.d.arrayEnd() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadArrayElem() { f.d.arrayElem() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadMapElemKey() { f.d.mapElemKey() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadMapElemValue() { f.d.mapElemValue() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecDecodeFloat32() float32 { return f.d.decodeFloat32() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecCheckBreak() bool { return f.d.checkBreak() } - diff --git a/vendor/github.com/ugorji/go/codec/gen.generated.go b/vendor/github.com/ugorji/go/codec/gen.generated.go index 5aca5a488bf5..8b00090a8ff4 100644 --- a/vendor/github.com/ugorji/go/codec/gen.generated.go +++ b/vendor/github.com/ugorji/go/codec/gen.generated.go @@ -9,75 +9,56 @@ package codec const genDecMapTmpl = ` {{var "v"}} := *{{ .Varname }} -{{var "l"}} := z.DecReadMapStart() -if {{var "l"}} == codecSelferDecContainerLenNil{{xs}} { - *{{ .Varname }} = nil -} else { +{{var "l"}} := r.ReadMapStart() +{{var "bh"}} := z.DecBasicHandle() if {{var "v"}} == nil { - {{var "rl"}} := z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }}) + {{var "rl"}} := z.DecInferLen({{var "l"}}, {{var "bh"}}.MaxInitLen, {{ .Size }}) {{var "v"}} = make(map[{{ .KTyp }}]{{ .Typ }}, {{var "rl"}}) *{{ .Varname }} = {{var "v"}} } var {{var "mk"}} {{ .KTyp }} var {{var "mv"}} {{ .Typ }} var {{var "mg"}}, {{var "mdn"}} {{if decElemKindPtr}}, {{var "ms"}}, {{var "mok"}}{{end}} bool -if z.DecBasicHandle().MapValueReset { +if {{var "bh"}}.MapValueReset { {{if decElemKindPtr}}{{var "mg"}} = true - {{else if decElemKindIntf}}if !z.DecBasicHandle().InterfaceReset { {{var "mg"}} = true } + {{else if decElemKindIntf}}if !{{var "bh"}}.InterfaceReset { {{var "mg"}} = true } {{else if not decElemKindImmutable}}{{var "mg"}} = true {{end}} } if {{var "l"}} != 0 { - {{var "hl"}} := {{var "l"}} > 0 - for {{var "j"}} := 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ { - z.DecReadMapElemKey() - {{ $x := printf "%vmk%v" .TempVar .Rand }}{{ decLineVarK $x -}} - {{ if eq .KTyp "interface{}" }}{{/* // special case if a byte array. */ -}} - if {{var "bv"}}, {{var "bok"}} := {{var "mk"}}.([]byte); {{var "bok"}} { +{{var "hl"}} := {{var "l"}} > 0 + for {{var "j"}} := 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || r.CheckBreak()); {{var "j"}}++ { + r.ReadMapElemKey() {{/* z.DecSendContainerState(codecSelfer_containerMapKey{{ .Sfx }}) */}} + {{ $x := printf "%vmk%v" .TempVar .Rand }}{{ decLineVarK $x }} +{{ if eq .KTyp "interface{}" }}{{/* // special case if a byte array. */}}if {{var "bv"}}, {{var "bok"}} := {{var "mk"}}.([]byte); {{var "bok"}} { {{var "mk"}} = string({{var "bv"}}) - } - {{ end -}} - {{if decElemKindPtr -}} - {{var "ms"}} = true - {{end -}} + }{{ end }}{{if decElemKindPtr}} + {{var "ms"}} = true{{end}} if {{var "mg"}} { - {{if decElemKindPtr -}} - {{var "mv"}}, {{var "mok"}} = {{var "v"}}[{{var "mk"}}] + {{if decElemKindPtr}}{{var "mv"}}, {{var "mok"}} = {{var "v"}}[{{var "mk"}}] if {{var "mok"}} { {{var "ms"}} = false - } - {{else -}} - {{var "mv"}} = {{var "v"}}[{{var "mk"}}] - {{end -}} + } {{else}}{{var "mv"}} = {{var "v"}}[{{var "mk"}}] {{end}} } {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}} - z.DecReadMapElemValue() + r.ReadMapElemValue() {{/* z.DecSendContainerState(codecSelfer_containerMapValue{{ .Sfx }}) */}} {{var "mdn"}} = false - {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ $y := printf "%vmdn%v" .TempVar .Rand }}{{ decLineVar $x $y -}} + {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ $y := printf "%vmdn%v" .TempVar .Rand }}{{ decLineVar $x $y }} if {{var "mdn"}} { - if z.DecBasicHandle().DeleteOnNilMapValue { delete({{var "v"}}, {{var "mk"}}) } else { {{var "v"}}[{{var "mk"}}] = {{decElemZero}} } + if {{ var "bh" }}.DeleteOnNilMapValue { delete({{var "v"}}, {{var "mk"}}) } else { {{var "v"}}[{{var "mk"}}] = {{decElemZero}} } } else if {{if decElemKindPtr}} {{var "ms"}} && {{end}} {{var "v"}} != nil { {{var "v"}}[{{var "mk"}}] = {{var "mv"}} } } } // else len==0: TODO: Should we clear map entries? -z.DecReadMapEnd() -} +r.ReadMapEnd() {{/* z.DecSendContainerState(codecSelfer_containerMapEnd{{ .Sfx }}) */}} ` const genDecListTmpl = ` {{var "v"}} := {{if not isArray}}*{{end}}{{ .Varname }} -{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}} -{{if not isArray -}} +{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}}{{if not isArray}} var {{var "c"}} bool {{/* // changed */}} -_ = {{var "c"}} -if {{var "h"}}.IsNil { - if {{var "v"}} != nil { - {{var "v"}} = nil - {{var "c"}} = true - } -} else {{end -}} +_ = {{var "c"}}{{end}} if {{var "l"}} == 0 { - {{if isSlice -}} - if {{var "v"}} == nil { + {{if isSlice }}if {{var "v"}} == nil { {{var "v"}} = []{{ .Typ }}{} {{var "c"}} = true } else if len({{var "v"}}) != 0 { @@ -86,8 +67,7 @@ if {{var "l"}} == 0 { } {{else if isChan }}if {{var "v"}} == nil { {{var "v"}} = make({{ .CTyp }}, 0) {{var "c"}} = true - } - {{end -}} + } {{end}} } else { {{var "hl"}} := {{var "l"}} > 0 var {{var "rl"}} int @@ -105,11 +85,10 @@ if {{var "l"}} == 0 { {{var "v"}} = {{var "v"}}[:{{var "l"}}] {{var "c"}} = true } - } - {{end -}} + } {{end}} var {{var "j"}} int - {{/* // var {{var "dn"}} bool */ -}} - for {{var "j"}} = 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ { // bounds-check-elimination + // var {{var "dn"}} bool + for {{var "j"}} = 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || r.CheckBreak()); {{var "j"}}++ { // bounds-check-elimination {{if not isArray}} if {{var "j"}} == 0 && {{var "v"}} == nil { if {{var "hl"}} { {{var "rl"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }}) @@ -118,27 +97,27 @@ if {{var "l"}} == 0 { } {{var "v"}} = make({{if isSlice}}[]{{ .Typ }}{{else if isChan}}{{.CTyp}}{{end}}, {{var "rl"}}) {{var "c"}} = true - } - {{end -}} + }{{end}} {{var "h"}}.ElemContainerState({{var "j"}}) - {{/* {{var "dn"}} = r.TryDecodeAsNil() */}}{{/* commented out, as decLineVar handles this already each time */ -}} + {{/* {{var "dn"}} = r.TryDecodeAsNil() */}}{{/* commented out, as decLineVar handles this already each time */}} {{if isChan}}{{ $x := printf "%[1]vvcx%[2]v" .TempVar .Rand }}var {{$x}} {{ .Typ }} - {{ decLineVar $x -}} + {{ decLineVar $x }} {{var "v"}} <- {{ $x }} - {{else}}{{/* // if indefinite, etc, then expand the slice if necessary */ -}} + // println(">>>> sending ", {{ $x }}, " into ", {{var "v"}}) // TODO: remove this + {{else}}{{/* // if indefinite, etc, then expand the slice if necessary */}} var {{var "db"}} bool if {{var "j"}} >= len({{var "v"}}) { {{if isSlice }} {{var "v"}} = append({{var "v"}}, {{ zero }}) {{var "c"}} = true {{else}} z.DecArrayCannotExpand(len(v), {{var "j"}}+1); {{var "db"}} = true - {{end -}} + {{end}} } if {{var "db"}} { z.DecSwallow() } else { - {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x -}} + {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }} } - {{end -}} + {{end}} } {{if isSlice}} if {{var "j"}} < len({{var "v"}}) { {{var "v"}} = {{var "v"}}[:{{var "j"}}] @@ -146,14 +125,12 @@ if {{var "l"}} == 0 { } else if {{var "j"}} == 0 && {{var "v"}} == nil { {{var "v"}} = make([]{{ .Typ }}, 0) {{var "c"}} = true - } - {{end -}} + } {{end}} } {{var "h"}}.End() {{if not isArray }}if {{var "c"}} { *{{ .Varname }} = {{var "v"}} -} -{{end -}} +}{{end}} ` const genEncChanTmpl = ` diff --git a/vendor/github.com/ugorji/go/codec/gen.go b/vendor/github.com/ugorji/go/codec/gen.go index 3573bc32e7de..74c4aa86af73 100644 --- a/vendor/github.com/ugorji/go/codec/gen.go +++ b/vendor/github.com/ugorji/go/codec/gen.go @@ -105,14 +105,8 @@ import ( // v7: // v8: current - we now maintain compatibility with old generated code. // v9: skipped -// v10: modified encDriver and decDriver interfaces. -// v11: remove deprecated methods of encDriver and decDriver. -// v12: removed deprecated methods from genHelper and changed container tracking logic -// v13: 20190603 removed DecodeString - use DecodeStringAsBytes instead -// v14: 20190611 refactored nil handling: TryDecodeAsNil -> selective TryNil, etc -// v15: 20190626 encDriver.EncodeString handles StringToRaw flag inside handle -// v16: 20190629 refactoring for v1.1.6 -const genVersion = 16 +// v10: modified encDriver and decDriver interfaces. Remove deprecated methods after Jan 1, 2019 +const genVersion = 10 const ( genCodecPkg = "codec1978" @@ -129,21 +123,6 @@ const ( // // From testing, it didn't make much difference in runtime, so keep as true (one function only) genUseOneFunctionForDecStructMap = true - - // genFastpathCanonical configures whether we support Canonical in fast path. - // The savings is not much. - // - // NOTE: This MUST ALWAYS BE TRUE. fast-path.go.tmp doesn't handle it being false. - genFastpathCanonical = true // MUST be true - - // genFastpathTrimTypes configures whether we trim uncommon fastpath types. - genFastpathTrimTypes = true - - // genDecStructArrayInlineLoopCheck configures whether we create a next function - // for each iteration in the loop and call it, or just inline it. - // - // with inlining, we get better performance but about 10% larger files. - genDecStructArrayInlineLoopCheck = true ) type genStructMapStyle uint8 @@ -178,11 +157,10 @@ func (x *genBuf) reset() { // genRunner holds some state used during a Gen run. type genRunner struct { - w io.Writer // output - c uint64 // counter used for generating varsfx - f uint64 // counter used for saying false + w io.Writer // output + c uint64 // counter used for generating varsfx + t []reflect.Type // list of types to run selfer on - t []reflect.Type // list of types to run selfer on tc reflect.Type // currently running selfer on this type te map[uintptr]bool // types for which the encoder has been created td map[uintptr]bool // types for which the decoder has been created @@ -209,30 +187,6 @@ type genRunner struct { nx bool // no extensions } -type genIfClause struct { - hasIf bool -} - -func (g *genIfClause) end(x *genRunner) { - if g.hasIf { - x.line("}") - } -} - -func (g *genIfClause) c(last bool) (v string) { - if last { - if g.hasIf { - v = " } else { " - } - } else if g.hasIf { - v = " } else if " - } else { - v = "if " - g.hasIf = true - } - return -} - // Gen will write a complete go file containing Selfer implementations for each // type passed. All the types must be in the same package. // @@ -279,9 +233,9 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool, } x.genRefPkgs(t) } - x.line("// +build go1.6") if buildTags != "" { x.line("// +build " + buildTags) + x.line("") } x.line(` @@ -324,41 +278,50 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool, x.linef("// ----- value types used ----") for _, vt := range [...]valueType{ valueTypeArray, valueTypeMap, valueTypeString, - valueTypeInt, valueTypeUint, valueTypeFloat, - valueTypeNil, - } { + valueTypeInt, valueTypeUint, valueTypeFloat} { x.linef("codecSelferValueType%s%s = %v", vt.String(), x.xs, int64(vt)) } x.linef("codecSelferBitsize%s = uint8(32 << (^uint(0) >> 63))", x.xs) - x.linef("codecSelferDecContainerLenNil%s = %d", x.xs, int64(decContainerLenNil)) x.line(")") x.line("var (") - x.line("errCodecSelferOnlyMapOrArrayEncodeToStruct" + x.xs + " = " + "\nerrors.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("") x.hn = "codecSelfer" + x.xs x.line("type " + x.hn + " struct{}") x.line("") - x.linef("func %sFalse() bool { return false }", x.hn) - x.line("") + x.varsfxreset() x.line("func init() {") x.linef("if %sGenVersion != %v {", x.cpfx, genVersion) x.line("_, file, _, _ := runtime.Caller(0)") - x.linef("ver := strconv.FormatInt(int64(%sGenVersion), 10)", x.cpfx) - x.outf(`panic("codecgen version mismatch: current: %v, need " + ver + ". Re-generate file: " + file)`, genVersion) + 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("}") - if len(imKeys) > 0 { - x.line("if false { // reference the types, but skip this branch at build/run time") - for _, k := range imKeys { - t := x.im[k] - x.linef("var _ %s.%s", x.imn[k], t.Name()) + x.line("if false { var _ byte = 0; // 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 { + t := x.im[k] + x.linef("var v%v %s.%s", n, x.imn[k], t.Name()) + n++ + } + if n > 0 { + x.out("_") + for i := 1; i < n; i++ { + x.out(", _") + } + x.out(" = v0") + for i := 1; i < n; i++ { + x.outf(", v%v", i) } - x.line("} ") // close if false } - x.line("}") // close init + x.line("} ") // close if false + x.line("}") // close init x.line("") // generate rest of type info @@ -459,15 +422,6 @@ func (x *genRunner) genRefPkgs(t reflect.Type) { } } -// sayFalse will either say "false" or use a function call that returns false. -func (x *genRunner) sayFalse() string { - x.f++ - if x.f%2 == 0 { - return x.hn + "False()" - } - return "false" -} - func (x *genRunner) varsfx() string { x.c++ return strconv.FormatUint(x.c, 10) @@ -498,12 +452,6 @@ func (x *genRunner) line(s string) { } } -func (x *genRunner) lineIf(s string) { - if s != "" { - x.line(s) - } -} - func (x *genRunner) linef(s string, params ...interface{}) { x.outf(s, params...) if len(s) == 0 || s[len(s)-1] != '\n' { @@ -512,7 +460,7 @@ func (x *genRunner) linef(s string, params ...interface{}) { } func (x *genRunner) genTypeName(t reflect.Type) (n string) { - // defer func() { xdebugf(">>>> ####: genTypeName: t: %v, name: '%s'\n", t, n) }() + // defer func() { fmt.Printf(">>>> ####: genTypeName: t: %v, name: '%s'\n", t, n) }() // if the type has a PkgPath, which doesn't match the current package, // then include it. @@ -690,19 +638,14 @@ func (x *genRunner) registerXtraT(t reflect.Type) { // encVar will encode a variable. // The parameter, t, is the reflect.Type of the variable itself func (x *genRunner) encVar(varname string, t reflect.Type) { + // fmt.Printf(">>>>>> varname: %s, t: %v\n", varname, t) var checkNil bool - // case reflect.Ptr, reflect.Interface, reflect.Slice, reflect.Map, reflect.Chan: - // do not include checkNil for slice and maps, as we already checkNil below it switch t.Kind() { - case reflect.Ptr, reflect.Interface, reflect.Chan: + case reflect.Ptr, reflect.Interface, reflect.Slice, reflect.Map, reflect.Chan: checkNil = true } - x.encVarChkNil(varname, t, checkNil) -} - -func (x *genRunner) encVarChkNil(varname string, t reflect.Type, checkNil bool) { if checkNil { - x.linef("if %s == nil { r.EncodeNil() } else {", varname) + x.linef("if %s == nil { r.EncodeNil() } else { ", varname) } switch t.Kind() { @@ -731,6 +674,7 @@ func (x *genRunner) encVarChkNil(varname string, t reflect.Type, checkNil bool) if checkNil { x.line("}") } + } // enc will encode a variable (varname) of type t, where t represents T. @@ -749,18 +693,17 @@ func (x *genRunner) enc(varname string, t reflect.Type) { // tptr := reflect.PtrTo(t) tk := t.Kind() if x.checkForSelfer(t, varname) { - if tk == reflect.Array || - (tk == reflect.Struct && rtid != timeTypId) { // varname is of type *T + if tk == reflect.Array || (tk == reflect.Struct && rtid != timeTypId) { // varname is of type *T // if tptr.Implements(selferTyp) || t.Implements(selferTyp) { - if ti2.isFlag(tiflagSelfer) || ti2.isFlag(tiflagSelferPtr) { + if ti2.isFlag(typeInfoFlagIsZeroerPtr) || ti2.isFlag(typeInfoFlagIsZeroer) { x.line(varname + ".CodecEncodeSelf(e)") return } } else { // varname is of type T - if ti2.isFlag(tiflagSelfer) { + if ti2.cs { // t.Implements(selferTyp) { x.line(varname + ".CodecEncodeSelf(e)") return - } else if ti2.isFlag(tiflagSelferPtr) { + } else if ti2.csp { // tptr.Implements(selferTyp) { x.linef("%ssf%s := &%s", genTempVarPfx, mi, varname) x.linef("%ssf%s.CodecEncodeSelf(e)", genTempVarPfx, mi) return @@ -795,56 +738,53 @@ func (x *genRunner) enc(varname string, t reflect.Type) { // - type is time.Time, RawExt, Raw // - the type implements (Text|JSON|Binary)(Unm|M)arshal - var hasIf genIfClause - defer hasIf.end(x) // end if block (if necessary) + x.line("if false {") //start if block + defer func() { x.line("}") }() //end if block if t == timeTyp { - x.linef("%s !z.EncBasicHandle().TimeNotBuiltin { r.EncodeTime(%s)", hasIf.c(false), varname) + x.linef("} else if !z.EncBasicHandle().TimeNotBuiltin { r.EncodeTime(%s)", varname) // return } if t == rawTyp { - x.linef("%s z.EncRaw(%s)", hasIf.c(true), varname) + x.linef("} else { z.EncRaw(%s)", varname) return } if t == rawExtTyp { - x.linef("%s r.EncodeRawExt(%s)", hasIf.c(true), varname) + x.linef("} else { r.EncodeRawExt(%s, e)", varname) return } - // only check for extensions if extensions are configured, - // and the type is named, and has a packagePath, - // and this is not the CodecEncodeSelf or CodecDecodeSelf method (i.e. it is not a Selfer) + // 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 && varname != genTopLevelVarName && genImportPath(t) != "" && t.Name() != "" { + if !x.nx && genImportPath(t) != "" && t.Name() != "" { yy := fmt.Sprintf("%sxt%s", genTempVarPfx, mi) - x.linef("%s %s := z.Extension(z.I2Rtid(%s)); %s != nil { z.EncExtension(%s, %s) ", - hasIf.c(false), yy, varname, yy, varname, yy) + x.linef("} else if %s := z.Extension(z.I2Rtid(%s)); %s != nil { z.EncExtension(%s, %s) ", yy, varname, yy, varname, yy) } if arrayOrStruct { // varname is of type *T - if ti2.isFlag(tiflagBinaryMarshaler) || ti2.isFlag(tiflagBinaryMarshalerPtr) { - x.linef("%s z.EncBinary() { z.EncBinaryMarshal(%v) ", hasIf.c(false), varname) + if ti2.bm || ti2.bmp { // t.Implements(binaryMarshalerTyp) || tptr.Implements(binaryMarshalerTyp) { + x.linef("} else if z.EncBinary() { z.EncBinaryMarshal(%v) ", varname) } - if ti2.isFlag(tiflagJsonMarshaler) || ti2.isFlag(tiflagJsonMarshalerPtr) { - x.linef("%s !z.EncBinary() && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", hasIf.c(false), varname) - } else if ti2.isFlag(tiflagTextUnmarshaler) || ti2.isFlag(tiflagTextUnmarshalerPtr) { - x.linef("%s !z.EncBinary() { z.EncTextMarshal(%v) ", hasIf.c(false), 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 ti2.isFlag(tiflagBinaryMarshaler) { - x.linef("%s z.EncBinary() { z.EncBinaryMarshal(%v) ", hasIf.c(false), varname) - } else if ti2.isFlag(tiflagBinaryMarshalerPtr) { - x.linef("%s z.EncBinary() { z.EncBinaryMarshal(&%v) ", hasIf.c(false), 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 ti2.isFlag(tiflagJsonMarshaler) { - x.linef("%s !z.EncBinary() && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", hasIf.c(false), varname) - } else if ti2.isFlag(tiflagJsonMarshalerPtr) { - x.linef("%s !z.EncBinary() && z.IsJSONHandle() { z.EncJSONMarshal(&%v) ", hasIf.c(false), varname) - } else if ti2.isFlag(tiflagTextMarshaler) { - x.linef("%s !z.EncBinary() { z.EncTextMarshal(%v) ", hasIf.c(false), varname) - } else if ti2.isFlag(tiflagTextMarshalerPtr) { - x.linef("%s !z.EncBinary() { z.EncTextMarshal(&%v) ", hasIf.c(false), 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.lineIf(hasIf.c(true)) + x.line("} else {") switch t.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: @@ -858,7 +798,7 @@ func (x *genRunner) enc(varname string, t reflect.Type) { case reflect.Bool: x.line("r.EncodeBool(bool(" + varname + "))") case reflect.String: - x.linef("r.EncodeString(string(%s))", varname) + x.linef("if z.EncBasicHandle().StringToRaw { r.EncodeStringBytesRaw(z.BytesView(string(%s))) } else { r.EncodeStringEnc(codecSelferCcUTF8%s, string(%s)) }", varname, x.xs, varname) case reflect.Chan: x.xtraSM(varname, t, true, false) // x.encListFallback(varname, rtid, t) @@ -871,30 +811,29 @@ func (x *genRunner) enc(varname string, t reflect.Type) { // else write encode function in-line. // - if elements are primitives or Selfers, call dedicated function on each member. // - else call Encoder.encode(XXX) on it. - x.linef("if %s == nil { r.EncodeNil() } else {", varname) if rtid == uint8SliceTypId { x.line("r.EncodeStringBytesRaw([]byte(" + varname + "))") } else if fastpathAV.index(rtid) != -1 { - g := x.newFastpathGenV(t) + g := x.newGenV(t) x.line("z.F." + g.MethodNamePfx("Enc", false) + "V(" + varname + ", e)") } else { x.xtraSM(varname, t, true, false) + // x.encListFallback(varname, rtid, t) } - x.linef("} // end block: if %s slice == nil", varname) case reflect.Map: // if nil, call dedicated function // if a known fastpath map, call dedicated function // else write encode function in-line. // - if elements are primitives or Selfers, call dedicated function on each member. // - else call Encoder.encode(XXX) on it. - x.linef("if %s == nil { r.EncodeNil() } else {", varname) + // x.line("if " + varname + " == nil { \nr.EncodeNil()\n } else { ") if fastpathAV.index(rtid) != -1 { - g := x.newFastpathGenV(t) + g := x.newGenV(t) x.line("z.F." + g.MethodNamePfx("Enc", false) + "V(" + varname + ", e)") } else { x.xtraSM(varname, t, true, false) + // x.encMapFallback(varname, rtid, t) } - x.linef("} // end block: if %s map == nil", varname) case reflect.Struct: if !inlist { delete(x.te, rtid) @@ -923,17 +862,12 @@ func (x *genRunner) encZero(t reflect.Type) { case reflect.Bool: x.line("r.EncodeBool(false)") case reflect.String: - x.linef(`r.EncodeString("")`) + x.linef(`if z.EncBasicHandle().StringToRaw { r.EncodeStringBytesRaw([]byte{}) } else { r.EncodeStringEnc(codecSelferCcUTF8%s, "") }`, x.xs) default: x.line("r.EncodeNil()") } } -func (x *genRunner) doEncOmitEmptyLine(t2 reflect.StructField, varname string, buf *genBuf) { - x.f = 0 - x.encOmitEmptyLine(t2, varname, buf) -} - 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) @@ -947,16 +881,16 @@ func (x *genRunner) encOmitEmptyLine(t2 reflect.StructField, varname string, buf buf.s("!(").s(varname2).s(".IsZero())") break } - if ti2.isFlag(tiflagIsZeroerPtr) || ti2.isFlag(tiflagIsZeroer) { + if ti2.isFlag(typeInfoFlagIsZeroerPtr) || ti2.isFlag(typeInfoFlagIsZeroer) { buf.s("!(").s(varname2).s(".IsZero())") break } - if ti2.isFlag(tiflagComparable) { + if ti2.isFlag(typeInfoFlagComparable) { buf.s(varname2).s(" != ").s(x.genZeroValueR(t2.Type)) break } // buf.s("(") - buf.s(x.sayFalse()) // buf.s("false") + buf.s("false") for i, n := 0, t2.Type.NumField(); i < n; i++ { f := t2.Type.Field(i) if f.PkgPath != "" { // unexported @@ -1005,7 +939,9 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) { for j, si := range tisfi { _ = 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 @@ -1032,31 +968,36 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) { } } } - x.doEncOmitEmptyLine(t2, varname, &omitline) + x.encOmitEmptyLine(t2, varname, &omitline) x.linef("%s, // %s", omitline.v(), si.fieldName) } x.line("}") x.linef("_ = %s", numfieldsvar) } - - type genFQN struct { - i string - fqname string - nilLine genBuf - nilVar string - canNil bool - sf reflect.StructField + // 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 { + // 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) + } else { + x.linef("r.WriteMapStart(%d)", len(tisfi)) } + x.line("}") // close if not StructToArray - genFQNs := make([]genFQN, len(tisfi)) for j, si := range tisfi { - q := &genFQNs[j] - q.i = x.varsfx() - q.nilVar = genTempVarPfx + "n" + q.i - q.canNil = false - q.fqname = varname + i := x.varsfx() + isNilVarName := genTempVarPfx + "n" + i + var labelUsed bool + var t2 reflect.StructField { t2typ := t + varname3 := varname for ij, ix := range si.is { if uint8(ij) == si.nis { break @@ -1064,69 +1005,51 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) { for t2typ.Kind() == reflect.Ptr { t2typ = t2typ.Elem() } - q.sf = t2typ.Field(int(ix)) - t2typ = q.sf.Type - q.fqname += "." + q.sf.Name + t2 = t2typ.Field(int(ix)) + t2typ = t2.Type + varname3 = varname3 + "." + t2.Name if t2typ.Kind() == reflect.Ptr { - if !q.canNil { - q.nilLine.f("%s == nil", q.fqname) - q.canNil = true - } else { - q.nilLine.f(" || %s == nil", q.fqname) + if !labelUsed { + x.line("var " + isNilVarName + " bool") } + x.line("if " + varname3 + " == nil { " + isNilVarName + " = true ") + x.line("goto LABEL" + i) + x.line("}") + labelUsed = true + // "varname3 = new(" + x.genTypeName(t3.Elem()) + ") }") } } + // t2 = t.FieldByIndex(si.is) } - } - - for j := range genFQNs { - q := &genFQNs[j] - if q.canNil { - x.linef("var %s bool = %s", q.nilVar, q.nilLine.v()) + if labelUsed { + x.line("LABEL" + i + ":") } - } - - x.linef("if %s || %s {", ti2arrayvar, struct2arrvar) // if ti.toArray - x.linef("z.EncWriteArrayStart(%d)", len(tisfi)) - - for j, si := range tisfi { - q := &genFQNs[j] // if the type of the field is a Selfer, or one of the ones - if q.canNil { - x.linef("if %s { z.EncWriteArrayElem(); r.EncodeNil() } else { ", q.nilVar) + + x.linef("if %s || %s {", ti2arrayvar, struct2arrvar) // if ti.toArray + if labelUsed { + x.linef("if %s { r.WriteArrayElem(); r.EncodeNil() } else { ", isNilVarName) } - x.linef("z.EncWriteArrayElem()") + x.line("r.WriteArrayElem()") if si.omitEmpty() { x.linef("if %s[%v] {", numfieldsvar, j) } - x.encVarChkNil(q.fqname, q.sf.Type, false) + x.encVar(varname+"."+t2.Name, t2.Type) if si.omitEmpty() { x.linef("} else {") - x.encZero(q.sf.Type) + x.encZero(t2.Type) x.linef("}") } - if q.canNil { + if labelUsed { x.line("}") } - } - x.line("z.EncWriteArrayEnd()") - x.linef("} else {") // if not ti.toArray - if ti.anyOmitEmpty { - x.linef("var %snn%s int", genTempVarPfx, i) - x.linef("for _, b := range %s { if b { %snn%s++ } }", numfieldsvar, genTempVarPfx, i) - x.linef("z.EncWriteMapStart(%snn%s)", genTempVarPfx, i) - x.linef("%snn%s = %v", genTempVarPfx, i, 0) - } else { - x.linef("z.EncWriteMapStart(%d)", len(tisfi)) - } + x.linef("} else {") // if not ti.toArray - for j, si := range tisfi { - q := &genFQNs[j] if si.omitEmpty() { x.linef("if %s[%v] {", numfieldsvar, j) } - x.linef("z.EncWriteMapElemKey()") + x.line("r.WriteMapElemKey()") // emulate EncStructFieldKey switch ti.keyType { @@ -1140,29 +1063,34 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) { if si.encNameAsciiAlphaNum { x.linef(`if z.IsJSONHandle() { z.WriteStr("\"%s\"") } else { `, si.encName) } - x.linef("r.EncodeString(`%s`)", si.encName) + x.linef("r.EncodeStringEnc(codecSelferCcUTF8%s, `%s`)", x.xs, si.encName) if si.encNameAsciiAlphaNum { x.linef("}") } } - x.line("z.EncWriteMapElemValue()") - if q.canNil { - x.line("if " + q.nilVar + " { r.EncodeNil() } else { ") - x.encVarChkNil(q.fqname, q.sf.Type, false) + // 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) x.line("}") } else { - x.encVarChkNil(q.fqname, q.sf.Type, false) + x.encVar(varname+"."+t2.Name, t2.Type) } if si.omitEmpty() { x.line("}") } + x.linef("} ") // end if/else ti.toArray } - x.line("z.EncWriteMapEnd()") - x.linef("} ") // end if/else ti.toArray + x.linef("if %s || %s {", ti2arrayvar, struct2arrvar) // if ti.toArray { + x.line("r.WriteArrayEnd()") + x.line("} else {") + x.line("r.WriteMapEnd()") + x.line("}") + } func (x *genRunner) encListFallback(varname string, t reflect.Type) { - x.linef("if %s == nil { r.EncodeNil(); return }", varname) elemBytes := t.Elem().Kind() == reflect.Uint8 if t.AssignableTo(uint8SliceTyp) { x.linef("r.EncodeStringBytesRaw([]byte(%s))", varname) @@ -1187,6 +1115,7 @@ func (x *genRunner) encListFallback(varname string, t reflect.Type) { if err != nil { panic(err) } + // x.linef("%s = sch%s", varname, i) if elemBytes { x.linef("r.EncodeStringBytesRaw([]byte(%s))", "sch"+i) x.line("}") @@ -1195,38 +1124,37 @@ func (x *genRunner) encListFallback(varname string, t reflect.Type) { varname = "sch" + i } - x.line("z.EncWriteArrayStart(len(" + varname + "))") + x.line("r.WriteArrayStart(len(" + varname + "))") x.linef("for _, %sv%s := range %s {", genTempVarPfx, i, varname) - x.linef("z.EncWriteArrayElem()") + x.line("r.WriteArrayElem()") x.encVar(genTempVarPfx+"v"+i, t.Elem()) x.line("}") - x.line("z.EncWriteArrayEnd()") + x.line("r.WriteArrayEnd()") if t.Kind() == reflect.Chan { x.line("}") } } func (x *genRunner) encMapFallback(varname string, t reflect.Type) { - x.linef("if %s == nil { r.EncodeNil(); return }", varname) - // NOTE: Canonical Option is not honored + // TODO: expand this to handle canonical. i := x.varsfx() - x.line("z.EncWriteMapStart(len(" + varname + "))") + x.line("r.WriteMapStart(len(" + varname + "))") x.linef("for %sk%s, %sv%s := range %s {", genTempVarPfx, i, genTempVarPfx, i, varname) - x.linef("z.EncWriteMapElemKey()") + x.line("r.WriteMapElemKey()") x.encVar(genTempVarPfx+"k"+i, t.Key()) - x.line("z.EncWriteMapElemValue()") + x.line("r.WriteMapElemValue()") x.encVar(genTempVarPfx+"v"+i, t.Elem()) x.line("}") - x.line("z.EncWriteMapEnd()") + x.line("r.WriteMapEnd()") } func (x *genRunner) decVarInitPtr(varname, nilvar string, t reflect.Type, si *structFieldInfo, - newbuf, nilbuf *genBuf) (varname3 string, t2 reflect.StructField) { + 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) - varname3 = varname t2typ := t + varname3 := varname t2kind := t2typ.Kind() var nilbufed bool if si != nil { @@ -1234,8 +1162,7 @@ func (x *genRunner) decVarInitPtr(varname, nilvar string, t reflect.Type, si *st if uint8(ij) == si.nis { break } - // only one-level pointers can be seen in a type - if t2typ.Kind() == reflect.Ptr { + for t2typ.Kind() == reflect.Ptr { t2typ = t2typ.Elem() } t2 = t2typ.Field(int(ix)) @@ -1246,24 +1173,23 @@ func (x *genRunner) decVarInitPtr(varname, nilvar string, t reflect.Type, si *st continue } if newbuf != nil { - if len(newbuf.buf) > 0 { - newbuf.s("\n") - } - newbuf.f("if %s == nil { %s = new(%s) }", varname3, varname3, x.genTypeName(t2typ.Elem())) + newbuf.f("if %s == nil { %s = new(%s) }\n", varname3, varname3, x.genTypeName(t2typ.Elem())) } if nilbuf != nil { if !nilbufed { - nilbuf.s("if ").s(varname3).s(" != nil") + nilbuf.s("if true") nilbufed = true - } else { - nilbuf.s(" && ").s(varname3).s(" != nil") } + nilbuf.s(" && ").s(varname3).s(" != nil") } } } + // if t2typ.Kind() == reflect.Ptr { + // varname3 = varname3 + t2.Name + // } if nilbuf != nil { if nilbufed { - nilbuf.s(" { ").s("// remove the if-true\n") + nilbuf.s(" { ") } if nilvar != "" { nilbuf.s(nilvar).s(" = true") @@ -1280,7 +1206,7 @@ func (x *genRunner) decVarInitPtr(varname, nilvar string, t reflect.Type, si *st nilbuf.s("}") } } - return + return t2 } // decVar takes a variable called varname, of type t @@ -1306,7 +1232,8 @@ func (x *genRunner) decVarMain(varname, rand string, t reflect.Type, checkNotNil for t = t.Elem(); t.Kind() == reflect.Ptr; t = t.Elem() { ptrPfx += "*" if checkNotNil { - x.linef("if %s%s == nil { %s%s = new(%s)}", ptrPfx, varname, ptrPfx, varname, x.genTypeName(t)) + 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. @@ -1323,6 +1250,7 @@ func (x *genRunner) decVarMain(varname, rand string, t reflect.Type, checkNotNil // 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. @@ -1331,15 +1259,22 @@ func (x *genRunner) decVar(varname, nilvar string, t reflect.Type, canBeNil, che // 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 t.Kind() == reflect.Ptr { + if !canBeNil { + canBeNil = genAnythingCanBeNil || !genIsImmutable(t) + } + + if canBeNil { var buf genBuf x.decVarInitPtr(varname, nilvar, t, nil, nil, &buf) - x.linef("if r.TryNil() { %s } else {", buf.buf) - x.decVarMain(varname, i, t, checkNotNil) - x.line("} ") + x.linef("if r.TryDecodeAsNil() { %s } else {", buf.buf) } else { - x.decVarMain(varname, i, t, checkNotNil) + x.line("// cannot be nil") + } + + x.decVarMain(varname, i, t, checkNotNil) + + if canBeNil { + x.line("} ") } } @@ -1351,8 +1286,9 @@ func (x *genRunner) dec(varname string, t reflect.Type, isptr bool) { // - t is always a baseType T (not a *T, etc). rtid := rt2id(t) ti2 := x.ti.get(rtid, t) + // tptr := reflect.PtrTo(t) if x.checkForSelfer(t, varname) { - if ti2.isFlag(tiflagSelfer) || ti2.isFlag(tiflagSelferPtr) { + if ti2.cs || ti2.csp { // t.Implements(selferTyp) || tptr.Implements(selferTyp) { x.line(varname + ".CodecDecodeSelf(d)") return } @@ -1385,9 +1321,10 @@ func (x *genRunner) dec(varname string, t reflect.Type, isptr bool) { // - the type implements (Text|JSON|Binary)(Unm|M)arshal mi := x.varsfx() - - var hasIf genIfClause - defer hasIf.end(x) + // 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 { @@ -1396,38 +1333,37 @@ func (x *genRunner) dec(varname string, t reflect.Type, isptr bool) { addrPfx = "&" } if t == timeTyp { - x.linef("%s !z.DecBasicHandle().TimeNotBuiltin { %s%v = r.DecodeTime()", hasIf.c(false), ptrPfx, varname) + x.linef("} else if !z.DecBasicHandle().TimeNotBuiltin { %s%v = r.DecodeTime()", ptrPfx, varname) // return } if t == rawTyp { - x.linef("%s %s%v = z.DecRaw()", hasIf.c(true), ptrPfx, varname) + x.linef("} else { %s%v = z.DecRaw()", ptrPfx, varname) return } if t == rawExtTyp { - x.linef("%s r.DecodeExt(%s%v, 0, nil)", hasIf.c(true), addrPfx, varname) + x.linef("} else { r.DecodeExt(%s%v, 0, nil)", addrPfx, varname) return } - // only check for extensions if extensions are configured, - // and the type is named, and has a packagePath, - // and this is not the CodecEncodeSelf or CodecDecodeSelf method (i.e. it is not a Selfer) - if !x.nx && varname != genTopLevelVarName && genImportPath(t) != "" && t.Name() != "" { + // 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) yy := fmt.Sprintf("%sxt%s", genTempVarPfx, mi) - x.linef("%s %s := z.Extension(z.I2Rtid(%s)); %s != nil { z.DecExtension(%s, %s) ", hasIf.c(false), yy, varname, yy, varname, yy) + x.linef("} else if %s := z.Extension(z.I2Rtid(%s)); %s != nil { z.DecExtension(%s, %s) ", yy, varname, yy, varname, yy) } - if ti2.isFlag(tiflagBinaryUnmarshaler) || ti2.isFlag(tiflagBinaryUnmarshalerPtr) { - x.linef("%s z.DecBinary() { z.DecBinaryUnmarshal(%s%v) ", hasIf.c(false), addrPfx, 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 ti2.isFlag(tiflagJsonUnmarshaler) || ti2.isFlag(tiflagJsonUnmarshalerPtr) { - x.linef("%s !z.DecBinary() && z.IsJSONHandle() { z.DecJSONUnmarshal(%s%v)", hasIf.c(false), addrPfx, varname) - } else if ti2.isFlag(tiflagTextUnmarshaler) || ti2.isFlag(tiflagTextUnmarshalerPtr) { - x.linef("%s !z.DecBinary() { z.DecTextUnmarshal(%s%v)", hasIf.c(false), addrPfx, 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.lineIf(hasIf.c(true)) + x.line("} else {") if x.decTryAssignPrimitive(varname, t, isptr) { return @@ -1446,7 +1382,7 @@ func (x *genRunner) dec(varname string, t reflect.Type, isptr bool) { x.linef("%s%s = r.DecodeBytes(%s(%s[]byte)(%s), false)", ptrPfx, varname, ptrPfx, ptrPfx, varname) } else if fastpathAV.index(rtid) != -1 { - g := x.newFastpathGenV(t) + g := x.newGenV(t) x.linef("z.F.%sX(%s%s, d)", g.MethodNamePfx("Dec", false), addrPfx, varname) } else { x.xtraSM(varname, t, false, isptr) @@ -1458,10 +1394,11 @@ func (x *genRunner) dec(varname string, t reflect.Type, isptr bool) { // - if elements are primitives or Selfers, call dedicated function on each member. // - else call Encoder.encode(XXX) on it. if fastpathAV.index(rtid) != -1 { - g := x.newFastpathGenV(t) + g := x.newGenV(t) x.linef("z.F.%sX(%s%s, d)", g.MethodNamePfx("Dec", false), addrPfx, varname) } else { x.xtraSM(varname, t, false, isptr) + // x.decMapFallback(varname, rtid, t) } case reflect.Struct: if inlist { @@ -1520,14 +1457,14 @@ func (x *genRunner) decTryAssignPrimitive(varname string, t reflect.Type, isptr 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%s = (%s)(z.DecDecodeFloat32())", ptr, varname, x.genTypeName(t)) + x.linef("%s%s = (%s)(r.DecodeFloat32As64())", ptr, varname, x.genTypeName(t)) case reflect.Float64: x.linef("%s%s = (%s)(r.DecodeFloat64())", ptr, varname, x.genTypeName(t)) case reflect.Bool: x.linef("%s%s = (%s)(r.DecodeBool())", ptr, varname, x.genTypeName(t)) case reflect.String: - x.linef("%s%s = (%s)(string(r.DecodeStringAsBytes()))", ptr, varname, x.genTypeName(t)) + x.linef("%s%s = (%s)(r.DecodeString())", ptr, varname, x.genTypeName(t)) default: return false } @@ -1545,7 +1482,6 @@ func (x *genRunner) decListFallback(varname string, rtid uintptr, t reflect.Type } type tstruc struct { TempVar string - Sfx string Rand string Varname string CTyp string @@ -1554,7 +1490,7 @@ func (x *genRunner) decListFallback(varname string, rtid uintptr, t reflect.Type Size int } telem := t.Elem() - ts := tstruc{genTempVarPfx, x.xs, x.varsfx(), varname, x.genTypeName(t), x.genTypeName(telem), genIsImmutable(telem), int(telem.Size())} + ts := tstruc{genTempVarPfx, x.varsfx(), varname, x.genTypeName(t), x.genTypeName(telem), genIsImmutable(telem), int(telem.Size())} funcs := make(template.FuncMap) @@ -1565,9 +1501,6 @@ func (x *genRunner) decListFallback(varname string, rtid uintptr, t reflect.Type funcs["var"] = func(s string) string { return ts.TempVar + s + ts.Rand } - funcs["xs"] = func() string { - return ts.Sfx - } funcs["zero"] = func() string { return x.genZeroValueR(telem) } @@ -1630,9 +1563,6 @@ func (x *genRunner) decMapFallback(varname string, rtid uintptr, t reflect.Type) funcs["var"] = func(s string) string { return ts.TempVar + s + ts.Rand } - funcs["xs"] = func() string { - return ts.Sfx - } tm, err := template.New("").Funcs(funcs).Parse(genDecMapTmpl) if err != nil { @@ -1652,14 +1582,10 @@ func (x *genRunner) decStructMapSwitch(kName string, varname string, rtid uintpt x.line("case \"" + si.encName + "\":") newbuf.reset() nilbuf.reset() - varname3, t2 := x.decVarInitPtr(varname, "", t, si, &newbuf, &nilbuf) - if len(newbuf.buf) > 0 { - x.linef("if r.TryNil() { %s } else { %s", nilbuf.buf, newbuf.buf) - } - x.decVarMain(varname3, x.varsfx(), t2.Type, false) - if len(newbuf.buf) > 0 { - x.line("}") - } + 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 @@ -1677,14 +1603,14 @@ func (x *genRunner) decStructMap(varname, lenvarname string, rtid uintptr, t ref case genStructMapStyleLenPrefix: x.linef("for %sj%s := 0; %sj%s < %s; %sj%s++ {", tpfx, i, tpfx, i, lenvarname, tpfx, i) case genStructMapStyleCheckBreak: - x.linef("for %sj%s := 0; !z.DecCheckBreak(); %sj%s++ {", tpfx, i, tpfx, i) + x.linef("for %sj%s := 0; !r.CheckBreak(); %sj%s++ {", tpfx, i, tpfx, i) default: // 0, otherwise. x.linef("var %shl%s bool = %s >= 0", tpfx, i, lenvarname) // has length x.linef("for %sj%s := 0; ; %sj%s++ {", tpfx, i, tpfx, i) x.linef("if %shl%s { if %sj%s >= %s { break }", tpfx, i, tpfx, i, lenvarname) - x.line("} else { if z.DecCheckBreak() { break }; }") + x.line("} else { if r.CheckBreak() { break }; }") } - x.line("z.DecReadMapElemKey()") + x.line("r.ReadMapElemKey()") // emulate decstructfieldkey switch ti.keyType { @@ -1697,11 +1623,13 @@ func (x *genRunner) decStructMap(varname, lenvarname string, rtid uintptr, t ref 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("z.DecReadMapElemValue()") + x.line("r.ReadMapElemValue()") x.decStructMapSwitch(kName, varname, rtid, t) x.line("} // end for " + tpfx + "j" + i) + x.line("r.ReadMapEnd()") } func (x *genRunner) decStructArray(varname, lenvarname, breakString string, rtid uintptr, t reflect.Type) { @@ -1712,56 +1640,40 @@ func (x *genRunner) decStructArray(varname, lenvarname, breakString string, rtid 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 - if !genDecStructArrayInlineLoopCheck { - x.linef("var %sfn%s = func() bool { ", tpfx, i) - x.linef("%sj%s++; if %shl%s { %sb%s = %sj%s > %s } else { %sb%s = z.DecCheckBreak() };", - tpfx, i, tpfx, i, tpfx, i, - tpfx, i, lenvarname, tpfx, i) - x.linef("if %sb%s { z.DecReadArrayEnd(); return true }; return false", tpfx, i) - x.linef("} // end func %sfn%s", tpfx, i) - } var newbuf, nilbuf genBuf for _, si := range tisfi { - if genDecStructArrayInlineLoopCheck { - x.linef("%sj%s++; if %shl%s { %sb%s = %sj%s > %s } else { %sb%s = z.DecCheckBreak() }", - tpfx, i, tpfx, i, tpfx, i, - tpfx, i, lenvarname, tpfx, i) - x.linef("if %sb%s { z.DecReadArrayEnd(); %s }", tpfx, i, breakString) - } else { - x.linef("if %sfn%s() { %s }", tpfx, i, breakString) - } - x.line("z.DecReadArrayElem()") + 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.line("r.ReadArrayElem()") newbuf.reset() nilbuf.reset() - varname3, t2 := x.decVarInitPtr(varname, "", t, si, &newbuf, &nilbuf) - if len(newbuf.buf) > 0 { - x.linef("if r.TryNil() { %s } else { %s", nilbuf.buf, newbuf.buf) - } - x.decVarMain(varname3, x.varsfx(), t2.Type, false) - if len(newbuf.buf) > 0 { - x.line("}") - } + 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 {") - x.linef("%sj%s++; if %shl%s { %sb%s = %sj%s > %s } else { %sb%s = z.DecCheckBreak() }", + 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 { break }", tpfx, i) - x.line("z.DecReadArrayElem()") + x.line("r.ReadArrayElem()") x.linef(`z.DecStructFieldNotFound(%sj%s - 1, "")`, tpfx, i) x.line("}") + x.line("r.ReadArrayEnd()") } func (x *genRunner) decStruct(varname string, rtid uintptr, t reflect.Type) { // 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 == codecSelferValueTypeNil%s {", genTempVarPfx, i, x.xs) - x.linef("*(%s) = %s{}", varname, x.genTypeName(t)) - x.linef("} else if %sct%s == codecSelferValueTypeMap%s {", genTempVarPfx, i, x.xs) - x.line(genTempVarPfx + "l" + i + " := z.DecReadMapStart()") + 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()") if genUseOneFunctionForDecStructMap { x.line("} else { ") x.linef("%s.codecDecodeSelfFromMap(%sl%s, d)", varname, genTempVarPfx, i) @@ -1772,15 +1684,15 @@ func (x *genRunner) decStruct(varname string, rtid uintptr, t reflect.Type) { x.line(varname + ".codecDecodeSelfFromMapCheckBreak(" + genTempVarPfx + "l" + i + ", d)") } x.line("}") - x.line("z.DecReadMapEnd()") // else if container is array x.linef("} else if %sct%s == codecSelferValueTypeArray%s {", genTempVarPfx, i, x.xs) - x.line(genTempVarPfx + "l" + i + " := z.DecReadArrayStart()") - x.linef("if %sl%s != 0 {", genTempVarPfx, i) + x.line(genTempVarPfx + "l" + i + " := r.ReadArrayStart()") + x.linef("if %sl%s == 0 {", genTempVarPfx, i) + x.line("r.ReadArrayEnd()") + x.line("} else { ") x.linef("%s.codecDecodeSelfFromArray(%sl%s, d)", varname, genTempVarPfx, i) x.line("}") - x.line("z.DecReadArrayEnd()") // else panic x.line("} else { ") x.line("panic(errCodecSelferOnlyMapOrArrayEncodeToStruct" + x.xs + ")") @@ -1789,17 +1701,15 @@ func (x *genRunner) decStruct(varname string, rtid uintptr, t reflect.Type) { // -------- -type fastpathGenV struct { - // fastpathGenV is either a primitive (Primitive != "") or a map (MapKey != "") or a slice - MapKey string - Elem string - Primitive string - Size int - NoCanonical bool +type genV struct { + // genV is either a primitive (Primitive != "") or a map (MapKey != "") or a slice + MapKey string + Elem string + Primitive string + Size int } -func (x *genRunner) newFastpathGenV(t reflect.Type) (v fastpathGenV) { - v.NoCanonical = !genFastpathCanonical +func (x *genRunner) newGenV(t reflect.Type) (v genV) { switch t.Kind() { case reflect.Slice, reflect.Array: te := t.Elem() @@ -1811,12 +1721,12 @@ func (x *genRunner) newFastpathGenV(t reflect.Type) (v fastpathGenV) { v.MapKey = x.genTypeName(tk) v.Size = int(te.Size() + tk.Size()) default: - panic("unexpected type for newFastpathGenV. Requires map or slice type") + panic("unexpected type for newGenV. Requires map or slice type") } return } -func (x *fastpathGenV) MethodNamePfx(prefix string, prim bool) string { +func (x *genV) MethodNamePfx(prefix string, prim bool) string { var name []byte if prefix != "" { name = append(name, prefix...) @@ -1833,6 +1743,7 @@ func (x *fastpathGenV) MethodNamePfx(prefix string, prim bool) string { name = append(name, genTitleCaseName(x.Elem)...) } return string(name) + } // genImportPath returns import path of a non-predeclared named typed, or an empty string otherwise. @@ -1880,8 +1791,6 @@ func genTitleCaseName(s string) string { switch s { case "interface{}", "interface {}": return "Intf" - case "[]byte", "[]uint8", "bytes": - return "Bytes" default: return strings.ToUpper(s[0:1]) + s[1:] } @@ -1969,7 +1878,7 @@ func genIsImmutable(t reflect.Type) (v bool) { type genInternal struct { Version int - Values []fastpathGenV + Values []genV } func (x genInternal) FastpathLen() (l int) { @@ -1985,8 +1894,6 @@ func genInternalZeroValue(s string) string { switch s { case "interface{}", "interface {}": return "nil" - case "[]byte", "[]uint8", "bytes": - return "nil" case "bool": return "false" case "string": @@ -1996,59 +1903,49 @@ func genInternalZeroValue(s string) string { } } -var genInternalNonZeroValueIdx [6]uint64 -var genInternalNonZeroValueStrs = [...][6]string{ - {`"string-is-an-interface-1"`, "true", `"some-string-1"`, `[]byte("some-string-1")`, "11.1", "111"}, - {`"string-is-an-interface-2"`, "false", `"some-string-2"`, `[]byte("some-string-2")`, "22.2", "77"}, - {`"string-is-an-interface-3"`, "true", `"some-string-3"`, `[]byte("some-string-3")`, "33.3e3", "127"}, +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"}, } -// Note: last numbers must be in range: 0-127 (as they may be put into a int8, uint8, etc) - func genInternalNonZeroValue(s string) string { - var i int switch s { case "interface{}", "interface {}": - i = 0 + genInternalNonZeroValueIdx[0]++ + return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[0]%2][0] // return string, to remove ambiguity case "bool": - i = 1 + genInternalNonZeroValueIdx[1]++ + return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[1]%2][1] case "string": - i = 2 - case "bytes", "[]byte", "[]uint8": - i = 3 + genInternalNonZeroValueIdx[2]++ + return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[2]%2][2] case "float32", "float64", "float", "double": - i = 4 + genInternalNonZeroValueIdx[3]++ + return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[3]%2][3] default: - i = 5 + genInternalNonZeroValueIdx[4]++ + return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[4]%2][4] } - genInternalNonZeroValueIdx[i]++ - idx := genInternalNonZeroValueIdx[i] - slen := uint64(len(genInternalNonZeroValueStrs)) - return genInternalNonZeroValueStrs[idx%slen][i] // return string, to remove ambiguity } func genInternalEncCommandAsString(s string, vname string) string { switch s { - case "uint64": - return "e.e.EncodeUint(" + vname + ")" - case "uint", "uint8", "uint16", "uint32": - return "e.e.EncodeUint(uint64(" + vname + "))" - case "int64": - return "e.e.EncodeInt(" + vname + ")" - case "int", "int8", "int16", "int32": - return "e.e.EncodeInt(int64(" + vname + "))" - case "[]byte", "[]uint8", "bytes": - return "e.e.EncodeStringBytesRaw(" + vname + ")" + case "uint", "uint8", "uint16", "uint32", "uint64": + return "ee.EncodeUint(uint64(" + vname + "))" + case "int", "int8", "int16", "int32", "int64": + return "ee.EncodeInt(int64(" + vname + "))" case "string": - return "e.e.EncodeString(" + vname + ")" + return "if e.h.StringToRaw { ee.EncodeStringBytesRaw(bytesView(" + vname + ")) " + + "} else { ee.EncodeStringEnc(cUTF8, " + vname + ") }" case "float32": - return "e.e.EncodeFloat32(" + vname + ")" + return "ee.EncodeFloat32(" + vname + ")" case "float64": - return "e.e.EncodeFloat64(" + vname + ")" + return "ee.EncodeFloat64(" + vname + ")" case "bool": - return "e.e.EncodeBool(" + vname + ")" + return "ee.EncodeBool(" + vname + ")" // case "symbol": - // return "e.e.EncodeSymbol(" + vname + ")" + // return "ee.EncodeSymbol(" + vname + ")" default: return "e.encode(" + vname + ")" } @@ -2057,61 +1954,50 @@ func genInternalEncCommandAsString(s string, vname string) string { func genInternalDecCommandAsString(s string) string { switch s { case "uint": - return "uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))" + return "uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))" case "uint8": - return "uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))" + return "uint8(chkOvf.UintV(dd.DecodeUint64(), 8))" case "uint16": - return "uint16(chkOvf.UintV(d.d.DecodeUint64(), 16))" + return "uint16(chkOvf.UintV(dd.DecodeUint64(), 16))" case "uint32": - return "uint32(chkOvf.UintV(d.d.DecodeUint64(), 32))" + return "uint32(chkOvf.UintV(dd.DecodeUint64(), 32))" case "uint64": - return "d.d.DecodeUint64()" + return "dd.DecodeUint64()" case "uintptr": - return "uintptr(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))" + return "uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))" case "int": - return "int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))" + return "int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))" case "int8": - return "int8(chkOvf.IntV(d.d.DecodeInt64(), 8))" + return "int8(chkOvf.IntV(dd.DecodeInt64(), 8))" case "int16": - return "int16(chkOvf.IntV(d.d.DecodeInt64(), 16))" + return "int16(chkOvf.IntV(dd.DecodeInt64(), 16))" case "int32": - return "int32(chkOvf.IntV(d.d.DecodeInt64(), 32))" + return "int32(chkOvf.IntV(dd.DecodeInt64(), 32))" case "int64": - return "d.d.DecodeInt64()" + return "dd.DecodeInt64()" case "string": - return "string(d.d.DecodeStringAsBytes())" - case "[]byte", "[]uint8", "bytes": - return "d.d.DecodeBytes(nil, false)" + return "dd.DecodeString()" case "float32": - return "float32(d.decodeFloat32())" + return "float32(chkOvf.Float32V(dd.DecodeFloat64()))" case "float64": - return "d.d.DecodeFloat64()" + return "dd.DecodeFloat64()" case "bool": - return "d.d.DecodeBool()" + return "dd.DecodeBool()" default: panic(errors.New("gen internal: unknown type for decode: " + s)) } } func genInternalSortType(s string, elem bool) string { - for _, v := range [...]string{ - "int", - "uint", - "float", - "bool", - "string", - "bytes", "[]uint8", "[]byte", - } { - if v == "[]byte" || v == "[]uint8" { - v = "bytes" - } + for _, v := range [...]string{"int", "uint", "float", "bool", "string"} { if strings.HasPrefix(s, v) { - if v == "int" || v == "uint" || v == "float" { - v += "64" - } if elem { - return v + if v == "int" || v == "uint" || v == "float" { + return v + "64" + } else { + return v + } } return v + "Slice" } @@ -2138,12 +2024,49 @@ var genInternalTmplFuncs template.FuncMap var genInternalOnce sync.Once func genInternalInit() { + types := [...]string{ + "interface{}", + "string", + "float32", + "float64", + "uint", + "uint8", + "uint16", + "uint32", + "uint64", + "uintptr", + "int", + "int8", + "int16", + "int32", + "int64", + "bool", + } + // keep as slice, so it is in specific iteration order. + // Initial order was uint64, string, interface{}, int, int64 + mapvaltypes := [...]string{ + "interface{}", + "string", + "uint", + "uint8", + "uint16", + "uint32", + "uint64", + "uintptr", + "int", + "int8", + "int16", + "int32", + "int64", + "float32", + "float64", + "bool", + } wordSizeBytes := int(intBitsize) / 8 - typesizes := map[string]int{ + mapvaltypes2 := map[string]int{ "interface{}": 2 * wordSizeBytes, "string": 2 * wordSizeBytes, - "[]byte": 3 * wordSizeBytes, "uint": 1 * wordSizeBytes, "uint8": 1, "uint16": 2, @@ -2159,133 +2082,20 @@ func genInternalInit() { "float64": 8, "bool": 1, } - - // keep as slice, so it is in specific iteration order. - // Initial order was uint64, string, interface{}, int, int64, ... - - var types = [...]string{ - "interface{}", - "string", - "[]byte", - "float32", - "float64", - "uint", - "uint8", - "uint16", - "uint32", - "uint64", - "uintptr", - "int", - "int8", - "int16", - "int32", - "int64", - "bool", - } - - var primitivetypes, slicetypes, mapkeytypes, mapvaltypes []string - - primitivetypes = types[:] - slicetypes = types[:] - mapkeytypes = types[:] - mapvaltypes = types[:] - - if genFastpathTrimTypes { - slicetypes = []string{ - "interface{}", - "string", - "[]byte", - "float32", - "float64", - "uint", - // "uint8", // no need for fastpath of []uint8, as it is handled specially - "uint16", - "uint32", - "uint64", - // "uintptr", - "int", - "int8", - "int16", - "int32", - "int64", - "bool", - } - - mapkeytypes = []string{ - //"interface{}", - "string", - //"[]byte", - //"float32", - //"float64", - "uint", - "uint8", - //"uint16", - //"uint32", - "uint64", - //"uintptr", - "int", - //"int8", - //"int16", - //"int32", - "int64", - // "bool", - } - - mapvaltypes = []string{ - "interface{}", - "string", - "[]byte", - "uint", - "uint8", - //"uint16", - //"uint32", - "uint64", - // "uintptr", - "int", - //"int8", - //"int16", - //"int32", - "int64", - "float32", - "float64", - "bool", - } - } - - // var mapkeytypes [len(&types) - 1]string // skip bool - // copy(mapkeytypes[:], types[:]) - - // var mb []byte - // mb = append(mb, '|') - // for _, s := range mapkeytypes { - // mb = append(mb, s...) - // mb = append(mb, '|') - // } - // var mapkeytypestr = string(mb) - var gt = genInternal{Version: genVersion} // For each slice or map type, there must be a (symmetrical) Encode and Decode fast-path function - - for _, s := range primitivetypes { - gt.Values = append(gt.Values, - fastpathGenV{Primitive: s, Size: typesizes[s], NoCanonical: !genFastpathCanonical}) - } - for _, s := range slicetypes { + 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, fastpathGenV{Elem: s, Size: typesizes[s]}) - // } - gt.Values = append(gt.Values, - fastpathGenV{Elem: s, Size: typesizes[s], NoCanonical: !genFastpathCanonical}) - } - for _, s := range mapkeytypes { - // if _, ok := typesizes[s]; !ok { - // if strings.Contains(mapkeytypestr, "|"+s+"|") { - // gt.Values = append(gt.Values, fastpathGenV{MapKey: s, Elem: s, Size: 2 * typesizes[s]}) + // 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]}) + } for _, ms := range mapvaltypes { - gt.Values = append(gt.Values, - fastpathGenV{MapKey: s, Elem: ms, Size: typesizes[s] + typesizes[ms], NoCanonical: !genFastpathCanonical}) + gt.Values = append(gt.Values, genV{MapKey: s, Elem: ms, Size: mapvaltypes2[s] + mapvaltypes2[ms]}) } } diff --git a/vendor/github.com/ugorji/go/codec/go.mod b/vendor/github.com/ugorji/go/codec/go.mod deleted file mode 100644 index b4760da40717..000000000000 --- a/vendor/github.com/ugorji/go/codec/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module github.com/ugorji/go/codec - -require ( -github.com/ugorji/go v1.1.7 -) diff --git a/vendor/github.com/ugorji/go/codec/goversion_fmt_time_gte_go15.go b/vendor/github.com/ugorji/go/codec/goversion_fmt_time_gte_go15.go deleted file mode 100644 index a35359887291..000000000000 --- a/vendor/github.com/ugorji/go/codec/goversion_fmt_time_gte_go15.go +++ /dev/null @@ -1,12 +0,0 @@ -// 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 - -package codec - -import "time" - -func fmtTime(t time.Time, b []byte) []byte { - return t.AppendFormat(b, time.RFC3339Nano) -} diff --git a/vendor/github.com/ugorji/go/codec/goversion_fmt_time_lt_go15.go b/vendor/github.com/ugorji/go/codec/goversion_fmt_time_lt_go15.go deleted file mode 100644 index 41700c32179b..000000000000 --- a/vendor/github.com/ugorji/go/codec/goversion_fmt_time_lt_go15.go +++ /dev/null @@ -1,15 +0,0 @@ -// 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 - -package codec - -import "time" - -func fmtTime(t time.Time, b []byte) []byte { - s := t.Format(time.RFC3339Nano) - b = b[:len(s)] - copy(b, s) - return b -} diff --git a/vendor/github.com/ugorji/go/codec/goversion_maprange_gte_go112.go b/vendor/github.com/ugorji/go/codec/goversion_maprange_gte_go112.go deleted file mode 100644 index 9931cb6ead63..000000000000 --- a/vendor/github.com/ugorji/go/codec/goversion_maprange_gte_go112.go +++ /dev/null @@ -1,44 +0,0 @@ -// 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.12 -// +build safe - -package codec - -import "reflect" - -type mapIter struct { - t *reflect.MapIter - m reflect.Value - values bool -} - -func (t *mapIter) ValidKV() (r bool) { - return true -} - -func (t *mapIter) Next() (r bool) { - return t.t.Next() -} - -func (t *mapIter) Key() reflect.Value { - return t.t.Key() -} - -func (t *mapIter) Value() (r reflect.Value) { - if t.values { - return t.t.Value() - } - return -} - -func (t *mapIter) Done() {} - -func mapRange(t *mapIter, m, k, v reflect.Value, values bool) { - *t = mapIter{ - m: m, - t: m.MapRange(), - values: values, - } -} diff --git a/vendor/github.com/ugorji/go/codec/goversion_maprange_lt_go112.go b/vendor/github.com/ugorji/go/codec/goversion_maprange_lt_go112.go deleted file mode 100644 index 1f020bde026a..000000000000 --- a/vendor/github.com/ugorji/go/codec/goversion_maprange_lt_go112.go +++ /dev/null @@ -1,47 +0,0 @@ -// 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.12 -// +build !go1.7 safe - -package codec - -import "reflect" - -type mapIter struct { - m reflect.Value - keys []reflect.Value - j int - values bool -} - -func (t *mapIter) ValidKV() (r bool) { - return true -} - -func (t *mapIter) Next() (r bool) { - t.j++ - return t.j < len(t.keys) -} - -func (t *mapIter) Key() reflect.Value { - return t.keys[t.j] -} - -func (t *mapIter) Value() (r reflect.Value) { - if t.values { - return t.m.MapIndex(t.keys[t.j]) - } - return -} - -func (t *mapIter) Done() {} - -func mapRange(t *mapIter, m, k, v reflect.Value, values bool) { - *t = mapIter{ - m: m, - keys: m.MapKeys(), - values: values, - j: -1, - } -} diff --git a/vendor/github.com/ugorji/go/codec/helper.go b/vendor/github.com/ugorji/go/codec/helper.go index 8f7626bc0c1c..8ada846bee08 100644 --- a/vendor/github.com/ugorji/go/codec/helper.go +++ b/vendor/github.com/ugorji/go/codec/helper.go @@ -28,6 +28,16 @@ package codec // Some streams also are text-based, and use explicit separators to denote the // end/beginning of different values. // +// During encode, we use a high-level condition to determine how to iterate through +// the container. That decision is based on whether the container is text-based (with +// separators) or binary (without separators). If binary, we do not even call the +// encoding of separators. +// +// During decode, we use a different high-level condition to determine how to iterate +// through the containers. That decision is based on whether the stream contained +// a length prefix, or if it used explicit breaks. If length-prefixed, we assume that +// it has to be binary, and we do not even try to read separators. +// // Philosophy // ------------ // On decode, this codec will update containers appropriately: @@ -75,59 +85,16 @@ package codec // and we don't have to keep sending the error value along with each call // or storing it in the En|Decoder and checking it constantly along the way. // +// The disadvantage is that small functions which use panics cannot be inlined. +// The code accounts for that by only using panics behind an interface; +// since interface calls cannot be inlined, this is irrelevant. +// // We considered storing the error is En|Decoder. // - once it has its err field set, it cannot be used again. // - panicing will be optional, controlled by const flag. // - code should always check error first and return early. -// // We eventually decided against it as it makes the code clumsier to always // check for these error conditions. -// -// ------------------------------------------ -// We use sync.Pool only for the aid of long-lived objects shared across multiple goroutines. -// Encoder, Decoder, enc|decDriver, reader|writer, etc do not fall into this bucket. -// -// Also, GC is much better now, eliminating some of the reasons to use a shared pool structure. -// Instead, the short-lived objects use free-lists that live as long as the object exists. -// -// ------------------------------------------ -// Performance is affected by the following: -// - Bounds Checking -// - Inlining -// - Pointer chasing -// This package tries hard to manage the performance impact of these. -// -// ------------------------------------------ -// To alleviate performance due to pointer-chasing: -// - Prefer non-pointer values in a struct field -// - Refer to these directly within helper classes -// e.g. json.go refers directly to d.d.decRd -// -// We made the changes to embed En/Decoder in en/decDriver, -// but we had to explicitly reference the fields as opposed to using a function -// to get the better performance that we were looking for. -// For example, we explicitly call d.d.decRd.fn() instead of d.d.r().fn(). -// -// ------------------------------------------ -// Bounds Checking -// - Allow bytesDecReader to incur "bounds check error", and -// recover that as an io.EOF. -// This allows the bounds check branch to always be taken by the branch predictor, -// giving better performance (in theory), while ensuring that the code is shorter. -// -// ------------------------------------------ -// Escape Analysis -// - Prefer to return non-pointers if the value is used right away. -// Newly allocated values returned as pointers will be heap-allocated as they escape. -// -// Prefer functions and methods that -// - take no parameters and -// - return no results and -// - do not allocate. -// These are optimized by the runtime. -// For example, in json, we have dedicated functions for ReadMapElemKey, etc -// which do not delegate to readDelim, as readDelim takes a parameter. -// The difference in runtime was as much as 5%. import ( "bytes" @@ -147,10 +114,7 @@ import ( ) const ( - // rvNLen is the length of the array for readn or writen calls - rwNLen = 7 - - // scratchByteArrayLen = 64 + scratchByteArrayLen = 32 // initCollectionCap = 16 // 32 is defensive. 16 is preferred. // Support encoding.(Binary|Text)(Unm|M)arshaler. @@ -175,81 +139,51 @@ const ( // so structFieldInfo fits into 8 bytes maxLevelsEmbedding = 14 - // xdebug controls whether xdebugf prints any output - xdebug = true + // useFinalizers=true configures finalizers to release pool'ed resources + // acquired by Encoder/Decoder during their GC. + // + // Note that calling SetFinalizer is always expensive, + // as code must be run on the systemstack even for SetFinalizer(t, nil). + // + // We document that folks SHOULD call Release() when done, or they can + // explicitly call SetFinalizer themselves e.g. + // runtime.SetFinalizer(e, (*Encoder).Release) + // runtime.SetFinalizer(d, (*Decoder).Release) + useFinalizers = false ) -var ( - oneByteArr [1]byte - zeroByteSlice = oneByteArr[:0:0] - - codecgen bool - - panicv panicHdl +var oneByteArr [1]byte +var zeroByteSlice = oneByteArr[:0:0] - refBitset bitset32 - isnilBitset bitset32 - scalarBitset bitset32 -) +var codecgen bool -var ( - errMapTypeNotMapKind = errors.New("MapType MUST be of Map Kind") - errSliceTypeNotSliceKind = errors.New("SliceType MUST be of Slice Kind") -) - -var pool4tiload = sync.Pool{New: func() interface{} { return new(typeInfoLoadArray) }} +var refBitset bitset256 +var pool pooler +var panicv panicHdl func init() { - refBitset = refBitset. - set(byte(reflect.Map)). - set(byte(reflect.Ptr)). - set(byte(reflect.Func)). - set(byte(reflect.Chan)). - set(byte(reflect.UnsafePointer)) - - isnilBitset = isnilBitset. - set(byte(reflect.Map)). - set(byte(reflect.Ptr)). - set(byte(reflect.Func)). - set(byte(reflect.Chan)). - set(byte(reflect.UnsafePointer)). - set(byte(reflect.Interface)). - set(byte(reflect.Slice)) - - scalarBitset = scalarBitset. - set(byte(reflect.Bool)). - set(byte(reflect.Int)). - set(byte(reflect.Int8)). - set(byte(reflect.Int16)). - set(byte(reflect.Int32)). - set(byte(reflect.Int64)). - set(byte(reflect.Uint)). - set(byte(reflect.Uint8)). - set(byte(reflect.Uint16)). - set(byte(reflect.Uint32)). - set(byte(reflect.Uint64)). - set(byte(reflect.Uintptr)). - set(byte(reflect.Float32)). - set(byte(reflect.Float64)). - set(byte(reflect.Complex64)). - set(byte(reflect.Complex128)). - set(byte(reflect.String)) - -} - -type handleFlag uint8 + pool.init() -const ( - initedHandleFlag handleFlag = 1 << iota - binaryHandleFlag - jsonHandleFlag -) + refBitset.set(byte(reflect.Map)) + refBitset.set(byte(reflect.Ptr)) + refBitset.set(byte(reflect.Func)) + refBitset.set(byte(reflect.Chan)) +} type clsErr struct { closed bool // is it closed? errClosed error // error on closing } +// type entryType uint8 + +// const ( +// entryTypeBytes entryType = iota // make this 0, so a comparison is cheap +// entryTypeIo +// entryTypeBufio +// entryTypeUnset = 255 +// ) + type charEncoding uint8 const ( @@ -323,15 +257,21 @@ type containerState uint8 const ( _ containerState = iota - containerMapStart + containerMapStart // slot left open, since Driver method already covers it containerMapKey containerMapValue containerMapEnd - containerArrayStart + containerArrayStart // slot left open, since Driver methods already cover it containerArrayElem containerArrayEnd ) +// // 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). // The second time this back-reference happens, break out, @@ -353,15 +293,16 @@ const ( typeInfoLoadArrayBLen = 8 * 4 ) -// typeInfoLoad is a transient object used while loading up a typeInfo. type typeInfoLoad struct { + // fNames []string + // encNames []string etypes []uintptr sfis []structFieldInfo } -// typeInfoLoadArray is a cache object used to efficiently load up a typeInfo without -// much allocation. type typeInfoLoadArray struct { + // fNames [typeInfoLoadArrayLen]string + // encNames [typeInfoLoadArrayLen]string sfis [typeInfoLoadArraySfisLen]structFieldInfo sfiidx [typeInfoLoadArraySfiidxLen]byte etypes [typeInfoLoadArrayEtypesLen]uintptr @@ -406,6 +347,8 @@ func (e codecError) Error() string { return fmt.Sprintf("%s error: %v", e.name, e.err) } +// type byteAccepter func(byte) bool + var ( bigen = binary.BigEndian structInfoFieldName = "_struct" @@ -498,15 +441,6 @@ var immutableKindsSet = [32]bool{ // reflect.UnsafePointer } -// SelfExt is a sentinel extension signifying that types -// registered with it SHOULD be encoded and decoded -// based on the native mode of the format. -// -// This allows users to define a tag for an extension, -// but signify that the types should be encoded/decoded as the native encoding. -// This way, users need not also define how to encode or decode the extension. -var SelfExt = &extFailWrapper{} - // 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. @@ -586,22 +520,13 @@ type BasicHandle struct { extHandle - rtidFns atomicRtidFnSlice - rtidFnsNoExt atomicRtidFnSlice + intf2impls - // ---- cache line - - DecodeOptions + inited uint32 + _ uint32 // padding // ---- cache line - EncodeOptions - - intf2impls - - mu sync.Mutex - inited uint32 // holds if inited, and also handle flags (binary encoding, json handler, etc) - RPCOptions // TimeNotBuiltin configures whether time.Time should be treated as a builtin type. @@ -612,14 +537,8 @@ type BasicHandle struct { // However, users can elect to handle time.Time as a custom extension, or via the // standard library's encoding.Binary(M|Unm)arshaler or Text(M|Unm)arshaler interface. // To elect this behavior, users can set TimeNotBuiltin=true. - // // Note: Setting TimeNotBuiltin=true can be used to enable the legacy behavior // (for Cbor and Msgpack), where time.Time was not a builtin supported type. - // - // Note: DO NOT CHANGE AFTER FIRST USE. - // - // Once a Handle has been used, do not modify this option. - // It will lead to unexpected behaviour during encoding and decoding. TimeNotBuiltin bool // ExplicitRelease configures whether Release() is implicitly called after an encode or @@ -638,65 +557,37 @@ type BasicHandle struct { // are returned to the shared pool before it is garbage-collected. Do it as below: // runtime.SetFinalizer(e, (*Encoder).Release) // runtime.SetFinalizer(d, (*Decoder).Release) - // - // Deprecated: This is not longer used as pools are only used for long-lived objects - // which are shared across goroutines. - // Setting this value has no effect. It is maintained for backward compatibility. ExplicitRelease bool + be bool // is handle a binary encoding? + js bool // is handle javascript handler? + n byte // first letter of handle name + _ uint16 // padding + // ---- cache line -} -// basicHandle returns an initialized BasicHandle from the Handle. -func basicHandle(hh Handle) (x *BasicHandle) { - x = hh.getBasicHandle() - // ** We need to simulate once.Do, to ensure no data race within the block. - // ** Consequently, below would not work. - // if atomic.CompareAndSwapUint32(&x.inited, 0, 1) { - // x.be = hh.isBinary() - // _, x.js = hh.(*JsonHandle) - // x.n = hh.Name()[0] - // } + DecodeOptions - // simulate once.Do using our own stored flag and mutex as a CompareAndSwap - // is not sufficient, since a race condition can occur within init(Handle) function. - // init is made noinline, so that this function can be inlined by its caller. - if atomic.LoadUint32(&x.inited) == 0 { - x.init(hh) - } - return -} + // ---- cache line -func (x *BasicHandle) isJs() bool { - return handleFlag(x.inited)&jsonHandleFlag != 0 -} + EncodeOptions + + // noBuiltInTypeChecker -func (x *BasicHandle) isBe() bool { - return handleFlag(x.inited)&binaryHandleFlag != 0 + rtidFns atomicRtidFnSlice + mu sync.Mutex + // r []uintptr // rtids mapped to s above } -//go:noinline -func (x *BasicHandle) init(hh Handle) { - // make it uninlineable, as it is called at most once - x.mu.Lock() - if x.inited == 0 { - var f = initedHandleFlag - if hh.isBinary() { - f |= binaryHandleFlag - } - if _, b := hh.(*JsonHandle); b { - f |= jsonHandleFlag - } - atomic.StoreUint32(&x.inited, uint32(f)) - // ensure MapType and SliceType are of correct type - if x.MapType != nil && x.MapType.Kind() != reflect.Map { - panic(errMapTypeNotMapKind) - } - if x.SliceType != nil && x.SliceType.Kind() != reflect.Slice { - panic(errSliceTypeNotSliceKind) - } +// basicHandle returns an initialized BasicHandle from the Handle. +func basicHandle(hh Handle) (x *BasicHandle) { + x = hh.getBasicHandle() + if atomic.CompareAndSwapUint32(&x.inited, 0, 1) { + x.be = hh.isBinary() + _, x.js = hh.(*JsonHandle) + x.n = hh.Name()[0] } - x.mu.Unlock() + return } func (x *BasicHandle) getBasicHandle() *BasicHandle { @@ -733,54 +624,31 @@ LOOP: return } -func (x *BasicHandle) fn(rt reflect.Type) (fn *codecFn) { - return x.fnVia(rt, &x.rtidFns, true) -} - -func (x *BasicHandle) fnNoExt(rt reflect.Type) (fn *codecFn) { - return x.fnVia(rt, &x.rtidFnsNoExt, false) -} - -func (x *BasicHandle) fnVia(rt reflect.Type, fs *atomicRtidFnSlice, checkExt bool) (fn *codecFn) { +func (x *BasicHandle) fn(rt reflect.Type, checkFastpath, checkCodecSelfer bool) (fn *codecFn) { rtid := rt2id(rt) - sp := fs.load() + sp := x.rtidFns.load() if sp != nil { if _, fn = findFn(sp, rtid); fn != nil { + // xdebugf("<<<< %c: found fn for %v in rtidfns of size: %v", c.n, rt, len(sp)) return } } - fn = x.fnLoad(rt, rtid, checkExt) - x.mu.Lock() - var sp2 []codecRtidFn - sp = fs.load() - if sp == nil { - sp2 = []codecRtidFn{{rtid, fn}} - fs.store(sp2) - } else { - idx, fn2 := findFn(sp, rtid) - if fn2 == nil { - sp2 = make([]codecRtidFn, len(sp)+1) - copy(sp2, sp[:idx]) - copy(sp2[idx+1:], sp[idx:]) - sp2[idx] = codecRtidFn{rtid, fn} - fs.store(sp2) - } - } - x.mu.Unlock() - return -} - -func (x *BasicHandle) fnLoad(rt reflect.Type, rtid uintptr, checkExt bool) (fn *codecFn) { + c := x + // xdebugf("#### for %c: load fn for %v in rtidfns of size: %v", c.n, rt, len(sp)) fn = new(codecFn) fi := &(fn.i) - ti := x.getTypeInfo(rtid, rt) + ti := c.getTypeInfo(rtid, rt) fi.ti = ti rk := reflect.Kind(ti.kind) - // anything can be an extension except the built-in ones: time, raw and rawext - - if rtid == timeTypId && !x.TimeNotBuiltin { + 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 && !c.TimeNotBuiltin { fn.fe = (*Encoder).kTime fn.fd = (*Decoder).kTime } else if rtid == rawTypId { @@ -792,7 +660,7 @@ func (x *BasicHandle) fnLoad(rt reflect.Type, rtid uintptr, checkExt bool) (fn * fi.addrF = true fi.addrD = true fi.addrE = true - } else if xfFn := x.getExt(rtid, checkExt); xfFn != nil { + } else if xfFn := c.getExt(rtid); xfFn != nil { fi.xfTag, fi.xfFn = xfFn.tag, xfFn.ext fn.fe = (*Encoder).ext fn.fd = (*Decoder).ext @@ -801,39 +669,27 @@ func (x *BasicHandle) fnLoad(rt reflect.Type, rtid uintptr, checkExt bool) (fn * if rk == reflect.Struct || rk == reflect.Array { fi.addrE = true } - } else if ti.isFlag(tiflagSelfer) || ti.isFlag(tiflagSelferPtr) { - fn.fe = (*Encoder).selferMarshal - fn.fd = (*Decoder).selferUnmarshal - fi.addrF = true - fi.addrD = ti.isFlag(tiflagSelferPtr) - fi.addrE = ti.isFlag(tiflagSelferPtr) - } else if supportMarshalInterfaces && x.isBe() && - (ti.isFlag(tiflagBinaryMarshaler) || ti.isFlag(tiflagBinaryMarshalerPtr)) && - (ti.isFlag(tiflagBinaryUnmarshaler) || ti.isFlag(tiflagBinaryUnmarshalerPtr)) { + } else if supportMarshalInterfaces && c.be && (ti.bm || ti.bmp) && (ti.bu || ti.bup) { fn.fe = (*Encoder).binaryMarshal fn.fd = (*Decoder).binaryUnmarshal fi.addrF = true - fi.addrD = ti.isFlag(tiflagBinaryUnmarshalerPtr) - fi.addrE = ti.isFlag(tiflagBinaryMarshalerPtr) - } else if supportMarshalInterfaces && !x.isBe() && x.isJs() && - (ti.isFlag(tiflagJsonMarshaler) || ti.isFlag(tiflagJsonMarshalerPtr)) && - (ti.isFlag(tiflagJsonUnmarshaler) || ti.isFlag(tiflagJsonUnmarshalerPtr)) { + 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 fi.addrF = true - fi.addrD = ti.isFlag(tiflagJsonUnmarshalerPtr) - fi.addrE = ti.isFlag(tiflagJsonMarshalerPtr) - } else if supportMarshalInterfaces && !x.isBe() && - (ti.isFlag(tiflagTextMarshaler) || ti.isFlag(tiflagTextMarshalerPtr)) && - (ti.isFlag(tiflagTextUnmarshaler) || ti.isFlag(tiflagTextUnmarshalerPtr)) { + 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.isFlag(tiflagTextUnmarshalerPtr) - fi.addrE = ti.isFlag(tiflagTextMarshalerPtr) + fi.addrD = ti.tup + fi.addrE = ti.tmp } else { - if fastpathEnabled && (rk == reflect.Map || rk == reflect.Slice) { + if fastpathEnabled && checkFastpath && (rk == reflect.Map || rk == reflect.Slice) { if ti.pkgpath == "" { // un-named slice or map if idx := fastpathAV.index(rtid); idx != -1 { fn.fe = fastpathAV[idx].encfn @@ -854,17 +710,16 @@ func (x *BasicHandle) fnLoad(rt reflect.Type, rtid uintptr, checkExt bool) (fn * xfnf := fastpathAV[idx].encfn xrt := fastpathAV[idx].rt fn.fe = func(e *Encoder, xf *codecFnInfo, xrv reflect.Value) { - xfnf(e, xf, rvConvert(xrv, xrt)) + xfnf(e, xf, xrv.Convert(xrt)) } fi.addrD = true fi.addrF = false // meaning it can be an address(ptr) or a value xfnf2 := fastpathAV[idx].decfn - xptr2rt := reflect.PtrTo(xrt) fn.fd = func(d *Decoder, xf *codecFnInfo, xrv reflect.Value) { if xrv.Kind() == reflect.Ptr { - xfnf2(d, xf, rvConvert(xrv, xptr2rt)) + xfnf2(d, xf, xrv.Convert(reflect.PtrTo(xrt))) } else { - xfnf2(d, xf, rvConvert(xrv, xrt)) + xfnf2(d, xf, xrv.Convert(xrt)) } } } @@ -876,16 +731,6 @@ func (x *BasicHandle) fnLoad(rt reflect.Type, rtid uintptr, checkExt bool) (fn * fn.fe = (*Encoder).kBool fn.fd = (*Decoder).kBool case reflect.String: - // Do not use different functions based on StringToRaw option, - // as that will statically set the function for a string type, - // and if the Handle is modified thereafter, behaviour is non-deterministic. - // i.e. DO NOT DO: - // if x.StringToRaw { - // fn.fe = (*Encoder).kStringToRaw - // } else { - // fn.fe = (*Encoder).kStringEnc - // } - fn.fe = (*Encoder).kString fn.fd = (*Decoder).kString case reflect.Int: @@ -932,26 +777,24 @@ func (x *BasicHandle) fnLoad(rt reflect.Type, rtid uintptr, checkExt bool) (fn * fn.fd = (*Decoder).kErr case reflect.Chan: fi.seq = seqTypeChan - fn.fe = (*Encoder).kChan - fn.fd = (*Decoder).kSliceForChan + fn.fe = (*Encoder).kSlice + fn.fd = (*Decoder).kSlice case reflect.Slice: fi.seq = seqTypeSlice fn.fe = (*Encoder).kSlice fn.fd = (*Decoder).kSlice case reflect.Array: fi.seq = seqTypeArray - fn.fe = (*Encoder).kArray + fn.fe = (*Encoder).kSlice fi.addrF = false fi.addrD = false rt2 := reflect.SliceOf(ti.elem) fn.fd = func(d *Decoder, xf *codecFnInfo, xrv reflect.Value) { - // call fnVia directly, so fn(...) is not recursive, and can be inlined - d.h.fnVia(rt2, &x.rtidFns, true).fd(d, xf, rvGetSlice4Array(xrv, rt2)) + d.h.fn(rt2, true, false).fd(d, xf, xrv.Slice(0, xrv.Len())) } + // fn.fd = (*Decoder).kArray case reflect.Struct: - if ti.anyOmitEmpty || - ti.isFlag(tiflagMissingFielder) || - ti.isFlag(tiflagMissingFielderPtr) { + if ti.anyOmitEmpty || ti.mf || ti.mfp { fn.fe = (*Encoder).kStruct } else { fn.fe = (*Encoder).kStructNoOmitempty @@ -971,6 +814,28 @@ func (x *BasicHandle) fnLoad(rt reflect.Type, rtid uintptr, checkExt bool) (fn * } } } + + c.mu.Lock() + var sp2 []codecRtidFn + sp = c.rtidFns.load() + if sp == nil { + sp2 = []codecRtidFn{{rtid, fn}} + c.rtidFns.store(sp2) + // xdebugf(">>>> adding rt: %v to rtidfns of size: %v", rt, len(sp2)) + // xdebugf(">>>> loading stored rtidfns of size: %v", len(c.rtidFns.load())) + } else { + idx, fn2 := findFn(sp, rtid) + if fn2 == nil { + sp2 = make([]codecRtidFn, len(sp)+1) + copy(sp2, sp[:idx]) + copy(sp2[idx+1:], sp[idx:]) + sp2[idx] = codecRtidFn{rtid, fn} + c.rtidFns.store(sp2) + // xdebugf(">>>> adding rt: %v to rtidfns of size: %v", rt, len(sp2)) + + } + } + c.mu.Unlock() return } @@ -980,11 +845,8 @@ func (x *BasicHandle) fnLoad(rt reflect.Type, rtid uintptr, checkExt bool) (fn * // Once a handle is configured, it can be shared across multiple Encoders and Decoders. // // Note that a Handle is NOT safe for concurrent modification. -// -// A Handle also should not be modified after it is configured and has -// been used at least once. This is because stored state may be out of sync with the -// new configuration, and a data race can occur when multiple goroutines access it. -// i.e. multiple Encoders or Decoders in different goroutines. +// Consequently, do not modify it after it is configured if shared among +// multiple Encoders and Decoders in different goroutines. // // Consequently, the typical usage model is that a Handle is pre-configured // before first time use, and not modified while in use. @@ -994,9 +856,12 @@ type Handle interface { // return the basic handle. It may not have been inited. // Prefer to use basicHandle() helper function that ensures it has been inited. getBasicHandle() *BasicHandle - newEncDriver() encDriver - newDecDriver() decDriver + recreateEncDriver(encDriver) bool + newEncDriver(w *Encoder) encDriver + newDecDriver(r *Decoder) decDriver isBinary() bool + hasElemSeparators() bool + // IsBuiltinType(rtid uintptr) bool } // Raw represents raw formatted bytes. @@ -1067,7 +932,7 @@ type addExtWrapper struct { } func (x addExtWrapper) WriteExt(v interface{}) []byte { - bs, err := x.encFn(rv4i(v)) + bs, err := x.encFn(reflect.ValueOf(v)) if err != nil { panic(err) } @@ -1075,7 +940,7 @@ func (x addExtWrapper) WriteExt(v interface{}) []byte { } func (x addExtWrapper) ReadExt(v interface{}, bs []byte) { - if err := x.decFn(rv4i(v), bs); err != nil { + if err := x.decFn(reflect.ValueOf(v), bs); err != nil { panic(err) } } @@ -1088,6 +953,11 @@ func (x addExtWrapper) UpdateExt(dest interface{}, v interface{}) { x.ReadExt(dest, v.([]byte)) } +type extWrapper struct { + BytesExt + InterfaceExt +} + type bytesExtFailer struct{} func (bytesExtFailer) WriteExt(v interface{}) []byte { @@ -1108,21 +978,6 @@ func (interfaceExtFailer) UpdateExt(dest interface{}, v interface{}) { panicv.errorstr("InterfaceExt.UpdateExt is not supported") } -type bytesExtWrapper struct { - interfaceExtFailer - BytesExt -} - -type interfaceExtWrapper struct { - bytesExtFailer - InterfaceExt -} - -type extFailWrapper struct { - bytesExtFailer - interfaceExtFailer -} - type binaryEncodingType struct{} func (binaryEncodingType) isBinary() bool { return true } @@ -1134,16 +989,29 @@ 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 noBuiltInTypes struct{ noBuiltInTypeChecker } + type noBuiltInTypes struct{} 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 } + +type noElemSeparators struct{} + +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. type bigenHelper struct { x []byte // must be correctly sliced to appropriate len. slicing is a cost. - w *encWr + w *encWriterSwitch } func (z bigenHelper) writeUint16(v uint16) { @@ -1167,7 +1035,7 @@ type extTypeTagFn struct { rt reflect.Type tag uint64 ext Ext - // _ [1]uint64 // padding + _ [1]uint64 // padding } type extHandle []extTypeTagFn @@ -1193,8 +1061,6 @@ func (o *extHandle) AddExt(rt reflect.Type, tag byte, // 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 - // We EXPECT *o is a pointer to a non-nil extHandle. - rk := rt.Kind() for rk == reflect.Ptr { rt = rt.Elem() @@ -1208,12 +1074,16 @@ func (o *extHandle) SetExt(rt reflect.Type, tag uint64, ext Ext) (err error) { rtid := rt2id(rt) switch rtid { case timeTypId, rawTypId, rawExtTypId: - // all natively supported type, so cannot have an extension. - // However, we do not return an error for these, as we do not document that. - // Instead, we silently treat as a no-op, and return. - return + // 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 { @@ -1222,14 +1092,11 @@ func (o *extHandle) SetExt(rt reflect.Type, tag uint64, ext Ext) (err error) { } } rtidptr := rt2id(reflect.PtrTo(rt)) - *o = append(o2, extTypeTagFn{rtid, rtidptr, rt, tag, ext}) // , [1]uint64{}}) + *o = append(o2, extTypeTagFn{rtid, rtidptr, rt, tag, ext, [1]uint64{}}) return } -func (o extHandle) getExt(rtid uintptr, check bool) (v *extTypeTagFn) { - if !check { - return - } +func (o extHandle) getExt(rtid uintptr) (v *extTypeTagFn) { for i := range o { v = &o[i] if v.rtid == rtid || v.rtidptr == rtid { @@ -1287,11 +1154,10 @@ func (o intf2impls) intf2impl(rtid uintptr) (rv reflect.Value) { if v.impl == nil { return } - vkind := v.impl.Kind() - if vkind == reflect.Ptr { + if v.impl.Kind() == reflect.Ptr { return reflect.New(v.impl.Elem()) } - return rvZeroAddrK(v.impl, vkind) + return reflect.New(v.impl).Elem() } } return @@ -1334,14 +1200,14 @@ type structFieldInfo struct { encNameAsciiAlphaNum bool // the encName only contains ascii alphabet and numbers structFieldInfoFlag - // _ [1]byte // padding + _ [1]byte // padding } -// func (si *structFieldInfo) setToZeroValue(v reflect.Value) { -// if v, valid := si.field(v, false); valid { -// v.Set(reflect.Zero(v.Type())) -// } -// } +func (si *structFieldInfo) setToZeroValue(v reflect.Value) { + if v, valid := si.field(v, false); valid { + v.Set(reflect.Zero(v.Type())) + } +} // rv returns the field of the struct. // If anonymous, it returns an Invalid @@ -1360,6 +1226,11 @@ 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 parseStructInfo(stag string) (toArray, omitEmpty bool, keytype valueType) { keytype = valueTypeString // default if stag == "" { @@ -1406,6 +1277,9 @@ func (si *structFieldInfo) parseTag(stag string) { switch s { case "omitempty": si.flagSet(structFieldInfoFlagOmitEmpty) + // si.omitEmpty = true + // case "toarray": + // si.toArray = true } } } @@ -1455,7 +1329,6 @@ type structFieldNode struct { func (x *structFieldNode) field(si *structFieldInfo) (fv reflect.Value) { // return si.fieldval(x.v, x.update) - // Note: we only cache if nis=2 or nis=3 i.e. up to 2 levels of embedding // This mostly saves us time on the repeated calls to v.Elem, v.Field, etc. var valid bool @@ -1497,54 +1370,26 @@ func (x *structFieldNode) field(si *structFieldInfo) (fv reflect.Value) { func baseStructRv(v reflect.Value, update bool) (v2 reflect.Value, valid bool) { for v.Kind() == reflect.Ptr { - if rvIsNil(v) { + if v.IsNil() { if !update { return } - rvSetDirect(v, reflect.New(v.Type().Elem())) + v.Set(reflect.New(v.Type().Elem())) } v = v.Elem() } return v, true } -type tiflag uint32 +type typeInfoFlag uint8 const ( - _ tiflag = 1 << iota - - tiflagComparable - - tiflagIsZeroer - tiflagIsZeroerPtr - - tiflagBinaryMarshaler - tiflagBinaryMarshalerPtr - - tiflagBinaryUnmarshaler - tiflagBinaryUnmarshalerPtr - - tiflagTextMarshaler - tiflagTextMarshalerPtr - - tiflagTextUnmarshaler - tiflagTextUnmarshalerPtr - - tiflagJsonMarshaler - tiflagJsonMarshalerPtr - - tiflagJsonUnmarshaler - tiflagJsonUnmarshalerPtr - - tiflagSelfer - tiflagSelferPtr - - tiflagMissingFielder - tiflagMissingFielderPtr + typeInfoFlagComparable = 1 << iota + typeInfoFlagIsZeroer + typeInfoFlagIsZeroerPtr ) -// typeInfo keeps static (non-changing readonly)information -// about each (non-ptr) type referenced in the encode/decode sequence. +// 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 @@ -1558,6 +1403,7 @@ type typeInfo struct { pkgpath string rtid uintptr + // rv0 reflect.Value // saved zero value, used if immutableKind numMeth uint16 // number of methods kind uint8 @@ -1578,35 +1424,38 @@ type typeInfo struct { // sfis []structFieldInfo // all sfi, in src order, as created. sfiNamesSort []byte // all names, with indexes into the sfiSort - // rv0 is the zero value for the type. - // It is mostly beneficial for all non-reference kinds - // i.e. all but map/chan/func/ptr/unsafe.pointer - // so beneficial for intXX, bool, slices, structs, etc - rv0 reflect.Value - - elemsize uintptr + // format of marshal type fields below: [btj][mu]p? OR csp? + + 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 // 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 + mf bool // T is a MissingFielder + mfp bool // *T is a MissingFielder // other flags, with individual bits representing if set. - flags tiflag - + flags typeInfoFlag infoFieldOmitempty bool - elemkind uint8 - _ [2]byte // padding - // _ [1]uint64 // padding + _ [6]byte // padding + _ [2]uint64 // padding } -func (ti *typeInfo) isFlag(f tiflag) bool { +func (ti *typeInfo) isFlag(f typeInfoFlag) bool { return ti.flags&f != 0 } -func (ti *typeInfo) flag(when bool, f tiflag) *typeInfo { - if when { - ti.flags |= f - } - return ti -} - func (ti *typeInfo) indexForEncName(name []byte) (index int16) { var sn []byte if len(name)+2 <= 32 { @@ -1638,9 +1487,8 @@ type TypeInfos struct { // infos: formerly map[uintptr]*typeInfo, now *[]rtid2ti, 2 words expected infos atomicTypeInfoSlice mu sync.Mutex - _ uint64 // padding (cache-aligned) tags []string - _ uint64 // padding (cache-aligned) + _ [2]uint64 // padding } // NewTypeInfos creates a TypeInfos given a set of struct tags keys. @@ -1667,6 +1515,11 @@ func findTypeInfo(s []rtid2ti, rtid uintptr) (i uint, ti *typeInfo) { // binary search. adapted from sort/search.go. // Note: we use goto (instead of for loop) so this can be inlined. + // if sp == nil { + // return -1, nil + // } + // s := *sp + // h, i, j := 0, 0, len(s) var h uint // var h, i uint var j = uint(len(s)) @@ -1710,31 +1563,30 @@ func (x *TypeInfos) get(rtid uintptr, rt reflect.Type) (pti *typeInfo) { pkgpath: rt.PkgPath(), keyType: valueTypeString, // default it - so it's never 0 } - ti.rv0 = reflect.Zero(rt) + // ti.rv0 = reflect.Zero(rt) + // ti.comparable = rt.Comparable() ti.numMeth = uint16(rt.NumMethod()) - var b1, b2 bool - b1, b2 = implIntf(rt, binaryMarshalerTyp) - ti.flag(b1, tiflagBinaryMarshaler).flag(b2, tiflagBinaryMarshalerPtr) - b1, b2 = implIntf(rt, binaryUnmarshalerTyp) - ti.flag(b1, tiflagBinaryUnmarshaler).flag(b2, tiflagBinaryUnmarshalerPtr) - b1, b2 = implIntf(rt, textMarshalerTyp) - ti.flag(b1, tiflagTextMarshaler).flag(b2, tiflagTextMarshalerPtr) - b1, b2 = implIntf(rt, textUnmarshalerTyp) - ti.flag(b1, tiflagTextUnmarshaler).flag(b2, tiflagTextUnmarshalerPtr) - b1, b2 = implIntf(rt, jsonMarshalerTyp) - ti.flag(b1, tiflagJsonMarshaler).flag(b2, tiflagJsonMarshalerPtr) - b1, b2 = implIntf(rt, jsonUnmarshalerTyp) - ti.flag(b1, tiflagJsonUnmarshaler).flag(b2, tiflagJsonUnmarshalerPtr) - b1, b2 = implIntf(rt, selferTyp) - ti.flag(b1, tiflagSelfer).flag(b2, tiflagSelferPtr) - b1, b2 = implIntf(rt, missingFielderTyp) - ti.flag(b1, tiflagMissingFielder).flag(b2, tiflagMissingFielderPtr) - b1, b2 = implIntf(rt, iszeroTyp) - ti.flag(b1, tiflagIsZeroer).flag(b2, tiflagIsZeroerPtr) - b1 = rt.Comparable() - ti.flag(b1, tiflagComparable) + 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) + ti.mf, ti.mfp = implIntf(rt, missingFielderTyp) + + b1, b2 := implIntf(rt, iszeroTyp) + if b1 { + ti.flags |= typeInfoFlagIsZeroer + } + if b2 { + ti.flags |= typeInfoFlagIsZeroerPtr + } + if rt.Comparable() { + ti.flags |= typeInfoFlagComparable + } switch rk { case reflect.Struct: @@ -1745,12 +1597,13 @@ func (x *TypeInfos) get(rtid uintptr, rt reflect.Type) (pti *typeInfo) { } else { ti.keyType = valueTypeString } - pp, pi := &pool4tiload, pool4tiload.Get() // pool.tiLoad() + pp, pi := &pool.tiload, pool.tiload.Get() // pool.tiLoad() pv := pi.(*typeInfoLoadArray) 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.sfis = vv.sfis ti.sfiSrc, ti.sfiSort, ti.sfiNamesSort, ti.anyOmitEmpty = rgetResolveSFI(rt, vv.sfis, pv) pp.Put(pi) case reflect.Map: @@ -1759,18 +1612,13 @@ func (x *TypeInfos) get(rtid uintptr, rt reflect.Type) (pti *typeInfo) { case reflect.Slice: ti.mbs, _ = implIntf(rt, mapBySliceTyp) ti.elem = rt.Elem() - ti.elemsize = ti.elem.Size() - ti.elemkind = uint8(ti.elem.Kind()) case reflect.Chan: ti.elem = rt.Elem() ti.chandir = uint8(rt.ChanDir()) - case reflect.Array: - ti.elem = rt.Elem() - ti.elemsize = ti.elem.Size() - ti.elemkind = uint8(ti.elem.Kind()) - case reflect.Ptr: + case reflect.Array, reflect.Ptr: ti.elem = rt.Elem() } + // sfi = sfiSrc x.mu.Lock() sp = x.infos.load() @@ -1917,6 +1765,9 @@ LOOP: si.fieldName = f.Name si.flagSet(structFieldInfoFlagReady) + // pv.encNames = append(pv.encNames, si.encName) + + // si.ikind = int(f.Type.Kind()) if len(indexstack) > maxLevelsEmbedding-1 { panicv.errorf("codec: only supports up to %v depth of embedding - type has %v depth", maxLevelsEmbedding-1, len(indexstack)) @@ -1934,12 +1785,10 @@ LOOP: func tiSep(name string) uint8 { // (xn[0]%64) // (between 192-255 - outside ascii BMP) - // Tried the following before settling on correct implementation: - // 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) + // 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) } @@ -1962,7 +1811,7 @@ func rgetResolveSFI(rt reflect.Type, x []structFieldInfo, pv *typeInfoLoadArray) for i := range x { ui = uint16(i) xn = x[i].encName // fieldName or encName? use encName for now. - if len(xn)+2 > cap(sn) { + if len(xn)+2 > cap(pv.b) { sn = make([]byte, len(xn)+2) } else { sn = sn[:len(xn)+2] @@ -1979,22 +1828,24 @@ func rgetResolveSFI(rt reflect.Type, x []structFieldInfo, pv *typeInfoLoadArray) 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 cleared (reset to nil), - // and the index updated appropriately - i2clear := ui // index to be cleared - if x[i].nis < x[index].nis { // this one is shallower - // update the index to point to this later one. + // 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) - // clear the earlier one, as this later one is shallower. - i2clear = index - } - if x[i2clear].ready() { - x[i2clear].flagClr(structFieldInfoFlagReady) - n-- + if x[index].ready() { + x[index].flagClr(structFieldInfoFlagReady) + n-- + } + } else { + if x[i].ready() { + x[i].flagClr(structFieldInfoFlagReady) + n-- + } } } - } + } var w []structFieldInfo sharingArray := len(x) <= typeInfoLoadArraySfisLen // sharing array with typeInfoLoadArray if sharingArray { @@ -2070,13 +1921,13 @@ func isEmptyStruct(v reflect.Value, tinfos *TypeInfos, deref, checkStruct bool) if ti.rtid == timeTypId { return rv2i(v).(time.Time).IsZero() } - if ti.isFlag(tiflagIsZeroerPtr) && v.CanAddr() { + if ti.isFlag(typeInfoFlagIsZeroerPtr) && v.CanAddr() { return rv2i(v.Addr()).(isZeroer).IsZero() } - if ti.isFlag(tiflagIsZeroer) { + if ti.isFlag(typeInfoFlagIsZeroer) { return rv2i(v).(isZeroer).IsZero() } - if ti.isFlag(tiflagComparable) { + if ti.isFlag(typeInfoFlagComparable) { return rv2i(v) == rv2i(reflect.Zero(vt)) } if !checkStruct { @@ -2113,13 +1964,7 @@ func panicToErr(h errDecorator, err *error) { } } -func isSliceBoundsError(s string) bool { - return strings.Contains(s, "index out of range") || - strings.Contains(s, "slice bounds out of range") -} - func panicValToErr(h errDecorator, v interface{}, err *error) { - d, dok := h.(*Decoder) switch xerr := v.(type) { case nil: case error: @@ -2129,19 +1974,11 @@ func panicValToErr(h errDecorator, v interface{}, err *error) { // treat as special (bubble up) *err = xerr default: - if dok && d.bytes && isSliceBoundsError(xerr.Error()) { - *err = io.EOF - } else { - h.wrapErr(xerr, err) - } + h.wrapErr(xerr, err) } case string: if xerr != "" { - if dok && d.bytes && isSliceBoundsError(xerr) { - *err = io.EOF - } else { - h.wrapErr(xerr, err) - } + h.wrapErr(xerr, err) } case fmt.Stringer: if xerr != nil { @@ -2158,16 +1995,6 @@ func isImmutableKind(k reflect.Kind) (v bool) { return immutableKindsSet[k%reflect.Kind(len(immutableKindsSet))] // bounds-check-elimination } -func usableByteSlice(bs []byte, slen int) []byte { - if cap(bs) >= slen { - if bs == nil { - return []byte{} - } - return bs[:slen] - } - return make([]byte, slen) -} - // ---- type codecFnInfo struct { @@ -2188,7 +2015,7 @@ type codecFn struct { i codecFnInfo fe func(*Encoder, *codecFnInfo, reflect.Value) fd func(*Decoder, *codecFnInfo, reflect.Value) - _ [1]uint64 // padding (cache-aligned) + _ [1]uint64 // padding } type codecRtidFn struct { @@ -2196,29 +2023,6 @@ type codecRtidFn struct { fn *codecFn } -func makeExt(ext interface{}) Ext { - if ext == nil { - return &extFailWrapper{} - } - switch t := ext.(type) { - case nil: - return &extFailWrapper{} - case Ext: - return t - case BytesExt: - return &bytesExtWrapper{BytesExt: t} - case InterfaceExt: - return &interfaceExtWrapper{InterfaceExt: t} - } - return &extFailWrapper{} -} - -func baseRV(v interface{}) (rv reflect.Value) { - for rv = rv4i(v); rv.Kind() == reflect.Ptr; rv = rv.Elem() { - } - return -} - // ---- // these "checkOverflow" functions must be inlinable, and not call anybody. @@ -2301,52 +2105,9 @@ func (x checkOverflow) SignedIntV(v uint64) int64 { return int64(v) } -// ------------------ FLOATING POINT ----------------- - -func isNaN64(f float64) bool { return f != f } -func isNaN32(f float32) bool { return f != f } -func abs32(f float32) float32 { - return math.Float32frombits(math.Float32bits(f) &^ (1 << 31)) -} - -// Per go spec, floats are represented in memory as -// IEEE single or double precision floating point values. -// -// We also looked at the source for stdlib math/modf.go, -// reviewed https://github.com/chewxy/math32 -// and read wikipedia documents describing the formats. -// -// It became clear that we could easily look at the bits to determine -// whether any fraction exists. -// -// This is all we need for now. - -func noFrac64(f float64) (v bool) { - x := math.Float64bits(f) - e := uint64(x>>52)&0x7FF - 1023 // uint(x>>shift)&mask - bias - // clear top 12+e bits, the integer part; if the rest is 0, then no fraction. - if e < 52 { - // return x&((1<<64-1)>>(12+e)) == 0 - return x<<(12+e) == 0 - } - return -} - -func noFrac32(f float32) (v bool) { - x := math.Float32bits(f) - e := uint32(x>>23)&0xFF - 127 // uint(x>>shift)&mask - bias - // clear top 9+e bits, the integer part; if the rest is 0, then no fraction. - if e < 23 { - // return x&((1<<32-1)>>(9+e)) == 0 - return x<<(9+e) == 0 - } - return -} +// ------------------ SORT ----------------- -// func noFrac(f float64) bool { -// _, frac := math.Modf(float64(f)) -// return frac == 0 -// } +func isNaN(f float64) bool { return f != f } // ----------------------- @@ -2364,21 +2125,141 @@ type ioBuffered interface { // ----------------------- +type intSlice []int64 +type uintSlice []uint64 + +// type uintptrSlice []uintptr +type floatSlice []float64 +type boolSlice []bool +type stringSlice []string + +// type bytesSlice [][]byte + +func (p intSlice) Len() int { return len(p) } +func (p intSlice) Less(i, j int) bool { return p[uint(i)] < p[uint(j)] } +func (p intSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } + +func (p uintSlice) Len() int { return len(p) } +func (p uintSlice) Less(i, j int) bool { return p[uint(i)] < p[uint(j)] } +func (p uintSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } + +// func (p uintptrSlice) Len() int { return len(p) } +// func (p uintptrSlice) Less(i, j int) bool { return p[uint(i)] < p[uint(j)] } +// func (p uintptrSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } + +func (p floatSlice) Len() int { return len(p) } +func (p floatSlice) Less(i, j int) bool { + return p[uint(i)] < p[uint(j)] || isNaN(p[uint(i)]) && !isNaN(p[uint(j)]) +} +func (p floatSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } + +func (p stringSlice) Len() int { return len(p) } +func (p stringSlice) Less(i, j int) bool { return p[uint(i)] < p[uint(j)] } +func (p stringSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } + +// func (p bytesSlice) Len() int { return len(p) } +// func (p bytesSlice) Less(i, j int) bool { return bytes.Compare(p[uint(i)], p[uint(j)]) == -1 } +// func (p bytesSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } + +func (p boolSlice) Len() int { return len(p) } +func (p boolSlice) Less(i, j int) bool { return !p[uint(i)] && p[uint(j)] } +func (p boolSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } + +// --------------------- + type sfiRv struct { v *structFieldInfo r reflect.Value } +type intRv struct { + v int64 + r reflect.Value +} +type intRvSlice []intRv +type uintRv struct { + v uint64 + r reflect.Value +} +type uintRvSlice []uintRv +type floatRv struct { + v float64 + r reflect.Value +} +type floatRvSlice []floatRv +type boolRv struct { + v bool + r reflect.Value +} +type boolRvSlice []boolRv +type stringRv struct { + v string + r reflect.Value +} +type stringRvSlice []stringRv +type bytesRv struct { + v []byte + 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[uint(i)].v < p[uint(j)].v } +func (p intRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } + +func (p uintRvSlice) Len() int { return len(p) } +func (p uintRvSlice) Less(i, j int) bool { return p[uint(i)].v < p[uint(j)].v } +func (p uintRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } + +func (p floatRvSlice) Len() int { return len(p) } +func (p floatRvSlice) Less(i, j int) bool { + return p[uint(i)].v < p[uint(j)].v || isNaN(p[uint(i)].v) && !isNaN(p[uint(j)].v) +} +func (p floatRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } + +func (p stringRvSlice) Len() int { return len(p) } +func (p stringRvSlice) Less(i, j int) bool { return p[uint(i)].v < p[uint(j)].v } +func (p stringRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } + +func (p bytesRvSlice) Len() int { return len(p) } +func (p bytesRvSlice) Less(i, j int) bool { return bytes.Compare(p[uint(i)].v, p[uint(j)].v) == -1 } +func (p bytesRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } + +func (p boolRvSlice) Len() int { return len(p) } +func (p boolRvSlice) Less(i, j int) bool { return !p[uint(i)].v && p[uint(j)].v } +func (p boolRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } + +func (p timeRvSlice) Len() int { return len(p) } +func (p timeRvSlice) Less(i, j int) bool { return p[uint(i)].v.Before(p[uint(j)].v) } +func (p timeRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } + +// ----------------- + +type bytesI struct { + v []byte + i interface{} +} + +type bytesISlice []bytesI + +func (p bytesISlice) Len() int { return len(p) } +func (p bytesISlice) Less(i, j int) bool { return bytes.Compare(p[uint(i)].v, p[uint(j)].v) == -1 } +func (p bytesISlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } + // ----------------- -type set []interface{} +type set []uintptr -func (s *set) add(v interface{}) (exists bool) { +func (s *set) add(v uintptr) (exists bool) { // e.ci is always nil, or len >= 1 x := *s - if x == nil { - x = make([]interface{}, 1, 8) + x = make([]uintptr, 1, 8) x[0] = v *s = x return @@ -2415,7 +2296,7 @@ func (s *set) add(v interface{}) (exists bool) { return } -func (s *set) remove(v interface{}) (exists bool) { +func (s *set) remove(v uintptr) (exists bool) { x := *s if len(x) == 0 { return @@ -2453,13 +2334,8 @@ func (s *set) remove(v interface{}) (exists bool) { type bitset256 [32]byte -func (x *bitset256) check(pos byte) uint8 { - return x[pos>>3] & (1 << (pos & 7)) -} - func (x *bitset256) isset(pos byte) bool { - return x.check(pos) != 0 - // return x[pos>>3]&(1<<(pos&7)) != 0 + return x[pos>>3]&(1<<(pos&7)) != 0 } // func (x *bitset256) issetv(pos byte) byte { @@ -2470,20 +2346,6 @@ func (x *bitset256) set(pos byte) { x[pos>>3] |= (1 << (pos & 7)) } -type bitset32 uint32 - -func (x bitset32) set(pos byte) bitset32 { - return x | (1 << pos) -} - -func (x bitset32) check(pos byte) uint32 { - return uint32(x) & (1 << pos) -} -func (x bitset32) isset(pos byte) bool { - return x.check(pos) != 0 - // return x&(1<>3] &^= (1 << (pos & 7)) // } @@ -2506,6 +2368,103 @@ func (x bitset32) isset(pos byte) bool { // ------------ +type pooler struct { + // function-scoped pooled resources + tiload sync.Pool // for type info loading + sfiRv8, sfiRv16, sfiRv32, sfiRv64, sfiRv128 sync.Pool // for struct encoding + + // lifetime-scoped pooled resources + // dn sync.Pool // for decNaked + buf1k, buf2k, buf4k, buf8k, buf16k, buf32k, buf64k sync.Pool // for [N]byte +} + +func (p *pooler) init() { + p.tiload.New = func() interface{} { return new(typeInfoLoadArray) } + + p.sfiRv8.New = func() interface{} { return new([8]sfiRv) } + p.sfiRv16.New = func() interface{} { return new([16]sfiRv) } + p.sfiRv32.New = func() interface{} { return new([32]sfiRv) } + p.sfiRv64.New = func() interface{} { return new([64]sfiRv) } + p.sfiRv128.New = func() interface{} { return new([128]sfiRv) } + + // p.dn.New = func() interface{} { x := new(decNaked); x.init(); return x } + + p.buf1k.New = func() interface{} { return new([1 * 1024]byte) } + p.buf2k.New = func() interface{} { return new([2 * 1024]byte) } + p.buf4k.New = func() interface{} { return new([4 * 1024]byte) } + p.buf8k.New = func() interface{} { return new([8 * 1024]byte) } + p.buf16k.New = func() interface{} { return new([16 * 1024]byte) } + p.buf32k.New = func() interface{} { return new([32 * 1024]byte) } + p.buf64k.New = func() interface{} { return new([64 * 1024]byte) } + +} + +// func (p *pooler) sfiRv8() (sp *sync.Pool, v interface{}) { +// return &p.strRv8, p.strRv8.Get() +// } +// func (p *pooler) sfiRv16() (sp *sync.Pool, v interface{}) { +// return &p.strRv16, p.strRv16.Get() +// } +// func (p *pooler) sfiRv32() (sp *sync.Pool, v interface{}) { +// return &p.strRv32, p.strRv32.Get() +// } +// func (p *pooler) sfiRv64() (sp *sync.Pool, v interface{}) { +// return &p.strRv64, p.strRv64.Get() +// } +// func (p *pooler) sfiRv128() (sp *sync.Pool, v interface{}) { +// return &p.strRv128, p.strRv128.Get() +// } + +// func (p *pooler) bytes1k() (sp *sync.Pool, v interface{}) { +// return &p.buf1k, p.buf1k.Get() +// } +// func (p *pooler) bytes2k() (sp *sync.Pool, v interface{}) { +// return &p.buf2k, p.buf2k.Get() +// } +// func (p *pooler) bytes4k() (sp *sync.Pool, v interface{}) { +// return &p.buf4k, p.buf4k.Get() +// } +// func (p *pooler) bytes8k() (sp *sync.Pool, v interface{}) { +// return &p.buf8k, p.buf8k.Get() +// } +// func (p *pooler) bytes16k() (sp *sync.Pool, v interface{}) { +// return &p.buf16k, p.buf16k.Get() +// } +// func (p *pooler) bytes32k() (sp *sync.Pool, v interface{}) { +// return &p.buf32k, p.buf32k.Get() +// } +// func (p *pooler) bytes64k() (sp *sync.Pool, v interface{}) { +// return &p.buf64k, p.buf64k.Get() +// } + +// func (p *pooler) tiLoad() (sp *sync.Pool, v interface{}) { +// return &p.tiload, p.tiload.Get() +// } + +// func (p *pooler) decNaked() (sp *sync.Pool, v interface{}) { +// return &p.dn, p.dn.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) tiLoadGet() (v interface{}) { +// return p.tiload.Get() +// } +// func (p *pooler) decNakedPut(v interface{}) { +// p.dn.Put(v) +// } +// func (p *pooler) tiLoadPut(v interface{}) { +// p.tiload.Put(v) +// } + +// ---------------------------------------------------- + type panicHdl struct{} func (panicHdl) errorv(err error) { @@ -2521,13 +2480,12 @@ func (panicHdl) errorstr(message string) { } func (panicHdl) errorf(format string, params ...interface{}) { - if len(params) != 0 { - panic(fmt.Sprintf(format, params...)) - } - if len(params) == 0 { + if format == "" { + } else if len(params) == 0 { panic(format) + } else { + panic(fmt.Sprintf(format, params...)) } - panic("undefined error") } // ---------------------------------------------------- @@ -2571,112 +2529,169 @@ func (must) Float(s float64, err error) float64 { // ------------------- -func freelistCapacity(length int) (capacity int) { - for capacity = 8; capacity < length; capacity *= 2 { - } - return +type bytesBufPooler struct { + pool *sync.Pool + poolbuf interface{} } -type bytesFreelist [][]byte - -func (x *bytesFreelist) get(length int) (out []byte) { - var j int = -1 - for i := 0; i < len(*x); i++ { - if cap((*x)[i]) >= length && (j == -1 || cap((*x)[j]) > cap((*x)[i])) { - j = i - } - } - if j == -1 { - return make([]byte, length, freelistCapacity(length)) - } - out = (*x)[j][:length] - (*x)[j] = nil - for i := 0; i < len(out); i++ { - out[i] = 0 +func (z *bytesBufPooler) end() { + if z.pool != nil { + z.pool.Put(z.poolbuf) + z.pool, z.poolbuf = nil, nil } - return } -func (x *bytesFreelist) put(v []byte) { - if len(v) == 0 { - return - } - for i := 0; i < len(*x); i++ { - if cap((*x)[i]) == 0 { - (*x)[i] = v - return - } +func (z *bytesBufPooler) get(bufsize int) (buf []byte) { + // ensure an end is called first (if necessary) + if z.pool != nil { + z.pool.Put(z.poolbuf) + z.pool, z.poolbuf = nil, nil } - *x = append(*x, v) -} -func (x *bytesFreelist) check(v []byte, length int) (out []byte) { - if cap(v) < length { - x.put(v) - return x.get(length) + // // Try to use binary search. + // // This is not optimal, as most folks select 1k or 2k buffers + // // so a linear search is better (sequence of if/else blocks) + // if bufsize < 1 { + // bufsize = 0 + // } else { + // bufsize-- + // bufsize /= 1024 + // } + // switch bufsize { + // case 0: + // z.pool, z.poolbuf = pool.bytes1k() + // buf = z.poolbuf.(*[1 * 1024]byte)[:] + // case 1: + // z.pool, z.poolbuf = pool.bytes2k() + // buf = z.poolbuf.(*[2 * 1024]byte)[:] + // case 2, 3: + // z.pool, z.poolbuf = pool.bytes4k() + // buf = z.poolbuf.(*[4 * 1024]byte)[:] + // case 4, 5, 6, 7: + // z.pool, z.poolbuf = pool.bytes8k() + // buf = z.poolbuf.(*[8 * 1024]byte)[:] + // case 8, 9, 10, 11, 12, 13, 14, 15: + // z.pool, z.poolbuf = pool.bytes16k() + // buf = z.poolbuf.(*[16 * 1024]byte)[:] + // case 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31: + // z.pool, z.poolbuf = pool.bytes32k() + // buf = z.poolbuf.(*[32 * 1024]byte)[:] + // default: + // z.pool, z.poolbuf = pool.bytes64k() + // buf = z.poolbuf.(*[64 * 1024]byte)[:] + // } + // return + + if bufsize <= 1*1024 { + z.pool, z.poolbuf = &pool.buf1k, pool.buf1k.Get() // pool.bytes1k() + buf = z.poolbuf.(*[1 * 1024]byte)[:] + } else if bufsize <= 2*1024 { + z.pool, z.poolbuf = &pool.buf2k, pool.buf2k.Get() // pool.bytes2k() + buf = z.poolbuf.(*[2 * 1024]byte)[:] + } else if bufsize <= 4*1024 { + z.pool, z.poolbuf = &pool.buf4k, pool.buf4k.Get() // pool.bytes4k() + buf = z.poolbuf.(*[4 * 1024]byte)[:] + } else if bufsize <= 8*1024 { + z.pool, z.poolbuf = &pool.buf8k, pool.buf8k.Get() // pool.bytes8k() + buf = z.poolbuf.(*[8 * 1024]byte)[:] + } else if bufsize <= 16*1024 { + z.pool, z.poolbuf = &pool.buf16k, pool.buf16k.Get() // pool.bytes16k() + buf = z.poolbuf.(*[16 * 1024]byte)[:] + } else if bufsize <= 32*1024 { + z.pool, z.poolbuf = &pool.buf32k, pool.buf32k.Get() // pool.bytes32k() + buf = z.poolbuf.(*[32 * 1024]byte)[:] + } else { + z.pool, z.poolbuf = &pool.buf64k, pool.buf64k.Get() // pool.bytes64k() + buf = z.poolbuf.(*[64 * 1024]byte)[:] } - return v[:length] + return } -// ------------------------- +// ---------------- -type sfiRvFreelist [][]sfiRv +type sfiRvPooler struct { + pool *sync.Pool + poolv interface{} +} -func (x *sfiRvFreelist) get(length int) (out []sfiRv) { - var j int = -1 - for i := 0; i < len(*x); i++ { - if cap((*x)[i]) >= length && (j == -1 || cap((*x)[j]) > cap((*x)[i])) { - j = i - } - } - if j == -1 { - return make([]sfiRv, length, freelistCapacity(length)) - } - out = (*x)[j][:length] - (*x)[j] = nil - for i := 0; i < len(out); i++ { - out[i] = sfiRv{} +func (z *sfiRvPooler) end() { + if z.pool != nil { + z.pool.Put(z.poolv) + z.pool, z.poolv = nil, nil } - return } -func (x *sfiRvFreelist) put(v []sfiRv) { - for i := 0; i < len(*x); i++ { - if cap((*x)[i]) == 0 { - (*x)[i] = v - return - } +func (z *sfiRvPooler) get(newlen int) (fkvs []sfiRv) { + if newlen < 0 { // bounds-check-elimination + // cannot happen // here for bounds-check-elimination + } else if newlen <= 8 { + z.pool, z.poolv = &pool.sfiRv8, pool.sfiRv8.Get() // pool.sfiRv8() + fkvs = z.poolv.(*[8]sfiRv)[:newlen] + } else if newlen <= 16 { + z.pool, z.poolv = &pool.sfiRv16, pool.sfiRv16.Get() // pool.sfiRv16() + fkvs = z.poolv.(*[16]sfiRv)[:newlen] + } else if newlen <= 32 { + z.pool, z.poolv = &pool.sfiRv32, pool.sfiRv32.Get() // pool.sfiRv32() + fkvs = z.poolv.(*[32]sfiRv)[:newlen] + } else if newlen <= 64 { + z.pool, z.poolv = &pool.sfiRv64, pool.sfiRv64.Get() // pool.sfiRv64() + fkvs = z.poolv.(*[64]sfiRv)[:newlen] + } else if newlen <= 128 { + z.pool, z.poolv = &pool.sfiRv128, pool.sfiRv128.Get() // pool.sfiRv128() + fkvs = z.poolv.(*[128]sfiRv)[:newlen] + } else { + fkvs = make([]sfiRv, newlen) } - *x = append(*x, v) + return } -// ----------- - -// xdebugf printf. the message in red on the terminal. +// 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{}) { - xdebugAnyf("31", pattern, args...) -} - -// xdebug2f printf. the message in blue on the terminal. -// Use it in place of fmt.Printf (which it calls internally) -func xdebug2f(pattern string, args ...interface{}) { - xdebugAnyf("34", pattern, args...) -} - -func xdebugAnyf(colorcode, pattern string, args ...interface{}) { - if !xdebug { - return - } var delim string if len(pattern) > 0 && pattern[len(pattern)-1] != '\n' { delim = "\n" } - fmt.Printf("\033[1;"+colorcode+"m"+pattern+delim+"\033[0m", args...) - // os.Stderr.Flush() -} + 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 +// } -// register these here, so that staticcheck stops barfing -var _ = xdebug2f -var _ = xdebugf -var _ = isNaN32 +// 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.s b/vendor/github.com/ugorji/go/codec/helper.s deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/vendor/github.com/ugorji/go/codec/helper_internal.go b/vendor/github.com/ugorji/go/codec/helper_internal.go index 82d6e3140425..0cbd665e257f 100644 --- a/vendor/github.com/ugorji/go/codec/helper_internal.go +++ b/vendor/github.com/ugorji/go/codec/helper_internal.go @@ -104,9 +104,6 @@ func growCap(oldCap, unit, num int) (newCap int) { if num > 0 { newCap += num } - if newCap <= oldCap { - newCap = oldCap + 1 - } // ensure newCap is a multiple of 64 (if it is > 64) or 16. if newCap > 64 { 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 4572c6f4c4b0..74987f9f7f74 100644 --- a/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go +++ b/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go @@ -33,47 +33,26 @@ func bytesView(v string) []byte { return []byte(v) } -// isNil says whether the value v is nil. -// This applies to references like map/ptr/unsafepointer/chan/func, -// and non-reference values like interface/slice. -func isNil(v interface{}) (rv reflect.Value, isnil bool) { - rv = rv4i(v) - if isnilBitset.isset(byte(rv.Kind())) { - isnil = rv.IsNil() - } - return -} - -func rv4i(i interface{}) reflect.Value { - return reflect.ValueOf(i) +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 } func rv2i(rv reflect.Value) interface{} { return rv.Interface() } -func rvIsNil(rv reflect.Value) bool { - return rv.IsNil() -} - -func rvSetSliceLen(rv reflect.Value, length int) { - rv.SetLen(length) -} - -func rvZeroAddrK(t reflect.Type, k reflect.Kind) reflect.Value { - return reflect.New(t).Elem() -} - -func rvConvert(v reflect.Value, t reflect.Type) (rv reflect.Value) { - return v.Convert(t) -} - func rt2id(rt reflect.Type) uintptr { - return rv4i(rt).Pointer() + return reflect.ValueOf(rt).Pointer() } +// func rv2rtid(rv reflect.Value) uintptr { +// return reflect.ValueOf(rv.Type()).Pointer() +// } + func i2rtid(i interface{}) uintptr { - return rv4i(reflect.TypeOf(i)).Pointer() + return reflect.ValueOf(reflect.TypeOf(i)).Pointer() } // -------------------------- @@ -106,6 +85,14 @@ func isEmptyValue(v reflect.Value, tinfos *TypeInfos, deref, checkStruct bool) b return false } +// -------------------------- +// type ptrToRvMap struct{} + +// func (*ptrToRvMap) init() {} +// func (*ptrToRvMap) get(i interface{}) reflect.Value { +// return reflect.ValueOf(i).Elem() +// } + // -------------------------- type atomicClsErr struct { v atomic.Value @@ -156,254 +143,189 @@ func (x *atomicRtidFnSlice) store(p []codecRtidFn) { // -------------------------- func (n *decNaked) ru() reflect.Value { - return rv4i(&n.u).Elem() + return reflect.ValueOf(&n.u).Elem() } func (n *decNaked) ri() reflect.Value { - return rv4i(&n.i).Elem() + return reflect.ValueOf(&n.i).Elem() } func (n *decNaked) rf() reflect.Value { - return rv4i(&n.f).Elem() + return reflect.ValueOf(&n.f).Elem() } func (n *decNaked) rl() reflect.Value { - return rv4i(&n.l).Elem() + return reflect.ValueOf(&n.l).Elem() } func (n *decNaked) rs() reflect.Value { - return rv4i(&n.s).Elem() + return reflect.ValueOf(&n.s).Elem() } func (n *decNaked) rt() reflect.Value { - return rv4i(&n.t).Elem() + return reflect.ValueOf(&n.t).Elem() } func (n *decNaked) rb() reflect.Value { - return rv4i(&n.b).Elem() + return reflect.ValueOf(&n.b).Elem() } // -------------------------- -func rvSetBytes(rv reflect.Value, v []byte) { - rv.SetBytes(v) +func (d *Decoder) raw(f *codecFnInfo, rv reflect.Value) { + rv.SetBytes(d.rawBytes()) } -func rvSetString(rv reflect.Value, v string) { - rv.SetString(v) +func (d *Decoder) kString(f *codecFnInfo, rv reflect.Value) { + rv.SetString(d.d.DecodeString()) } -func rvSetBool(rv reflect.Value, v bool) { - rv.SetBool(v) +func (d *Decoder) kBool(f *codecFnInfo, rv reflect.Value) { + rv.SetBool(d.d.DecodeBool()) } -func rvSetTime(rv reflect.Value, v time.Time) { - rv.Set(rv4i(v)) +func (d *Decoder) kTime(f *codecFnInfo, rv reflect.Value) { + rv.Set(reflect.ValueOf(d.d.DecodeTime())) } -func rvSetFloat32(rv reflect.Value, v float32) { - rv.SetFloat(float64(v)) +func (d *Decoder) kFloat32(f *codecFnInfo, rv reflect.Value) { + fv := d.d.DecodeFloat64() + if chkOvf.Float32(fv) { + d.errorf("float32 overflow: %v", fv) + } + rv.SetFloat(fv) } -func rvSetFloat64(rv reflect.Value, v float64) { - rv.SetFloat(v) +func (d *Decoder) kFloat64(f *codecFnInfo, rv reflect.Value) { + rv.SetFloat(d.d.DecodeFloat64()) } -func rvSetInt(rv reflect.Value, v int) { - rv.SetInt(int64(v)) +func (d *Decoder) kInt(f *codecFnInfo, rv reflect.Value) { + rv.SetInt(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) } -func rvSetInt8(rv reflect.Value, v int8) { - rv.SetInt(int64(v)) +func (d *Decoder) kInt8(f *codecFnInfo, rv reflect.Value) { + rv.SetInt(chkOvf.IntV(d.d.DecodeInt64(), 8)) } -func rvSetInt16(rv reflect.Value, v int16) { - rv.SetInt(int64(v)) +func (d *Decoder) kInt16(f *codecFnInfo, rv reflect.Value) { + rv.SetInt(chkOvf.IntV(d.d.DecodeInt64(), 16)) } -func rvSetInt32(rv reflect.Value, v int32) { - rv.SetInt(int64(v)) +func (d *Decoder) kInt32(f *codecFnInfo, rv reflect.Value) { + rv.SetInt(chkOvf.IntV(d.d.DecodeInt64(), 32)) } -func rvSetInt64(rv reflect.Value, v int64) { - rv.SetInt(v) +func (d *Decoder) kInt64(f *codecFnInfo, rv reflect.Value) { + rv.SetInt(d.d.DecodeInt64()) } -func rvSetUint(rv reflect.Value, v uint) { - rv.SetUint(uint64(v)) +func (d *Decoder) kUint(f *codecFnInfo, rv reflect.Value) { + rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) } -func rvSetUintptr(rv reflect.Value, v uintptr) { - rv.SetUint(uint64(v)) +func (d *Decoder) kUintptr(f *codecFnInfo, rv reflect.Value) { + rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) } -func rvSetUint8(rv reflect.Value, v uint8) { - rv.SetUint(uint64(v)) +func (d *Decoder) kUint8(f *codecFnInfo, rv reflect.Value) { + rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), 8)) } -func rvSetUint16(rv reflect.Value, v uint16) { - rv.SetUint(uint64(v)) +func (d *Decoder) kUint16(f *codecFnInfo, rv reflect.Value) { + rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), 16)) } -func rvSetUint32(rv reflect.Value, v uint32) { - rv.SetUint(uint64(v)) +func (d *Decoder) kUint32(f *codecFnInfo, rv reflect.Value) { + rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), 32)) } -func rvSetUint64(rv reflect.Value, v uint64) { - rv.SetUint(v) +func (d *Decoder) kUint64(f *codecFnInfo, rv reflect.Value) { + rv.SetUint(d.d.DecodeUint64()) } // ---------------- -// rvSetDirect is rv.Set for all kinds except reflect.Interface -func rvSetDirect(rv reflect.Value, v reflect.Value) { - rv.Set(v) -} - -// rvSlice returns a slice of the slice of lenth -func rvSlice(rv reflect.Value, length int) reflect.Value { - return rv.Slice(0, length) +func (e *Encoder) kBool(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeBool(rv.Bool()) } -// ---------------- - -func rvSliceIndex(rv reflect.Value, i int, ti *typeInfo) reflect.Value { - return rv.Index(i) +func (e *Encoder) kTime(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeTime(rv2i(rv).(time.Time)) } -func rvGetSliceLen(rv reflect.Value) int { - return rv.Len() -} - -func rvGetSliceCap(rv reflect.Value) int { - return rv.Cap() -} - -func rvGetArrayBytesRO(rv reflect.Value, scratch []byte) (bs []byte) { - l := rv.Len() - if rv.CanAddr() { - return rvGetBytes(rv.Slice(0, l)) - } - - if l <= cap(scratch) { - bs = scratch[:l] +func (e *Encoder) kString(f *codecFnInfo, rv reflect.Value) { + s := rv.String() + if e.h.StringToRaw { + e.e.EncodeStringBytesRaw(bytesView(s)) } else { - bs = make([]byte, l) + e.e.EncodeStringEnc(cUTF8, s) } - reflect.Copy(rv4i(bs), rv) - return -} - -func rvGetArray4Slice(rv reflect.Value) (v reflect.Value) { - v = rvZeroAddrK(reflectArrayOf(rvGetSliceLen(rv), rv.Type().Elem()), reflect.Array) - reflect.Copy(v, rv) - return -} - -func rvGetSlice4Array(rv reflect.Value, tslice reflect.Type) (v reflect.Value) { - return rv.Slice(0, rv.Len()) -} - -func rvCopySlice(dest, src reflect.Value) { - reflect.Copy(dest, src) -} - -// ------------ - -func rvGetBool(rv reflect.Value) bool { - return rv.Bool() -} - -func rvGetBytes(rv reflect.Value) []byte { - return rv.Bytes() -} - -func rvGetTime(rv reflect.Value) time.Time { - return rv2i(rv).(time.Time) -} - -func rvGetString(rv reflect.Value) string { - return rv.String() } -func rvGetFloat64(rv reflect.Value) float64 { - return rv.Float() +func (e *Encoder) kFloat64(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeFloat64(rv.Float()) } -func rvGetFloat32(rv reflect.Value) float32 { - return float32(rv.Float()) +func (e *Encoder) kFloat32(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeFloat32(float32(rv.Float())) } -func rvGetInt(rv reflect.Value) int { - return int(rv.Int()) +func (e *Encoder) kInt(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeInt(rv.Int()) } -func rvGetInt8(rv reflect.Value) int8 { - return int8(rv.Int()) +func (e *Encoder) kInt8(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeInt(rv.Int()) } -func rvGetInt16(rv reflect.Value) int16 { - return int16(rv.Int()) +func (e *Encoder) kInt16(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeInt(rv.Int()) } -func rvGetInt32(rv reflect.Value) int32 { - return int32(rv.Int()) +func (e *Encoder) kInt32(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeInt(rv.Int()) } -func rvGetInt64(rv reflect.Value) int64 { - return rv.Int() +func (e *Encoder) kInt64(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeInt(rv.Int()) } -func rvGetUint(rv reflect.Value) uint { - return uint(rv.Uint()) +func (e *Encoder) kUint(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeUint(rv.Uint()) } -func rvGetUint8(rv reflect.Value) uint8 { - return uint8(rv.Uint()) +func (e *Encoder) kUint8(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeUint(rv.Uint()) } -func rvGetUint16(rv reflect.Value) uint16 { - return uint16(rv.Uint()) +func (e *Encoder) kUint16(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeUint(rv.Uint()) } -func rvGetUint32(rv reflect.Value) uint32 { - return uint32(rv.Uint()) +func (e *Encoder) kUint32(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeUint(rv.Uint()) } -func rvGetUint64(rv reflect.Value) uint64 { - return rv.Uint() +func (e *Encoder) kUint64(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeUint(rv.Uint()) } -func rvGetUintptr(rv reflect.Value) uintptr { - return uintptr(rv.Uint()) +func (e *Encoder) kUintptr(f *codecFnInfo, rv reflect.Value) { + e.e.EncodeUint(rv.Uint()) } -// ------------ map range and map indexing ---------- +// // 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) {} -func mapGet(m, k, v reflect.Value) (vv reflect.Value) { - return m.MapIndex(k) -} - -func mapSet(m, k, v reflect.Value) { - m.SetMapIndex(k, v) -} - -func mapDelete(m, k reflect.Value) { - m.SetMapIndex(k, reflect.Value{}) -} - -// return an addressable reflect value that can be used in mapRange and mapGet operations. -// -// all calls to mapGet or mapRange will call here to get an addressable reflect.Value. -func mapAddressableRV(t reflect.Type, k reflect.Kind) (r reflect.Value) { - return // reflect.New(t).Elem() -} +// // 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) {} -// ---------- ENCODER optimized --------------- - -func (e *Encoder) jsondriver() *jsonEncDriver { - return e.e.(*jsonEncDriver) -} - -// ---------- DECODER optimized --------------- - -func (d *Decoder) checkBreak() bool { - return d.d.CheckBreak() -} - -func (d *Decoder) jsondriver() *jsonDecDriver { - return d.d.(*jsonDecDriver) -} +// 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 9a22ccf5d493..3bc34d90d7c2 100644 --- a/vendor/github.com/ugorji/go/codec/helper_unsafe.go +++ b/vendor/github.com/ugorji/go/codec/helper_unsafe.go @@ -17,23 +17,10 @@ import ( // This file has unsafe variants of some helper methods. // NOTE: See helper_not_unsafe.go for the usage information. -// For reflect.Value code, we decided to do the following: -// - if we know the kind, we can elide conditional checks for -// - SetXXX (Int, Uint, String, Bool, etc) -// - SetLen -// -// We can also optimize -// - IsNil +// var zeroRTv [4]uintptr const safeMode = false - -// keep in sync with GO_ROOT/src/reflect/value.go -const ( - unsafeFlagIndir = 1 << 7 - unsafeFlagAddr = 1 << 8 - unsafeFlagKindMask = (1 << 5) - 1 // 5 bits for 27 kinds (up to 31) - // unsafeTypeKindDirectIface = 1 << 5 -) +const unsafeFlagIndir = 1 << 7 // keep in sync with GO_ROOT/src/reflect/value.go type unsafeString struct { Data unsafe.Pointer @@ -73,92 +60,47 @@ func bytesView(v string) []byte { return *(*[]byte)(unsafe.Pointer(&unsafeSlice{sx.Data, sx.Len, sx.Len})) } -// // isNilRef says whether the interface is a nil reference or not. -// // -// // A reference here is a pointer-sized reference i.e. map, ptr, chan, func, unsafepointer. -// // It is optional to extend this to also check if slices or interfaces are nil also. -// // -// // NOTE: 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. -// func isNilRef(v interface{}) (rv reflect.Value, isnil bool) { -// isnil = ((*unsafeIntf)(unsafe.Pointer(&v))).word == nil -// return -// } - -func isNil(v interface{}) (rv reflect.Value, isnil bool) { - var ui = (*unsafeIntf)(unsafe.Pointer(&v)) - if ui.word == nil { - isnil = true - return - } - rv = rv4i(v) // reflect.value is cheap and inline'able - tk := rv.Kind() - isnil = (tk == reflect.Interface || tk == reflect.Slice) && *(*unsafe.Pointer)(ui.word) == nil - return -} - -func rv2ptr(urv *unsafeReflectValue) (ptr unsafe.Pointer) { - // true references (map, func, chan, ptr - NOT slice) may be double-referenced? as flagIndir - if refBitset.isset(byte(urv.flag&unsafeFlagKindMask)) && urv.flag&unsafeFlagIndir != 0 { - ptr = *(*unsafe.Pointer)(urv.ptr) - } else { - ptr = urv.ptr - } - return -} - -func rv4i(i interface{}) (rv reflect.Value) { - // Unfortunately, we cannot get the "kind" of the interface directly here. - // We need the 'rtype', whose structure changes in different go versions. - // Finally, it's not clear that there is benefit to reimplementing it, - // as the "escapes(i)" is not clearly expensive since we want i to exist on the heap. +func definitelyNil(v interface{}) bool { + // 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 reflect.ValueOf(i) + return ((*unsafeIntf)(unsafe.Pointer(&v))).word == nil } func rv2i(rv reflect.Value) interface{} { - // We tap into implememtation details from + // 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)) - return *(*interface{})(unsafe.Pointer(&unsafeIntf{typ: urv.typ, word: rv2ptr(urv)})) -} -func rvIsNil(rv reflect.Value) bool { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - if urv.flag&unsafeFlagIndir != 0 { - return *(*unsafe.Pointer)(urv.ptr) == nil + // 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 urv.ptr == nil -} - -func rvSetSliceLen(rv reflect.Value, length int) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - (*unsafeString)(urv.ptr).Len = length -} - -func rvZeroAddrK(t reflect.Type, k reflect.Kind) (rv reflect.Value) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - urv.flag = uintptr(k) | unsafeFlagIndir | unsafeFlagAddr - urv.typ = ((*unsafeIntf)(unsafe.Pointer(&t))).word - urv.ptr = unsafe_New(urv.typ) - return -} - -func rvConvert(v reflect.Value, t reflect.Type) (rv reflect.Value) { - uv := (*unsafeReflectValue)(unsafe.Pointer(&v)) - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *urv = *uv - urv.typ = ((*unsafeIntf)(unsafe.Pointer(&t))).word - return + return *(*interface{})(unsafe.Pointer(&unsafeIntf{typ: urv.typ, word: ptr})) } func rt2id(rt reflect.Type) uintptr { return uintptr(((*unsafeIntf)(unsafe.Pointer(&rt))).word) } +// func rv2rtid(rv reflect.Value) uintptr { +// return uintptr((*unsafeReflectValue)(unsafe.Pointer(&rv)).typ) +// } + func i2rtid(i interface{}) uintptr { return uintptr(((*unsafeIntf)(unsafe.Pointer(&i))).typ) } @@ -215,7 +157,7 @@ func isEmptyValue(v reflect.Value, tinfos *TypeInfos, deref, checkStruct bool) b } return isnil case reflect.Ptr: - // isnil := urv.ptr == nil // (not sufficient, as a pointer value encodes the type) + // isnil := urv.ptr == nil (not sufficient, as a pointer value encodes the type) isnil := urv.ptr == nil || *(*unsafe.Pointer)(urv.ptr) == nil if deref { if isnil { @@ -244,7 +186,7 @@ func isEmptyValue(v reflect.Value, tinfos *TypeInfos, deref, checkStruct bool) b // ---------------------- type atomicTypeInfoSlice struct { v unsafe.Pointer // *[]rtid2ti - _ uint64 // padding (atomicXXX expected to be 2 words) + _ uintptr // padding (atomicXXX expected to be 2 words) } func (x *atomicTypeInfoSlice) load() (s []rtid2ti) { @@ -262,7 +204,7 @@ func (x *atomicTypeInfoSlice) store(p []rtid2ti) { // -------------------------- type atomicRtidFnSlice struct { v unsafe.Pointer // *[]codecRtidFn - _ uint64 // padding (atomicXXX expected to be 2 words) (make 1 word so JsonHandle fits) + _ uintptr // padding (atomicXXX expected to be 2 words) } func (x *atomicRtidFnSlice) load() (s []codecRtidFn) { @@ -280,7 +222,7 @@ func (x *atomicRtidFnSlice) store(p []codecRtidFn) { // -------------------------- type atomicClsErr struct { v unsafe.Pointer // *clsErr - _ uint64 // padding (atomicXXX expected to be 2 words) + _ uintptr // padding (atomicXXX expected to be 2 words) } func (x *atomicClsErr) load() (e clsErr) { @@ -310,14 +252,14 @@ type unsafeDecNakedWrapper struct { } func (n *unsafeDecNakedWrapper) init() { - n.ru = rv4i(&n.u).Elem() - n.ri = rv4i(&n.i).Elem() - n.rf = rv4i(&n.f).Elem() - n.rl = rv4i(&n.l).Elem() - n.rs = rv4i(&n.s).Elem() - n.rt = rv4i(&n.t).Elem() - n.rb = rv4i(&n.b).Elem() - // n.rr[] = rv4i(&n.) + 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.rr[] = reflect.ValueOf(&n.) } var defUnsafeDecNakedWrapper unsafeDecNakedWrapper @@ -363,505 +305,441 @@ func (n *decNaked) rb() (v reflect.Value) { } // -------------------------- -func rvSetBytes(rv reflect.Value, v []byte) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*[]byte)(urv.ptr) = v -} - -func rvSetString(rv reflect.Value, v string) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*string)(urv.ptr) = v -} - -func rvSetBool(rv reflect.Value, v bool) { +func (d *Decoder) raw(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*bool)(urv.ptr) = v + *(*[]byte)(urv.ptr) = d.rawBytes() } -func rvSetTime(rv reflect.Value, v time.Time) { +func (d *Decoder) kString(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*time.Time)(urv.ptr) = v + *(*string)(urv.ptr) = d.d.DecodeString() } -func rvSetFloat32(rv reflect.Value, v float32) { +func (d *Decoder) kBool(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*float32)(urv.ptr) = v + *(*bool)(urv.ptr) = d.d.DecodeBool() } -func rvSetFloat64(rv reflect.Value, v float64) { +func (d *Decoder) kTime(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*float64)(urv.ptr) = v + *(*time.Time)(urv.ptr) = d.d.DecodeTime() } -func rvSetInt(rv reflect.Value, v int) { +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)) - *(*int)(urv.ptr) = v + *(*float32)(urv.ptr) = float32(fv) } -func rvSetInt8(rv reflect.Value, v int8) { +func (d *Decoder) kFloat64(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*int8)(urv.ptr) = v + *(*float64)(urv.ptr) = d.d.DecodeFloat64() } -func rvSetInt16(rv reflect.Value, v int16) { +func (d *Decoder) kInt(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*int16)(urv.ptr) = v + *(*int)(urv.ptr) = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) } -func rvSetInt32(rv reflect.Value, v int32) { +func (d *Decoder) kInt8(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*int32)(urv.ptr) = v + *(*int8)(urv.ptr) = int8(chkOvf.IntV(d.d.DecodeInt64(), 8)) } -func rvSetInt64(rv reflect.Value, v int64) { +func (d *Decoder) kInt16(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*int64)(urv.ptr) = v + *(*int16)(urv.ptr) = int16(chkOvf.IntV(d.d.DecodeInt64(), 16)) } -func rvSetUint(rv reflect.Value, v uint) { +func (d *Decoder) kInt32(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*uint)(urv.ptr) = v + *(*int32)(urv.ptr) = int32(chkOvf.IntV(d.d.DecodeInt64(), 32)) } -func rvSetUintptr(rv reflect.Value, v uintptr) { +func (d *Decoder) kInt64(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*uintptr)(urv.ptr) = v + *(*int64)(urv.ptr) = d.d.DecodeInt64() } -func rvSetUint8(rv reflect.Value, v uint8) { +func (d *Decoder) kUint(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*uint8)(urv.ptr) = v + *(*uint)(urv.ptr) = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) } -func rvSetUint16(rv reflect.Value, v uint16) { +func (d *Decoder) kUintptr(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*uint16)(urv.ptr) = v + *(*uintptr)(urv.ptr) = uintptr(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) } -func rvSetUint32(rv reflect.Value, v uint32) { +func (d *Decoder) kUint8(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*uint32)(urv.ptr) = v + *(*uint8)(urv.ptr) = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) } -func rvSetUint64(rv reflect.Value, v uint64) { +func (d *Decoder) kUint16(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*uint64)(urv.ptr) = v + *(*uint16)(urv.ptr) = uint16(chkOvf.UintV(d.d.DecodeUint64(), 16)) } -// ---------------- - -// rvSetDirect is rv.Set for all kinds except reflect.Interface -func rvSetDirect(rv reflect.Value, v reflect.Value) { +func (d *Decoder) kUint32(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - uv := (*unsafeReflectValue)(unsafe.Pointer(&v)) - if uv.flag&unsafeFlagIndir == 0 { - *(*unsafe.Pointer)(urv.ptr) = uv.ptr - } else { - typedmemmove(urv.typ, urv.ptr, uv.ptr) - } + *(*uint32)(urv.ptr) = uint32(chkOvf.UintV(d.d.DecodeUint64(), 32)) } -// rvSlice returns a slice of the slice of lenth -func rvSlice(rv reflect.Value, length int) (v reflect.Value) { +func (d *Decoder) kUint64(f *codecFnInfo, rv reflect.Value) { urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - uv := (*unsafeReflectValue)(unsafe.Pointer(&v)) - *uv = *urv - var x []unsafe.Pointer - uv.ptr = unsafe.Pointer(&x) - *(*unsafeSlice)(uv.ptr) = *(*unsafeSlice)(urv.ptr) - (*unsafeSlice)(uv.ptr).Len = length - return + *(*uint64)(urv.ptr) = d.d.DecodeUint64() } // ------------ -func rvSliceIndex(rv reflect.Value, i int, ti *typeInfo) (v reflect.Value) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - uv := (*unsafeReflectValue)(unsafe.Pointer(&v)) - uv.ptr = unsafe.Pointer(uintptr(((*unsafeSlice)(urv.ptr)).Data) + (ti.elemsize * uintptr(i))) - uv.typ = ((*unsafeIntf)(unsafe.Pointer(&ti.elem))).word - uv.flag = uintptr(ti.elemkind) | unsafeFlagIndir | unsafeFlagAddr - return -} - -func rvGetSliceLen(rv reflect.Value) int { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return (*unsafeSlice)(urv.ptr).Len -} - -func rvGetSliceCap(rv reflect.Value) int { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return (*unsafeSlice)(urv.ptr).Cap -} - -func rvGetArrayBytesRO(rv reflect.Value, scratch []byte) (bs []byte) { - l := rv.Len() - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - bx := (*unsafeSlice)(unsafe.Pointer(&bs)) - bx.Data = urv.ptr - bx.Len, bx.Cap = l, l - return -} - -func rvGetArray4Slice(rv reflect.Value) (v reflect.Value) { - // It is possible that this slice is based off an array with a larger - // len that we want (where array len == slice cap). - // However, it is ok to create an array type that is a subset of the full - // e.g. full slice is based off a *[16]byte, but we can create a *[4]byte - // off of it. That is ok. - // - // Consequently, we use rvGetSliceLen, not rvGetSliceCap. - - t := reflectArrayOf(rvGetSliceLen(rv), rv.Type().Elem()) - // v = rvZeroAddrK(t, reflect.Array) - - uv := (*unsafeReflectValue)(unsafe.Pointer(&v)) - uv.flag = uintptr(reflect.Array) | unsafeFlagIndir | unsafeFlagAddr - uv.typ = ((*unsafeIntf)(unsafe.Pointer(&t))).word - - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - uv.ptr = *(*unsafe.Pointer)(urv.ptr) // slice rv has a ptr to the slice. - - return -} - -func rvGetSlice4Array(rv reflect.Value, tslice reflect.Type) (v reflect.Value) { - uv := (*unsafeReflectValue)(unsafe.Pointer(&v)) - - var x []unsafe.Pointer - - uv.ptr = unsafe.Pointer(&x) - uv.typ = ((*unsafeIntf)(unsafe.Pointer(&tslice))).word - uv.flag = unsafeFlagIndir | uintptr(reflect.Slice) - - s := (*unsafeSlice)(uv.ptr) - s.Data = ((*unsafeReflectValue)(unsafe.Pointer(&rv))).ptr - s.Len = rv.Len() - s.Cap = s.Len - return -} - -func rvCopySlice(dest, src reflect.Value) { - t := dest.Type().Elem() - urv := (*unsafeReflectValue)(unsafe.Pointer(&dest)) - destPtr := urv.ptr - urv = (*unsafeReflectValue)(unsafe.Pointer(&src)) - typedslicecopy((*unsafeIntf)(unsafe.Pointer(&t)).word, - *(*unsafeSlice)(destPtr), *(*unsafeSlice)(urv.ptr)) -} - -// ------------ - -func rvGetBool(rv reflect.Value) bool { +func (e *Encoder) kBool(f *codecFnInfo, rv reflect.Value) { v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*bool)(v.ptr) + e.e.EncodeBool(*(*bool)(v.ptr)) } -func rvGetBytes(rv reflect.Value) []byte { +func (e *Encoder) kTime(f *codecFnInfo, rv reflect.Value) { v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*[]byte)(v.ptr) + e.e.EncodeTime(*(*time.Time)(v.ptr)) } -func rvGetTime(rv reflect.Value) time.Time { +func (e *Encoder) kString(f *codecFnInfo, rv reflect.Value) { v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*time.Time)(v.ptr) -} - -func rvGetString(rv reflect.Value) string { - v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*string)(v.ptr) + s := *(*string)(v.ptr) + if e.h.StringToRaw { + e.e.EncodeStringBytesRaw(bytesView(s)) + } else { + e.e.EncodeStringEnc(cUTF8, s) + } } -func rvGetFloat64(rv reflect.Value) float64 { +func (e *Encoder) kFloat64(f *codecFnInfo, rv reflect.Value) { v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*float64)(v.ptr) + e.e.EncodeFloat64(*(*float64)(v.ptr)) } -func rvGetFloat32(rv reflect.Value) float32 { +func (e *Encoder) kFloat32(f *codecFnInfo, rv reflect.Value) { v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*float32)(v.ptr) + e.e.EncodeFloat32(*(*float32)(v.ptr)) } -func rvGetInt(rv reflect.Value) int { +func (e *Encoder) kInt(f *codecFnInfo, rv reflect.Value) { v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*int)(v.ptr) + e.e.EncodeInt(int64(*(*int)(v.ptr))) } -func rvGetInt8(rv reflect.Value) int8 { +func (e *Encoder) kInt8(f *codecFnInfo, rv reflect.Value) { v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*int8)(v.ptr) + e.e.EncodeInt(int64(*(*int8)(v.ptr))) } -func rvGetInt16(rv reflect.Value) int16 { +func (e *Encoder) kInt16(f *codecFnInfo, rv reflect.Value) { v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*int16)(v.ptr) + e.e.EncodeInt(int64(*(*int16)(v.ptr))) } -func rvGetInt32(rv reflect.Value) int32 { +func (e *Encoder) kInt32(f *codecFnInfo, rv reflect.Value) { v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*int32)(v.ptr) + e.e.EncodeInt(int64(*(*int32)(v.ptr))) } -func rvGetInt64(rv reflect.Value) int64 { +func (e *Encoder) kInt64(f *codecFnInfo, rv reflect.Value) { v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*int64)(v.ptr) + e.e.EncodeInt(int64(*(*int64)(v.ptr))) } -func rvGetUint(rv reflect.Value) uint { +func (e *Encoder) kUint(f *codecFnInfo, rv reflect.Value) { v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*uint)(v.ptr) + e.e.EncodeUint(uint64(*(*uint)(v.ptr))) } -func rvGetUint8(rv reflect.Value) uint8 { +func (e *Encoder) kUint8(f *codecFnInfo, rv reflect.Value) { v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*uint8)(v.ptr) + e.e.EncodeUint(uint64(*(*uint8)(v.ptr))) } -func rvGetUint16(rv reflect.Value) uint16 { +func (e *Encoder) kUint16(f *codecFnInfo, rv reflect.Value) { v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*uint16)(v.ptr) + e.e.EncodeUint(uint64(*(*uint16)(v.ptr))) } -func rvGetUint32(rv reflect.Value) uint32 { +func (e *Encoder) kUint32(f *codecFnInfo, rv reflect.Value) { v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*uint32)(v.ptr) + e.e.EncodeUint(uint64(*(*uint32)(v.ptr))) } -func rvGetUint64(rv reflect.Value) uint64 { +func (e *Encoder) kUint64(f *codecFnInfo, rv reflect.Value) { v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*uint64)(v.ptr) + e.e.EncodeUint(uint64(*(*uint64)(v.ptr))) } -func rvGetUintptr(rv reflect.Value) uintptr { +func (e *Encoder) kUintptr(f *codecFnInfo, rv reflect.Value) { v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*uintptr)(v.ptr) -} - -// ------------ map range and map indexing ---------- - -// regular calls to map via reflection: MapKeys, MapIndex, MapRange/MapIter etc -// will always allocate for each map key or value. -// -// It is more performant to provide a value that the map entry is set into, -// and that elides the allocation. - -// unsafeMapHashIter -// -// go 1.4+ has runtime/hashmap.go or runtime/map.go which has a -// hIter struct with the first 2 values being key and value -// of the current iteration. -// -// This *hIter is passed to mapiterinit, mapiternext, mapiterkey, mapiterelem. -// We bypass the reflect wrapper functions and just use the *hIter directly. -// -// Though *hIter has many fields, we only care about the first 2. -type unsafeMapHashIter struct { - key, value unsafe.Pointer - // other fields are ignored -} - -type mapIter struct { - unsafeMapIter -} - -type unsafeMapIter struct { - it *unsafeMapHashIter - // k, v reflect.Value - mtyp, ktyp, vtyp unsafe.Pointer - mptr, kptr, vptr unsafe.Pointer - kisref, visref bool - mapvalues bool - done bool - started bool - // _ [2]uint64 // padding (cache-aligned) -} - -func (t *unsafeMapIter) ValidKV() (r bool) { - return false -} - -func (t *unsafeMapIter) Next() (r bool) { - if t == nil || t.done { - return - } - if t.started { - mapiternext((unsafe.Pointer)(t.it)) - } else { - t.started = true - } - - t.done = t.it.key == nil - if t.done { - return - } - unsafeMapSet(t.kptr, t.ktyp, t.it.key, t.kisref) - if t.mapvalues { - unsafeMapSet(t.vptr, t.vtyp, t.it.value, t.visref) - } - return true -} - -func (t *unsafeMapIter) Key() (r reflect.Value) { - return -} - -func (t *unsafeMapIter) Value() (r reflect.Value) { - return -} - -func (t *unsafeMapIter) Done() { -} - -func unsafeMapSet(p, ptyp, p2 unsafe.Pointer, isref bool) { - if isref { - *(*unsafe.Pointer)(p) = *(*unsafe.Pointer)(p2) // p2 - } else { - typedmemmove(ptyp, p, p2) // *(*unsafe.Pointer)(p2)) // p2) - } -} - -func unsafeMapKVPtr(urv *unsafeReflectValue) unsafe.Pointer { - if urv.flag&unsafeFlagIndir == 0 { - return unsafe.Pointer(&urv.ptr) - } - return urv.ptr + e.e.EncodeUint(uint64(*(*uintptr)(v.ptr))) } -func mapRange(t *mapIter, m, k, v reflect.Value, mapvalues bool) { - if rvIsNil(m) { - t.done = true - return - } - t.done = false - t.started = false - t.mapvalues = mapvalues - - var urv *unsafeReflectValue - - urv = (*unsafeReflectValue)(unsafe.Pointer(&m)) - t.mtyp = urv.typ - t.mptr = rv2ptr(urv) - - t.it = (*unsafeMapHashIter)(mapiterinit(t.mtyp, t.mptr)) - - urv = (*unsafeReflectValue)(unsafe.Pointer(&k)) - t.ktyp = urv.typ - t.kptr = urv.ptr - t.kisref = refBitset.isset(byte(k.Kind())) - - if mapvalues { - urv = (*unsafeReflectValue)(unsafe.Pointer(&v)) - t.vtyp = urv.typ - t.vptr = urv.ptr - t.visref = refBitset.isset(byte(v.Kind())) - } else { - t.vtyp = nil - t.vptr = nil - } -} - -func mapGet(m, k, v reflect.Value) (vv reflect.Value) { - var urv = (*unsafeReflectValue)(unsafe.Pointer(&k)) - var kptr = unsafeMapKVPtr(urv) - - urv = (*unsafeReflectValue)(unsafe.Pointer(&m)) - - vvptr := mapaccess(urv.typ, rv2ptr(urv), kptr) - if vvptr == nil { - return - } - // vvptr = *(*unsafe.Pointer)(vvptr) - - urv = (*unsafeReflectValue)(unsafe.Pointer(&v)) - - unsafeMapSet(urv.ptr, urv.typ, vvptr, refBitset.isset(byte(v.Kind()))) - return v -} - -func mapSet(m, k, v reflect.Value) { - var urv = (*unsafeReflectValue)(unsafe.Pointer(&k)) - var kptr = unsafeMapKVPtr(urv) - urv = (*unsafeReflectValue)(unsafe.Pointer(&v)) - var vptr = unsafeMapKVPtr(urv) - urv = (*unsafeReflectValue)(unsafe.Pointer(&m)) - mapassign(urv.typ, rv2ptr(urv), kptr, vptr) -} +// ------------ -// func mapDelete(m, k reflect.Value) { -// var urv = (*unsafeReflectValue)(unsafe.Pointer(&k)) -// var kptr = unsafeMapKVPtr(urv) -// urv = (*unsafeReflectValue)(unsafe.Pointer(&m)) -// mapdelete(urv.typ, rv2ptr(urv), kptr) +// 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() // } -// return an addressable reflect value that can be used in mapRange and mapGet operations. -// -// all calls to mapGet or mapRange will call here to get an addressable reflect.Value. -func mapAddressableRV(t reflect.Type, k reflect.Kind) (r reflect.Value) { - // return reflect.New(t).Elem() - return rvZeroAddrK(t, k) -} - -//go:linkname mapiterinit reflect.mapiterinit -//go:noescape -func mapiterinit(typ unsafe.Pointer, it unsafe.Pointer) (key unsafe.Pointer) - -//go:linkname mapiternext reflect.mapiternext -//go:noescape -func mapiternext(it unsafe.Pointer) (key unsafe.Pointer) - -//go:linkname mapaccess reflect.mapaccess -//go:noescape -func mapaccess(typ unsafe.Pointer, m unsafe.Pointer, key unsafe.Pointer) (val unsafe.Pointer) - -//go:linkname mapassign reflect.mapassign -//go:noescape -func mapassign(typ unsafe.Pointer, m unsafe.Pointer, key, val unsafe.Pointer) +// 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}) +// } -//go:linkname mapdelete reflect.mapdelete -//go:noescape -func mapdelete(typ unsafe.Pointer, m unsafe.Pointer, key unsafe.Pointer) +// 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})) +// } -//go:linkname typedmemmove reflect.typedmemmove -//go:noescape -func typedmemmove(typ unsafe.Pointer, dst, src unsafe.Pointer) +// 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) +// } -//go:linkname unsafe_New reflect.unsafe_New -//go:noescape -func unsafe_New(typ unsafe.Pointer) unsafe.Pointer +// func keepAlive4BytesView(v string) { +// runtime.KeepAlive(v) +// } -//go:linkname typedslicecopy reflect.typedslicecopy -//go:noescape -func typedslicecopy(elemType unsafe.Pointer, dst, src unsafeSlice) int +// func keepAlive4StringView(v []byte) { +// runtime.KeepAlive(v) +// } -// ---------- ENCODER optimized --------------- +// func rt2id(rt reflect.Type) uintptr { +// return uintptr(((*unsafeIntf)(unsafe.Pointer(&rt))).word) +// // var i interface{} = rt +// // // ui := (*unsafeIntf)(unsafe.Pointer(&i)) +// // return ((*unsafeIntf)(unsafe.Pointer(&i))).word +// } -func (e *Encoder) jsondriver() *jsonEncDriver { - return (*jsonEncDriver)((*unsafeIntf)(unsafe.Pointer(&e.e)).word) -} +// func rv2i(rv reflect.Value) interface{} { +// urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) +// // non-reference type: already indir +// // reference type: depend on flagIndir property ('cos maybe was double-referenced) +// // const (unsafeRvFlagKindMask = 1<<5 - 1 , unsafeRvFlagIndir = 1 << 7 ) +// // rvk := reflect.Kind(urv.flag & (1<<5 - 1)) +// // if (rvk == reflect.Chan || +// // rvk == reflect.Func || +// // rvk == reflect.Interface || +// // rvk == reflect.Map || +// // rvk == reflect.Ptr || +// // rvk == reflect.UnsafePointer) && urv.flag&(1<<8) != 0 { +// // fmt.Printf(">>>>> ---- double indirect reference: %v, %v\n", rvk, rv.Type()) +// // return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: *(*unsafe.Pointer)(urv.ptr), typ: urv.typ})) +// // } +// if urv.flag&(1<<5-1) == uintptr(reflect.Map) && urv.flag&(1<<7) != 0 { +// // fmt.Printf(">>>>> ---- double indirect reference: %v, %v\n", rvk, rv.Type()) +// return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: *(*unsafe.Pointer)(urv.ptr), typ: urv.typ})) +// } +// // fmt.Printf(">>>>> ++++ direct reference: %v, %v\n", rvk, rv.Type()) +// return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: urv.ptr, typ: urv.typ})) +// } -// ---------- DECODER optimized --------------- +// const ( +// unsafeRvFlagKindMask = 1<<5 - 1 +// unsafeRvKindDirectIface = 1 << 5 +// unsafeRvFlagIndir = 1 << 7 +// unsafeRvFlagAddr = 1 << 8 +// unsafeRvFlagMethod = 1 << 9 + +// _USE_RV_INTERFACE bool = false +// _UNSAFE_RV_DEBUG = true +// ) + +// type unsafeRtype struct { +// _ [2]uintptr +// _ uint32 +// _ uint8 +// _ uint8 +// _ uint8 +// kind uint8 +// _ [2]uintptr +// _ int32 +// } -func (d *Decoder) checkBreak() bool { - // jsonDecDriver.CheckBreak() CANNOT be inlined. - // Consequently, there's no benefit in incurring the cost of this - // wrapping function checkBreak. - // - // It is faster to just call the interface method directly. +// func _rv2i(rv reflect.Value) interface{} { +// // Note: From use, +// // - it's never an interface +// // - the only calls here are for ifaceIndir types. +// // (though that conditional is wrong) +// // To know for sure, we need the value of t.kind (which is not exposed). +// // +// // Need to validate the path: type is indirect ==> only value is indirect ==> default (value is direct) +// // - Type indirect, Value indirect: ==> numbers, boolean, slice, struct, array, string +// // - Type Direct, Value indirect: ==> map??? +// // - Type Direct, Value direct: ==> pointers, unsafe.Pointer, func, chan, map +// // +// // TRANSLATES TO: +// // if typeIndirect { } else if valueIndirect { } else { } +// // +// // Since we don't deal with funcs, then "flagNethod" is unset, and can be ignored. + +// if _USE_RV_INTERFACE { +// return rv.Interface() +// } +// urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) + +// // if urv.flag&unsafeRvFlagMethod != 0 || urv.flag&unsafeRvFlagKindMask == uintptr(reflect.Interface) { +// // println("***** IS flag method or interface: delegating to rv.Interface()") +// // return rv.Interface() +// // } + +// // if urv.flag&unsafeRvFlagKindMask == uintptr(reflect.Interface) { +// // println("***** IS Interface: delegate to rv.Interface") +// // return rv.Interface() +// // } +// // if urv.flag&unsafeRvFlagKindMask&unsafeRvKindDirectIface == 0 { +// // if urv.flag&unsafeRvFlagAddr == 0 { +// // println("***** IS ifaceIndir typ") +// // // ui := unsafeIntf{word: urv.ptr, typ: urv.typ} +// // // return *(*interface{})(unsafe.Pointer(&ui)) +// // // return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: urv.ptr, typ: urv.typ})) +// // } +// // } else if urv.flag&unsafeRvFlagIndir != 0 { +// // println("***** IS flagindir") +// // // return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: *(*unsafe.Pointer)(urv.ptr), typ: urv.typ})) +// // } else { +// // println("***** NOT flagindir") +// // return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: urv.ptr, typ: urv.typ})) +// // } +// // println("***** default: delegate to rv.Interface") + +// urt := (*unsafeRtype)(unsafe.Pointer(urv.typ)) +// if _UNSAFE_RV_DEBUG { +// fmt.Printf(">>>> start: %v: ", rv.Type()) +// fmt.Printf("%v - %v\n", *urv, *urt) +// } +// if urt.kind&unsafeRvKindDirectIface == 0 { +// if _UNSAFE_RV_DEBUG { +// fmt.Printf("**** +ifaceIndir type: %v\n", rv.Type()) +// } +// // println("***** IS ifaceIndir typ") +// // if true || urv.flag&unsafeRvFlagAddr == 0 { +// // // println(" ***** IS NOT addr") +// return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: urv.ptr, typ: urv.typ})) +// // } +// } else if urv.flag&unsafeRvFlagIndir != 0 { +// if _UNSAFE_RV_DEBUG { +// fmt.Printf("**** +flagIndir type: %v\n", rv.Type()) +// } +// // println("***** IS flagindir") +// return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: *(*unsafe.Pointer)(urv.ptr), typ: urv.typ})) +// } else { +// if _UNSAFE_RV_DEBUG { +// fmt.Printf("**** -flagIndir type: %v\n", rv.Type()) +// } +// // println("***** NOT flagindir") +// return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: urv.ptr, typ: urv.typ})) +// } +// // println("***** default: delegating to rv.Interface()") +// // return rv.Interface() +// } - // if d.js { - // return d.jsondriver().CheckBreak() - // } - // if d.cbor { - // return d.cbordriver().CheckBreak() - // } - return d.d.CheckBreak() -} +// var staticM0 = make(map[string]uint64) +// var staticI0 = (int32)(-5) + +// func staticRv2iTest() { +// i0 := (int32)(-5) +// m0 := make(map[string]uint16) +// m0["1"] = 1 +// for _, i := range []interface{}{ +// (int)(7), +// (uint)(8), +// (int16)(-9), +// (uint16)(19), +// (uintptr)(77), +// (bool)(true), +// float32(-32.7), +// float64(64.9), +// complex(float32(19), 5), +// complex(float64(-32), 7), +// [4]uint64{1, 2, 3, 4}, +// (chan<- int)(nil), // chan, +// rv2i, // func +// io.Writer(ioutil.Discard), +// make(map[string]uint), +// (map[string]uint)(nil), +// staticM0, +// m0, +// &m0, +// i0, +// &i0, +// &staticI0, +// &staticM0, +// []uint32{6, 7, 8}, +// "abc", +// Raw{}, +// RawExt{}, +// &Raw{}, +// &RawExt{}, +// unsafe.Pointer(&i0), +// } { +// i2 := rv2i(reflect.ValueOf(i)) +// eq := reflect.DeepEqual(i, i2) +// fmt.Printf(">>>> %v == %v? %v\n", i, i2, eq) +// } +// // os.Exit(0) +// } -func (d *Decoder) jsondriver() *jsonDecDriver { - return (*jsonDecDriver)((*unsafeIntf)(unsafe.Pointer(&d.d)).word) -} +// func init() { +// staticRv2iTest() +// } -// func (d *Decoder) cbordriver() *cborDecDriver { -// return (*cborDecDriver)((*unsafeIntf)(unsafe.Pointer(&d.d)).word) +// func rv2i(rv reflect.Value) interface{} { +// if _USE_RV_INTERFACE || rv.Kind() == reflect.Interface || rv.CanAddr() { +// return rv.Interface() +// } +// // var i interface{} +// // ui := (*unsafeIntf)(unsafe.Pointer(&i)) +// var ui unsafeIntf +// urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) +// // fmt.Printf("urv: flag: %b, typ: %b, ptr: %b\n", urv.flag, uintptr(urv.typ), uintptr(urv.ptr)) +// if (urv.flag&unsafeRvFlagKindMask)&unsafeRvKindDirectIface == 0 { +// if urv.flag&unsafeRvFlagAddr != 0 { +// println("***** indirect and addressable! Needs typed move - delegate to rv.Interface()") +// return rv.Interface() +// } +// println("****** indirect type/kind") +// ui.word = urv.ptr +// } else if urv.flag&unsafeRvFlagIndir != 0 { +// println("****** unsafe rv flag indir") +// ui.word = *(*unsafe.Pointer)(urv.ptr) +// } else { +// println("****** default: assign prt to word directly") +// ui.word = urv.ptr +// } +// // ui.word = urv.ptr +// ui.typ = urv.typ +// // fmt.Printf("(pointers) ui.typ: %p, word: %p\n", ui.typ, ui.word) +// // fmt.Printf("(binary) ui.typ: %b, word: %b\n", uintptr(ui.typ), uintptr(ui.word)) +// return *(*interface{})(unsafe.Pointer(&ui)) +// // return i // } diff --git a/vendor/github.com/ugorji/go/codec/json.go b/vendor/github.com/ugorji/go/codec/json.go index 7b64e02ec143..619bc5b520fb 100644 --- a/vendor/github.com/ugorji/go/codec/json.go +++ b/vendor/github.com/ugorji/go/codec/json.go @@ -18,10 +18,14 @@ package codec // - we cannot use strconv.Quote and strconv.Unquote because json quotes/unquotes differently. // We implement it here. +// Top-level methods of json(End|Dec)Driver (which are implementations of (en|de)cDriver +// MUST not call one-another. + import ( "bytes" "encoding/base64" "math" + "reflect" "strconv" "time" "unicode" @@ -42,20 +46,11 @@ const ( jsonLitTrue = 1 jsonLitFalseQ = 6 jsonLitFalse = 7 - jsonLitNullQ = 13 - jsonLitNull = 14 + // jsonLitNullQ = 13 + jsonLitNull = 14 ) var ( - // jsonLiteralTrueQ = jsonLiterals[jsonLitTrueQ : jsonLitTrueQ+6] - // jsonLiteralFalseQ = jsonLiterals[jsonLitFalseQ : jsonLitFalseQ+7] - // jsonLiteralNullQ = jsonLiterals[jsonLitNullQ : jsonLitNullQ+6] - - jsonLiteralTrue = jsonLiterals[jsonLitTrue : jsonLitTrue+4] - jsonLiteralFalse = jsonLiterals[jsonLitFalse : jsonLitFalse+5] - jsonLiteralNull = jsonLiterals[jsonLitNull : jsonLitNull+4] - - // these are used, after consuming the first char jsonLiteral4True = jsonLiterals[jsonLitTrue+1 : jsonLitTrue+4] jsonLiteral4False = jsonLiterals[jsonLitFalse+1 : jsonLitFalse+5] jsonLiteral4Null = jsonLiterals[jsonLitNull+1 : jsonLitNull+4] @@ -66,7 +61,7 @@ const ( jsonU4Chk1 = 'a' - 10 jsonU4Chk0 = 'A' - 10 - // jsonScratchArrayLen = cacheLineSize + 32 // 96 + jsonScratchArrayLen = 64 ) const ( @@ -125,280 +120,429 @@ func init() { // ---------------- -type jsonEncDriver struct { - noBuiltInTypes - h *JsonHandle +type jsonEncDriverTypical struct { + w *encWriterSwitch + b *[jsonScratchArrayLen]byte + tw bool // term white space + c containerState +} - se interfaceExtWrapper +func (e *jsonEncDriverTypical) typical() {} - // ---- cpu cache line boundary? - di int8 // indent per: if negative, use tabs - d bool // indenting? - dl uint16 // indent level - ks bool // map key as string - is byte // integer as string +func (e *jsonEncDriverTypical) reset(ee *jsonEncDriver) { + e.w = ee.ew + e.b = &ee.b + e.tw = ee.h.TermWhitespace + e.c = 0 +} + +func (e *jsonEncDriverTypical) WriteArrayStart(length int) { + e.w.writen1('[') + e.c = containerArrayStart +} - typical bool +func (e *jsonEncDriverTypical) WriteArrayElem() { + if e.c != containerArrayStart { + e.w.writen1(',') + } + e.c = containerArrayElem +} - s *bitset256 // safe set for characters (taking h.HTMLAsIs into consideration) - // scratch: encode time, numbers, etc. Note: leave 1 byte for containerState - b [cacheLineSize + 24]byte // buffer for encoding numbers and time +func (e *jsonEncDriverTypical) WriteArrayEnd() { + e.w.writen1(']') + e.c = containerArrayEnd +} - e Encoder +func (e *jsonEncDriverTypical) WriteMapStart(length int) { + e.w.writen1('{') + e.c = containerMapStart } -// Keep writeIndent, WriteArrayElem, WriteMapElemKey, WriteMapElemValue -// in jsonEncDriver, so that *Encoder can directly call them +func (e *jsonEncDriverTypical) WriteMapElemKey() { + if e.c != containerMapStart { + e.w.writen1(',') + } + e.c = containerMapKey +} -func (e *jsonEncDriver) encoder() *Encoder { return &e.e } +func (e *jsonEncDriverTypical) WriteMapElemValue() { + e.w.writen1(':') + e.c = containerMapValue +} -func (e *jsonEncDriver) writeIndent() { - e.e.encWr.writen1('\n') - x := int(e.di) * int(e.dl) - if e.di < 0 { - x = -x - for x > jsonSpacesOrTabsLen { - e.e.encWr.writeb(jsonTabs[:]) - x -= jsonSpacesOrTabsLen - } - e.e.encWr.writeb(jsonTabs[:x]) +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 { - for x > jsonSpacesOrTabsLen { - e.e.encWr.writeb(jsonSpaces[:]) - x -= jsonSpacesOrTabsLen - } - e.e.encWr.writeb(jsonSpaces[:x]) + e.w.writeb(jsonLiterals[jsonLitFalse : jsonLitFalse+5]) } } -func (e *jsonEncDriver) WriteArrayElem() { - if e.e.c != containerArrayStart { - e.e.encWr.writen1(',') +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 *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: +// - newline and indent are added before each mapKey or arrayElem +// - newline and indent are added before each ending, +// except there was no entry (so we can have {} or []) + +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.writeIndent() + e.dl++ } + e.w.writen1('[') + e.c = containerArrayStart } -func (e *jsonEncDriver) WriteMapElemKey() { - if e.e.c != containerMapStart { - e.e.encWr.writen1(',') +func (e *jsonEncDriverGeneric) WriteArrayElem() { + if e.c != containerArrayStart { + e.w.writen1(',') } if e.d { e.writeIndent() } + e.c = containerArrayElem } -func (e *jsonEncDriver) WriteMapElemValue() { +func (e *jsonEncDriverGeneric) WriteArrayEnd() { if e.d { - e.e.encWr.writen2(':', ' ') - } else { - e.e.encWr.writen1(':') + e.dl-- + if e.c != containerArrayStart { + e.writeIndent() + } } + e.w.writen1(']') + e.c = containerArrayEnd } -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.e.encWr.writeb(jsonLiteralNull) - e.e.encWr.writen([rwNLen]byte{'n', 'u', 'l', 'l'}, 4) +func (e *jsonEncDriverGeneric) WriteMapStart(length int) { + if e.d { + e.dl++ + } + e.w.writen1('{') + e.c = containerMapStart } -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) +func (e *jsonEncDriverGeneric) WriteMapElemKey() { + if e.c != containerMapStart { + e.w.writen1(',') + } + if e.d { + e.writeIndent() + } + e.c = containerMapKey +} - if t.IsZero() { - e.EncodeNil() +func (e *jsonEncDriverGeneric) WriteMapElemValue() { + if e.d { + e.w.writen2(':', ' ') } else { - e.b[0] = '"' - b := fmtTime(t, e.b[1:1]) - e.b[len(b)+1] = '"' - e.e.encWr.writeb(e.b[:len(b)+2]) + e.w.writen1(':') } + e.c = containerMapValue } -func (e *jsonEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext) { - if ext == SelfExt { - rv2 := baseRV(rv) - e.e.encodeValue(rv2, e.h.fnNoExt(rv2.Type())) - } else if v := ext.ConvertExt(rv); v == nil { - e.EncodeNil() - } else { - e.e.encode(v) +func (e *jsonEncDriverGeneric) WriteMapEnd() { + if e.d { + e.dl-- + if e.c != containerMapStart { + e.writeIndent() + } } + e.w.writen1('}') + e.c = containerMapEnd } -func (e *jsonEncDriver) EncodeRawExt(re *RawExt) { - // only encodes re.Value (never re.Data) - if re.Value == nil { - e.EncodeNil() +func (e *jsonEncDriverGeneric) writeIndent() { + e.w.writen1('\n') + 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 { - e.e.encode(re.Value) + for x > jsonSpacesOrTabsLen { + e.w.writeb(jsonSpaces[:]) + x -= jsonSpacesOrTabsLen + } + e.w.writeb(jsonSpaces[:x]) } } -func (e *jsonEncDriver) EncodeBool(b bool) { - // Use writen with an array instead of writeb with a slice - // i.e. in place of e.e.encWr.writeb(jsonLiteralTrueQ) - // OR jsonLiteralTrue, jsonLiteralFalse, jsonLiteralFalseQ, etc - - if e.ks && e.e.c == containerMapKey { +func (e *jsonEncDriverGeneric) EncodeBool(b bool) { + if e.ks && e.c == containerMapKey { if b { - e.e.encWr.writen([rwNLen]byte{'"', 't', 'r', 'u', 'e', '"'}, 6) + e.w.writeb(jsonLiterals[jsonLitTrueQ : jsonLitTrueQ+6]) } else { - e.e.encWr.writen([rwNLen]byte{'"', 'f', 'a', 'l', 's', 'e', '"'}, 7) + e.w.writeb(jsonLiterals[jsonLitFalseQ : jsonLitFalseQ+7]) } } else { if b { - e.e.encWr.writen([rwNLen]byte{'t', 'r', 'u', 'e'}, 4) + e.w.writeb(jsonLiterals[jsonLitTrue : jsonLitTrue+4]) } else { - e.e.encWr.writen([rwNLen]byte{'f', 'a', 'l', 's', 'e'}, 5) + e.w.writeb(jsonLiterals[jsonLitFalse : jsonLitFalse+5]) } } } -func (e *jsonEncDriver) encodeFloat(f float64, bitsize, fmt byte, prec int8) { - var blen uint - if e.ks && e.e.c == containerMapKey { - blen = 2 + uint(len(strconv.AppendFloat(e.b[1:1], f, fmt, int(prec), int(bitsize)))) - // _ = e.b[:blen] +func (e *jsonEncDriverGeneric) EncodeFloat64(f float64) { + // instead of using 'g', specify whether to use 'e' or 'f' + fmt, prec := jsonFloatStrconvFmtPrec(f) + + 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] = '"' - e.e.encWr.writeb(e.b[:blen]) } else { - e.e.encWr.writeb(strconv.AppendFloat(e.b[:0], f, fmt, int(prec), int(bitsize))) + blen = len(strconv.AppendFloat(e.b[:0], f, fmt, prec, 64)) } + e.w.writeb(e.b[:blen]) } -func (e *jsonEncDriver) EncodeFloat64(f float64) { - fmt, prec := jsonFloatStrconvFmtPrec64(f) - e.encodeFloat(f, 64, fmt, prec) -} - -func (e *jsonEncDriver) EncodeFloat32(f float32) { - fmt, prec := jsonFloatStrconvFmtPrec32(f) - e.encodeFloat(float64(f), 32, fmt, prec) -} - -func (e *jsonEncDriver) EncodeInt(v int64) { - if e.is == 'A' || e.is == 'L' && (v > 1<<53 || v < -(1<<53)) || - (e.ks && e.e.c == containerMapKey) { +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.e.encWr.writeb(e.b[:blen]) + e.w.writeb(e.b[:blen]) return } - e.e.encWr.writeb(strconv.AppendInt(e.b[:0], v, 10)) + e.w.writeb(strconv.AppendInt(e.b[:0], v, 10)) } -func (e *jsonEncDriver) EncodeUint(v uint64) { - if e.is == 'A' || e.is == 'L' && v > 1<<53 || (e.ks && e.e.c == containerMapKey) { +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.e.encWr.writeb(e.b[:blen]) + e.w.writeb(e.b[:blen]) return } - e.e.encWr.writeb(strconv.AppendUint(e.b[:0], v, 10)) + e.w.writeb(strconv.AppendUint(e.b[:0], v, 10)) } -func (e *jsonEncDriver) EncodeString(v string) { - if e.h.StringToRaw { - e.EncodeStringBytesRaw(bytesView(v)) - return +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(' ') + } } - e.quoteStr(v) } -func (e *jsonEncDriver) EncodeStringBytesRaw(v []byte) { - // if encoding raw bytes and RawBytesExt is configured, use it to encode - if v == nil { +// -------------------- + +type jsonEncDriver struct { + noBuiltInTypes + e *Encoder + h *JsonHandle + ew *encWriterSwitch + se extWrapper + // ---- cpu cache line boundary? + bs []byte // scratch + // ---- cpu cache line boundary? + b [jsonScratchArrayLen]byte // scratch (encode time, + _ [2]uint64 // padding +} + +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() - return - } - if e.se.InterfaceExt != nil { - e.EncodeExt(v, 0, &e.se) - return + } 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) +} - slen := base64.StdEncoding.EncodedLen(len(v)) + 2 - var bs []byte - if len(e.b) < slen { - bs = e.e.blist.get(slen) +func (e *jsonEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext, en *Encoder) { + if v := ext.ConvertExt(rv); v == nil { + e.EncodeNil() } else { - bs = e.b[:slen] + en.encode(v) } - bs[0] = '"' - base64.StdEncoding.Encode(bs[1:], v) - bs[len(bs)-1] = '"' - e.e.encWr.writeb(bs) - if len(e.b) < slen { - e.e.blist.put(bs) +} + +func (e *jsonEncDriver) EncodeRawExt(re *RawExt, en *Encoder) { + // only encodes re.Value (never re.Data) + if re.Value == nil { + e.EncodeNil() + } else { + en.encode(re.Value) } } -// indent is done as below: -// - newline and indent are added before each mapKey or arrayElem -// - newline and indent are added before each ending, -// except there was no entry (so we can have {} or []) +func (e *jsonEncDriver) EncodeString(c charEncoding, v string) { + e.quoteStr(v) +} -func (e *jsonEncDriver) WriteArrayStart(length int) { - if e.d { - e.dl++ - } - e.e.encWr.writen1('[') +func (e *jsonEncDriver) EncodeStringEnc(c charEncoding, v string) { + e.quoteStr(v) } -func (e *jsonEncDriver) WriteArrayEnd() { - if e.d { - e.dl-- - e.writeIndent() +func (e *jsonEncDriver) EncodeStringBytes(c charEncoding, v []byte) { + // if encoding raw bytes and RawBytesExt is configured, use it to encode + if v == nil { + e.EncodeNil() + return } - e.e.encWr.writen1(']') -} + if c == cRAW { + if e.se.InterfaceExt != nil { + e.EncodeExt(v, 0, &e.se, e.e) + return + } -func (e *jsonEncDriver) WriteMapStart(length int) { - if e.d { - e.dl++ + slen := base64.StdEncoding.EncodedLen(len(v)) + 2 + if cap(e.bs) >= slen { + e.bs = e.bs[:slen] + } else { + e.bs = make([]byte, slen) + } + e.bs[0] = '"' + base64.StdEncoding.Encode(e.bs[1:], v) + e.bs[slen-1] = '"' + e.ew.writeb(e.bs) + } else { + e.quoteStr(stringView(v)) } - e.e.encWr.writen1('{') } -func (e *jsonEncDriver) WriteMapEnd() { - if e.d { - e.dl-- - if e.e.c != containerMapStart { - e.writeIndent() - } +func (e *jsonEncDriver) EncodeStringBytesRaw(v []byte) { + // if encoding raw bytes and RawBytesExt is configured, use it to encode + if v == nil { + e.EncodeNil() + return + } + if e.se.InterfaceExt != nil { + e.EncodeExt(v, 0, &e.se, e.e) + return + } + + slen := base64.StdEncoding.EncodedLen(len(v)) + 2 + if cap(e.bs) >= slen { + e.bs = e.bs[:slen] + } else { + e.bs = make([]byte, slen) } - e.e.encWr.writen1('}') + e.bs[0] = '"' + base64.StdEncoding.Encode(e.bs[1:], v) + e.bs[slen-1] = '"' + e.ew.writeb(e.bs) +} + +func (e *jsonEncDriver) EncodeAsis(v []byte) { + e.ew.writeb(v) } func (e *jsonEncDriver) quoteStr(s string) { // adapted from std pkg encoding/json const hex = "0123456789abcdef" - w := e.e.w() + w := e.ew + htmlasis := e.h.HTMLCharsAsIs w.writen1('"') - var i, start uint - for i < uint(len(s)) { + var start int + for i, slen := 0, len(s); i < slen; { // encode all bytes < 0x20 (except \r, \n). // also encode < > & to prevent security holes when served to some browsers. - - // We optimize for ascii, by assumining that most characters are in the BMP - // and natively consumed by json without much computation. - - // if 0x20 <= b && b != '\\' && b != '"' && b != '<' && b != '>' && b != '&' { - // if (htmlasis && jsonCharSafeSet.isset(b)) || jsonCharHtmlSafeSet.isset(b) { - b := s[i] - if e.s.isset(b) { - i++ - continue - } - if b < utf8.RuneSelf { + if b := s[i]; b < utf8.RuneSelf { + // if 0x20 <= b && b != '\\' && b != '"' && b != '<' && b != '>' && b != '&' { + // if (htmlasis && jsonCharSafeSet.isset(b)) || jsonCharHtmlSafeSet.isset(b) { + if jsonCharHtmlSafeSet.isset(b) || (htmlasis && jsonCharSafeSet.isset(b)) { + i++ + continue + } if start < i { w.writestr(s[start:i]) } @@ -424,15 +568,13 @@ func (e *jsonEncDriver) quoteStr(s string) { continue } c, size := utf8.DecodeRuneInString(s[i:]) - if c == utf8.RuneError { - if size == 1 { - if start < i { - w.writestr(s[start:i]) - } - w.writestr(`\ufffd`) - i++ - start = i + if c == utf8.RuneError && size == 1 { + if start < i { + w.writestr(s[start:i]) } + w.writestr(`\ufffd`) + i += size + start = i continue } // U+2028 is LINE SEPARATOR. U+2029 is PARAGRAPH SEPARATOR. @@ -443,47 +585,39 @@ func (e *jsonEncDriver) quoteStr(s string) { } w.writestr(`\u202`) w.writen1(hex[c&0xF]) - i += uint(size) + i += size start = i continue } - i += uint(size) + i += size } - if start < uint(len(s)) { + if start < len(s) { w.writestr(s[start:]) } w.writen1('"') } -func (e *jsonEncDriver) atEndOfEncode() { - if e.h.TermWhitespace { - if e.e.c == 0 { // scalar written, output space - e.e.encWr.writen1(' ') - } else { // container written, output new-line - e.e.encWr.writen1('\n') - } - } -} - -// ---------- - type jsonDecDriver struct { noBuiltInTypes - h *JsonHandle - - tok uint8 // used to store the token read right after skipWhiteSpace - fnil bool // found null - _ [2]byte // padding - bstr [4]byte // scratch used for string \UXXX parsing - - buf []byte - se interfaceExtWrapper - - _ uint64 // padding - + d *Decoder + h *JsonHandle + r *decReaderSwitch + 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 + 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 - d Decoder + // _ [3]uint64 // padding + // n jsonNum } // func jsonIsWS(b byte) bool { @@ -491,144 +625,158 @@ type jsonDecDriver struct { // return jsonCharWhitespaceSet.isset(b) // } -func (d *jsonDecDriver) decoder() *Decoder { - return &d.d -} - func (d *jsonDecDriver) uncacheRead() { if d.tok != 0 { - d.d.decRd.unreadn1() + d.r.unreadn1() d.tok = 0 } } func (d *jsonDecDriver) ReadMapStart() int { - d.advance() - if d.tok == 'n' { - d.readLit4Null() - return decContainerLenNil + if d.tok == 0 { + d.tok = d.r.skip(&jsonCharWhitespaceSet) } - if d.tok != '{' { - d.d.errorf("read map - expect char '%c' but got char '%c'", '{', d.tok) + const xc uint8 = '{' + if d.tok != xc { + d.d.errorf("read map - expect char '%c' but got char '%c'", xc, d.tok) } d.tok = 0 - return decContainerLenUnknown + d.c = containerMapStart + return -1 } func (d *jsonDecDriver) ReadArrayStart() int { - d.advance() - if d.tok == 'n' { - d.readLit4Null() - return decContainerLenNil + if d.tok == 0 { + d.tok = d.r.skip(&jsonCharWhitespaceSet) } - if d.tok != '[' { - d.d.errorf("read array - expect char '%c' but got char '%c'", '[', d.tok) + const xc uint8 = '[' + if d.tok != xc { + d.d.errorf("read array - expect char '%c' but got char '%c'", xc, d.tok) } d.tok = 0 - return decContainerLenUnknown + d.c = containerArrayStart + return -1 } func (d *jsonDecDriver) CheckBreak() bool { - d.advance() + if d.tok == 0 { + d.tok = d.r.skip(&jsonCharWhitespaceSet) + } 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 comes in go1.11 which supports inlining of +// one-liners, we explicitly write them all 5 out to elide the extra func call. +// +// TODO: For Go 1.11, if inlined, consider consolidating these. + func (d *jsonDecDriver) ReadArrayElem() { const xc uint8 = ',' - if d.d.c != containerArrayStart { - d.advance() + if d.tok == 0 { + d.tok = d.r.skip(&jsonCharWhitespaceSet) + } + if d.c != containerArrayStart { if d.tok != xc { - d.readDelimError(xc) + d.d.errorf("read array element - expect char '%c' but got char '%c'", xc, d.tok) } d.tok = 0 } + d.c = containerArrayElem } func (d *jsonDecDriver) ReadArrayEnd() { const xc uint8 = ']' - d.advance() + if d.tok == 0 { + d.tok = d.r.skip(&jsonCharWhitespaceSet) + } if d.tok != xc { - d.readDelimError(xc) + d.d.errorf("read array end - 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.d.c != containerMapStart { - d.advance() + if d.tok == 0 { + d.tok = d.r.skip(&jsonCharWhitespaceSet) + } + if d.c != containerMapStart { if d.tok != xc { - d.readDelimError(xc) + d.d.errorf("read map key - expect char '%c' but got char '%c'", xc, d.tok) } d.tok = 0 } + d.c = containerMapKey } func (d *jsonDecDriver) ReadMapElemValue() { const xc uint8 = ':' - d.advance() + if d.tok == 0 { + d.tok = d.r.skip(&jsonCharWhitespaceSet) + } if d.tok != xc { - d.readDelimError(xc) + d.d.errorf("read map value - expect char '%c' but got char '%c'", xc, d.tok) } d.tok = 0 + d.c = containerMapValue } func (d *jsonDecDriver) ReadMapEnd() { const xc uint8 = '}' - d.advance() + if d.tok == 0 { + d.tok = d.r.skip(&jsonCharWhitespaceSet) + } if d.tok != xc { - d.readDelimError(xc) + d.d.errorf("read map end - expect char '%c' but got char '%c'", xc, d.tok) } d.tok = 0 + d.c = containerMapEnd } -// func (d *jsonDecDriver) readDelim(xc uint8) { -// d.advance() -// if d.tok != xc { -// d.readDelimError(xc) -// } +// func (d *jsonDecDriver) readLit(length, fromIdx uint8) { +// // length here is always less than 8 (literals are: null, true, false) +// bs := d.r.readx(int(length)) // d.tok = 0 +// if jsonValidateSymbols && !bytes.Equal(bs, jsonLiterals[fromIdx:fromIdx+length]) { +// d.d.errorf("expecting %s: got %s", jsonLiterals[fromIdx:fromIdx+length], bs) +// } // } -func (d *jsonDecDriver) readDelimError(xc uint8) { - d.d.errorf("read json delimiter - expect char '%c' but got char '%c'", xc, d.tok) -} - func (d *jsonDecDriver) readLit4True() { - bs := d.d.decRd.readn(3) + bs := d.r.readx(3) d.tok = 0 - if jsonValidateSymbols && bs != [rwNLen]byte{'r', 'u', 'e'} { // !Equal jsonLiteral4True + if jsonValidateSymbols && !bytes.Equal(bs, jsonLiteral4True) { d.d.errorf("expecting %s: got %s", jsonLiteral4True, bs) } } func (d *jsonDecDriver) readLit4False() { - bs := d.d.decRd.readn(4) + bs := d.r.readx(4) d.tok = 0 - if jsonValidateSymbols && bs != [rwNLen]byte{'a', 'l', 's', 'e'} { // !Equal jsonLiteral4False + if jsonValidateSymbols && !bytes.Equal(bs, jsonLiteral4False) { d.d.errorf("expecting %s: got %s", jsonLiteral4False, bs) } } func (d *jsonDecDriver) readLit4Null() { - bs := d.d.decRd.readn(3) // readx(3) + bs := d.r.readx(3) d.tok = 0 - if jsonValidateSymbols && bs != [rwNLen]byte{'u', 'l', 'l'} { // !Equal jsonLiteral4Null + if jsonValidateSymbols && !bytes.Equal(bs, jsonLiteral4Null) { d.d.errorf("expecting %s: got %s", jsonLiteral4Null, bs) } - d.fnil = true } -func (d *jsonDecDriver) advance() { +func (d *jsonDecDriver) TryDecodeAsNil() bool { if d.tok == 0 { - d.fnil = false - d.tok = d.d.decRd.skip(&jsonCharWhitespaceSet) + d.tok = d.r.skip(&jsonCharWhitespaceSet) } -} - -func (d *jsonDecDriver) TryNil() bool { - d.advance() - // we shouldn't try to see if quoted "null" was here, right? + // 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.readLit4Null() @@ -637,19 +785,13 @@ func (d *jsonDecDriver) TryNil() bool { return false } -func (d *jsonDecDriver) Nil() bool { - return d.fnil -} - func (d *jsonDecDriver) DecodeBool() (v bool) { - d.advance() - if d.tok == 'n' { - d.readLit4Null() - return + if d.tok == 0 { + d.tok = d.r.skip(&jsonCharWhitespaceSet) } - fquot := d.d.c == containerMapKey && d.tok == '"' + fquot := d.c == containerMapKey && d.tok == '"' if fquot { - d.tok = d.d.decRd.readn1() + d.tok = d.r.readn1() } switch d.tok { case 'f': @@ -663,20 +805,18 @@ func (d *jsonDecDriver) DecodeBool() (v bool) { // v = false // "unreachable" } if fquot { - d.d.decRd.readn1() + d.r.readn1() } return } func (d *jsonDecDriver) DecodeTime() (t time.Time) { // read string, and pass the string into json.unmarshal - d.advance() - if d.tok == 'n' { - d.readLit4Null() + d.appendStringAsBytes() + if d.fnull { return } - bs := d.readString() - t, err := time.Parse(time.RFC3339, stringView(bs)) + t, err := time.Parse(time.RFC3339, stringView(d.bs)) if err != nil { d.d.errorv(err) } @@ -685,38 +825,41 @@ func (d *jsonDecDriver) DecodeTime() (t time.Time) { func (d *jsonDecDriver) ContainerType() (vt valueType) { // check container type by checking the first char - d.advance() + 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 d.tok == '{' { + if b := d.tok; b == '{' { return valueTypeMap - } else if d.tok == '[' { + } else if b == '[' { return valueTypeArray - } else if d.tok == 'n' { - d.readLit4Null() + } else if b == 'n' { return valueTypeNil - } else if d.tok == '"' { + } else if b == '"' { return valueTypeString } return valueTypeUnset } func (d *jsonDecDriver) decNumBytes() (bs []byte) { - d.advance() + // stores num bytes in d.bs + if d.tok == 0 { + d.tok = d.r.skip(&jsonCharWhitespaceSet) + } if d.tok == '"' { - bs = d.d.decRd.readUntil('"', false) - } else if d.tok == 'n' { - d.readLit4Null() + bs = d.r.readUntil(d.b2[:0], '"') + bs = bs[:len(bs)-1] } else { - d.d.decRd.unreadn1() - bs = d.d.decRd.readTo(&jsonNumSet) + d.r.unreadn1() + bs = d.r.readTo(d.bs[:0], &jsonNumSet) } d.tok = 0 - return + return bs } func (d *jsonDecDriver) DecodeUint64() (u uint64) { @@ -731,7 +874,7 @@ func (d *jsonDecDriver) DecodeUint64() (u uint64) { d.d.errorf("minus found parsing unsigned integer: %s", bs) } else if badsyntax { // fallback: try to decode as float, and cast - n = d.decUint64ViaFloat(bs) + n = d.decUint64ViaFloat(stringView(bs)) } return n } @@ -749,9 +892,9 @@ func (d *jsonDecDriver) DecodeInt64() (i int64) { // d.d.errorf("invalid syntax for integer: %s", bs) // fallback: try to decode as float, and cast if neg { - n = d.decUint64ViaFloat(bs[1:]) + n = d.decUint64ViaFloat(stringView(bs[1:])) } else { - n = d.decUint64ViaFloat(bs) + n = d.decUint64ViaFloat(stringView(bs)) } } if neg { @@ -768,13 +911,14 @@ func (d *jsonDecDriver) DecodeInt64() (i int64) { return } -func (d *jsonDecDriver) decUint64ViaFloat(s []byte) (u uint64) { +func (d *jsonDecDriver) decUint64ViaFloat(s string) (u uint64) { if len(s) == 0 { return } - f, err := parseFloat64(s) + f, err := strconv.ParseFloat(s, 64) if err != nil { d.d.errorf("invalid syntax for integer: %s", s) + // d.d.errorv(err) } fi, ff := math.Modf(f) if ff > 0 { @@ -786,62 +930,28 @@ func (d *jsonDecDriver) decUint64ViaFloat(s []byte) (u uint64) { } func (d *jsonDecDriver) DecodeFloat64() (f float64) { - var err error - if bs := d.decNumBytes(); len(bs) > 0 { - if f, err = parseFloat64(bs); err != nil { - d.d.errorv(err) - } + bs := d.decNumBytes() + if len(bs) == 0 { + return } - return -} - -func (d *jsonDecDriver) DecodeFloat32() (f float32) { - var err error - if bs := d.decNumBytes(); len(bs) > 0 { - if f, err = parseFloat32(bs); err != nil { - d.d.errorv(err) - } + f, err := strconv.ParseFloat(stringView(bs), 64) + if err != nil { + d.d.errorv(err) } return } -func (d *jsonDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) { - d.advance() - if d.tok == 'n' { - d.readLit4Null() - return - } +func (d *jsonDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxtag uint64) { if ext == nil { re := rv.(*RawExt) re.Tag = xtag d.d.decode(&re.Value) - } else if ext == SelfExt { - rv2 := baseRV(rv) - d.d.decodeValue(rv2, d.h.fnNoExt(rv2.Type())) - } else { - d.d.interfaceExtConvertAndDecode(rv, ext) - } -} - -func (d *jsonDecDriver) decBytesFromArray(bs []byte) []byte { - if bs == nil { - bs = []byte{} } else { - bs = bs[:0] + var v interface{} + d.d.decode(&v) + ext.UpdateExt(rv, v) } - d.tok = 0 - bs = append(bs, uint8(d.DecodeUint64())) - d.tok = d.d.decRd.skip(&jsonCharWhitespaceSet) - for d.tok != ']' { - if d.tok != ',' { - d.d.errorf("read array element - expect char '%c' but got char '%c'", ',', d.tok) - } - d.tok = 0 - bs = append(bs, uint8(chkOvf.UintV(d.DecodeUint64(), 8))) - d.tok = d.d.decRd.skip(&jsonCharWhitespaceSet) - } - d.tok = 0 - return bs + return } func (d *jsonDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { @@ -851,41 +961,37 @@ func (d *jsonDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { d.DecodeExt(&bsOut, 0, &d.se) return } - d.advance() + 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) - if zerocopy && len(bs) == 0 { - bs = d.d.b[:] - } - return d.decBytesFromArray(bs) + 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{}. - // appendStringAsBytes returns a zero-len slice for both, so as not to reset d.buf. - // However, it sets a fnil field to true, so we can check if a null was found. - - if d.tok == 'n' { - d.readLit4Null() - return nil + // appendStringAsBytes returns a zero-len slice for both, so as not to reset d.bs. + // However, it sets a fnull field to true, so we can check if a null was found. + if len(d.bs) == 0 { + if d.fnull { + return nil + } + return []byte{} } - - bs1 := d.readString() - slen := base64.StdEncoding.DecodedLen(len(bs1)) - if slen == 0 { - bsOut = []byte{} - } else if slen <= cap(bs) { + bs0 := d.bs + slen := base64.StdEncoding.DecodedLen(len(bs0)) + if slen <= cap(bs) { bsOut = bs[:slen] - } else if zerocopy { - d.buf = d.d.blist.check(d.buf, slen) - bsOut = d.buf + } else if zerocopy && slen <= cap(d.b2) { + bsOut = d.b2[:slen] } else { bsOut = make([]byte, slen) } - slen2, err := base64.StdEncoding.Decode(bsOut, bs1) + slen2, err := base64.StdEncoding.Decode(bsOut, bs0) if err != nil { - d.d.errorf("error decoding base64 binary '%s': %v", bs1, err) + d.d.errorf("error decoding base64 binary '%s': %v", bs0, err) return nil } if slen != slen2 { @@ -894,179 +1000,157 @@ func (d *jsonDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { return } +func (d *jsonDecDriver) DecodeString() (s string) { + d.appendStringAsBytes() + return d.bsToString() +} + func (d *jsonDecDriver) DecodeStringAsBytes() (s []byte) { - d.advance() + d.appendStringAsBytes() + return d.bs +} + +func (d *jsonDecDriver) appendStringAsBytes() { + if d.tok == 0 { + d.tok = d.r.skip(&jsonCharWhitespaceSet) + } + + d.fnull = false if 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.readLit4Null() - return []byte{} + d.bs = d.bs[:0] + d.fnull = true case 'f': d.readLit4False() - return jsonLiteralFalse + d.bs = d.bs[:5] + copy(d.bs, "false") case 't': d.readLit4True() - return jsonLiteralTrue + d.bs = d.bs[:4] + copy(d.bs, "true") + default: + // try to parse a valid number + bs := d.decNumBytes() + if len(bs) <= cap(d.bs) { + d.bs = d.bs[:len(bs)] + } else { + d.bs = make([]byte, len(bs)) + } + copy(d.bs, bs) } - // try to parse a valid number - return d.decNumBytes() - } - s = d.appendStringAsBytes() - if d.fnil { - return nil - } - return -} - -func (d *jsonDecDriver) readString() (bs []byte) { - if d.tok != '"' { - d.d.errorf("expecting string starting with '\"'; got '%c'", d.tok) return } - bs = d.d.decRd.readUntil('"', false) d.tok = 0 - return -} - -func (d *jsonDecDriver) appendStringAsBytes() (bs []byte) { - if d.buf != nil { - d.buf = d.buf[:0] - } - d.tok = 0 - + r := d.r + var cs = r.readUntil(d.b2[:0], '"') + var cslen = uint(len(cs)) + var c uint8 + v := d.bs[:0] // append on each byte seen can be expensive, so we just // keep track of where we last read a contiguous set of // non-special bytes (using cursor variable), // and when we see a special byte // e.g. end-of-slice, " or \, // we will append the full range into the v slice before proceeding - - var cs = d.d.decRd.readUntil('"', true) - var c uint8 var i, cursor uint for { - if i >= uint(len(cs)) { - d.buf = append(d.buf, cs[cursor:]...) - cs = d.d.decRd.readUntil('"', true) + if i == cslen { + v = append(v, cs[cursor:]...) + cs = r.readUntil(d.b2[:0], '"') + cslen = uint(len(cs)) i, cursor = 0, 0 - continue // this continue helps elide the cs[i] below } c = cs[i] if c == '"' { + v = append(v, cs[cursor:i]...) break } if c != '\\' { i++ continue } - - d.buf = append(d.buf, cs[cursor:i]...) + v = append(v, cs[cursor:i]...) i++ - if i >= uint(len(cs)) { - d.d.errorf("need at least 1 more bytes for \\ escape sequence") - return // bounds-check elimination - } c = cs[i] switch c { case '"', '\\', '/', '\'': - d.buf = append(d.buf, c) + v = append(v, c) case 'b': - d.buf = append(d.buf, '\b') + v = append(v, '\b') case 'f': - d.buf = append(d.buf, '\f') + v = append(v, '\f') case 'n': - d.buf = append(d.buf, '\n') + v = append(v, '\n') case 'r': - d.buf = append(d.buf, '\r') + v = append(v, '\r') case 't': - d.buf = append(d.buf, '\t') + v = append(v, '\t') case 'u': - i = d.appendStringAsBytesSlashU(cs, i) - default: - d.d.errorf("unsupported escaped value: %c", c) - } - i++ - cursor = i - } - if len(cs) > 0 { - if len(d.buf) > 0 && cursor < uint(len(cs)) { - d.buf = append(d.buf, cs[cursor:i]...) - } else { - // if bytes, just return the cs got from readUntil. - // do not do it for io, especially bufio, as the buffer is needed for other things - cs = cs[:i] - if d.d.bytes { - return cs + var r rune + var rr uint32 + if cslen < i+4 { + d.d.errorf("need at least 4 more bytes for unicode sequence") } - d.buf = d.d.blist.check(d.buf, len(cs)) - copy(d.buf, cs) - } - } - return d.buf -} - -func (d *jsonDecDriver) appendStringAsBytesSlashU(cs []byte, i uint) uint { - var r rune - var rr uint32 - var j uint - var c byte - if uint(len(cs)) < i+4 { - d.d.errorf("need at least 4 more bytes for unicode sequence") - return 0 // bounds-check elimination - } - for _, c = range cs[i+1 : i+5] { // bounds-check-elimination - // best to use explicit if-else - // - not a table, etc which involve memory loads, array lookup with bounds checks, etc - 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 + var j uint + for _, c = range cs[i+1 : i+5] { // bounds-check-elimination + // best to use explicit if-else + // - not a table, etc which involve memory loads, array lookup with bounds checks, etc + 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 + } + } + r = rune(rr) i += 4 - goto encode_rune - } - } - r = rune(rr) - i += 4 - if utf16.IsSurrogate(r) { - if len(cs) >= int(i+6) { - var cx = cs[i+1:][:6:6] // [:6] affords bounds-check-elimination - //var cx [6]byte - //copy(cx[:], cs[i+1:]) - if cx[0] == '\\' && cx[1] == 'u' { - i += 2 - var rr1 uint32 - for j = 2; j < 6; j++ { - c = cx[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 + if utf16.IsSurrogate(r) { + if len(cs) >= int(i+6) { + var cx = cs[i+1:][:6:6] // [:6] affords bounds-check-elimination + if cx[0] == '\\' && cx[1] == 'u' { + i += 2 + var rr1 uint32 + for j = 2; j < 6; j++ { + c = cx[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 + } + } + r = utf16.DecodeRune(r, rune(rr1)) i += 4 goto encode_rune } } - r = utf16.DecodeRune(r, rune(rr1)) - i += 4 - goto encode_rune + r = unicode.ReplacementChar } + encode_rune: + w2 := utf8.EncodeRune(d.bstr[:], r) + v = append(v, d.bstr[:w2]...) + default: + d.d.errorf("unsupported escaped value: %c", c) } - r = unicode.ReplacementChar + i++ + cursor = i } -encode_rune: - w2 := utf8.EncodeRune(d.bstr[:], r) - d.buf = append(d.buf, d.bstr[:w2]...) - return i + d.bs = v } func (d *jsonDecDriver) nakedNum(z *decNaked, bs []byte) (err error) { @@ -1114,22 +1198,25 @@ func (d *jsonDecDriver) nakedNum(z *decNaked, bs []byte) (err error) { return F: z.v = valueTypeFloat - z.f, err = parseFloat64(bs) + z.f, err = strconv.ParseFloat(stringView(bs), 64) return } -func (d *jsonDecDriver) sliceToString(bs []byte) string { - if d.d.is != nil && (jsonAlwaysReturnInternString || d.d.c == containerMapKey) { - return d.d.string(bs) +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(bs) + return string(d.bs) } func (d *jsonDecDriver) DecodeNaked() { z := d.d.naked() + // var decodeFurther bool - d.advance() - var bs []byte + if d.tok == 0 { + d.tok = d.r.skip(&jsonCharWhitespaceSet) + } switch d.tok { case 'n': d.readLit4Null() @@ -1148,29 +1235,30 @@ func (d *jsonDecDriver) DecodeNaked() { z.v = valueTypeArray // don't consume. kInterfaceNaked will call ReadArrayStart case '"': // if a string, and MapKeyAsString, then try to decode it as a nil, bool or number first - bs = d.appendStringAsBytes() - if len(bs) > 0 && d.d.c == containerMapKey && d.h.MapKeyAsString { - if bytes.Equal(bs, jsonLiteralNull) { + d.appendStringAsBytes() + if len(d.bs) > 0 && d.c == containerMapKey && d.h.MapKeyAsString { + switch stringView(d.bs) { + case "null": z.v = valueTypeNil - } else if bytes.Equal(bs, jsonLiteralTrue) { + case "true": z.v = valueTypeBool z.b = true - } else if bytes.Equal(bs, jsonLiteralFalse) { + case "false": z.v = valueTypeBool z.b = false - } else { + default: // check if a number: float, int or uint - if err := d.nakedNum(z, bs); err != nil { + if err := d.nakedNum(z, d.bs); err != nil { z.v = valueTypeString - z.s = d.sliceToString(bs) + z.s = d.bsToString() } } } else { z.v = valueTypeString - z.s = d.sliceToString(bs) + z.s = d.bsToString() } default: // number - bs = d.decNumBytes() + bs := d.decNumBytes() if len(bs) == 0 { d.d.errorf("decode number from empty string") return @@ -1180,6 +1268,9 @@ func (d *jsonDecDriver) DecodeNaked() { return } } + // if decodeFurther { + // d.s.sc.retryRead() + // } } //---------------------- @@ -1251,117 +1342,121 @@ type JsonHandle struct { // The only caveat is that nil value is ALWAYS written as null (never as "null") MapKeyAsString bool - // _ uint64 // padding (cache line) + // _ [2]byte // padding - // Note: below, we store hardly-used items - // e.g. RawBytesExt (which is already cached in the (en|de)cDriver). + // 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 - _ [5]uint64 // padding (cache line) + _ [2]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) 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' } -func (h *JsonHandle) newEncDriver() encDriver { - var e = &jsonEncDriver{h: h} - e.e.e = e - e.e.js = true - e.e.init(h) - e.reset() - return e +type jsonTypical interface { + typical() } -func (h *JsonHandle) newDecDriver() decDriver { - var d = &jsonDecDriver{h: h} - d.d.d = d - d.d.js = true - d.d.jsms = h.MapKeyAsString - d.d.init(h) - d.reset() - return d +func (h *JsonHandle) recreateEncDriver(ed encDriver) (v bool) { + _, v = ed.(jsonTypical) + return v != h.typical() } -func (e *jsonEncDriver) reset() { - // (htmlasis && jsonCharSafeSet.isset(b)) || jsonCharHtmlSafeSet.isset(b) - e.typical = e.h.typical() - if e.h.HTMLCharsAsIs { - e.s = &jsonCharSafeSet +// SetInterfaceExt sets an extension +func (h *JsonHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) { + return h.SetExt(rt, tag, &extWrapper{bytesExtFailer{}, ext}) +} + +type jsonEncDriverTypicalImpl struct { + jsonEncDriver + jsonEncDriverTypical + _ [1]uint64 // padding +} + +func (x *jsonEncDriverTypicalImpl) reset() { + x.jsonEncDriver.reset() + x.jsonEncDriverTypical.reset(&x.jsonEncDriver) +} + +type jsonEncDriverGenericImpl struct { + jsonEncDriver + jsonEncDriverGeneric + // _ [2]uint64 // padding +} + +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 { - e.s = &jsonCharHtmlSafeSet + 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.ew = e.e.w e.se.InterfaceExt = e.h.RawBytesExt - e.d, e.dl, e.di = false, 0, 0 - if e.h.Indent != 0 { - e.d = true - e.di = int8(e.h.Indent) + if e.bs != nil { + e.bs = e.bs[:0] } - e.ks = e.h.MapKeyAsString - e.is = e.h.IntegerAsString } func (d *jsonDecDriver) reset() { + d.r = d.d.r d.se.InterfaceExt = d.h.RawBytesExt - d.buf = d.d.blist.check(d.buf, 256)[:0] - d.tok = 0 - d.fnil = false -} - -func (d *jsonDecDriver) atEndOfDecode() {} - -// jsonFloatStrconvFmtPrec ... -// -// ensure that every float has an 'e' or '.' in it,/ for easy differentiation from integers. -// this is better/faster than checking if encoded value has [e.] and appending if needed. - -// func jsonFloatStrconvFmtPrec(f float64, bits32 bool) (fmt byte, prec int) { -// fmt = 'f' -// prec = -1 -// var abs = math.Abs(f) -// if abs == 0 || abs == 1 { -// prec = 1 -// } else if !bits32 && (abs < 1e-6 || abs >= 1e21) || -// bits32 && (float32(abs) < 1e-6 || float32(abs) >= 1e21) { -// fmt = 'e' -// } else if _, frac := math.Modf(abs); frac == 0 { -// // ensure that floats have a .0 at the end, for easy identification as floats -// prec = 1 -// } -// return -// } - -func jsonFloatStrconvFmtPrec64(f float64) (fmt byte, prec int8) { - fmt = 'f' - prec = -1 - var abs = math.Abs(f) - if abs == 0 || abs == 1 { - prec = 1 - } else if abs < 1e-6 || abs >= 1e21 { - fmt = 'e' - } else if noFrac64(abs) { // _, frac := math.Modf(abs); frac == 0 { - prec = 1 + if d.bs != nil { + d.bs = d.bs[:0] } - return + d.c, d.tok = 0, 0 + // d.n.reset() } -func jsonFloatStrconvFmtPrec32(f float32) (fmt byte, prec int8) { - fmt = 'f' +func jsonFloatStrconvFmtPrec(f float64) (fmt byte, prec int) { prec = -1 - var abs = abs32(f) - if abs == 0 || abs == 1 { - prec = 1 - } else if abs < 1e-6 || abs >= 1e21 { + var abs = math.Abs(f) + if abs != 0 && (abs < 1e-6 || abs >= 1e21) { fmt = 'e' - } else if noFrac32(abs) { // _, frac := math.Modf(abs); frac == 0 { - prec = 1 + } 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 } @@ -1407,87 +1502,7 @@ func jsonParseInteger(s []byte) (n uint64, neg, badSyntax, overflow bool) { return } -var _ decDriverContainerTracker = (*jsonDecDriver)(nil) -var _ encDriverContainerTracker = (*jsonEncDriver)(nil) var _ decDriver = (*jsonDecDriver)(nil) - -var _ encDriver = (*jsonEncDriver)(nil) - -// ---------------- - -/* -type jsonEncDriverTypical jsonEncDriver - -func (e *jsonEncDriverTypical) WriteArrayStart(length int) { - e.e.encWr.writen1('[') -} - -func (e *jsonEncDriverTypical) WriteArrayElem() { - if e.e.c != containerArrayStart { - e.e.encWr.writen1(',') - } -} - -func (e *jsonEncDriverTypical) WriteArrayEnd() { - e.e.encWr.writen1(']') -} - -func (e *jsonEncDriverTypical) WriteMapStart(length int) { - e.e.encWr.writen1('{') -} - -func (e *jsonEncDriverTypical) WriteMapElemKey() { - if e.e.c != containerMapStart { - e.e.encWr.writen1(',') - } -} - -func (e *jsonEncDriverTypical) WriteMapElemValue() { - e.e.encWr.writen1(':') -} - -func (e *jsonEncDriverTypical) WriteMapEnd() { - e.e.encWr.writen1('}') -} - -func (e *jsonEncDriverTypical) EncodeBool(b bool) { - if b { - // e.e.encWr.writeb(jsonLiteralTrue) - e.e.encWr.writen([rwNLen]byte{'t', 'r', 'u', 'e'}, 4) - } else { - // e.e.encWr.writeb(jsonLiteralFalse) - e.e.encWr.writen([rwNLen]byte{'f', 'a', 'l', 's', 'e'}, 5) - } -} - -func (e *jsonEncDriverTypical) EncodeInt(v int64) { - e.e.encWr.writeb(strconv.AppendInt(e.b[:0], v, 10)) -} - -func (e *jsonEncDriverTypical) EncodeUint(v uint64) { - e.e.encWr.writeb(strconv.AppendUint(e.b[:0], v, 10)) -} - -func (e *jsonEncDriverTypical) EncodeFloat64(f float64) { - fmt, prec := jsonFloatStrconvFmtPrec64(f) - e.e.encWr.writeb(strconv.AppendFloat(e.b[:0], f, fmt, int(prec), 64)) - // e.e.encWr.writeb(strconv.AppendFloat(e.b[:0], f, jsonFloatStrconvFmtPrec64(f), 64)) -} - -func (e *jsonEncDriverTypical) EncodeFloat32(f float32) { - fmt, prec := jsonFloatStrconvFmtPrec32(f) - e.e.encWr.writeb(strconv.AppendFloat(e.b[:0], float64(f), fmt, int(prec), 32)) -} - -// func (e *jsonEncDriverTypical) encodeFloat(f float64, bitsize uint8) { -// fmt, prec := jsonFloatStrconvFmtPrec(f, bitsize == 32) -// e.e.encWr.writeb(strconv.AppendFloat(e.b[:0], f, fmt, prec, int(bitsize))) -// } - -// func (e *jsonEncDriverTypical) atEndOfEncode() { -// if e.tw { -// e.e.encWr.writen1(' ') -// } -// } - -*/ +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 ba55b396fc68..c598cc73a5eb 100644 --- a/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl +++ b/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl @@ -7,6 +7,7 @@ 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. @@ -17,37 +18,37 @@ func init() { _ = fmt.Printf } // so we can include fmt as needed type TestMammoth struct { -{{range .Values }}{{if .Primitive -}} -{{ .MethodNamePfx "F" true }} {{ .Primitive }} +{{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 }} +{{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 }} +{{range .Values }}{{if not .Primitive }}{{if .MapKey }}{{/* +*/}}{{ .MethodNamePfx "F" false }} map[{{ .MapKey }}]{{ .Elem }} {{ .MethodNamePfx "Fptr" false }} *map[{{ .MapKey }}]{{ .Elem }} {{end}}{{end}}{{end}} } -{{range .Values }}{{if not .Primitive }}{{if not .MapKey -}} -type {{ .MethodNamePfx "typMbs" false }} []{{ .Elem }} +{{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 }} +{{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 -}} +{{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 }} } } { - {{/* + 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 @@ -60,19 +61,16 @@ func doTestMammothSlices(t *testing.T, h Handle) { // - // - rinse and repeat for a MapBySlice version // - - */ -}} + */}} var v{{$i}}v1, v{{$i}}v2 []{{ .Elem }} - var bs{{$i}} []byte v{{$i}}v1 = v - bs{{$i}} = testMarshalErr(v{{$i}}v1, h, t, "enc-slice-v{{$i}}") - if v != nil { + 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(rv4i(v{{$i}}v2), bs{{$i}}, h, t, "dec-slice-v{{$i}}-noaddr") // non-addressable value + 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 @@ -104,11 +102,9 @@ func doTestMammothSlices(t *testing.T, h Handle) { 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) - if v != nil { 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) @@ -119,21 +115,19 @@ func doTestMammothSlices(t *testing.T, h Handle) { } func doTestMammothMaps(t *testing.T, h Handle) { -{{range $i, $e := .Values }}{{if not .Primitive }}{{if .MapKey -}} +{{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 }} - var bs{{$i}} []byte v{{$i}}v1 = v - bs{{$i}} = testMarshalErr(v{{$i}}v1, h, t, "enc-map-v{{$i}}") - if v != nil { + 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(rv4i(v{{$i}}v2), bs{{$i}}, h, t, "dec-map-v{{$i}}-noaddr") // decode into non-addressable map value + 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") @@ -146,12 +140,10 @@ func doTestMammothMaps(t *testing.T, h Handle) { 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) - if v != nil { 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}} } diff --git a/vendor/github.com/ugorji/go/codec/msgpack.go b/vendor/github.com/ugorji/go/codec/msgpack.go index 4543337d2e19..85c71f22fb99 100644 --- a/vendor/github.com/ugorji/go/codec/msgpack.go +++ b/vendor/github.com/ugorji/go/codec/msgpack.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a MIT license found in the LICENSE file. /* +MSGPACK + Msgpack-c implementation powers the c, c++, python, ruby, etc libraries. We need to maintain compatibility with it and how it encodes integer values without caring about the type. @@ -22,6 +24,7 @@ import ( "io" "math" "net/rpc" + "reflect" "time" ) @@ -197,18 +200,16 @@ var ( type msgpackEncDriver struct { noBuiltInTypes encDriverNoopContainerWriter + // encNoSeparator + e *Encoder + w *encWriterSwitch h *MsgpackHandle x [8]byte - _ [6]uint64 // padding - e Encoder -} - -func (e *msgpackEncDriver) encoder() *Encoder { - return &e.e + // _ [3]uint64 // padding } func (e *msgpackEncDriver) EncodeNil() { - e.e.encWr.writen1(mpNil) + e.w.writen1(mpNil) } func (e *msgpackEncDriver) EncodeInt(i int64) { @@ -216,72 +217,72 @@ func (e *msgpackEncDriver) EncodeInt(i int64) { e.EncodeUint(uint64(i)) } else if i > math.MaxInt8 { if i <= math.MaxInt16 { - e.e.encWr.writen1(mpInt16) - bigenHelper{e.x[:2], e.e.w()}.writeUint16(uint16(i)) + e.w.writen1(mpInt16) + bigenHelper{e.x[:2], e.w}.writeUint16(uint16(i)) } else if i <= math.MaxInt32 { - e.e.encWr.writen1(mpInt32) - bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(i)) + e.w.writen1(mpInt32) + bigenHelper{e.x[:4], e.w}.writeUint32(uint32(i)) } else { - e.e.encWr.writen1(mpInt64) - bigenHelper{e.x[:8], e.e.w()}.writeUint64(uint64(i)) + e.w.writen1(mpInt64) + bigenHelper{e.x[:8], e.w}.writeUint64(uint64(i)) } } else if i >= -32 { if e.h.NoFixedNum { - e.e.encWr.writen2(mpInt8, byte(i)) + e.w.writen2(mpInt8, byte(i)) } else { - e.e.encWr.writen1(byte(i)) + e.w.writen1(byte(i)) } } else if i >= math.MinInt8 { - e.e.encWr.writen2(mpInt8, byte(i)) + e.w.writen2(mpInt8, byte(i)) } else if i >= math.MinInt16 { - e.e.encWr.writen1(mpInt16) - bigenHelper{e.x[:2], e.e.w()}.writeUint16(uint16(i)) + e.w.writen1(mpInt16) + bigenHelper{e.x[:2], e.w}.writeUint16(uint16(i)) } else if i >= math.MinInt32 { - e.e.encWr.writen1(mpInt32) - bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(i)) + e.w.writen1(mpInt32) + bigenHelper{e.x[:4], e.w}.writeUint32(uint32(i)) } else { - e.e.encWr.writen1(mpInt64) - bigenHelper{e.x[:8], e.e.w()}.writeUint64(uint64(i)) + e.w.writen1(mpInt64) + bigenHelper{e.x[:8], e.w}.writeUint64(uint64(i)) } } func (e *msgpackEncDriver) EncodeUint(i uint64) { if i <= math.MaxInt8 { if e.h.NoFixedNum { - e.e.encWr.writen2(mpUint8, byte(i)) + e.w.writen2(mpUint8, byte(i)) } else { - e.e.encWr.writen1(byte(i)) + e.w.writen1(byte(i)) } } else if i <= math.MaxUint8 { - e.e.encWr.writen2(mpUint8, byte(i)) + e.w.writen2(mpUint8, byte(i)) } else if i <= math.MaxUint16 { - e.e.encWr.writen1(mpUint16) - bigenHelper{e.x[:2], e.e.w()}.writeUint16(uint16(i)) + e.w.writen1(mpUint16) + bigenHelper{e.x[:2], e.w}.writeUint16(uint16(i)) } else if i <= math.MaxUint32 { - e.e.encWr.writen1(mpUint32) - bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(i)) + e.w.writen1(mpUint32) + bigenHelper{e.x[:4], e.w}.writeUint32(uint32(i)) } else { - e.e.encWr.writen1(mpUint64) - bigenHelper{e.x[:8], e.e.w()}.writeUint64(uint64(i)) + e.w.writen1(mpUint64) + bigenHelper{e.x[:8], e.w}.writeUint64(uint64(i)) } } func (e *msgpackEncDriver) EncodeBool(b bool) { if b { - e.e.encWr.writen1(mpTrue) + e.w.writen1(mpTrue) } else { - e.e.encWr.writen1(mpFalse) + e.w.writen1(mpFalse) } } func (e *msgpackEncDriver) EncodeFloat32(f float32) { - e.e.encWr.writen1(mpFloat) - bigenHelper{e.x[:4], e.e.w()}.writeUint32(math.Float32bits(f)) + e.w.writen1(mpFloat) + bigenHelper{e.x[:4], e.w}.writeUint32(math.Float32bits(f)) } func (e *msgpackEncDriver) EncodeFloat64(f float64) { - e.e.encWr.writen1(mpDouble) - bigenHelper{e.x[:8], e.e.w()}.writeUint64(math.Float64bits(f)) + e.w.writen1(mpDouble) + bigenHelper{e.x[:8], e.w}.writeUint64(math.Float64bits(f)) } func (e *msgpackEncDriver) EncodeTime(t time.Time) { @@ -308,65 +309,56 @@ func (e *msgpackEncDriver) EncodeTime(t time.Time) { } switch l { case 4: - bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(data64)) + bigenHelper{e.x[:4], e.w}.writeUint32(uint32(data64)) case 8: - bigenHelper{e.x[:8], e.e.w()}.writeUint64(data64) + bigenHelper{e.x[:8], e.w}.writeUint64(data64) case 12: - bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(nsec)) - bigenHelper{e.x[:8], e.e.w()}.writeUint64(uint64(sec)) + 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) { - var bs []byte - if ext == SelfExt { - bs = e.e.blist.get(1024)[:0] - e.e.sideEncode(v, &bs) - } else { - bs = ext.WriteExt(v) - } +func (e *msgpackEncDriver) EncodeExt(v interface{}, xtag uint64, ext Ext, _ *Encoder) { + bs := ext.WriteExt(v) if bs == nil { e.EncodeNil() return } if e.h.WriteExt { e.encodeExtPreamble(uint8(xtag), len(bs)) - e.e.encWr.writeb(bs) + e.w.writeb(bs) } else { e.EncodeStringBytesRaw(bs) } - if ext == SelfExt { - e.e.blist.put(bs) - } } -func (e *msgpackEncDriver) EncodeRawExt(re *RawExt) { +func (e *msgpackEncDriver) EncodeRawExt(re *RawExt, _ *Encoder) { e.encodeExtPreamble(uint8(re.Tag), len(re.Data)) - e.e.encWr.writeb(re.Data) + e.w.writeb(re.Data) } func (e *msgpackEncDriver) encodeExtPreamble(xtag byte, l int) { if l == 1 { - e.e.encWr.writen2(mpFixExt1, xtag) + e.w.writen2(mpFixExt1, xtag) } else if l == 2 { - e.e.encWr.writen2(mpFixExt2, xtag) + e.w.writen2(mpFixExt2, xtag) } else if l == 4 { - e.e.encWr.writen2(mpFixExt4, xtag) + e.w.writen2(mpFixExt4, xtag) } else if l == 8 { - e.e.encWr.writen2(mpFixExt8, xtag) + e.w.writen2(mpFixExt8, xtag) } else if l == 16 { - e.e.encWr.writen2(mpFixExt16, xtag) + e.w.writen2(mpFixExt16, xtag) } else if l < 256 { - e.e.encWr.writen2(mpExt8, byte(l)) - e.e.encWr.writen1(xtag) + e.w.writen2(mpExt8, byte(l)) + e.w.writen1(xtag) } else if l < 65536 { - e.e.encWr.writen1(mpExt16) - bigenHelper{e.x[:2], e.e.w()}.writeUint16(uint16(l)) - e.e.encWr.writen1(xtag) + e.w.writen1(mpExt16) + bigenHelper{e.x[:2], e.w}.writeUint16(uint16(l)) + e.w.writen1(xtag) } else { - e.e.encWr.writen1(mpExt32) - bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(l)) - e.e.encWr.writen1(xtag) + e.w.writen1(mpExt32) + bigenHelper{e.x[:4], e.w}.writeUint32(uint32(l)) + e.w.writen1(xtag) } } @@ -378,20 +370,39 @@ func (e *msgpackEncDriver) WriteMapStart(length int) { e.writeContainerLen(msgpackContainerMap, length) } -func (e *msgpackEncDriver) EncodeString(s string) { - var ct msgpackContainerType - if e.h.WriteExt { - if e.h.StringToRaw { - ct = msgpackContainerBin - } else { - ct = msgpackContainerStr - } +func (e *msgpackEncDriver) EncodeString(c charEncoding, s string) { + slen := len(s) + if c == cRAW && e.h.WriteExt { + e.writeContainerLen(msgpackContainerBin, slen) + } else { + e.writeContainerLen(msgpackContainerRawLegacy, slen) + } + if slen > 0 { + e.w.writestr(s) + } +} + +func (e *msgpackEncDriver) EncodeStringEnc(c charEncoding, s string) { + slen := len(s) + e.writeContainerLen(msgpackContainerStr, slen) + if slen > 0 { + e.w.writestr(s) + } +} + +func (e *msgpackEncDriver) EncodeStringBytes(c charEncoding, bs []byte) { + if bs == nil { + e.EncodeNil() + return + } + slen := len(bs) + if c == cRAW && e.h.WriteExt { + e.writeContainerLen(msgpackContainerBin, slen) } else { - ct = msgpackContainerRawLegacy + e.writeContainerLen(msgpackContainerRawLegacy, slen) } - e.writeContainerLen(ct, len(s)) - if len(s) > 0 { - e.e.encWr.writestr(s) + if slen > 0 { + e.w.writeb(bs) } } @@ -400,46 +411,46 @@ func (e *msgpackEncDriver) EncodeStringBytesRaw(bs []byte) { e.EncodeNil() return } + slen := len(bs) if e.h.WriteExt { - e.writeContainerLen(msgpackContainerBin, len(bs)) + e.writeContainerLen(msgpackContainerBin, slen) } else { - e.writeContainerLen(msgpackContainerRawLegacy, len(bs)) + e.writeContainerLen(msgpackContainerRawLegacy, slen) } - if len(bs) > 0 { - e.e.encWr.writeb(bs) + if slen > 0 { + e.w.writeb(bs) } } func (e *msgpackEncDriver) writeContainerLen(ct msgpackContainerType, l int) { if ct.fixCutoff > 0 && l < int(ct.fixCutoff) { - e.e.encWr.writen1(ct.bFixMin | byte(l)) + e.w.writen1(ct.bFixMin | byte(l)) } else if ct.b8 > 0 && l < 256 { - e.e.encWr.writen2(ct.b8, uint8(l)) + e.w.writen2(ct.b8, uint8(l)) } else if l < 65536 { - e.e.encWr.writen1(ct.b16) - bigenHelper{e.x[:2], e.e.w()}.writeUint16(uint16(l)) + e.w.writen1(ct.b16) + bigenHelper{e.x[:2], e.w}.writeUint16(uint16(l)) } else { - e.e.encWr.writen1(ct.b32) - bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(l)) + e.w.writen1(ct.b32) + bigenHelper{e.x[:4], e.w}.writeUint32(uint32(l)) } } //--------------------------------------------- type msgpackDecDriver struct { - decDriverNoopContainerReader + d *Decoder + r *decReaderSwitch h *MsgpackHandle // b [scratchByteArrayLen]byte bd byte bdRead bool - fnil bool + br bool // bytes reader noBuiltInTypes - _ [6]uint64 // padding - d Decoder -} - -func (d *msgpackDecDriver) decoder() *Decoder { - return &d.d + // noStreamingCodec + // decNoSeparator + decDriverNoopContainerReader + // _ [3]uint64 // padding } // Note: This returns either a primitive (int, bool, etc) for non-containers, @@ -451,7 +462,6 @@ func (d *msgpackDecDriver) DecodeNaked() { if !d.bdRead { d.readNextBd() } - d.fnil = false bd := d.bd n := d.d.naked() var decodeFurther bool @@ -460,7 +470,6 @@ func (d *msgpackDecDriver) DecodeNaked() { case mpNil: n.v = valueTypeNil d.bdRead = false - d.fnil = true case mpFalse: n.v = valueTypeBool n.b = false @@ -470,36 +479,36 @@ func (d *msgpackDecDriver) DecodeNaked() { case mpFloat: n.v = valueTypeFloat - n.f = float64(math.Float32frombits(bigen.Uint32(d.d.decRd.readx(4)))) + n.f = float64(math.Float32frombits(bigen.Uint32(d.r.readx(4)))) case mpDouble: n.v = valueTypeFloat - n.f = math.Float64frombits(bigen.Uint64(d.d.decRd.readx(8))) + n.f = math.Float64frombits(bigen.Uint64(d.r.readx(8))) case mpUint8: n.v = valueTypeUint - n.u = uint64(d.d.decRd.readn1()) + n.u = uint64(d.r.readn1()) case mpUint16: n.v = valueTypeUint - n.u = uint64(bigen.Uint16(d.d.decRd.readx(2))) + n.u = uint64(bigen.Uint16(d.r.readx(2))) case mpUint32: n.v = valueTypeUint - n.u = uint64(bigen.Uint32(d.d.decRd.readx(4))) + n.u = uint64(bigen.Uint32(d.r.readx(4))) case mpUint64: n.v = valueTypeUint - n.u = uint64(bigen.Uint64(d.d.decRd.readx(8))) + n.u = uint64(bigen.Uint64(d.r.readx(8))) case mpInt8: n.v = valueTypeInt - n.i = int64(int8(d.d.decRd.readn1())) + n.i = int64(int8(d.r.readn1())) case mpInt16: n.v = valueTypeInt - n.i = int64(int16(bigen.Uint16(d.d.decRd.readx(2)))) + n.i = int64(int16(bigen.Uint16(d.r.readx(2)))) case mpInt32: n.v = valueTypeInt - n.i = int64(int32(bigen.Uint32(d.d.decRd.readx(4)))) + n.i = int64(int32(bigen.Uint32(d.r.readx(4)))) case mpInt64: n.v = valueTypeInt - n.i = int64(int64(bigen.Uint64(d.d.decRd.readx(8)))) + n.i = int64(int64(bigen.Uint64(d.r.readx(8)))) default: switch { @@ -512,15 +521,15 @@ func (d *msgpackDecDriver) DecodeNaked() { n.v = valueTypeInt n.i = int64(int8(bd)) case bd == mpStr8, bd == mpStr16, bd == mpStr32, bd >= mpFixStrMin && bd <= mpFixStrMax: - if d.h.WriteExt || d.h.RawToString { + if d.h.WriteExt { n.v = valueTypeString - n.s = string(d.DecodeStringAsBytes()) + n.s = d.DecodeString() } else { n.v = valueTypeBytes n.l = d.DecodeBytes(nil, false) } case bd == mpBin8, bd == mpBin16, bd == mpBin32: - decNakedReadRawBytes(d, &d.d, n, d.h.RawToString) + decNakedReadRawBytes(d, d.d, n, d.h.RawToString) case bd == mpArray16, bd == mpArray32, bd >= mpFixArrayMin && bd <= mpFixArrayMax: n.v = valueTypeArray decodeFurther = true @@ -530,14 +539,14 @@ func (d *msgpackDecDriver) DecodeNaked() { case bd >= mpFixExt1 && bd <= mpFixExt16, bd >= mpExt8 && bd <= mpExt32: n.v = valueTypeExt clen := d.readExtLen() - n.u = uint64(d.d.decRd.readn1()) + n.u = uint64(d.r.readn1()) if n.u == uint64(mpTimeExtTagU) { n.v = valueTypeTime n.t = d.decodeTime(clen) - } else if d.d.bytes { - n.l = d.d.decRd.readx(uint(clen)) + } else if d.br { + n.l = d.r.readx(uint(clen)) } else { - n.l = decByteSlice(d.d.r(), clen, d.d.h.MaxInitLen, d.d.b[:]) + n.l = decByteSlice(d.r, clen, d.d.h.MaxInitLen, d.d.b[:]) } default: d.d.errorf("cannot infer value: %s: Ox%x/%d/%s", msgBadDesc, bd, bd, mpdesc(bd)) @@ -554,26 +563,26 @@ func (d *msgpackDecDriver) DecodeNaked() { // int can be decoded from msgpack type: intXXX or uintXXX func (d *msgpackDecDriver) DecodeInt64() (i int64) { - if d.advanceNil() { - return + if !d.bdRead { + d.readNextBd() } switch d.bd { case mpUint8: - i = int64(uint64(d.d.decRd.readn1())) + i = int64(uint64(d.r.readn1())) case mpUint16: - i = int64(uint64(bigen.Uint16(d.d.decRd.readx(2)))) + i = int64(uint64(bigen.Uint16(d.r.readx(2)))) case mpUint32: - i = int64(uint64(bigen.Uint32(d.d.decRd.readx(4)))) + i = int64(uint64(bigen.Uint32(d.r.readx(4)))) case mpUint64: - i = int64(bigen.Uint64(d.d.decRd.readx(8))) + i = int64(bigen.Uint64(d.r.readx(8))) case mpInt8: - i = int64(int8(d.d.decRd.readn1())) + i = int64(int8(d.r.readn1())) case mpInt16: - i = int64(int16(bigen.Uint16(d.d.decRd.readx(2)))) + i = int64(int16(bigen.Uint16(d.r.readx(2)))) case mpInt32: - i = int64(int32(bigen.Uint32(d.d.decRd.readx(4)))) + i = int64(int32(bigen.Uint32(d.r.readx(4)))) case mpInt64: - i = int64(bigen.Uint64(d.d.decRd.readx(8))) + i = int64(bigen.Uint64(d.r.readx(8))) default: switch { case d.bd >= mpPosFixNumMin && d.bd <= mpPosFixNumMax: @@ -591,41 +600,41 @@ func (d *msgpackDecDriver) DecodeInt64() (i int64) { // uint can be decoded from msgpack type: intXXX or uintXXX func (d *msgpackDecDriver) DecodeUint64() (ui uint64) { - if d.advanceNil() { - return + if !d.bdRead { + d.readNextBd() } switch d.bd { case mpUint8: - ui = uint64(d.d.decRd.readn1()) + ui = uint64(d.r.readn1()) case mpUint16: - ui = uint64(bigen.Uint16(d.d.decRd.readx(2))) + ui = uint64(bigen.Uint16(d.r.readx(2))) case mpUint32: - ui = uint64(bigen.Uint32(d.d.decRd.readx(4))) + ui = uint64(bigen.Uint32(d.r.readx(4))) case mpUint64: - ui = bigen.Uint64(d.d.decRd.readx(8)) + ui = bigen.Uint64(d.r.readx(8)) case mpInt8: - if i := int64(int8(d.d.decRd.readn1())); i >= 0 { + if i := int64(int8(d.r.readn1())); i >= 0 { ui = uint64(i) } else { d.d.errorf("assigning negative signed value: %v, to unsigned type", i) return } case mpInt16: - if i := int64(int16(bigen.Uint16(d.d.decRd.readx(2)))); i >= 0 { + if i := int64(int16(bigen.Uint16(d.r.readx(2)))); i >= 0 { ui = uint64(i) } else { d.d.errorf("assigning negative signed value: %v, to unsigned type", i) return } case mpInt32: - if i := int64(int32(bigen.Uint32(d.d.decRd.readx(4)))); i >= 0 { + if i := int64(int32(bigen.Uint32(d.r.readx(4)))); i >= 0 { ui = uint64(i) } else { d.d.errorf("assigning negative signed value: %v, to unsigned type", i) return } case mpInt64: - if i := int64(bigen.Uint64(d.d.decRd.readx(8))); i >= 0 { + if i := int64(bigen.Uint64(d.r.readx(8))); i >= 0 { ui = uint64(i) } else { d.d.errorf("assigning negative signed value: %v, to unsigned type", i) @@ -649,13 +658,13 @@ func (d *msgpackDecDriver) DecodeUint64() (ui uint64) { // float can either be decoded from msgpack type: float, double or intX func (d *msgpackDecDriver) DecodeFloat64() (f float64) { - if d.advanceNil() { - return + if !d.bdRead { + d.readNextBd() } if d.bd == mpFloat { - f = float64(math.Float32frombits(bigen.Uint32(d.d.decRd.readx(4)))) + f = float64(math.Float32frombits(bigen.Uint32(d.r.readx(4)))) } else if d.bd == mpDouble { - f = math.Float64frombits(bigen.Uint64(d.d.decRd.readx(8))) + f = math.Float64frombits(bigen.Uint64(d.r.readx(8))) } else { f = float64(d.DecodeInt64()) } @@ -665,8 +674,8 @@ func (d *msgpackDecDriver) DecodeFloat64() (f float64) { // bool can be decoded from bool, fixnum 0 or 1. func (d *msgpackDecDriver) DecodeBool() (b bool) { - if d.advanceNil() { - return + if !d.bdRead { + d.readNextBd() } if d.bd == mpFalse || d.bd == 0 { // b = false @@ -681,30 +690,26 @@ func (d *msgpackDecDriver) DecodeBool() (b bool) { } func (d *msgpackDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { - if d.advanceNil() { - return + if !d.bdRead { + d.readNextBd() } bd := d.bd var clen int - if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 { + if bd == mpNil { + d.bdRead = false + return + } else if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 { clen = d.readContainerLen(msgpackContainerBin) // binary - } else if bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || - (bd >= mpFixStrMin && bd <= mpFixStrMax) { + } else if bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || (bd >= mpFixStrMin && bd <= mpFixStrMax) { clen = d.readContainerLen(msgpackContainerStr) // string/raw - } else if bd == mpArray16 || bd == mpArray32 || - (bd >= mpFixArrayMin && bd <= mpFixArrayMax) { + } else if bd == mpArray16 || bd == mpArray32 || (bd >= mpFixArrayMin && bd <= mpFixArrayMax) { // check if an "array" of uint8's if zerocopy && len(bs) == 0 { bs = d.d.b[:] } - // bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d) - slen := d.ReadArrayStart() - bs = usableByteSlice(bs, slen) - for i := 0; i < len(bs); i++ { - bs[i] = uint8(chkOvf.UintV(d.DecodeUint64(), 8)) - } - return bs + bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d) + return } else { d.d.errorf("invalid byte descriptor for decoding bytes, got: 0x%x", d.bd) return @@ -712,13 +717,17 @@ func (d *msgpackDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) d.bdRead = false if zerocopy { - if d.d.bytes { - return d.d.decRd.readx(uint(clen)) + if d.br { + return d.r.readx(uint(clen)) } else if len(bs) == 0 { bs = d.d.b[:] } } - return decByteSlice(d.d.r(), clen, d.h.MaxInitLen, bs) + return decByteSlice(d.r, clen, d.h.MaxInitLen, bs) +} + +func (d *msgpackDecDriver) DecodeString() (s string) { + return string(d.DecodeBytes(d.d.b[:], true)) } func (d *msgpackDecDriver) DecodeStringAsBytes() (s []byte) { @@ -726,32 +735,15 @@ func (d *msgpackDecDriver) DecodeStringAsBytes() (s []byte) { } func (d *msgpackDecDriver) readNextBd() { - d.bd = d.d.decRd.readn1() + d.bd = d.r.readn1() d.bdRead = true } func (d *msgpackDecDriver) uncacheRead() { if d.bdRead { - d.d.decRd.unreadn1() - d.bdRead = false - } -} - -func (d *msgpackDecDriver) advanceNil() (null bool) { - d.fnil = false - if !d.bdRead { - d.readNextBd() - } - if d.bd == mpNil { + d.r.unreadn1() d.bdRead = false - d.fnil = true - null = true } - return -} - -func (d *msgpackDecDriver) Nil() bool { - return d.fnil } func (d *msgpackDecDriver) ContainerType() (vt valueType) { @@ -759,16 +751,23 @@ func (d *msgpackDecDriver) ContainerType() (vt valueType) { d.readNextBd() } bd := d.bd - d.fnil = false + // if bd == mpNil { + // // nil + // } else if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 { + // // binary + // } else if bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || (bd >= mpFixStrMin && bd <= mpFixStrMax) { + // // string/raw + // } else if bd == mpArray16 || bd == mpArray32 || (bd >= mpFixArrayMin && bd <= mpFixArrayMax) { + // // array + // } else if bd == mpMap16 || bd == mpMap32 || (bd >= mpFixMapMin && bd <= mpFixMapMax) { + // // map + // } if bd == mpNil { - d.bdRead = false - d.fnil = true return valueTypeNil } else if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 { return valueTypeBytes - } else if bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || - (bd >= mpFixStrMin && bd <= mpFixStrMax) { - if d.h.WriteExt || d.h.RawToString { // UTF-8 string (new spec) + } else if bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || (bd >= mpFixStrMin && bd <= mpFixStrMax) { + if d.h.WriteExt { // UTF-8 string (new spec) return valueTypeString } return valueTypeBytes // raw (old spec) @@ -777,21 +776,33 @@ func (d *msgpackDecDriver) ContainerType() (vt valueType) { } else if bd == mpMap16 || bd == mpMap32 || (bd >= mpFixMapMin && bd <= mpFixMapMax) { return valueTypeMap } + // else { + // d.d.errorf("isContainerType: unsupported parameter: %v", vt) + // } return valueTypeUnset } -func (d *msgpackDecDriver) TryNil() (v bool) { - return d.advanceNil() +func (d *msgpackDecDriver) TryDecodeAsNil() (v bool) { + if !d.bdRead { + d.readNextBd() + } + if d.bd == mpNil { + d.bdRead = false + return true + } + return } func (d *msgpackDecDriver) readContainerLen(ct msgpackContainerType) (clen int) { bd := d.bd - if bd == ct.b8 { - clen = int(d.d.decRd.readn1()) + if bd == mpNil { + clen = -1 // to represent nil + } else if bd == ct.b8 { + clen = int(d.r.readn1()) } else if bd == ct.b16 { - clen = int(bigen.Uint16(d.d.decRd.readx(2))) + clen = int(bigen.Uint16(d.r.readx(2))) } else if bd == ct.b32 { - clen = int(bigen.Uint32(d.d.decRd.readx(4))) + clen = int(bigen.Uint32(d.r.readx(4))) } else if (ct.bFixMin & bd) == ct.bFixMin { clen = int(ct.bFixMin ^ bd) } else { @@ -803,21 +814,23 @@ func (d *msgpackDecDriver) readContainerLen(ct msgpackContainerType) (clen int) } func (d *msgpackDecDriver) ReadMapStart() int { - if d.advanceNil() { - return decContainerLenNil + if !d.bdRead { + d.readNextBd() } return d.readContainerLen(msgpackContainerMap) } func (d *msgpackDecDriver) ReadArrayStart() int { - if d.advanceNil() { - return decContainerLenNil + if !d.bdRead { + d.readNextBd() } return d.readContainerLen(msgpackContainerList) } func (d *msgpackDecDriver) readExtLen() (clen int) { switch d.bd { + case mpNil: + clen = -1 // to represent nil case mpFixExt1: clen = 1 case mpFixExt2: @@ -829,11 +842,11 @@ func (d *msgpackDecDriver) readExtLen() (clen int) { case mpFixExt16: clen = 16 case mpExt8: - clen = int(d.d.decRd.readn1()) + clen = int(d.r.readn1()) case mpExt16: - clen = int(bigen.Uint16(d.d.decRd.readx(2))) + clen = int(bigen.Uint16(d.r.readx(2))) case mpExt32: - clen = int(bigen.Uint32(d.d.decRd.readx(4))) + clen = int(bigen.Uint32(d.r.readx(4))) default: d.d.errorf("decoding ext bytes: found unexpected byte: %x", d.bd) return @@ -843,25 +856,27 @@ func (d *msgpackDecDriver) readExtLen() (clen int) { func (d *msgpackDecDriver) DecodeTime() (t time.Time) { // decode time from string bytes or ext - if d.advanceNil() { - return + if !d.bdRead { + d.readNextBd() } bd := d.bd var clen int - if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 { + if bd == mpNil { + d.bdRead = false + return + } else if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 { clen = d.readContainerLen(msgpackContainerBin) // binary - } else if bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || - (bd >= mpFixStrMin && bd <= mpFixStrMax) { + } else if bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || (bd >= mpFixStrMin && bd <= mpFixStrMax) { clen = d.readContainerLen(msgpackContainerStr) // string/raw } else { // expect to see mpFixExt4,-1 OR mpFixExt8,-1 OR mpExt8,12,-1 d.bdRead = false - b2 := d.d.decRd.readn1() + 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.d.decRd.readn1() == mpTimeExtTagU { + } else if d.bd == mpExt8 && b2 == 12 && d.r.readn1() == mpTimeExtTagU { clen = 12 } else { d.d.errorf("invalid stream for decoding time as extension: got 0x%x, 0x%x", d.bd, b2) @@ -872,17 +887,17 @@ func (d *msgpackDecDriver) DecodeTime() (t time.Time) { } func (d *msgpackDecDriver) decodeTime(clen int) (t time.Time) { - // bs = d.d.decRd.readx(clen) + // bs = d.r.readx(clen) d.bdRead = false switch clen { case 4: - t = time.Unix(int64(bigen.Uint32(d.d.decRd.readx(4))), 0).UTC() + t = time.Unix(int64(bigen.Uint32(d.r.readx(4))), 0).UTC() case 8: - tv := bigen.Uint64(d.d.decRd.readx(8)) + tv := bigen.Uint64(d.r.readx(8)) t = time.Unix(int64(tv&0x00000003ffffffff), int64(tv>>34)).UTC() case 12: - nsec := bigen.Uint32(d.d.decRd.readx(4)) - sec := bigen.Uint64(d.d.decRd.readx(8)) + 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) @@ -891,28 +906,27 @@ func (d *msgpackDecDriver) decodeTime(clen int) (t time.Time) { return } -func (d *msgpackDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) { +func (d *msgpackDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxtag uint64) { if xtag > 0xff { d.d.errorf("ext: tag must be <= 0xff; got: %v", xtag) return } - if d.advanceNil() { - return - } realxtag1, xbs := d.decodeExtV(ext != nil, uint8(xtag)) - realxtag := uint64(realxtag1) + realxtag = uint64(realxtag1) if ext == nil { re := rv.(*RawExt) re.Tag = realxtag - re.Data = detachZeroCopyBytes(d.d.bytes, re.Data, xbs) - } else if ext == SelfExt { - d.d.sideDecode(rv, xbs) + re.Data = detachZeroCopyBytes(d.br, re.Data, xbs) } else { ext.ReadExt(rv, xbs) } + return } func (d *msgpackDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs []byte) { + if !d.bdRead { + d.readNextBd() + } xbd := d.bd if xbd == mpBin8 || xbd == mpBin16 || xbd == mpBin32 { xbs = d.DecodeBytes(nil, true) @@ -921,15 +935,15 @@ func (d *msgpackDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs xbs = d.DecodeStringAsBytes() } else { clen := d.readExtLen() - xtag = d.d.decRd.readn1() + xtag = d.r.readn1() if verifyTag && xtag != tag { d.d.errorf("wrong extension tag - got %b, expecting %v", xtag, tag) return } - if d.d.bytes { - xbs = d.d.decRd.readx(uint(clen)) + if d.br { + xbs = d.r.readx(uint(clen)) } else { - xbs = decByteSlice(d.d.r(), clen, d.d.h.MaxInitLen, d.d.b[:]) + xbs = decByteSlice(d.r, clen, d.d.h.MaxInitLen, d.d.b[:]) } } d.bdRead = false @@ -940,7 +954,6 @@ func (d *msgpackDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs //MsgpackHandle is a Handle for the Msgpack Schema-Free Encoding Format. type MsgpackHandle struct { - binaryEncodingType BasicHandle // NoFixedNum says to output all signed integers as 2-bytes, never as 1-byte fixednum. @@ -963,34 +976,35 @@ type MsgpackHandle struct { // PositiveIntUnsigned says to encode positive integers as unsigned. PositiveIntUnsigned bool - _ [7]uint64 // padding (cache-aligned) + binaryEncodingType + noElemSeparators + + // _ [1]uint64 // padding } // Name returns the name of the handle: msgpack func (h *MsgpackHandle) Name() string { return "msgpack" } -func (h *MsgpackHandle) newEncDriver() encDriver { - var e = &msgpackEncDriver{h: h} - e.e.e = e - e.e.init(h) - e.reset() - return e +// SetBytesExt sets an extension +func (h *MsgpackHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) { + return h.SetExt(rt, tag, &extWrapper{ext, interfaceExtFailer{}}) } -func (h *MsgpackHandle) newDecDriver() decDriver { - d := &msgpackDecDriver{h: h} - d.d.d = d - d.d.init(h) - d.reset() - return d +func (h *MsgpackHandle) newEncDriver(e *Encoder) encDriver { + return &msgpackEncDriver{e: e, w: e.w, h: h} +} + +func (h *MsgpackHandle) newDecDriver(d *Decoder) decDriver { + return &msgpackDecDriver{d: d, h: h, r: d.r, br: d.bytes} } func (e *msgpackEncDriver) reset() { + e.w = e.e.w } func (d *msgpackDecDriver) reset() { + d.r, d.br = d.d.r, d.d.bytes d.bd, d.bdRead = 0, false - d.fnil = false } //-------------------------------------------------- @@ -1051,7 +1065,11 @@ func (c *msgpackSpecRpcCodec) parseCustomHeader(expectTypeByte byte, msgid *uint // so that the body can be decoded on its own from the stream at a later time. const fia byte = 0x94 //four item array descriptor value - + // Not sure why the panic of EOF is swallowed above. + // if bs1 := c.dec.r.readn1(); bs1 != fia { + // err = fmt.Errorf("Unexpected value for array descriptor: Expecting %v. Received %v", fia, bs1) + // return + // } var ba [1]byte var n int for { diff --git a/vendor/github.com/ugorji/go/codec/prebuild.go b/vendor/github.com/ugorji/go/codec/prebuild.go deleted file mode 100644 index 7771057efe1b..000000000000 --- a/vendor/github.com/ugorji/go/codec/prebuild.go +++ /dev/null @@ -1,136 +0,0 @@ -// +build prebuild - -package main - -// prebuild.go generates sort implementations for -// various slice types and combination slice+reflect.Value types. -// -// The combination slice+reflect.Value types are used -// during canonical encode, and the others are used during fast-path -// encoding of map keys. - -import ( - "bytes" - "go/format" - "io/ioutil" - "os" - "strings" - "text/template" -) - -// genInternalSortableTypes returns the types -// that are used for fast-path canonical's encoding of maps. -// -// For now, we only support the highest sizes for -// int64, uint64, float64, bool, string, bytes. -func genInternalSortableTypes() []string { - return []string{ - "string", - // "float32", - "float64", - // "uint", - // "uint8", - // "uint16", - // "uint32", - "uint64", - "uintptr", - // "int", - // "int8", - // "int16", - // "int32", - "int64", - "bool", - "time", - "bytes", - } -} - -// genInternalSortablePlusTypes returns the types -// that are used for reflection-based canonical's encoding of maps. -// -// For now, we only support the highest sizes for -// int64, uint64, float64, bool, string, bytes. -func genInternalSortablePlusTypes() []string { - return []string{ - "string", - "float64", - "uint64", - "uintptr", - "int64", - "bool", - "time", - "bytes", - } -} - -func genTypeForShortName(s string) string { - switch s { - case "time": - return "time.Time" - case "bytes": - return "[]byte" - } - return s -} - -func genArgs(args ...interface{}) map[string]interface{} { - m := make(map[string]interface{}, len(args)/2) - for i := 0; i < len(args); { - m[args[i].(string)] = args[i+1] - i += 2 - } - return m -} - -func genEndsWith(s0 string, sn ...string) bool { - for _, s := range sn { - if strings.HasSuffix(s0, s) { - return true - } - } - return false -} - -func chkerr(err error) { - if err != nil { - panic(err) - } -} - -func run(fnameIn, fnameOut string) { - var err error - - funcs := make(template.FuncMap) - funcs["sortables"] = genInternalSortableTypes - funcs["sortablesplus"] = genInternalSortablePlusTypes - funcs["tshort"] = genTypeForShortName - funcs["endswith"] = genEndsWith - funcs["args"] = genArgs - - t := template.New("").Funcs(funcs) - fin, err := os.Open(fnameIn) - chkerr(err) - defer fin.Close() - fout, err := os.Create(fnameOut) - chkerr(err) - defer fout.Close() - tmplstr, err := ioutil.ReadAll(fin) - chkerr(err) - t, err = t.Parse(string(tmplstr)) - chkerr(err) - var out bytes.Buffer - err = t.Execute(&out, 0) - chkerr(err) - bout, err := format.Source(out.Bytes()) - if err != nil { - fout.Write(out.Bytes()) // write out if error, so we can still see. - } - chkerr(err) - // write out if error, as much as possible, so we can still see. - _, err = fout.Write(bout) - chkerr(err) -} - -func main() { - run("sort-slice.go.tmpl", "sort-slice.generated.go") -} diff --git a/vendor/github.com/ugorji/go/codec/reader.go b/vendor/github.com/ugorji/go/codec/reader.go deleted file mode 100644 index 1c3fe88e4b1a..000000000000 --- a/vendor/github.com/ugorji/go/codec/reader.go +++ /dev/null @@ -1,1017 +0,0 @@ -// 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 - -import "io" - -// decReader abstracts the reading source, allowing implementations that can -// read from an io.Reader or directly off a byte slice with zero-copying. -type decReader interface { - unreadn1() - // readx will use the implementation scratch buffer if possible i.e. n < len(scratchbuf), OR - // just return a view of the []byte being decoded from. - // Ensure you call detachZeroCopyBytes later if this needs to be sent outside codec control. - readx(n uint) []byte - readb([]byte) - readn1() uint8 - // read up to 7 bytes at a time - readn(num uint8) (v [rwNLen]byte) - numread() uint // number of bytes read - track() - stopTrack() []byte - - // skip will skip any byte that matches, and return the first non-matching byte - skip(accept *bitset256) (token byte) - // readTo will read any byte that matches, stopping once no-longer matching. - readTo(accept *bitset256) (out []byte) - // readUntil will read, only stopping once it matches the 'stop' byte. - readUntil(stop byte, includeLast bool) (out []byte) -} - -// ------------------------------------------------ - -type unreadByteStatus uint8 - -// unreadByteStatus goes from -// undefined (when initialized) -- (read) --> canUnread -- (unread) --> canRead ... -const ( - unreadByteUndefined unreadByteStatus = iota - unreadByteCanRead - unreadByteCanUnread -) - -// -------------------- - -type ioDecReaderCommon struct { - r io.Reader // the reader passed in - - n uint // num read - - l byte // last byte - ls unreadByteStatus // last byte status - trb bool // tracking bytes turned on - _ bool - b [4]byte // tiny buffer for reading single bytes - - blist *bytesFreelist - - tr []byte // buffer for tracking bytes - bufr []byte // buffer for readTo/readUntil -} - -func (z *ioDecReaderCommon) last() byte { - return z.l -} - -func (z *ioDecReaderCommon) reset(r io.Reader, blist *bytesFreelist) { - z.blist = blist - z.r = r - z.ls = unreadByteUndefined - z.l, z.n = 0, 0 - z.trb = false -} - -func (z *ioDecReaderCommon) numread() uint { - return z.n -} - -func (z *ioDecReaderCommon) track() { - z.tr = z.blist.check(z.tr, 256)[:0] - z.trb = true -} - -func (z *ioDecReaderCommon) stopTrack() (bs []byte) { - z.trb = false - return z.tr -} - -// ------------------------------------------ - -// ioDecReader is a decReader that reads off an io.Reader. -// -// It also has a fallback implementation of ByteScanner if needed. -type ioDecReader struct { - ioDecReaderCommon - - // rr io.Reader - br io.ByteScanner - - x [64 + 16]byte // for: get struct field name, swallow valueTypeBytes, etc - // _ [1]uint64 // padding -} - -func (z *ioDecReader) reset(r io.Reader, blist *bytesFreelist) { - z.ioDecReaderCommon.reset(r, blist) - - z.br, _ = r.(io.ByteScanner) -} - -func (z *ioDecReader) Read(p []byte) (n int, err error) { - if len(p) == 0 { - return - } - var firstByte bool - if z.ls == unreadByteCanRead { - z.ls = unreadByteCanUnread - p[0] = z.l - if len(p) == 1 { - n = 1 - return - } - firstByte = true - p = p[1:] - } - n, err = z.r.Read(p) - if n > 0 { - if err == io.EOF && n == len(p) { - err = nil // read was successful, so postpone EOF (till next time) - } - z.l = p[n-1] - z.ls = unreadByteCanUnread - } - if firstByte { - n++ - } - return -} - -func (z *ioDecReader) ReadByte() (c byte, err error) { - if z.br != nil { - c, err = z.br.ReadByte() - if err == nil { - z.l = c - z.ls = unreadByteCanUnread - } - return - } - - n, err := z.Read(z.b[:1]) - if n == 1 { - c = z.b[0] - if err == io.EOF { - err = nil // read was successful, so postpone EOF (till next time) - } - } - return -} - -func (z *ioDecReader) UnreadByte() (err error) { - if z.br != nil { - err = z.br.UnreadByte() - if err == nil { - z.ls = unreadByteCanRead - } - return - } - - switch z.ls { - case unreadByteCanUnread: - z.ls = unreadByteCanRead - case unreadByteCanRead: - err = errDecUnreadByteLastByteNotRead - case unreadByteUndefined: - err = errDecUnreadByteNothingToRead - default: - err = errDecUnreadByteUnknown - } - return -} - -func (z *ioDecReader) readn(num uint8) (bs [rwNLen]byte) { - z.readb(bs[:num]) - // copy(bs[:], z.readx(uint(num))) - return -} - -func (z *ioDecReader) readx(n uint) (bs []byte) { - if n == 0 { - return - } - if n < uint(len(z.x)) { - bs = z.x[:n] - } else { - bs = make([]byte, n) - } - if _, err := decReadFull(z.r, bs); err != nil { - panic(err) - } - z.n += uint(len(bs)) - if z.trb { - z.tr = append(z.tr, bs...) - } - return -} - -func (z *ioDecReader) readb(bs []byte) { - if len(bs) == 0 { - return - } - if _, err := decReadFull(z.r, bs); err != nil { - panic(err) - } - z.n += uint(len(bs)) - if z.trb { - z.tr = append(z.tr, bs...) - } -} - -func (z *ioDecReader) readn1eof() (b uint8, eof bool) { - b, err := z.ReadByte() - if err == nil { - z.n++ - if z.trb { - z.tr = append(z.tr, b) - } - } else if err == io.EOF { - eof = true - } else { - panic(err) - } - return -} - -func (z *ioDecReader) readn1() (b uint8) { - b, err := z.ReadByte() - if err == nil { - z.n++ - if z.trb { - z.tr = append(z.tr, b) - } - return - } - panic(err) -} - -func (z *ioDecReader) skip(accept *bitset256) (token byte) { - var eof bool -LOOP: - token, eof = z.readn1eof() - if eof { - return - } - if accept.isset(token) { - goto LOOP - } - return -} - -func (z *ioDecReader) readTo(accept *bitset256) []byte { - z.bufr = z.blist.check(z.bufr, 256)[:0] -LOOP: - token, eof := z.readn1eof() - if eof { - return z.bufr - } - if accept.isset(token) { - z.bufr = append(z.bufr, token) - goto LOOP - } - z.unreadn1() - return z.bufr -} - -func (z *ioDecReader) readUntil(stop byte, includeLast bool) []byte { - z.bufr = z.blist.check(z.bufr, 256)[:0] -LOOP: - token, eof := z.readn1eof() - if eof { - panic(io.EOF) - } - z.bufr = append(z.bufr, token) - if token == stop { - if includeLast { - return z.bufr - } - return z.bufr[:len(z.bufr)-1] - } - goto LOOP -} - -//go:noinline -func (z *ioDecReader) unreadn1() { - err := z.UnreadByte() - if err != nil { - panic(err) - } - z.n-- - if z.trb { - if l := len(z.tr) - 1; l >= 0 { - z.tr = z.tr[:l] - } - } -} - -// ------------------------------------ - -type bufioDecReader struct { - ioDecReaderCommon - - c uint // cursor - buf []byte -} - -func (z *bufioDecReader) reset(r io.Reader, bufsize int, blist *bytesFreelist) { - z.ioDecReaderCommon.reset(r, blist) - z.c = 0 - if cap(z.buf) < bufsize { - z.buf = blist.get(bufsize) - } - z.buf = z.buf[:0] -} - -func (z *bufioDecReader) readb(p []byte) { - var n = uint(copy(p, z.buf[z.c:])) - z.n += n - z.c += n - if len(p) == int(n) { - if z.trb { - z.tr = append(z.tr, p...) - } - } else { - z.readbFill(p, n) - } -} - -func (z *bufioDecReader) readbFill(p0 []byte, n uint) { - // at this point, there's nothing in z.buf to read (z.buf is fully consumed) - p := p0[n:] - var n2 uint - var err error - if len(p) > cap(z.buf) { - n2, err = decReadFull(z.r, p) - if err != nil { - panic(err) - } - n += n2 - z.n += n2 - // always keep last byte in z.buf - z.buf = z.buf[:1] - z.buf[0] = p[len(p)-1] - z.c = 1 - if z.trb { - z.tr = append(z.tr, p0[:n]...) - } - return - } - // z.c is now 0, and len(p) <= cap(z.buf) -LOOP: - // for len(p) > 0 && z.err == nil { - if len(p) > 0 { - z.buf = z.buf[0:cap(z.buf)] - var n1 int - n1, err = z.r.Read(z.buf) - n2 = uint(n1) - if n2 == 0 && err != nil { - panic(err) - } - z.buf = z.buf[:n2] - n2 = uint(copy(p, z.buf)) - z.c = n2 - n += n2 - z.n += n2 - p = p[n2:] - goto LOOP - } - if z.c == 0 { - z.buf = z.buf[:1] - z.buf[0] = p[len(p)-1] - z.c = 1 - } - if z.trb { - z.tr = append(z.tr, p0[:n]...) - } -} - -func (z *bufioDecReader) last() byte { - return z.buf[z.c-1] -} - -func (z *bufioDecReader) readn1() (b byte) { - // fast-path, so we elide calling into Read() most of the time - if z.c < uint(len(z.buf)) { - b = z.buf[z.c] - z.c++ - z.n++ - if z.trb { - z.tr = append(z.tr, b) - } - } else { // meaning z.c == len(z.buf) or greater ... so need to fill - z.readbFill(z.b[:1], 0) - b = z.b[0] - } - return -} - -func (z *bufioDecReader) unreadn1() { - if z.c == 0 { - panic(errDecUnreadByteNothingToRead) - } - z.c-- - z.n-- - if z.trb { - z.tr = z.tr[:len(z.tr)-1] - } -} - -func (z *bufioDecReader) readn(num uint8) (bs [rwNLen]byte) { - z.readb(bs[:num]) - // copy(bs[:], z.readx(uint(num))) - return -} - -func (z *bufioDecReader) readx(n uint) (bs []byte) { - if n == 0 { - // return - } else if z.c+n <= uint(len(z.buf)) { - bs = z.buf[z.c : z.c+n] - z.n += n - z.c += n - if z.trb { - z.tr = append(z.tr, bs...) - } - } else { - bs = make([]byte, n) - // n no longer used - can reuse - n = uint(copy(bs, z.buf[z.c:])) - z.n += n - z.c += n - z.readbFill(bs, n) - } - return -} - -func (z *bufioDecReader) skip(accept *bitset256) (token byte) { - i := z.c -LOOP: - if i < uint(len(z.buf)) { - // inline z.skipLoopFn(i) and refactor, so cost is within inline budget - token = z.buf[i] - i++ - if accept.isset(token) { - goto LOOP - } - z.n += i - 2 - z.c - if z.trb { - z.tr = append(z.tr, z.buf[z.c:i]...) // z.doTrack(i) - } - z.c = i - return - } - return z.skipFill(accept) -} - -func (z *bufioDecReader) skipFill(accept *bitset256) (token byte) { - z.n += uint(len(z.buf)) - z.c - if z.trb { - z.tr = append(z.tr, z.buf[z.c:]...) - } - var i, n2 int - var err error - for { - z.c = 0 - z.buf = z.buf[0:cap(z.buf)] - n2, err = z.r.Read(z.buf) - if n2 == 0 && err != nil { - panic(err) - } - z.buf = z.buf[:n2] - for i, token = range z.buf { - // if !accept.isset(token) { - if accept.check(token) == 0 { - z.n += (uint(i) - z.c) - 1 - z.loopFn(uint(i + 1)) - return - } - } - z.n += uint(n2) - if z.trb { - z.tr = append(z.tr, z.buf...) - } - } -} - -func (z *bufioDecReader) loopFn(i uint) { - if z.trb { - z.tr = append(z.tr, z.buf[z.c:i]...) // z.doTrack(i) - } - z.c = i -} - -func (z *bufioDecReader) readTo(accept *bitset256) (out []byte) { - i := z.c -LOOP: - if i < uint(len(z.buf)) { - // if !accept.isset(z.buf[i]) { - if accept.check(z.buf[i]) == 0 { - // inline readToLoopFn here (for performance) - z.n += (i - z.c) - 1 - out = z.buf[z.c:i] - if z.trb { - z.tr = append(z.tr, z.buf[z.c:i]...) // z.doTrack(i) - } - z.c = i - return - } - i++ - goto LOOP - } - return z.readToFill(accept) -} - -func (z *bufioDecReader) readToFill(accept *bitset256) []byte { - z.bufr = z.blist.check(z.bufr, 256)[:0] - z.n += uint(len(z.buf)) - z.c - z.bufr = append(z.bufr, z.buf[z.c:]...) - if z.trb { - z.tr = append(z.tr, z.buf[z.c:]...) - } - var n2 int - var err error - for { - z.c = 0 - z.buf = z.buf[:cap(z.buf)] - n2, err = z.r.Read(z.buf) - if n2 == 0 && err != nil { - if err == io.EOF { - return z.bufr // readTo should read until it matches or end is reached - } - panic(err) - } - z.buf = z.buf[:n2] - for i, token := range z.buf { - // if !accept.isset(token) { - if accept.check(token) == 0 { - z.n += (uint(i) - z.c) - 1 - z.bufr = append(z.bufr, z.buf[z.c:i]...) - z.loopFn(uint(i)) - return z.bufr - } - } - z.bufr = append(z.bufr, z.buf...) - z.n += uint(n2) - if z.trb { - z.tr = append(z.tr, z.buf...) - } - } -} - -func (z *bufioDecReader) readUntil(stop byte, includeLast bool) (out []byte) { - i := z.c -LOOP: - if i < uint(len(z.buf)) { - if z.buf[i] == stop { - z.n += (i - z.c) - 1 - i++ - out = z.buf[z.c:i] - if z.trb { - z.tr = append(z.tr, z.buf[z.c:i]...) // z.doTrack(i) - } - z.c = i - goto FINISH - } - i++ - goto LOOP - } - out = z.readUntilFill(stop) -FINISH: - if includeLast { - return - } - return out[:len(out)-1] -} - -func (z *bufioDecReader) readUntilFill(stop byte) []byte { - z.bufr = z.blist.check(z.bufr, 256)[:0] - z.n += uint(len(z.buf)) - z.c - z.bufr = append(z.bufr, z.buf[z.c:]...) - if z.trb { - z.tr = append(z.tr, z.buf[z.c:]...) - } - for { - z.c = 0 - z.buf = z.buf[0:cap(z.buf)] - n1, err := z.r.Read(z.buf) - if n1 == 0 && err != nil { - panic(err) - } - n2 := uint(n1) - z.buf = z.buf[:n2] - for i, token := range z.buf { - if token == stop { - z.n += (uint(i) - z.c) - 1 - z.bufr = append(z.bufr, z.buf[z.c:i+1]...) - z.loopFn(uint(i + 1)) - return z.bufr - } - } - z.bufr = append(z.bufr, z.buf...) - z.n += n2 - if z.trb { - z.tr = append(z.tr, z.buf...) - } - } -} - -// ------------------------------------ - -// bytesDecReader is a decReader that reads off a byte slice with zero copying -type bytesDecReader struct { - b []byte // data - c uint // cursor - t uint // track start - // a int // available -} - -func (z *bytesDecReader) reset(in []byte) { - z.b = in - z.c = 0 - z.t = 0 -} - -func (z *bytesDecReader) numread() uint { - return z.c -} - -func (z *bytesDecReader) last() byte { - return z.b[z.c-1] -} - -func (z *bytesDecReader) unreadn1() { - if z.c == 0 || len(z.b) == 0 { - panic(errBytesDecReaderCannotUnread) - } - z.c-- -} - -func (z *bytesDecReader) readx(n uint) (bs []byte) { - // slicing from a non-constant start position is more expensive, - // as more computation is required to decipher the pointer start position. - // However, we do it only once, and it's better than reslicing both z.b and return value. - - z.c += n - return z.b[z.c-n : z.c] -} - -func (z *bytesDecReader) readb(bs []byte) { - copy(bs, z.readx(uint(len(bs)))) -} - -func (z *bytesDecReader) readn1() (v uint8) { - v = z.b[z.c] - z.c++ - return -} - -func (z *bytesDecReader) readn(num uint8) (bs [rwNLen]byte) { - // if z.c >= uint(len(z.b)) || z.c+uint(num) >= uint(len(z.b)) { - // panic(io.EOF) - // } - - // for bounds-check elimination, reslice z.b and ensure bs is within len - // bb := z.b[z.c:][:num] - bb := z.b[z.c : z.c+uint(num)] - _ = bs[len(bb)-1] - var i int -LOOP: - if i < len(bb) { - bs[i] = bb[i] - i++ - goto LOOP - } - - z.c += uint(num) - return -} - -func (z *bytesDecReader) skip(accept *bitset256) (token byte) { - i := z.c -LOOP: - // if i < uint(len(z.b)) { - token = z.b[i] - i++ - if accept.isset(token) { - goto LOOP - } - z.c = i - return -} - -func (z *bytesDecReader) readTo(accept *bitset256) (out []byte) { - i := z.c -LOOP: - if i < uint(len(z.b)) { - if accept.isset(z.b[i]) { - i++ - goto LOOP - } - } - - out = z.b[z.c:i] - z.c = i - return // z.b[c:i] -} - -func (z *bytesDecReader) readUntil(stop byte, includeLast bool) (out []byte) { - i := z.c -LOOP: - // if i < uint(len(z.b)) { - if z.b[i] == stop { - i++ - if includeLast { - out = z.b[z.c:i] - } else { - out = z.b[z.c : i-1] - } - // z.a -= (i - z.c) - z.c = i - return - } - i++ - goto LOOP - // } - // panic(io.EOF) -} - -func (z *bytesDecReader) track() { - z.t = z.c -} - -func (z *bytesDecReader) stopTrack() (bs []byte) { - return z.b[z.t:z.c] -} - -// -------------- - -type decRd struct { - mtr bool // is maptype a known type? - str bool // is slicetype a known type? - - be bool // is binary encoding - js bool // is json handle - jsms bool // is json handle, and MapKeyAsString - cbor bool // is cbor handle - - bytes bool // is bytes reader - bufio bool // is this a bufioDecReader? - - rb bytesDecReader - ri *ioDecReader - bi *bufioDecReader -} - -// numread, track and stopTrack are always inlined, as they just check int fields, etc. - -// the if/else-if/else block is expensive to inline. -// Each node of this construct costs a lot and dominates the budget. -// Best to only do an if fast-path else block (so fast-path is inlined). -// This is irrespective of inlineExtraCallCost set in $GOROOT/src/cmd/compile/internal/gc/inl.go -// -// In decRd methods below, we delegate all IO functions into their own methods. -// This allows for the inlining of the common path when z.bytes=true. -// Go 1.12+ supports inlining methods with up to 1 inlined function (or 2 if no other constructs). -// -// However, up through Go 1.13, decRd's readXXX, skip and unreadXXX methods are not inlined. -// Consequently, there is no benefit to do the xxxIO methods for decRd at this time. -// Instead, we have a if/else-if/else block so that IO calls do not have to jump through -// a second unnecessary function call. -// -// If golang inlining gets better and bytesDecReader methods can be inlined, -// then we can revert to using these 2 functions so the bytesDecReader -// methods are inlined and the IO paths call out to a function. - -func (z *decRd) numread() uint { - if z.bytes { - return z.rb.numread() - } else if z.bufio { - return z.bi.numread() - } else { - return z.ri.numread() - } -} -func (z *decRd) stopTrack() []byte { - if z.bytes { - return z.rb.stopTrack() - } else if z.bufio { - return z.bi.stopTrack() - } else { - return z.ri.stopTrack() - } -} - -func (z *decRd) track() { - if z.bytes { - z.rb.track() - } else if z.bufio { - z.bi.track() - } else { - z.ri.track() - } -} - -func (z *decRd) unreadn1() { - if z.bytes { - z.rb.unreadn1() - } else if z.bufio { - z.bi.unreadn1() - } else { - z.ri.unreadn1() // not inlined - } -} - -func (z *decRd) readn(num uint8) [rwNLen]byte { - if z.bytes { - return z.rb.readn(num) - } else if z.bufio { - return z.bi.readn(num) - } else { - return z.ri.readn(num) - } -} - -func (z *decRd) readx(n uint) []byte { - if z.bytes { - return z.rb.readx(n) - } else if z.bufio { - return z.bi.readx(n) - } else { - return z.ri.readx(n) - } -} - -func (z *decRd) readb(s []byte) { - if z.bytes { - z.rb.readb(s) - } else if z.bufio { - z.bi.readb(s) - } else { - z.ri.readb(s) - } -} - -func (z *decRd) readn1() uint8 { - if z.bytes { - return z.rb.readn1() - } else if z.bufio { - return z.bi.readn1() - } else { - return z.ri.readn1() - } -} - -func (z *decRd) skip(accept *bitset256) (token byte) { - if z.bytes { - return z.rb.skip(accept) - } else if z.bufio { - return z.bi.skip(accept) - } else { - return z.ri.skip(accept) - } -} - -func (z *decRd) readTo(accept *bitset256) (out []byte) { - if z.bytes { - return z.rb.readTo(accept) - } else if z.bufio { - return z.bi.readTo(accept) - } else { - return z.ri.readTo(accept) - } -} - -func (z *decRd) readUntil(stop byte, includeLast bool) (out []byte) { - if z.bytes { - return z.rb.readUntil(stop, includeLast) - } else if z.bufio { - return z.bi.readUntil(stop, includeLast) - } else { - return z.ri.readUntil(stop, includeLast) - } -} - -/* -func (z *decRd) track() { - if z.bytes { - z.rb.track() - } else { - z.trackIO() - } -} -func (z *decRd) trackIO() { - if z.bufio { - z.bi.track() - } else { - z.ri.track() - } -} - -func (z *decRd) unreadn1() { - if z.bytes { - z.rb.unreadn1() - } else { - z.unreadn1IO() - } -} -func (z *decRd) unreadn1IO() { - if z.bufio { - z.bi.unreadn1() - } else { - z.ri.unreadn1() - } -} - -func (z *decRd) readn(num uint8) [rwNLen]byte { - if z.bytes { - return z.rb.readn(num) - } - return z.readnIO(num) -} -func (z *decRd) readnIO(num uint8) [rwNLen]byte { - if z.bufio { - return z.bi.readn(num) - } - return z.ri.readn(num) -} - -func (z *decRd) readx(n uint) []byte { - if z.bytes { - return z.rb.readx(n) - } - return z.readxIO(n) -} -func (z *decRd) readxIO(n uint) []byte { - if z.bufio { - return z.bi.readx(n) - } - return z.ri.readx(n) -} - -func (z *decRd) readb(s []byte) { - if z.bytes { - z.rb.readb(s) - } else { - z.readbIO(s) - } -} -func (z *decRd) readbIO(s []byte) { - if z.bufio { - z.bi.readb(s) - } else { - z.ri.readb(s) - } -} - -func (z *decRd) readn1() uint8 { - if z.bytes { - return z.rb.readn1() - } - return z.readn1IO() -} -func (z *decRd) readn1IO() uint8 { - if z.bufio { - return z.bi.readn1() - } - return z.ri.readn1() -} - -func (z *decRd) skip(accept *bitset256) (token byte) { - if z.bytes { - return z.rb.skip(accept) - } - return z.skipIO(accept) -} -func (z *decRd) skipIO(accept *bitset256) (token byte) { - if z.bufio { - return z.bi.skip(accept) - } - return z.ri.skip(accept) -} - -func (z *decRd) readTo(accept *bitset256) (out []byte) { - if z.bytes { - return z.rb.readTo(accept) - } - return z.readToIO(accept) -} -func (z *decRd) readToIO(accept *bitset256) (out []byte) { - if z.bufio { - return z.bi.readTo(accept) - } - return z.ri.readTo(accept) -} - -func (z *decRd) readUntil(stop byte, includeLast bool) (out []byte) { - if z.bytes { - return z.rb.readUntil(stop, includeLast) - } - return z.readUntilIO(stop, includeLast) -} -func (z *decRd) readUntilIO(stop byte, includeLast bool) (out []byte) { - if z.bufio { - return z.bi.readUntil(stop, includeLast) - } - return z.ri.readUntil(stop, includeLast) -} -*/ - -var _ decReader = (*decRd)(nil) diff --git a/vendor/github.com/ugorji/go/codec/register_ext.go b/vendor/github.com/ugorji/go/codec/register_ext.go deleted file mode 100644 index 68b002cc8630..000000000000 --- a/vendor/github.com/ugorji/go/codec/register_ext.go +++ /dev/null @@ -1,38 +0,0 @@ -// 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 - -import "reflect" - -// This file exists, so that the files for specific formats do not all import reflect. -// This just helps us ensure that reflect package is isolated to a few files. - -// SetInterfaceExt sets an extension -func (h *JsonHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) { - return h.SetExt(rt, tag, makeExt(ext)) -} - -// SetInterfaceExt sets an extension -func (h *CborHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) { - return h.SetExt(rt, tag, makeExt(ext)) -} - -// SetBytesExt sets an extension -func (h *MsgpackHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) { - return h.SetExt(rt, tag, makeExt(ext)) -} - -// SetBytesExt sets an extension -func (h *SimpleHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) { - return h.SetExt(rt, tag, makeExt(ext)) -} - -// SetBytesExt sets an extension -func (h *BincHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) { - return h.SetExt(rt, tag, makeExt(ext)) -} - -// func (h *XMLHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) { -// return h.SetExt(rt, tag, &interfaceExtWrapper{InterfaceExt: ext}) -// } diff --git a/vendor/github.com/ugorji/go/codec/rpc.go b/vendor/github.com/ugorji/go/codec/rpc.go index 8ee235876e33..3925088152dc 100644 --- a/vendor/github.com/ugorji/go/codec/rpc.go +++ b/vendor/github.com/ugorji/go/codec/rpc.go @@ -97,6 +97,9 @@ func (c *rpcCodec) write(obj1, obj2 interface{}, writeObj2 bool) (err error) { if writeObj2 { err = c.enc.Encode(obj2) } + // if err == nil && c.f != nil { + // err = c.f.Flush() + // } } if c.f != nil { if err == nil { diff --git a/vendor/github.com/ugorji/go/codec/simple.go b/vendor/github.com/ugorji/go/codec/simple.go index 42bfd042b937..a3257c1a7bdd 100644 --- a/vendor/github.com/ugorji/go/codec/simple.go +++ b/vendor/github.com/ugorji/go/codec/simple.go @@ -5,6 +5,7 @@ package codec import ( "math" + "reflect" "time" ) @@ -32,49 +33,49 @@ const ( type simpleEncDriver struct { noBuiltInTypes - encDriverNoopContainerWriter + // encNoSeparator + e *Encoder h *SimpleHandle + w *encWriterSwitch b [8]byte - _ [6]uint64 // padding (cache-aligned) - e Encoder -} - -func (e *simpleEncDriver) encoder() *Encoder { - return &e.e + // c containerState + encDriverTrackContainerWriter + // encDriverNoopContainerWriter + _ [3]uint64 // padding } func (e *simpleEncDriver) EncodeNil() { - e.e.encWr.writen1(simpleVdNil) + e.w.writen1(simpleVdNil) } func (e *simpleEncDriver) EncodeBool(b bool) { - if e.h.EncZeroValuesAsNil && e.e.c != containerMapKey && !b { + if e.h.EncZeroValuesAsNil && e.c != containerMapKey && !b { e.EncodeNil() return } if b { - e.e.encWr.writen1(simpleVdTrue) + e.w.writen1(simpleVdTrue) } else { - e.e.encWr.writen1(simpleVdFalse) + e.w.writen1(simpleVdFalse) } } func (e *simpleEncDriver) EncodeFloat32(f float32) { - if e.h.EncZeroValuesAsNil && e.e.c != containerMapKey && f == 0.0 { + if e.h.EncZeroValuesAsNil && e.c != containerMapKey && f == 0.0 { e.EncodeNil() return } - e.e.encWr.writen1(simpleVdFloat32) - bigenHelper{e.b[:4], e.e.w()}.writeUint32(math.Float32bits(f)) + 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.e.c != containerMapKey && f == 0.0 { + if e.h.EncZeroValuesAsNil && e.c != containerMapKey && f == 0.0 { e.EncodeNil() return } - e.e.encWr.writen1(simpleVdFloat64) - bigenHelper{e.b[:8], e.e.w()}.writeUint64(math.Float64bits(f)) + e.w.writen1(simpleVdFloat64) + bigenHelper{e.b[:8], e.w}.writeUint64(math.Float64bits(f)) } func (e *simpleEncDriver) EncodeInt(v int64) { @@ -90,90 +91,91 @@ func (e *simpleEncDriver) EncodeUint(v uint64) { } func (e *simpleEncDriver) encUint(v uint64, bd uint8) { - if e.h.EncZeroValuesAsNil && e.e.c != containerMapKey && v == 0 { + if e.h.EncZeroValuesAsNil && e.c != containerMapKey && v == 0 { e.EncodeNil() return } if v <= math.MaxUint8 { - e.e.encWr.writen2(bd, uint8(v)) + e.w.writen2(bd, uint8(v)) } else if v <= math.MaxUint16 { - e.e.encWr.writen1(bd + 1) - bigenHelper{e.b[:2], e.e.w()}.writeUint16(uint16(v)) + e.w.writen1(bd + 1) + bigenHelper{e.b[:2], e.w}.writeUint16(uint16(v)) } else if v <= math.MaxUint32 { - e.e.encWr.writen1(bd + 2) - bigenHelper{e.b[:4], e.e.w()}.writeUint32(uint32(v)) + e.w.writen1(bd + 2) + bigenHelper{e.b[:4], e.w}.writeUint32(uint32(v)) } else { // if v <= math.MaxUint64 { - e.e.encWr.writen1(bd + 3) - bigenHelper{e.b[:8], e.e.w()}.writeUint64(v) + e.w.writen1(bd + 3) + bigenHelper{e.b[:8], e.w}.writeUint64(v) } } func (e *simpleEncDriver) encLen(bd byte, length int) { if length == 0 { - e.e.encWr.writen1(bd) + e.w.writen1(bd) } else if length <= math.MaxUint8 { - e.e.encWr.writen1(bd + 1) - e.e.encWr.writen1(uint8(length)) + e.w.writen1(bd + 1) + e.w.writen1(uint8(length)) } else if length <= math.MaxUint16 { - e.e.encWr.writen1(bd + 2) - bigenHelper{e.b[:2], e.e.w()}.writeUint16(uint16(length)) + e.w.writen1(bd + 2) + bigenHelper{e.b[:2], e.w}.writeUint16(uint16(length)) } else if int64(length) <= math.MaxUint32 { - e.e.encWr.writen1(bd + 3) - bigenHelper{e.b[:4], e.e.w()}.writeUint32(uint32(length)) + e.w.writen1(bd + 3) + bigenHelper{e.b[:4], e.w}.writeUint32(uint32(length)) } else { - e.e.encWr.writen1(bd + 4) - bigenHelper{e.b[:8], e.e.w()}.writeUint64(uint64(length)) + e.w.writen1(bd + 4) + bigenHelper{e.b[:8], e.w}.writeUint64(uint64(length)) } } -func (e *simpleEncDriver) EncodeExt(v interface{}, xtag uint64, ext Ext) { - var bs []byte - if ext == SelfExt { - bs = e.e.blist.get(1024)[:0] - e.e.sideEncode(v, &bs) - } else { - bs = ext.WriteExt(v) - } +func (e *simpleEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext, _ *Encoder) { + bs := ext.WriteExt(rv) if bs == nil { e.EncodeNil() return } e.encodeExtPreamble(uint8(xtag), len(bs)) - e.e.encWr.writeb(bs) - if ext == SelfExt { - e.e.blist.put(bs) - } + e.w.writeb(bs) } -func (e *simpleEncDriver) EncodeRawExt(re *RawExt) { +func (e *simpleEncDriver) EncodeRawExt(re *RawExt, _ *Encoder) { e.encodeExtPreamble(uint8(re.Tag), len(re.Data)) - e.e.encWr.writeb(re.Data) + e.w.writeb(re.Data) } func (e *simpleEncDriver) encodeExtPreamble(xtag byte, length int) { e.encLen(simpleVdExt, length) - e.e.encWr.writen1(xtag) + e.w.writen1(xtag) } 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(v string) { - if e.h.EncZeroValuesAsNil && e.e.c != containerMapKey && v == "" { +// func (e *simpleEncDriver) EncodeSymbol(v string) { +// e.EncodeStringEnc(cUTF8, v) +// } + +func (e *simpleEncDriver) EncodeStringEnc(c charEncoding, v string) { + if false && e.h.EncZeroValuesAsNil && e.c != containerMapKey && v == "" { e.EncodeNil() return } - if e.h.StringToRaw { - e.encLen(simpleVdByteArray, len(v)) - } else { - e.encLen(simpleVdString, len(v)) - } - e.e.encWr.writestr(v) + e.encLen(simpleVdString, len(v)) + e.w.writestr(v) +} + +func (e *simpleEncDriver) EncodeString(c charEncoding, v string) { + e.EncodeStringEnc(c, v) +} + +func (e *simpleEncDriver) EncodeStringBytes(c charEncoding, v []byte) { + e.EncodeStringBytesRaw(v) } func (e *simpleEncDriver) EncodeStringBytesRaw(v []byte) { @@ -183,7 +185,7 @@ func (e *simpleEncDriver) EncodeStringBytesRaw(v []byte) { return } e.encLen(simpleVdByteArray, len(v)) - e.e.encWr.writeb(v) + e.w.writeb(v) } func (e *simpleEncDriver) EncodeTime(t time.Time) { @@ -198,65 +200,45 @@ func (e *simpleEncDriver) EncodeTime(t time.Time) { return } // time.Time marshalbinary takes about 14 bytes. - e.e.encWr.writen2(simpleVdTime, uint8(len(v))) - e.e.encWr.writeb(v) + e.w.writen2(simpleVdTime, uint8(len(v))) + e.w.writeb(v) } //------------------------------------ type simpleDecDriver struct { + d *Decoder h *SimpleHandle + r *decReaderSwitch bdRead bool bd byte - fnil bool + br bool // a bytes reader? + c containerState + // b [scratchByteArrayLen]byte noBuiltInTypes + // noStreamingCodec decDriverNoopContainerReader - _ [6]uint64 // padding - d Decoder -} - -func (d *simpleDecDriver) decoder() *Decoder { - return &d.d + // _ [3]uint64 // padding } func (d *simpleDecDriver) readNextBd() { - d.bd = d.d.decRd.readn1() + d.bd = d.r.readn1() d.bdRead = true } func (d *simpleDecDriver) uncacheRead() { if d.bdRead { - d.d.decRd.unreadn1() + d.r.unreadn1() d.bdRead = false } } -func (d *simpleDecDriver) advanceNil() (null bool) { - d.fnil = false - if !d.bdRead { - d.readNextBd() - } - if d.bd == simpleVdNil { - d.bdRead = false - d.fnil = true - null = true - } - return -} - -func (d *simpleDecDriver) Nil() bool { - return d.fnil -} - func (d *simpleDecDriver) ContainerType() (vt valueType) { if !d.bdRead { d.readNextBd() } - d.fnil = false switch d.bd { case simpleVdNil: - d.bdRead = false - d.fnil = true return valueTypeNil case simpleVdByteArray, simpleVdByteArray + 1, simpleVdByteArray + 2, simpleVdByteArray + 3, simpleVdByteArray + 4: @@ -270,42 +252,56 @@ func (d *simpleDecDriver) ContainerType() (vt valueType) { case simpleVdMap, simpleVdMap + 1, simpleVdMap + 2, simpleVdMap + 3, simpleVdMap + 4: return valueTypeMap + // case simpleVdTime: + // return valueTypeTime } + // else { + // d.d.errorf("isContainerType: unsupported parameter: %v", vt) + // } return valueTypeUnset } -func (d *simpleDecDriver) TryNil() bool { - return d.advanceNil() +func (d *simpleDecDriver) TryDecodeAsNil() bool { + if !d.bdRead { + d.readNextBd() + } + if d.bd == simpleVdNil { + d.bdRead = false + return true + } + return false } func (d *simpleDecDriver) decCheckInteger() (ui uint64, neg bool) { + if !d.bdRead { + d.readNextBd() + } switch d.bd { case simpleVdPosInt: - ui = uint64(d.d.decRd.readn1()) + ui = uint64(d.r.readn1()) case simpleVdPosInt + 1: - ui = uint64(bigen.Uint16(d.d.decRd.readx(2))) + ui = uint64(bigen.Uint16(d.r.readx(2))) case simpleVdPosInt + 2: - ui = uint64(bigen.Uint32(d.d.decRd.readx(4))) + ui = uint64(bigen.Uint32(d.r.readx(4))) case simpleVdPosInt + 3: - ui = uint64(bigen.Uint64(d.d.decRd.readx(8))) + ui = uint64(bigen.Uint64(d.r.readx(8))) case simpleVdNegInt: - ui = uint64(d.d.decRd.readn1()) + ui = uint64(d.r.readn1()) neg = true case simpleVdNegInt + 1: - ui = uint64(bigen.Uint16(d.d.decRd.readx(2))) + ui = uint64(bigen.Uint16(d.r.readx(2))) neg = true case simpleVdNegInt + 2: - ui = uint64(bigen.Uint32(d.d.decRd.readx(4))) + ui = uint64(bigen.Uint32(d.r.readx(4))) neg = true case simpleVdNegInt + 3: - ui = uint64(bigen.Uint64(d.d.decRd.readx(8))) + ui = uint64(bigen.Uint64(d.r.readx(8))) neg = true default: d.d.errorf("integer only valid from pos/neg integer1..8. Invalid descriptor: %v", d.bd) return } - // DO NOT do this check below, because callers may only want the unsigned value: - // + // don't do this check, because callers may only want the unsigned value. // if ui > math.MaxInt64 { // d.d.errorf("decIntAny: Integer out of range for signed int64: %v", ui) // return @@ -314,9 +310,6 @@ func (d *simpleDecDriver) decCheckInteger() (ui uint64, neg bool) { } func (d *simpleDecDriver) DecodeInt64() (i int64) { - if d.advanceNil() { - return - } ui, neg := d.decCheckInteger() i = chkOvf.SignedIntV(ui) if neg { @@ -327,9 +320,6 @@ func (d *simpleDecDriver) DecodeInt64() (i int64) { } func (d *simpleDecDriver) DecodeUint64() (ui uint64) { - if d.advanceNil() { - return - } ui, neg := d.decCheckInteger() if neg { d.d.errorf("assigning negative signed value to unsigned type") @@ -340,13 +330,13 @@ func (d *simpleDecDriver) DecodeUint64() (ui uint64) { } func (d *simpleDecDriver) DecodeFloat64() (f float64) { - if d.advanceNil() { - return + if !d.bdRead { + d.readNextBd() } if d.bd == simpleVdFloat32 { - f = float64(math.Float32frombits(bigen.Uint32(d.d.decRd.readx(4)))) + f = float64(math.Float32frombits(bigen.Uint32(d.r.readx(4)))) } else if d.bd == simpleVdFloat64 { - f = math.Float64frombits(bigen.Uint64(d.d.decRd.readx(8))) + f = math.Float64frombits(bigen.Uint64(d.r.readx(8))) } else { if d.bd >= simpleVdPosInt && d.bd <= simpleVdNegInt+3 { f = float64(d.DecodeInt64()) @@ -361,12 +351,12 @@ func (d *simpleDecDriver) DecodeFloat64() (f float64) { // bool can be decoded from bool only (single byte). func (d *simpleDecDriver) DecodeBool() (b bool) { - if d.advanceNil() { - return + if !d.bdRead { + d.readNextBd() } - if d.bd == simpleVdFalse { - } else if d.bd == simpleVdTrue { + if d.bd == simpleVdTrue { b = true + } else if d.bd == simpleVdFalse { } else { d.d.errorf("cannot decode bool - %s: %x", msgBadDesc, d.bd) return @@ -376,38 +366,60 @@ func (d *simpleDecDriver) DecodeBool() (b bool) { } func (d *simpleDecDriver) ReadMapStart() (length int) { - if d.advanceNil() { - return decContainerLenNil + if !d.bdRead { + d.readNextBd() } d.bdRead = false + d.c = containerMapStart return d.decLen() } func (d *simpleDecDriver) ReadArrayStart() (length int) { - if d.advanceNil() { - return decContainerLenNil + if !d.bdRead { + 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: return 0 case 1: - return int(d.d.decRd.readn1()) + return int(d.r.readn1()) case 2: - return int(bigen.Uint16(d.d.decRd.readx(2))) + return int(bigen.Uint16(d.r.readx(2))) case 3: - ui := uint64(bigen.Uint32(d.d.decRd.readx(4))) + ui := uint64(bigen.Uint32(d.r.readx(4))) if chkOvf.Uint(ui, intBitsize) { d.d.errorf("overflow integer: %v", ui) return 0 } return int(ui) case 4: - ui := bigen.Uint64(d.d.decRd.readx(8)) + ui := bigen.Uint64(d.r.readx(8)) if chkOvf.Uint(ui, intBitsize) { d.d.errorf("overflow integer: %v", ui) return 0 @@ -418,12 +430,20 @@ func (d *simpleDecDriver) decLen() int { return -1 } +func (d *simpleDecDriver) DecodeString() (s string) { + return string(d.DecodeBytes(d.d.b[:], true)) +} + func (d *simpleDecDriver) DecodeStringAsBytes() (s []byte) { return d.DecodeBytes(d.d.b[:], true) } func (d *simpleDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { - if d.advanceNil() { + if !d.bdRead { + d.readNextBd() + } + if d.bd == simpleVdNil { + d.bdRead = false return } // check if an "array" of uint8's (see ContainerType for how to infer if an array) @@ -431,29 +451,28 @@ func (d *simpleDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { if len(bs) == 0 && zerocopy { bs = d.d.b[:] } - // bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d) - slen := d.ReadArrayStart() - bs = usableByteSlice(bs, slen) - for i := 0; i < len(bs); i++ { - bs[i] = uint8(chkOvf.UintV(d.DecodeUint64(), 8)) - } - return bs + bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d) + return } clen := d.decLen() d.bdRead = false if zerocopy { - if d.d.bytes { - return d.d.decRd.readx(uint(clen)) + if d.br { + return d.r.readx(uint(clen)) } else if len(bs) == 0 { bs = d.d.b[:] } } - return decByteSlice(d.d.r(), clen, d.d.h.MaxInitLen, bs) + return decByteSlice(d.r, clen, d.d.h.MaxInitLen, bs) } func (d *simpleDecDriver) DecodeTime() (t time.Time) { - if d.advanceNil() { + if !d.bdRead { + d.readNextBd() + } + if d.bd == simpleVdNil { + d.bdRead = false return } if d.bd != simpleVdTime { @@ -461,48 +480,47 @@ func (d *simpleDecDriver) DecodeTime() (t time.Time) { return } d.bdRead = false - clen := int(d.d.decRd.readn1()) - b := d.d.decRd.readx(uint(clen)) + clen := int(d.r.readn1()) + b := d.r.readx(uint(clen)) if err := (&t).UnmarshalBinary(b); err != nil { d.d.errorv(err) } return } -func (d *simpleDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) { +func (d *simpleDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxtag uint64) { if xtag > 0xff { d.d.errorf("ext: tag must be <= 0xff; got: %v", xtag) return } - if d.advanceNil() { - return - } realxtag1, xbs := d.decodeExtV(ext != nil, uint8(xtag)) - realxtag := uint64(realxtag1) + realxtag = uint64(realxtag1) if ext == nil { re := rv.(*RawExt) re.Tag = realxtag - re.Data = detachZeroCopyBytes(d.d.bytes, re.Data, xbs) - } else if ext == SelfExt { - d.d.sideDecode(rv, xbs) + re.Data = detachZeroCopyBytes(d.br, re.Data, xbs) } else { ext.ReadExt(rv, xbs) } + return } func (d *simpleDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs []byte) { + if !d.bdRead { + d.readNextBd() + } switch d.bd { case simpleVdExt, simpleVdExt + 1, simpleVdExt + 2, simpleVdExt + 3, simpleVdExt + 4: l := d.decLen() - xtag = d.d.decRd.readn1() + xtag = d.r.readn1() if verifyTag && xtag != tag { d.d.errorf("wrong extension tag. Got %b. Expecting: %v", xtag, tag) return } - if d.d.bytes { - xbs = d.d.decRd.readx(uint(l)) + if d.br { + xbs = d.r.readx(uint(l)) } else { - xbs = decByteSlice(d.d.r(), l, d.d.h.MaxInitLen, d.d.b[:]) + xbs = decByteSlice(d.r, l, d.d.h.MaxInitLen, d.d.b[:]) } case simpleVdByteArray, simpleVdByteArray + 1, simpleVdByteArray + 2, simpleVdByteArray + 3, simpleVdByteArray + 4: @@ -520,14 +538,12 @@ func (d *simpleDecDriver) DecodeNaked() { d.readNextBd() } - d.fnil = false n := d.d.naked() var decodeFurther bool switch d.bd { case simpleVdNil: n.v = valueTypeNil - d.fnil = true case simpleVdFalse: n.v = valueTypeBool n.b = false @@ -557,18 +573,18 @@ func (d *simpleDecDriver) DecodeNaked() { case simpleVdString, simpleVdString + 1, simpleVdString + 2, simpleVdString + 3, simpleVdString + 4: n.v = valueTypeString - n.s = string(d.DecodeStringAsBytes()) + n.s = d.DecodeString() case simpleVdByteArray, simpleVdByteArray + 1, simpleVdByteArray + 2, simpleVdByteArray + 3, simpleVdByteArray + 4: - decNakedReadRawBytes(d, &d.d, n, d.h.RawToString) + decNakedReadRawBytes(d, d.d, n, d.h.RawToString) case simpleVdExt, simpleVdExt + 1, simpleVdExt + 2, simpleVdExt + 3, simpleVdExt + 4: n.v = valueTypeExt l := d.decLen() - n.u = uint64(d.d.decRd.readn1()) - if d.d.bytes { - n.l = d.d.decRd.readx(uint(l)) + n.u = uint64(d.r.readn1()) + if d.br { + n.l = d.r.readx(uint(l)) } else { - n.l = decByteSlice(d.d.r(), l, d.d.h.MaxInitLen, d.d.b[:]) + n.l = decByteSlice(d.r, l, d.d.h.MaxInitLen, d.d.b[:]) } case simpleVdArray, simpleVdArray + 1, simpleVdArray + 2, simpleVdArray + 3, simpleVdArray + 4: @@ -608,39 +624,42 @@ func (d *simpleDecDriver) DecodeNaked() { // // The full spec will be published soon. type SimpleHandle struct { - binaryEncodingType BasicHandle + binaryEncodingType + noElemSeparators // EncZeroValuesAsNil says to encode zero values for numbers, bool, string, etc as nil EncZeroValuesAsNil bool - _ [7]uint64 // padding (cache-aligned) + // _ [1]uint64 // padding } // Name returns the name of the handle: simple func (h *SimpleHandle) Name() string { return "simple" } -func (h *SimpleHandle) newEncDriver() encDriver { - var e = &simpleEncDriver{h: h} - e.e.e = e - e.e.init(h) - e.reset() - return e +// SetBytesExt sets an extension +func (h *SimpleHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) { + 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} } -func (h *SimpleHandle) newDecDriver() decDriver { - d := &simpleDecDriver{h: h} - d.d.d = d - d.d.init(h) - d.reset() - return d +func (h *SimpleHandle) newDecDriver(d *Decoder) decDriver { + return &simpleDecDriver{d: d, h: h, r: d.r, br: d.bytes} } 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 - d.fnil = false } var _ decDriver = (*simpleDecDriver)(nil) diff --git a/vendor/github.com/ugorji/go/codec/sort-slice.generated.go b/vendor/github.com/ugorji/go/codec/sort-slice.generated.go deleted file mode 100644 index 352ddfbd8de4..000000000000 --- a/vendor/github.com/ugorji/go/codec/sort-slice.generated.go +++ /dev/null @@ -1,266 +0,0 @@ -// 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. - -// Code generated from sort-slice.go.tmpl - DO NOT EDIT. - -package codec - -import "time" -import "reflect" -import "bytes" - -type stringSlice []string - -func (p stringSlice) Len() int { return len(p) } -func (p stringSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p stringSlice) Less(i, j int) bool { - return p[uint(i)] < p[uint(j)] -} - -type float64Slice []float64 - -func (p float64Slice) Len() int { return len(p) } -func (p float64Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p float64Slice) Less(i, j int) bool { - return p[uint(i)] < p[uint(j)] || isNaN64(p[uint(i)]) && !isNaN64(p[uint(j)]) -} - -type uint64Slice []uint64 - -func (p uint64Slice) Len() int { return len(p) } -func (p uint64Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p uint64Slice) Less(i, j int) bool { - return p[uint(i)] < p[uint(j)] -} - -type uintptrSlice []uintptr - -func (p uintptrSlice) Len() int { return len(p) } -func (p uintptrSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p uintptrSlice) Less(i, j int) bool { - return p[uint(i)] < p[uint(j)] -} - -type int64Slice []int64 - -func (p int64Slice) Len() int { return len(p) } -func (p int64Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p int64Slice) Less(i, j int) bool { - return p[uint(i)] < p[uint(j)] -} - -type boolSlice []bool - -func (p boolSlice) Len() int { return len(p) } -func (p boolSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p boolSlice) Less(i, j int) bool { - return !p[uint(i)] && p[uint(j)] -} - -type timeSlice []time.Time - -func (p timeSlice) Len() int { return len(p) } -func (p timeSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p timeSlice) Less(i, j int) bool { - return p[uint(i)].Before(p[uint(j)]) -} - -type bytesSlice [][]byte - -func (p bytesSlice) Len() int { return len(p) } -func (p bytesSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p bytesSlice) Less(i, j int) bool { - return bytes.Compare(p[uint(i)], p[uint(j)]) == -1 -} - -type stringRv struct { - v string - r reflect.Value -} -type stringRvSlice []stringRv - -func (p stringRvSlice) Len() int { return len(p) } -func (p stringRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p stringRvSlice) Less(i, j int) bool { - return p[uint(i)].v < p[uint(j)].v -} - -type stringIntf struct { - v string - i interface{} -} -type stringIntfSlice []stringIntf - -func (p stringIntfSlice) Len() int { return len(p) } -func (p stringIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p stringIntfSlice) Less(i, j int) bool { - return p[uint(i)].v < p[uint(j)].v -} - -type float64Rv struct { - v float64 - r reflect.Value -} -type float64RvSlice []float64Rv - -func (p float64RvSlice) Len() int { return len(p) } -func (p float64RvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p float64RvSlice) Less(i, j int) bool { - return p[uint(i)].v < p[uint(j)].v || isNaN64(p[uint(i)].v) && !isNaN64(p[uint(j)].v) -} - -type float64Intf struct { - v float64 - i interface{} -} -type float64IntfSlice []float64Intf - -func (p float64IntfSlice) Len() int { return len(p) } -func (p float64IntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p float64IntfSlice) Less(i, j int) bool { - return p[uint(i)].v < p[uint(j)].v || isNaN64(p[uint(i)].v) && !isNaN64(p[uint(j)].v) -} - -type uint64Rv struct { - v uint64 - r reflect.Value -} -type uint64RvSlice []uint64Rv - -func (p uint64RvSlice) Len() int { return len(p) } -func (p uint64RvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p uint64RvSlice) Less(i, j int) bool { - return p[uint(i)].v < p[uint(j)].v -} - -type uint64Intf struct { - v uint64 - i interface{} -} -type uint64IntfSlice []uint64Intf - -func (p uint64IntfSlice) Len() int { return len(p) } -func (p uint64IntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p uint64IntfSlice) Less(i, j int) bool { - return p[uint(i)].v < p[uint(j)].v -} - -type uintptrRv struct { - v uintptr - r reflect.Value -} -type uintptrRvSlice []uintptrRv - -func (p uintptrRvSlice) Len() int { return len(p) } -func (p uintptrRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p uintptrRvSlice) Less(i, j int) bool { - return p[uint(i)].v < p[uint(j)].v -} - -type uintptrIntf struct { - v uintptr - i interface{} -} -type uintptrIntfSlice []uintptrIntf - -func (p uintptrIntfSlice) Len() int { return len(p) } -func (p uintptrIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p uintptrIntfSlice) Less(i, j int) bool { - return p[uint(i)].v < p[uint(j)].v -} - -type int64Rv struct { - v int64 - r reflect.Value -} -type int64RvSlice []int64Rv - -func (p int64RvSlice) Len() int { return len(p) } -func (p int64RvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p int64RvSlice) Less(i, j int) bool { - return p[uint(i)].v < p[uint(j)].v -} - -type int64Intf struct { - v int64 - i interface{} -} -type int64IntfSlice []int64Intf - -func (p int64IntfSlice) Len() int { return len(p) } -func (p int64IntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p int64IntfSlice) Less(i, j int) bool { - return p[uint(i)].v < p[uint(j)].v -} - -type boolRv struct { - v bool - r reflect.Value -} -type boolRvSlice []boolRv - -func (p boolRvSlice) Len() int { return len(p) } -func (p boolRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p boolRvSlice) Less(i, j int) bool { - return !p[uint(i)].v && p[uint(j)].v -} - -type boolIntf struct { - v bool - i interface{} -} -type boolIntfSlice []boolIntf - -func (p boolIntfSlice) Len() int { return len(p) } -func (p boolIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p boolIntfSlice) Less(i, j int) bool { - return !p[uint(i)].v && p[uint(j)].v -} - -type timeRv struct { - v time.Time - r reflect.Value -} -type timeRvSlice []timeRv - -func (p timeRvSlice) Len() int { return len(p) } -func (p timeRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p timeRvSlice) Less(i, j int) bool { - return p[uint(i)].v.Before(p[uint(j)].v) -} - -type timeIntf struct { - v time.Time - i interface{} -} -type timeIntfSlice []timeIntf - -func (p timeIntfSlice) Len() int { return len(p) } -func (p timeIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p timeIntfSlice) Less(i, j int) bool { - return p[uint(i)].v.Before(p[uint(j)].v) -} - -type bytesRv struct { - v []byte - r reflect.Value -} -type bytesRvSlice []bytesRv - -func (p bytesRvSlice) Len() int { return len(p) } -func (p bytesRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p bytesRvSlice) Less(i, j int) bool { - return bytes.Compare(p[uint(i)].v, p[uint(j)].v) == -1 -} - -type bytesIntf struct { - v []byte - i interface{} -} -type bytesIntfSlice []bytesIntf - -func (p bytesIntfSlice) Len() int { return len(p) } -func (p bytesIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p bytesIntfSlice) Less(i, j int) bool { - return bytes.Compare(p[uint(i)].v, p[uint(j)].v) == -1 -} diff --git a/vendor/github.com/ugorji/go/codec/sort-slice.go.tmpl b/vendor/github.com/ugorji/go/codec/sort-slice.go.tmpl deleted file mode 100644 index 95d348c9a115..000000000000 --- a/vendor/github.com/ugorji/go/codec/sort-slice.go.tmpl +++ /dev/null @@ -1,64 +0,0 @@ -// 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. - -// Code generated from sort-slice.go.tmpl - DO NOT EDIT. - -{{/* -xxxSlice -xxxIntf -xxxIntfSlice -xxxRv -xxxRvSlice - -I'm now going to create them for -- sortables -- sortablesplus - -With the parameters passed in sortables or sortablesplus, -'time, 'bytes' are special, and correspond to time.Time and []byte respectively. -*/}} - -package codec - -import "time" -import "reflect" -import "bytes" - -{{/* func init() { _ = time.Unix } */}} - -{{define "T"}} -func (p {{ .Type }}) Len() int { return len(p) } -func (p {{ .Type }}) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p {{ .Type }}) Less(i, j int) bool { - {{ if eq .Kind "bool" }} return !p[uint(i)]{{.V}} && p[uint(j)]{{.V}} - {{ else if eq .Kind "float32" }} return p[uint(i)]{{.V}} < p[uint(j)]{{.V}} || isNaN32(p[uint(i)]{{.V}}) && !isNaN32(p[uint(j)]{{.V}}) - {{ else if eq .Kind "float64" }} return p[uint(i)]{{.V}} < p[uint(j)]{{.V}} || isNaN64(p[uint(i)]{{.V}}) && !isNaN64(p[uint(j)]{{.V}}) - {{ else if eq .Kind "time" }} return p[uint(i)]{{.V}}.Before(p[uint(j)]{{.V}}) - {{ else if eq .Kind "bytes" }} return bytes.Compare(p[uint(i)]{{.V}}, p[uint(j)]{{.V}}) == -1 - {{ else }} return p[uint(i)]{{.V}} < p[uint(j)]{{.V}} - {{ end -}} -} -{{end}} - -{{range $i, $v := sortables }}{{ $t := tshort $v }} -type {{ $v }}Slice []{{ $t }} -{{template "T" args "Kind" $v "Type" (print $v "Slice") "V" ""}} -{{end}} - -{{range $i, $v := sortablesplus }}{{ $t := tshort $v }} - -type {{ $v }}Rv struct { - v {{ $t }} - r reflect.Value -} -type {{ $v }}RvSlice []{{ $v }}Rv -{{template "T" args "Kind" $v "Type" (print $v "RvSlice") "V" ".v"}} - -type {{ $v }}Intf struct { - v {{ $t }} - i interface{} -} -type {{ $v }}IntfSlice []{{ $v }}Intf -{{template "T" args "Kind" $v "Type" (print $v "IntfSlice") "V" ".v"}} - -{{end}} diff --git a/vendor/github.com/ugorji/go/codec/test.py b/vendor/github.com/ugorji/go/codec/test.py old mode 100755 new mode 100644 diff --git a/vendor/github.com/ugorji/go/codec/writer.go b/vendor/github.com/ugorji/go/codec/writer.go deleted file mode 100644 index 764790bff8d9..000000000000 --- a/vendor/github.com/ugorji/go/codec/writer.go +++ /dev/null @@ -1,267 +0,0 @@ -// 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 - -import "io" - -// encWriter abstracts writing to a byte array or to an io.Writer. -type encWriter interface { - writeb([]byte) - writestr(string) - writeqstr(string) // write string wrapped in quotes ie "..." - writen1(byte) - writen2(byte, byte) - // writen will write up to 7 bytes at a time. - writen(b [rwNLen]byte, num uint8) - end() -} - -// --------------------------------------------- - -// bufioEncWriter -type bufioEncWriter struct { - w io.Writer - - buf []byte - - n int - - b [16]byte // scratch buffer and padding (cache-aligned) -} - -func (z *bufioEncWriter) reset(w io.Writer, bufsize int, blist *bytesFreelist) { - z.w = w - z.n = 0 - if bufsize <= 0 { - bufsize = defEncByteBufSize - } - // bufsize must be >= 8, to accomodate writen methods (where n <= 8) - if bufsize <= 8 { - bufsize = 8 - } - if cap(z.buf) < bufsize { - if len(z.buf) > 0 && &z.buf[0] != &z.b[0] { - blist.put(z.buf) - } - if len(z.b) > bufsize { - z.buf = z.b[:] - } else { - z.buf = blist.get(bufsize) - } - } - z.buf = z.buf[:cap(z.buf)] -} - -//go:noinline - flush only called intermittently -func (z *bufioEncWriter) flushErr() (err error) { - n, err := z.w.Write(z.buf[:z.n]) - z.n -= n - if z.n > 0 && err == nil { - err = io.ErrShortWrite - } - if n > 0 && z.n > 0 { - copy(z.buf, z.buf[n:z.n+n]) - } - return err -} - -func (z *bufioEncWriter) flush() { - if err := z.flushErr(); err != nil { - panic(err) - } -} - -func (z *bufioEncWriter) writeb(s []byte) { -LOOP: - a := len(z.buf) - z.n - if len(s) > a { - z.n += copy(z.buf[z.n:], s[:a]) - s = s[a:] - z.flush() - goto LOOP - } - z.n += copy(z.buf[z.n:], s) -} - -func (z *bufioEncWriter) writestr(s string) { - // z.writeb(bytesView(s)) // inlined below -LOOP: - a := len(z.buf) - z.n - if len(s) > a { - z.n += copy(z.buf[z.n:], s[:a]) - s = s[a:] - z.flush() - goto LOOP - } - z.n += copy(z.buf[z.n:], s) -} - -func (z *bufioEncWriter) writeqstr(s string) { - // z.writen1('"') - // z.writestr(s) - // z.writen1('"') - - if z.n+len(s)+2 > len(z.buf) { - z.flush() - } - z.buf[z.n] = '"' - z.n++ -LOOP: - a := len(z.buf) - z.n - if len(s)+1 > a { - z.n += copy(z.buf[z.n:], s[:a]) - s = s[a:] - z.flush() - goto LOOP - } - z.n += copy(z.buf[z.n:], s) - z.buf[z.n] = '"' - z.n++ -} - -func (z *bufioEncWriter) writen1(b1 byte) { - if 1 > len(z.buf)-z.n { - z.flush() - } - z.buf[z.n] = b1 - z.n++ -} - -func (z *bufioEncWriter) writen2(b1, b2 byte) { - if 2 > len(z.buf)-z.n { - z.flush() - } - z.buf[z.n+1] = b2 - z.buf[z.n] = b1 - z.n += 2 -} - -func (z *bufioEncWriter) writen(b [rwNLen]byte, num uint8) { - if int(num) > len(z.buf)-z.n { - z.flush() - } - copy(z.buf[z.n:], b[:num]) - z.n += int(num) -} - -func (z *bufioEncWriter) endErr() (err error) { - if z.n > 0 { - err = z.flushErr() - } - return -} - -// --------------------------------------------- - -// bytesEncAppender implements encWriter and can write to an byte slice. -type bytesEncAppender struct { - b []byte - out *[]byte -} - -func (z *bytesEncAppender) writeb(s []byte) { - z.b = append(z.b, s...) -} -func (z *bytesEncAppender) writestr(s string) { - z.b = append(z.b, s...) -} -func (z *bytesEncAppender) writeqstr(s string) { - z.b = append(append(append(z.b, '"'), s...), '"') - - // z.b = append(z.b, '"') - // z.b = append(z.b, s...) - // z.b = append(z.b, '"') -} -func (z *bytesEncAppender) writen1(b1 byte) { - z.b = append(z.b, b1) -} -func (z *bytesEncAppender) writen2(b1, b2 byte) { - z.b = append(z.b, b1, b2) // cost: 81 -} -func (z *bytesEncAppender) writen(s [rwNLen]byte, num uint8) { - // if num <= rwNLen { - if int(num) <= len(s) { - z.b = append(z.b, s[:num]...) - } -} -func (z *bytesEncAppender) endErr() error { - *(z.out) = z.b - return nil -} -func (z *bytesEncAppender) reset(in []byte, out *[]byte) { - z.b = in[:0] - z.out = out -} - -// -------------------------------------------------- - -type encWr struct { - bytes bool // encoding to []byte - js bool // is json encoder? - be bool // is binary encoder? - - c containerState - - calls uint16 - - wb bytesEncAppender - wf *bufioEncWriter -} - -func (z *encWr) writeb(s []byte) { - if z.bytes { - z.wb.writeb(s) - } else { - z.wf.writeb(s) - } -} -func (z *encWr) writeqstr(s string) { - if z.bytes { - z.wb.writeqstr(s) - } else { - z.wf.writeqstr(s) - } -} -func (z *encWr) writestr(s string) { - if z.bytes { - z.wb.writestr(s) - } else { - z.wf.writestr(s) - } -} -func (z *encWr) writen1(b1 byte) { - if z.bytes { - z.wb.writen1(b1) - } else { - z.wf.writen1(b1) - } -} -func (z *encWr) writen2(b1, b2 byte) { - if z.bytes { - z.wb.writen2(b1, b2) - } else { - z.wf.writen2(b1, b2) - } -} -func (z *encWr) writen(b [rwNLen]byte, num uint8) { - if z.bytes { - z.wb.writen(b, num) - } else { - z.wf.writen(b, num) - } -} -func (z *encWr) endErr() error { - if z.bytes { - return z.wb.endErr() - } - return z.wf.endErr() -} - -func (z *encWr) end() { - if err := z.endErr(); err != nil { - panic(err) - } -} - -var _ encWriter = (*encWr)(nil) diff --git a/vendor/github.com/ugorji/go/codec/xml.go b/vendor/github.com/ugorji/go/codec/xml.go index 63fcdfca26ec..19fc36caf3cc 100644 --- a/vendor/github.com/ugorji/go/codec/xml.go +++ b/vendor/github.com/ugorji/go/codec/xml.go @@ -5,6 +5,8 @@ package codec +import "reflect" + /* A strict Non-validating namespace-aware XML 1.0 parser and (en|de)coder. @@ -421,7 +423,7 @@ func (x *xmlParser) next() (t *xmlToken) { // nextTag will parses the next element and fill up toks. // It set done flag if/once EOF is reached. func (x *xmlParser) nextTag() { - // ... + // TODO: implement. } // ----------- ENCODER ------------------- @@ -498,5 +500,9 @@ func (h *XMLHandle) newDecDriver(d *Decoder) decDriver { return &hd } +func (h *XMLHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) { + return h.SetExt(rt, tag, &extWrapper{bytesExtFailer{}, ext}) +} + var _ decDriver = (*xmlDecDriver)(nil) var _ encDriver = (*xmlEncDriver)(nil) diff --git a/vendor/modules.txt b/vendor/modules.txt index 6cc23d1a224b..e1e31396e72d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -202,6 +202,8 @@ github.com/edsrzf/mmap-go github.com/facette/natsort # github.com/fatih/color v1.7.0 github.com/fatih/color +# github.com/fluent/fluent-bit-go v0.0.0-20190925192703-ea13c021720c +github.com/fluent/fluent-bit-go/output # github.com/fsnotify/fsnotify v1.4.7 github.com/fsnotify/fsnotify # github.com/fsouza/fake-gcs-server v1.3.0 @@ -487,6 +489,8 @@ github.com/uber/jaeger-client-go/thrift-gen/agent # github.com/uber/jaeger-lib v2.0.0+incompatible github.com/uber/jaeger-lib/metrics/prometheus github.com/uber/jaeger-lib/metrics +# github.com/ugorji/go v1.1.4 +github.com/ugorji/go/codec # github.com/weaveworks/common v0.0.0-20190822150010-afb9996716e4 => github.com/sandlis/weaveworks-common v0.0.0-20190822064708-8fa0a1ca9d89 github.com/weaveworks/common/logging github.com/weaveworks/common/tracing