diff --git a/.travis.yml b/.travis.yml index 20084aa..e82e576 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: go go: - - 1.5 - 1.6 + - 1.7 script: - - make travis + - make test diff --git a/Makefile b/Makefile index 89694ee..6311819 100644 --- a/Makefile +++ b/Makefile @@ -11,44 +11,39 @@ export LD_LIBRARY_PATH export DYLD_LIBRARY_PATH export GO_BUILD_TAGS -GO=GO15VENDOREXPERIMENT="1" go - -PKGS=$(shell $(GO) list ./... | grep -v "cmd") - -all: build +all: build build: - $(GO) build -o bin/ledis-server -tags '$(GO_BUILD_TAGS)' cmd/ledis-server/* - $(GO) build -o bin/ledis-cli -tags '$(GO_BUILD_TAGS)' cmd/ledis-cli/* + rm -rf vendor && ln -s _vendor/vendor vendor + go build -o bin/ledis-benchmark -tags '$(GO_BUILD_TAGS)' cmd/ledis-benchmark/* + go build -o bin/ledis-dump -tags '$(GO_BUILD_TAGS)' cmd/ledis-dump/* + go build -o bin/ledis-load -tags '$(GO_BUILD_TAGS)' cmd/ledis-load/* + go build -o bin/ledis-repair -tags '$(GO_BUILD_TAGS)' cmd/ledis-repair/* + rm -rf vendor -build_all: build - $(GO) build -o bin/ledis-benchmark -tags '$(GO_BUILD_TAGS)' cmd/ledis-benchmark/* - $(GO) build -o bin/ledis-dump -tags '$(GO_BUILD_TAGS)' cmd/ledis-dump/* - $(GO) build -o bin/ledis-load -tags '$(GO_BUILD_TAGS)' cmd/ledis-load/* - $(GO) build -o bin/ledis-repair -tags '$(GO_BUILD_TAGS)' cmd/ledis-repair/* - test: - # use vendor for test - @rm -rf vendor && ln -s cmd/vendor vendor - @$(GO) test --race -tags '$(GO_BUILD_TAGS)' $(PKGS) - @rm -rf vendor + rm -rf vendor && ln -s _vendor/vendor vendor + go test --race -tags '$(GO_BUILD_TAGS)' -timeout 2m ./... + rm -rf vendor + clean: - $(GO) clean -i ./... + go clean -i ./... fmt: gofmt -w -s . 2>&1 | grep -vE 'vendor' | awk '{print} END{if(NR>0) {exit 1}}' -deps: - # see https://github.com/coreos/etcd/blob/master/scripts/updatedep.sh - rm -rf Godeps vendor cmd/vendor - mkdir -p cmd/vendor - ln -s cmd/vendor vendor - godep save ./... - rm -rf cmd/Godeps - rm vendor - mv Godeps cmd/ - -travis: - @rm -rf vendor && ln -s cmd/vendor vendor - @$(GO) test --race -tags '$(GO_BUILD_TAGS)' $(PKGS) \ No newline at end of file +update_vendor: + which glide >/dev/null || curl https://glide.sh/get | sh + which glide-vc || go get -v -u github.com/sgotti/glide-vc + rm -r vendor && mv _vendor/vendor vendor || true + rm -rf _vendor +ifdef PKG + glide get --strip-vendor --skip-test ${PKG} +else + glide update --strip-vendor --skip-test +endif + @echo "removing test files" + glide vc --only-code --no-tests + mkdir -p _vendor + mv vendor _vendor/vendor \ No newline at end of file diff --git a/README.md b/README.md index 64c2877..eedfd1d 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,6 @@ Create a workspace and checkout ledisdb source cd src/github.com/siddontang/ledisdb - #install godep and be sure godep command can be found in $PATH - go get github.com/tools/godep - #set build and run environment source dev.sh @@ -180,7 +177,7 @@ See [Clients](https://github.com/siddontang/ledisdb/wiki/Clients) to find or con ## Requirement -+ Go version >= 1.5 ++ Go version >= 1.6 ## Related Repos diff --git a/cmd/vendor/github.com/BurntSushi/toml/COPYING b/_vendor/vendor/github.com/BurntSushi/toml/COPYING similarity index 100% rename from cmd/vendor/github.com/BurntSushi/toml/COPYING rename to _vendor/vendor/github.com/BurntSushi/toml/COPYING diff --git a/cmd/vendor/github.com/BurntSushi/toml/decode.go b/_vendor/vendor/github.com/BurntSushi/toml/decode.go similarity index 98% rename from cmd/vendor/github.com/BurntSushi/toml/decode.go rename to _vendor/vendor/github.com/BurntSushi/toml/decode.go index 6c7d398..c26b00c 100644 --- a/cmd/vendor/github.com/BurntSushi/toml/decode.go +++ b/_vendor/vendor/github.com/BurntSushi/toml/decode.go @@ -225,6 +225,9 @@ func (md *MetaData) unify(data interface{}, rv reflect.Value) error { func (md *MetaData) unifyStruct(mapping interface{}, rv reflect.Value) error { tmap, ok := mapping.(map[string]interface{}) if !ok { + if mapping == nil { + return nil + } return mismatch(rv, "map", mapping) } @@ -267,6 +270,9 @@ func (md *MetaData) unifyStruct(mapping interface{}, rv reflect.Value) error { func (md *MetaData) unifyMap(mapping interface{}, rv reflect.Value) error { tmap, ok := mapping.(map[string]interface{}) if !ok { + if tmap == nil { + return nil + } return badtype("map", mapping) } if rv.IsNil() { @@ -292,6 +298,9 @@ func (md *MetaData) unifyMap(mapping interface{}, rv reflect.Value) error { func (md *MetaData) unifyArray(data interface{}, rv reflect.Value) error { datav := reflect.ValueOf(data) if datav.Kind() != reflect.Slice { + if !datav.IsValid() { + return nil + } return badtype("slice", data) } sliceLen := datav.Len() @@ -305,12 +314,16 @@ func (md *MetaData) unifyArray(data interface{}, rv reflect.Value) error { func (md *MetaData) unifySlice(data interface{}, rv reflect.Value) error { datav := reflect.ValueOf(data) if datav.Kind() != reflect.Slice { + if !datav.IsValid() { + return nil + } return badtype("slice", data) } - sliceLen := datav.Len() - if rv.IsNil() { - rv.Set(reflect.MakeSlice(rv.Type(), sliceLen, sliceLen)) + n := datav.Len() + if rv.IsNil() || rv.Cap() < n { + rv.Set(reflect.MakeSlice(rv.Type(), n, n)) } + rv.SetLen(n) return md.unifySliceArray(datav, rv) } diff --git a/cmd/vendor/github.com/BurntSushi/toml/decode_meta.go b/_vendor/vendor/github.com/BurntSushi/toml/decode_meta.go similarity index 100% rename from cmd/vendor/github.com/BurntSushi/toml/decode_meta.go rename to _vendor/vendor/github.com/BurntSushi/toml/decode_meta.go diff --git a/cmd/vendor/github.com/BurntSushi/toml/doc.go b/_vendor/vendor/github.com/BurntSushi/toml/doc.go similarity index 100% rename from cmd/vendor/github.com/BurntSushi/toml/doc.go rename to _vendor/vendor/github.com/BurntSushi/toml/doc.go diff --git a/cmd/vendor/github.com/BurntSushi/toml/encode.go b/_vendor/vendor/github.com/BurntSushi/toml/encode.go similarity index 94% rename from cmd/vendor/github.com/BurntSushi/toml/encode.go rename to _vendor/vendor/github.com/BurntSushi/toml/encode.go index c7e227c..4e4c97a 100644 --- a/cmd/vendor/github.com/BurntSushi/toml/encode.go +++ b/_vendor/vendor/github.com/BurntSushi/toml/encode.go @@ -306,19 +306,30 @@ func (enc *Encoder) eStruct(key Key, rv reflect.Value) { addFields = func(rt reflect.Type, rv reflect.Value, start []int) { for i := 0; i < rt.NumField(); i++ { f := rt.Field(i) - // skip unexporded fields - if f.PkgPath != "" { + // skip unexported fields + if f.PkgPath != "" && !f.Anonymous { continue } frv := rv.Field(i) if f.Anonymous { - frv := eindirect(frv) - t := frv.Type() - if t.Kind() != reflect.Struct { - encPanic(errAnonNonStruct) + t := f.Type + switch t.Kind() { + case reflect.Struct: + addFields(t, frv, f.Index) + continue + case reflect.Ptr: + if t.Elem().Kind() == reflect.Struct { + if !frv.IsNil() { + addFields(t.Elem(), frv.Elem(), f.Index) + } + continue + } + // Fall through to the normal field encoding logic below + // for non-struct anonymous fields. } - addFields(t, frv, f.Index) - } else if typeIsHash(tomlTypeOfGo(frv)) { + } + + if typeIsHash(tomlTypeOfGo(frv)) { fieldsSub = append(fieldsSub, append(start, f.Index...)) } else { fieldsDirect = append(fieldsDirect, append(start, f.Index...)) @@ -336,15 +347,14 @@ func (enc *Encoder) eStruct(key Key, rv reflect.Value) { continue } - keyName := sft.Tag.Get("toml") - if keyName == "-" { + tag := sft.Tag.Get("toml") + if tag == "-" { continue } + keyName, opts := getOptions(tag) if keyName == "" { keyName = sft.Name } - - keyName, opts := getOptions(keyName) if _, ok := opts["omitempty"]; ok && isEmpty(sf) { continue } else if _, ok := opts["omitzero"]; ok && isZero(sf) { @@ -457,34 +467,22 @@ func getOptions(keyName string) (string, map[string]struct{}) { func isZero(rv reflect.Value) bool { switch rv.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - if rv.Int() == 0 { - return true - } + return rv.Int() == 0 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - if rv.Uint() == 0 { - return true - } + return rv.Uint() == 0 case reflect.Float32, reflect.Float64: - if rv.Float() == 0.0 { - return true - } + return rv.Float() == 0.0 } - return false } func isEmpty(rv reflect.Value) bool { switch rv.Kind() { - case reflect.String: - if len(strings.TrimSpace(rv.String())) == 0 { - return true - } - case reflect.Array, reflect.Slice, reflect.Map: - if rv.Len() == 0 { - return true - } + case reflect.Array, reflect.Slice, reflect.Map, reflect.String: + return rv.Len() == 0 + case reflect.Bool: + return !rv.Bool() } - return false } diff --git a/cmd/vendor/github.com/BurntSushi/toml/encoding_types.go b/_vendor/vendor/github.com/BurntSushi/toml/encoding_types.go similarity index 100% rename from cmd/vendor/github.com/BurntSushi/toml/encoding_types.go rename to _vendor/vendor/github.com/BurntSushi/toml/encoding_types.go diff --git a/cmd/vendor/github.com/BurntSushi/toml/encoding_types_1.1.go b/_vendor/vendor/github.com/BurntSushi/toml/encoding_types_1.1.go similarity index 100% rename from cmd/vendor/github.com/BurntSushi/toml/encoding_types_1.1.go rename to _vendor/vendor/github.com/BurntSushi/toml/encoding_types_1.1.go diff --git a/cmd/vendor/github.com/BurntSushi/toml/lex.go b/_vendor/vendor/github.com/BurntSushi/toml/lex.go similarity index 99% rename from cmd/vendor/github.com/BurntSushi/toml/lex.go rename to _vendor/vendor/github.com/BurntSushi/toml/lex.go index 2191228..9b20b3a 100644 --- a/cmd/vendor/github.com/BurntSushi/toml/lex.go +++ b/_vendor/vendor/github.com/BurntSushi/toml/lex.go @@ -272,8 +272,6 @@ func lexTableNameStart(lx *lexer) stateFn { lx.ignore() lx.push(lexTableNameEnd) return lexValue // reuse string lexing - case isWhitespace(r): - return lexTableNameStart default: return lexBareTableName } @@ -560,7 +558,6 @@ func lexMultilineRawString(lx *lexer) stateFn { func lexMultilineStringEscape(lx *lexer) stateFn { // Handle the special case first: if isNL(lx.next()) { - lx.next() return lexMultilineString } else { lx.backup() diff --git a/cmd/vendor/github.com/BurntSushi/toml/parse.go b/_vendor/vendor/github.com/BurntSushi/toml/parse.go similarity index 97% rename from cmd/vendor/github.com/BurntSushi/toml/parse.go rename to _vendor/vendor/github.com/BurntSushi/toml/parse.go index c6069be..6a82e84 100644 --- a/cmd/vendor/github.com/BurntSushi/toml/parse.go +++ b/_vendor/vendor/github.com/BurntSushi/toml/parse.go @@ -81,7 +81,7 @@ func (p *parser) next() item { } func (p *parser) bug(format string, v ...interface{}) { - log.Fatalf("BUG: %s\n\n", fmt.Sprintf(format, v...)) + log.Panicf("BUG: %s\n\n", fmt.Sprintf(format, v...)) } func (p *parser) expect(typ itemType) item { @@ -216,7 +216,7 @@ func (p *parser) value(it item) (interface{}, tomlType) { case itemDatetime: t, err := time.Parse("2006-01-02T15:04:05Z", it.val) if err != nil { - p.bug("Expected Zulu formatted DateTime, but got '%s'.", it.val) + p.panicf("Invalid RFC3339 Zulu DateTime: '%s'.", it.val) } return t, p.typeOfPrimitive(it) case itemArray: @@ -401,7 +401,7 @@ func stripFirstNewline(s string) string { if len(s) == 0 || s[0] != '\n' { return s } - return s[1:len(s)] + return s[1:] } func stripEscapedWhitespace(s string) string { @@ -481,12 +481,7 @@ func (p *parser) asciiEscapeToUnicode(bs []byte) rune { p.bug("Could not parse '%s' as a hexadecimal number, but the "+ "lexer claims it's OK: %s", s, err) } - - // BUG(burntsushi) - // I honestly don't understand how this works. I can't seem - // to find a way to make this fail. I figured this would fail on invalid - // UTF-8 characters like U+DCFF, but it doesn't. - if !utf8.ValidString(string(rune(hex))) { + if !utf8.ValidRune(rune(hex)) { p.panicf("Escaped character '\\u%s' is not valid UTF-8.", s) } return rune(hex) diff --git a/cmd/vendor/github.com/BurntSushi/toml/type_check.go b/_vendor/vendor/github.com/BurntSushi/toml/type_check.go similarity index 100% rename from cmd/vendor/github.com/BurntSushi/toml/type_check.go rename to _vendor/vendor/github.com/BurntSushi/toml/type_check.go diff --git a/cmd/vendor/github.com/BurntSushi/toml/type_fields.go b/_vendor/vendor/github.com/BurntSushi/toml/type_fields.go similarity index 98% rename from cmd/vendor/github.com/BurntSushi/toml/type_fields.go rename to _vendor/vendor/github.com/BurntSushi/toml/type_fields.go index 7592f87..6da608a 100644 --- a/cmd/vendor/github.com/BurntSushi/toml/type_fields.go +++ b/_vendor/vendor/github.com/BurntSushi/toml/type_fields.go @@ -92,10 +92,10 @@ func typeFields(t reflect.Type) []field { // Scan f.typ for fields to include. for i := 0; i < f.typ.NumField(); i++ { sf := f.typ.Field(i) - if sf.PkgPath != "" { // unexported + if sf.PkgPath != "" && !sf.Anonymous { // unexported continue } - name := sf.Tag.Get("toml") + name, _ := getOptions(sf.Tag.Get("toml")) if name == "-" { continue } diff --git a/cmd/vendor/github.com/cupcake/rdb/LICENCE b/_vendor/vendor/github.com/cupcake/rdb/LICENCE similarity index 100% rename from cmd/vendor/github.com/cupcake/rdb/LICENCE rename to _vendor/vendor/github.com/cupcake/rdb/LICENCE diff --git a/cmd/vendor/github.com/cupcake/rdb/crc64/crc64.go b/_vendor/vendor/github.com/cupcake/rdb/crc64/crc64.go similarity index 99% rename from cmd/vendor/github.com/cupcake/rdb/crc64/crc64.go rename to _vendor/vendor/github.com/cupcake/rdb/crc64/crc64.go index 1a0c82d..54fed9c 100644 --- a/cmd/vendor/github.com/cupcake/rdb/crc64/crc64.go +++ b/_vendor/vendor/github.com/cupcake/rdb/crc64/crc64.go @@ -35,7 +35,7 @@ type digest struct { crc uint64 } -func New() hash.Hash { +func New() hash.Hash64 { return &digest{} } diff --git a/cmd/vendor/github.com/cupcake/rdb/decoder.go b/_vendor/vendor/github.com/cupcake/rdb/decoder.go similarity index 93% rename from cmd/vendor/github.com/cupcake/rdb/decoder.go rename to _vendor/vendor/github.com/cupcake/rdb/decoder.go index 0e0729b..dd3993b 100644 --- a/cmd/vendor/github.com/cupcake/rdb/decoder.go +++ b/_vendor/vendor/github.com/cupcake/rdb/decoder.go @@ -20,6 +20,10 @@ type Decoder interface { // StartDatabase is called when database n starts. // Once a database starts, another database will not start until EndDatabase is called. StartDatabase(n int) + // AUX field + Aux(key, value []byte) + // ResizeDB hint + ResizeDatabase(dbSize, expiresSize uint32) // Set is called once for each string key. Set(key, value []byte, expiry int64) // StartHash is called at the beginning of a hash. @@ -38,6 +42,7 @@ type Decoder interface { EndSet(key []byte) // StartList is called at the beginning of a list. // Rpush will be called exactly length times before EndList. + // If length of the list is not known, then length is -1 StartList(key []byte, length, expiry int64) // Rpush is called once for each value in a list. Rpush(key, value []byte) @@ -102,11 +107,12 @@ const ( TypeZSet ValueType = 3 TypeHash ValueType = 4 - TypeHashZipmap ValueType = 9 - TypeListZiplist ValueType = 10 - TypeSetIntset ValueType = 11 - TypeZSetZiplist ValueType = 12 - TypeHashZiplist ValueType = 13 + TypeHashZipmap ValueType = 9 + TypeListZiplist ValueType = 10 + TypeSetIntset ValueType = 11 + TypeZSetZiplist ValueType = 12 + TypeHashZiplist ValueType = 13 + TypeListQuicklist ValueType = 14 ) const ( @@ -115,6 +121,8 @@ const ( rdb32bitLen = 2 rdbEncVal = 3 + rdbFlagAux = 0xfa + rdbFlagResizeDB = 0xfb rdbFlagExpiryMS = 0xfc rdbFlagExpiry = 0xfd rdbFlagSelectDB = 0xfe @@ -154,6 +162,26 @@ func (d *decode) decode() error { return err } switch objType { + case rdbFlagAux: + auxKey, err := d.readString() + if err != nil { + return err + } + auxVal, err := d.readString() + if err != nil { + return err + } + d.event.Aux(auxKey, auxVal) + case rdbFlagResizeDB: + dbSize, _, err := d.readLength() + if err != nil { + return err + } + expiresSize, _, err := d.readLength() + if err != nil { + return err + } + d.event.ResizeDatabase(dbSize, expiresSize) case rdbFlagExpiryMS: _, err := io.ReadFull(d.r, d.intBuf) if err != nil { @@ -188,6 +216,7 @@ func (d *decode) decode() error { if err != nil { return err } + expiry = 0 } } @@ -216,6 +245,16 @@ func (d *decode) readObject(key []byte, typ ValueType, expiry int64) error { d.event.Rpush(key, value) } d.event.EndList(key) + case TypeListQuicklist: + length, _, err := d.readLength() + if err != nil { + return err + } + d.event.StartList(key, int64(-1), expiry) + for i := uint32(0); i < length; i++ { + d.readZiplist(key, 0, false) + } + d.event.EndList(key) case TypeSet: cardinality, _, err := d.readLength() if err != nil { @@ -269,7 +308,7 @@ func (d *decode) readObject(key []byte, typ ValueType, expiry int64) error { case TypeHashZipmap: return d.readZipmap(key, expiry) case TypeListZiplist: - return d.readZiplist(key, expiry) + return d.readZiplist(key, expiry, true) case TypeSetIntset: return d.readIntset(key, expiry) case TypeZSetZiplist: @@ -378,7 +417,7 @@ func readZipmapItemLength(buf *sliceBuffer, readFree bool) (int, int, error) { return int(b), int(free), err } -func (d *decode) readZiplist(key []byte, expiry int64) error { +func (d *decode) readZiplist(key []byte, expiry int64, addListEvents bool) error { ziplist, err := d.readString() if err != nil { return err @@ -388,7 +427,9 @@ func (d *decode) readZiplist(key []byte, expiry int64) error { if err != nil { return err } - d.event.StartList(key, length, expiry) + if addListEvents { + d.event.StartList(key, length, expiry) + } for i := int64(0); i < length; i++ { entry, err := readZiplistEntry(buf) if err != nil { @@ -396,7 +437,9 @@ func (d *decode) readZiplist(key []byte, expiry int64) error { } d.event.Rpush(key, entry) } - d.event.EndList(key) + if addListEvents { + d.event.EndList(key) + } return nil } @@ -585,7 +628,7 @@ func (d *decode) checkHeader() error { } version, _ := strconv.ParseInt(string(header[5:]), 10, 64) - if version < 1 || version > 6 { + if version < 1 || version > 7 { return fmt.Errorf("rdb: invalid RDB version number %d", version) } diff --git a/cmd/vendor/github.com/cupcake/rdb/encoder.go b/_vendor/vendor/github.com/cupcake/rdb/encoder.go similarity index 100% rename from cmd/vendor/github.com/cupcake/rdb/encoder.go rename to _vendor/vendor/github.com/cupcake/rdb/encoder.go diff --git a/cmd/vendor/github.com/cupcake/rdb/nopdecoder/nop_decoder.go b/_vendor/vendor/github.com/cupcake/rdb/nopdecoder/nop_decoder.go similarity index 90% rename from cmd/vendor/github.com/cupcake/rdb/nopdecoder/nop_decoder.go rename to _vendor/vendor/github.com/cupcake/rdb/nopdecoder/nop_decoder.go index 5ddfe5d..de93a69 100644 --- a/cmd/vendor/github.com/cupcake/rdb/nopdecoder/nop_decoder.go +++ b/_vendor/vendor/github.com/cupcake/rdb/nopdecoder/nop_decoder.go @@ -5,6 +5,8 @@ type NopDecoder struct{} func (d NopDecoder) StartRDB() {} func (d NopDecoder) StartDatabase(n int) {} +func (d NopDecoder) Aux(key, value []byte) {} +func (d NopDecoder) ResizeDatabase(dbSize, expiresSize uint32) {} func (d NopDecoder) EndDatabase(n int) {} func (d NopDecoder) EndRDB() {} func (d NopDecoder) Set(key, value []byte, expiry int64) {} diff --git a/cmd/vendor/github.com/cupcake/rdb/slice_buffer.go b/_vendor/vendor/github.com/cupcake/rdb/slice_buffer.go similarity index 100% rename from cmd/vendor/github.com/cupcake/rdb/slice_buffer.go rename to _vendor/vendor/github.com/cupcake/rdb/slice_buffer.go diff --git a/cmd/vendor/github.com/edsrzf/mmap-go/LICENSE b/_vendor/vendor/github.com/edsrzf/mmap-go/LICENSE similarity index 100% rename from cmd/vendor/github.com/edsrzf/mmap-go/LICENSE rename to _vendor/vendor/github.com/edsrzf/mmap-go/LICENSE diff --git a/cmd/vendor/github.com/edsrzf/mmap-go/mmap.go b/_vendor/vendor/github.com/edsrzf/mmap-go/mmap.go similarity index 100% rename from cmd/vendor/github.com/edsrzf/mmap-go/mmap.go rename to _vendor/vendor/github.com/edsrzf/mmap-go/mmap.go diff --git a/cmd/vendor/github.com/edsrzf/mmap-go/mmap_unix.go b/_vendor/vendor/github.com/edsrzf/mmap-go/mmap_unix.go similarity index 90% rename from cmd/vendor/github.com/edsrzf/mmap-go/mmap_unix.go rename to _vendor/vendor/github.com/edsrzf/mmap-go/mmap_unix.go index e5e1236..4af9842 100644 --- a/cmd/vendor/github.com/edsrzf/mmap-go/mmap_unix.go +++ b/_vendor/vendor/github.com/edsrzf/mmap-go/mmap_unix.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux openbsd solaris +// +build darwin dragonfly freebsd linux openbsd solaris netbsd package mmap @@ -35,7 +35,7 @@ func mmap(len int, inprot, inflags, fd uintptr, off int64) ([]byte, error) { } func flush(addr, len uintptr) error { - _, _, errno := syscall.Syscall(syscall.SYS_MSYNC, addr, len, syscall.MS_SYNC) + _, _, errno := syscall.Syscall(_SYS_MSYNC, addr, len, _MS_SYNC) if errno != 0 { return syscall.Errno(errno) } diff --git a/cmd/vendor/github.com/edsrzf/mmap-go/mmap_windows.go b/_vendor/vendor/github.com/edsrzf/mmap-go/mmap_windows.go similarity index 82% rename from cmd/vendor/github.com/edsrzf/mmap-go/mmap_windows.go rename to _vendor/vendor/github.com/edsrzf/mmap-go/mmap_windows.go index 1e0bd2e..c3d2d02 100644 --- a/cmd/vendor/github.com/edsrzf/mmap-go/mmap_windows.go +++ b/_vendor/vendor/github.com/edsrzf/mmap-go/mmap_windows.go @@ -73,7 +73,20 @@ func mmap(len int, prot, flags, hfile uintptr, off int64) ([]byte, error) { func flush(addr, len uintptr) error { errno := syscall.FlushViewOfFile(addr, len) - return os.NewSyscallError("FlushViewOfFile", errno) + if errno != nil { + return os.NewSyscallError("FlushViewOfFile", errno) + } + + handleLock.Lock() + defer handleLock.Unlock() + handle, ok := handleMap[addr] + if !ok { + // should be impossible; we would've errored above + return errors.New("unknown base address") + } + + errno = syscall.FlushFileBuffers(handle) + return os.NewSyscallError("FlushFileBuffers", errno) } func lock(addr, len uintptr) error { @@ -88,13 +101,18 @@ func unlock(addr, len uintptr) error { func unmap(addr, len uintptr) error { flush(addr, len) + // Lock the UnmapViewOfFile along with the handleMap deletion. + // As soon as we unmap the view, the OS is free to give the + // same addr to another new map. We don't want another goroutine + // to insert and remove the same addr into handleMap while + // we're trying to remove our old addr/handle pair. + handleLock.Lock() + defer handleLock.Unlock() err := syscall.UnmapViewOfFile(addr) if err != nil { return err } - handleLock.Lock() - defer handleLock.Unlock() handle, ok := handleMap[addr] if !ok { // should be impossible; we would've errored above diff --git a/_vendor/vendor/github.com/edsrzf/mmap-go/msync_netbsd.go b/_vendor/vendor/github.com/edsrzf/mmap-go/msync_netbsd.go new file mode 100644 index 0000000..a64b003 --- /dev/null +++ b/_vendor/vendor/github.com/edsrzf/mmap-go/msync_netbsd.go @@ -0,0 +1,8 @@ +// Copyright 2011 Evan Shaw. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mmap + +const _SYS_MSYNC = 277 +const _MS_SYNC = 0x04 diff --git a/_vendor/vendor/github.com/edsrzf/mmap-go/msync_unix.go b/_vendor/vendor/github.com/edsrzf/mmap-go/msync_unix.go new file mode 100644 index 0000000..91ee5f4 --- /dev/null +++ b/_vendor/vendor/github.com/edsrzf/mmap-go/msync_unix.go @@ -0,0 +1,14 @@ +// Copyright 2011 Evan Shaw. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build darwin dragonfly freebsd linux openbsd solaris + +package mmap + +import ( + "syscall" +) + +const _SYS_MSYNC = syscall.SYS_MSYNC +const _MS_SYNC = syscall.MS_SYNC diff --git a/cmd/vendor/github.com/golang/snappy/LICENSE b/_vendor/vendor/github.com/golang/snappy/LICENSE similarity index 100% rename from cmd/vendor/github.com/golang/snappy/LICENSE rename to _vendor/vendor/github.com/golang/snappy/LICENSE diff --git a/cmd/vendor/github.com/golang/snappy/decode.go b/_vendor/vendor/github.com/golang/snappy/decode.go similarity index 69% rename from cmd/vendor/github.com/golang/snappy/decode.go rename to _vendor/vendor/github.com/golang/snappy/decode.go index e7f1259..72efb03 100644 --- a/cmd/vendor/github.com/golang/snappy/decode.go +++ b/_vendor/vendor/github.com/golang/snappy/decode.go @@ -17,6 +17,8 @@ var ( ErrTooLarge = errors.New("snappy: decoded block is too large") // ErrUnsupported reports that the input isn't supported. ErrUnsupported = errors.New("snappy: unsupported input") + + errUnsupportedLiteralLength = errors.New("snappy: unsupported literal length") ) // DecodedLen returns the length of the decoded block. @@ -40,96 +42,33 @@ func decodedLen(src []byte) (blockLen, headerLen int, err error) { return int(v), n, nil } +const ( + decodeErrCodeCorrupt = 1 + decodeErrCodeUnsupportedLiteralLength = 2 +) + // Decode returns the decoded form of src. The returned slice may be a sub- // slice of dst if dst was large enough to hold the entire decoded block. // Otherwise, a newly allocated slice will be returned. -// It is valid to pass a nil dst. +// +// The dst and src must not overlap. It is valid to pass a nil dst. func Decode(dst, src []byte) ([]byte, error) { dLen, s, err := decodedLen(src) if err != nil { return nil, err } - if len(dst) < dLen { + if dLen <= len(dst) { + dst = dst[:dLen] + } else { dst = make([]byte, dLen) } - - var d, offset, length int - for s < len(src) { - switch src[s] & 0x03 { - case tagLiteral: - x := uint(src[s] >> 2) - switch { - case x < 60: - s++ - case x == 60: - s += 2 - if s > len(src) { - return nil, ErrCorrupt - } - x = uint(src[s-1]) - case x == 61: - s += 3 - if s > len(src) { - return nil, ErrCorrupt - } - x = uint(src[s-2]) | uint(src[s-1])<<8 - case x == 62: - s += 4 - if s > len(src) { - return nil, ErrCorrupt - } - x = uint(src[s-3]) | uint(src[s-2])<<8 | uint(src[s-1])<<16 - case x == 63: - s += 5 - if s > len(src) { - return nil, ErrCorrupt - } - x = uint(src[s-4]) | uint(src[s-3])<<8 | uint(src[s-2])<<16 | uint(src[s-1])<<24 - } - length = int(x + 1) - if length <= 0 { - return nil, errors.New("snappy: unsupported literal length") - } - if length > len(dst)-d || length > len(src)-s { - return nil, ErrCorrupt - } - copy(dst[d:], src[s:s+length]) - d += length - s += length - continue - - case tagCopy1: - s += 2 - if s > len(src) { - return nil, ErrCorrupt - } - length = 4 + int(src[s-2])>>2&0x7 - offset = int(src[s-2])&0xe0<<3 | int(src[s-1]) - - case tagCopy2: - s += 3 - if s > len(src) { - return nil, ErrCorrupt - } - length = 1 + int(src[s-3])>>2 - offset = int(src[s-2]) | int(src[s-1])<<8 - - case tagCopy4: - return nil, errors.New("snappy: unsupported COPY_4 tag") - } - - end := d + length - if offset > d || end > len(dst) { - return nil, ErrCorrupt - } - for ; d < end; d++ { - dst[d] = dst[d-offset] - } + switch decode(dst, src[s:]) { + case 0: + return dst, nil + case decodeErrCodeUnsupportedLiteralLength: + return nil, errUnsupportedLiteralLength } - if d != dLen { - return nil, ErrCorrupt - } - return dst[:d], nil + return nil, ErrCorrupt } // NewReader returns a new Reader that decompresses from r, using the framing @@ -138,12 +77,12 @@ func Decode(dst, src []byte) ([]byte, error) { func NewReader(r io.Reader) *Reader { return &Reader{ r: r, - decoded: make([]byte, maxUncompressedChunkLen), - buf: make([]byte, MaxEncodedLen(maxUncompressedChunkLen)+checksumSize), + decoded: make([]byte, maxBlockSize), + buf: make([]byte, maxEncodedLenOfMaxBlockSize+checksumSize), } } -// Reader is an io.Reader than can read Snappy-compressed bytes. +// Reader is an io.Reader that can read Snappy-compressed bytes. type Reader struct { r io.Reader err error @@ -165,9 +104,9 @@ func (r *Reader) Reset(reader io.Reader) { r.readHeader = false } -func (r *Reader) readFull(p []byte) (ok bool) { +func (r *Reader) readFull(p []byte, allowEOF bool) (ok bool) { if _, r.err = io.ReadFull(r.r, p); r.err != nil { - if r.err == io.ErrUnexpectedEOF { + if r.err == io.ErrUnexpectedEOF || (r.err == io.EOF && !allowEOF) { r.err = ErrCorrupt } return false @@ -186,7 +125,7 @@ func (r *Reader) Read(p []byte) (int, error) { r.i += n return n, nil } - if !r.readFull(r.buf[:4]) { + if !r.readFull(r.buf[:4], true) { return 0, r.err } chunkType := r.buf[0] @@ -213,7 +152,7 @@ func (r *Reader) Read(p []byte) (int, error) { return 0, r.err } buf := r.buf[:chunkLen] - if !r.readFull(buf) { + if !r.readFull(buf, false) { return 0, r.err } checksum := uint32(buf[0]) | uint32(buf[1])<<8 | uint32(buf[2])<<16 | uint32(buf[3])<<24 @@ -246,13 +185,17 @@ func (r *Reader) Read(p []byte) (int, error) { return 0, r.err } buf := r.buf[:checksumSize] - if !r.readFull(buf) { + if !r.readFull(buf, false) { return 0, r.err } checksum := uint32(buf[0]) | uint32(buf[1])<<8 | uint32(buf[2])<<16 | uint32(buf[3])<<24 // Read directly into r.decoded instead of via r.buf. n := chunkLen - checksumSize - if !r.readFull(r.decoded[:n]) { + if n > len(r.decoded) { + r.err = ErrCorrupt + return 0, r.err + } + if !r.readFull(r.decoded[:n], false) { return 0, r.err } if crc(r.decoded[:n]) != checksum { @@ -268,7 +211,7 @@ func (r *Reader) Read(p []byte) (int, error) { r.err = ErrCorrupt return 0, r.err } - if !r.readFull(r.buf[:len(magicBody)]) { + if !r.readFull(r.buf[:len(magicBody)], false) { return 0, r.err } for i := 0; i < len(magicBody); i++ { @@ -287,7 +230,7 @@ func (r *Reader) Read(p []byte) (int, error) { } // Section 4.4 Padding (chunk type 0xfe). // Section 4.6. Reserved skippable chunks (chunk types 0x80-0xfd). - if !r.readFull(r.buf[:chunkLen]) { + if !r.readFull(r.buf[:chunkLen], false) { return 0, r.err } } diff --git a/_vendor/vendor/github.com/golang/snappy/decode_amd64.go b/_vendor/vendor/github.com/golang/snappy/decode_amd64.go new file mode 100644 index 0000000..fcd192b --- /dev/null +++ b/_vendor/vendor/github.com/golang/snappy/decode_amd64.go @@ -0,0 +1,14 @@ +// Copyright 2016 The Snappy-Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !appengine +// +build gc +// +build !noasm + +package snappy + +// decode has the same semantics as in decode_other.go. +// +//go:noescape +func decode(dst, src []byte) int diff --git a/_vendor/vendor/github.com/golang/snappy/decode_amd64.s b/_vendor/vendor/github.com/golang/snappy/decode_amd64.s new file mode 100644 index 0000000..e6179f6 --- /dev/null +++ b/_vendor/vendor/github.com/golang/snappy/decode_amd64.s @@ -0,0 +1,490 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !appengine +// +build gc +// +build !noasm + +#include "textflag.h" + +// The asm code generally follows the pure Go code in decode_other.go, except +// where marked with a "!!!". + +// func decode(dst, src []byte) int +// +// All local variables fit into registers. The non-zero stack size is only to +// spill registers and push args when issuing a CALL. The register allocation: +// - AX scratch +// - BX scratch +// - CX length or x +// - DX offset +// - SI &src[s] +// - DI &dst[d] +// + R8 dst_base +// + R9 dst_len +// + R10 dst_base + dst_len +// + R11 src_base +// + R12 src_len +// + R13 src_base + src_len +// - R14 used by doCopy +// - R15 used by doCopy +// +// The registers R8-R13 (marked with a "+") are set at the start of the +// function, and after a CALL returns, and are not otherwise modified. +// +// The d variable is implicitly DI - R8, and len(dst)-d is R10 - DI. +// The s variable is implicitly SI - R11, and len(src)-s is R13 - SI. +TEXT ·decode(SB), NOSPLIT, $48-56 + // Initialize SI, DI and R8-R13. + MOVQ dst_base+0(FP), R8 + MOVQ dst_len+8(FP), R9 + MOVQ R8, DI + MOVQ R8, R10 + ADDQ R9, R10 + MOVQ src_base+24(FP), R11 + MOVQ src_len+32(FP), R12 + MOVQ R11, SI + MOVQ R11, R13 + ADDQ R12, R13 + +loop: + // for s < len(src) + CMPQ SI, R13 + JEQ end + + // CX = uint32(src[s]) + // + // switch src[s] & 0x03 + MOVBLZX (SI), CX + MOVL CX, BX + ANDL $3, BX + CMPL BX, $1 + JAE tagCopy + + // ---------------------------------------- + // The code below handles literal tags. + + // case tagLiteral: + // x := uint32(src[s] >> 2) + // switch + SHRL $2, CX + CMPL CX, $60 + JAE tagLit60Plus + + // case x < 60: + // s++ + INCQ SI + +doLit: + // This is the end of the inner "switch", when we have a literal tag. + // + // We assume that CX == x and x fits in a uint32, where x is the variable + // used in the pure Go decode_other.go code. + + // length = int(x) + 1 + // + // Unlike the pure Go code, we don't need to check if length <= 0 because + // CX can hold 64 bits, so the increment cannot overflow. + INCQ CX + + // Prepare to check if copying length bytes will run past the end of dst or + // src. + // + // AX = len(dst) - d + // BX = len(src) - s + MOVQ R10, AX + SUBQ DI, AX + MOVQ R13, BX + SUBQ SI, BX + + // !!! Try a faster technique for short (16 or fewer bytes) copies. + // + // if length > 16 || len(dst)-d < 16 || len(src)-s < 16 { + // goto callMemmove // Fall back on calling runtime·memmove. + // } + // + // The C++ snappy code calls this TryFastAppend. It also checks len(src)-s + // against 21 instead of 16, because it cannot assume that all of its input + // is contiguous in memory and so it needs to leave enough source bytes to + // read the next tag without refilling buffers, but Go's Decode assumes + // contiguousness (the src argument is a []byte). + CMPQ CX, $16 + JGT callMemmove + CMPQ AX, $16 + JLT callMemmove + CMPQ BX, $16 + JLT callMemmove + + // !!! Implement the copy from src to dst as a 16-byte load and store. + // (Decode's documentation says that dst and src must not overlap.) + // + // This always copies 16 bytes, instead of only length bytes, but that's + // OK. If the input is a valid Snappy encoding then subsequent iterations + // will fix up the overrun. Otherwise, Decode returns a nil []byte (and a + // non-nil error), so the overrun will be ignored. + // + // Note that on amd64, it is legal and cheap to issue unaligned 8-byte or + // 16-byte loads and stores. This technique probably wouldn't be as + // effective on architectures that are fussier about alignment. + MOVOU 0(SI), X0 + MOVOU X0, 0(DI) + + // d += length + // s += length + ADDQ CX, DI + ADDQ CX, SI + JMP loop + +callMemmove: + // if length > len(dst)-d || length > len(src)-s { etc } + CMPQ CX, AX + JGT errCorrupt + CMPQ CX, BX + JGT errCorrupt + + // copy(dst[d:], src[s:s+length]) + // + // This means calling runtime·memmove(&dst[d], &src[s], length), so we push + // DI, SI and CX as arguments. Coincidentally, we also need to spill those + // three registers to the stack, to save local variables across the CALL. + MOVQ DI, 0(SP) + MOVQ SI, 8(SP) + MOVQ CX, 16(SP) + MOVQ DI, 24(SP) + MOVQ SI, 32(SP) + MOVQ CX, 40(SP) + CALL runtime·memmove(SB) + + // Restore local variables: unspill registers from the stack and + // re-calculate R8-R13. + MOVQ 24(SP), DI + MOVQ 32(SP), SI + MOVQ 40(SP), CX + MOVQ dst_base+0(FP), R8 + MOVQ dst_len+8(FP), R9 + MOVQ R8, R10 + ADDQ R9, R10 + MOVQ src_base+24(FP), R11 + MOVQ src_len+32(FP), R12 + MOVQ R11, R13 + ADDQ R12, R13 + + // d += length + // s += length + ADDQ CX, DI + ADDQ CX, SI + JMP loop + +tagLit60Plus: + // !!! This fragment does the + // + // s += x - 58; if uint(s) > uint(len(src)) { etc } + // + // checks. In the asm version, we code it once instead of once per switch case. + ADDQ CX, SI + SUBQ $58, SI + MOVQ SI, BX + SUBQ R11, BX + CMPQ BX, R12 + JA errCorrupt + + // case x == 60: + CMPL CX, $61 + JEQ tagLit61 + JA tagLit62Plus + + // x = uint32(src[s-1]) + MOVBLZX -1(SI), CX + JMP doLit + +tagLit61: + // case x == 61: + // x = uint32(src[s-2]) | uint32(src[s-1])<<8 + MOVWLZX -2(SI), CX + JMP doLit + +tagLit62Plus: + CMPL CX, $62 + JA tagLit63 + + // case x == 62: + // x = uint32(src[s-3]) | uint32(src[s-2])<<8 | uint32(src[s-1])<<16 + MOVWLZX -3(SI), CX + MOVBLZX -1(SI), BX + SHLL $16, BX + ORL BX, CX + JMP doLit + +tagLit63: + // case x == 63: + // x = uint32(src[s-4]) | uint32(src[s-3])<<8 | uint32(src[s-2])<<16 | uint32(src[s-1])<<24 + MOVL -4(SI), CX + JMP doLit + +// The code above handles literal tags. +// ---------------------------------------- +// The code below handles copy tags. + +tagCopy4: + // case tagCopy4: + // s += 5 + ADDQ $5, SI + + // if uint(s) > uint(len(src)) { etc } + MOVQ SI, BX + SUBQ R11, BX + CMPQ BX, R12 + JA errCorrupt + + // length = 1 + int(src[s-5])>>2 + SHRQ $2, CX + INCQ CX + + // offset = int(uint32(src[s-4]) | uint32(src[s-3])<<8 | uint32(src[s-2])<<16 | uint32(src[s-1])<<24) + MOVLQZX -4(SI), DX + JMP doCopy + +tagCopy2: + // case tagCopy2: + // s += 3 + ADDQ $3, SI + + // if uint(s) > uint(len(src)) { etc } + MOVQ SI, BX + SUBQ R11, BX + CMPQ BX, R12 + JA errCorrupt + + // length = 1 + int(src[s-3])>>2 + SHRQ $2, CX + INCQ CX + + // offset = int(uint32(src[s-2]) | uint32(src[s-1])<<8) + MOVWQZX -2(SI), DX + JMP doCopy + +tagCopy: + // We have a copy tag. We assume that: + // - BX == src[s] & 0x03 + // - CX == src[s] + CMPQ BX, $2 + JEQ tagCopy2 + JA tagCopy4 + + // case tagCopy1: + // s += 2 + ADDQ $2, SI + + // if uint(s) > uint(len(src)) { etc } + MOVQ SI, BX + SUBQ R11, BX + CMPQ BX, R12 + JA errCorrupt + + // offset = int(uint32(src[s-2])&0xe0<<3 | uint32(src[s-1])) + MOVQ CX, DX + ANDQ $0xe0, DX + SHLQ $3, DX + MOVBQZX -1(SI), BX + ORQ BX, DX + + // length = 4 + int(src[s-2])>>2&0x7 + SHRQ $2, CX + ANDQ $7, CX + ADDQ $4, CX + +doCopy: + // This is the end of the outer "switch", when we have a copy tag. + // + // We assume that: + // - CX == length && CX > 0 + // - DX == offset + + // if offset <= 0 { etc } + CMPQ DX, $0 + JLE errCorrupt + + // if d < offset { etc } + MOVQ DI, BX + SUBQ R8, BX + CMPQ BX, DX + JLT errCorrupt + + // if length > len(dst)-d { etc } + MOVQ R10, BX + SUBQ DI, BX + CMPQ CX, BX + JGT errCorrupt + + // forwardCopy(dst[d:d+length], dst[d-offset:]); d += length + // + // Set: + // - R14 = len(dst)-d + // - R15 = &dst[d-offset] + MOVQ R10, R14 + SUBQ DI, R14 + MOVQ DI, R15 + SUBQ DX, R15 + + // !!! Try a faster technique for short (16 or fewer bytes) forward copies. + // + // First, try using two 8-byte load/stores, similar to the doLit technique + // above. Even if dst[d:d+length] and dst[d-offset:] can overlap, this is + // still OK if offset >= 8. Note that this has to be two 8-byte load/stores + // and not one 16-byte load/store, and the first store has to be before the + // second load, due to the overlap if offset is in the range [8, 16). + // + // if length > 16 || offset < 8 || len(dst)-d < 16 { + // goto slowForwardCopy + // } + // copy 16 bytes + // d += length + CMPQ CX, $16 + JGT slowForwardCopy + CMPQ DX, $8 + JLT slowForwardCopy + CMPQ R14, $16 + JLT slowForwardCopy + MOVQ 0(R15), AX + MOVQ AX, 0(DI) + MOVQ 8(R15), BX + MOVQ BX, 8(DI) + ADDQ CX, DI + JMP loop + +slowForwardCopy: + // !!! If the forward copy is longer than 16 bytes, or if offset < 8, we + // can still try 8-byte load stores, provided we can overrun up to 10 extra + // bytes. As above, the overrun will be fixed up by subsequent iterations + // of the outermost loop. + // + // The C++ snappy code calls this technique IncrementalCopyFastPath. Its + // commentary says: + // + // ---- + // + // The main part of this loop is a simple copy of eight bytes at a time + // until we've copied (at least) the requested amount of bytes. However, + // if d and d-offset are less than eight bytes apart (indicating a + // repeating pattern of length < 8), we first need to expand the pattern in + // order to get the correct results. For instance, if the buffer looks like + // this, with the eight-byte and patterns marked as + // intervals: + // + // abxxxxxxxxxxxx + // [------] d-offset + // [------] d + // + // a single eight-byte copy from to will repeat the pattern + // once, after which we can move two bytes without moving : + // + // ababxxxxxxxxxx + // [------] d-offset + // [------] d + // + // and repeat the exercise until the two no longer overlap. + // + // This allows us to do very well in the special case of one single byte + // repeated many times, without taking a big hit for more general cases. + // + // The worst case of extra writing past the end of the match occurs when + // offset == 1 and length == 1; the last copy will read from byte positions + // [0..7] and write to [4..11], whereas it was only supposed to write to + // position 1. Thus, ten excess bytes. + // + // ---- + // + // That "10 byte overrun" worst case is confirmed by Go's + // TestSlowForwardCopyOverrun, which also tests the fixUpSlowForwardCopy + // and finishSlowForwardCopy algorithm. + // + // if length > len(dst)-d-10 { + // goto verySlowForwardCopy + // } + SUBQ $10, R14 + CMPQ CX, R14 + JGT verySlowForwardCopy + +makeOffsetAtLeast8: + // !!! As above, expand the pattern so that offset >= 8 and we can use + // 8-byte load/stores. + // + // for offset < 8 { + // copy 8 bytes from dst[d-offset:] to dst[d:] + // length -= offset + // d += offset + // offset += offset + // // The two previous lines together means that d-offset, and therefore + // // R15, is unchanged. + // } + CMPQ DX, $8 + JGE fixUpSlowForwardCopy + MOVQ (R15), BX + MOVQ BX, (DI) + SUBQ DX, CX + ADDQ DX, DI + ADDQ DX, DX + JMP makeOffsetAtLeast8 + +fixUpSlowForwardCopy: + // !!! Add length (which might be negative now) to d (implied by DI being + // &dst[d]) so that d ends up at the right place when we jump back to the + // top of the loop. Before we do that, though, we save DI to AX so that, if + // length is positive, copying the remaining length bytes will write to the + // right place. + MOVQ DI, AX + ADDQ CX, DI + +finishSlowForwardCopy: + // !!! Repeat 8-byte load/stores until length <= 0. Ending with a negative + // length means that we overrun, but as above, that will be fixed up by + // subsequent iterations of the outermost loop. + CMPQ CX, $0 + JLE loop + MOVQ (R15), BX + MOVQ BX, (AX) + ADDQ $8, R15 + ADDQ $8, AX + SUBQ $8, CX + JMP finishSlowForwardCopy + +verySlowForwardCopy: + // verySlowForwardCopy is a simple implementation of forward copy. In C + // parlance, this is a do/while loop instead of a while loop, since we know + // that length > 0. In Go syntax: + // + // for { + // dst[d] = dst[d - offset] + // d++ + // length-- + // if length == 0 { + // break + // } + // } + MOVB (R15), BX + MOVB BX, (DI) + INCQ R15 + INCQ DI + DECQ CX + JNZ verySlowForwardCopy + JMP loop + +// The code above handles copy tags. +// ---------------------------------------- + +end: + // This is the end of the "for s < len(src)". + // + // if d != len(dst) { etc } + CMPQ DI, R10 + JNE errCorrupt + + // return 0 + MOVQ $0, ret+48(FP) + RET + +errCorrupt: + // return decodeErrCodeCorrupt + MOVQ $1, ret+48(FP) + RET diff --git a/_vendor/vendor/github.com/golang/snappy/decode_other.go b/_vendor/vendor/github.com/golang/snappy/decode_other.go new file mode 100644 index 0000000..8c9f204 --- /dev/null +++ b/_vendor/vendor/github.com/golang/snappy/decode_other.go @@ -0,0 +1,101 @@ +// Copyright 2016 The Snappy-Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !amd64 appengine !gc noasm + +package snappy + +// decode writes the decoding of src to dst. It assumes that the varint-encoded +// length of the decompressed bytes has already been read, and that len(dst) +// equals that length. +// +// It returns 0 on success or a decodeErrCodeXxx error code on failure. +func decode(dst, src []byte) int { + var d, s, offset, length int + for s < len(src) { + switch src[s] & 0x03 { + case tagLiteral: + x := uint32(src[s] >> 2) + switch { + case x < 60: + s++ + case x == 60: + s += 2 + if uint(s) > uint(len(src)) { // The uint conversions catch overflow from the previous line. + return decodeErrCodeCorrupt + } + x = uint32(src[s-1]) + case x == 61: + s += 3 + if uint(s) > uint(len(src)) { // The uint conversions catch overflow from the previous line. + return decodeErrCodeCorrupt + } + x = uint32(src[s-2]) | uint32(src[s-1])<<8 + case x == 62: + s += 4 + if uint(s) > uint(len(src)) { // The uint conversions catch overflow from the previous line. + return decodeErrCodeCorrupt + } + x = uint32(src[s-3]) | uint32(src[s-2])<<8 | uint32(src[s-1])<<16 + case x == 63: + s += 5 + if uint(s) > uint(len(src)) { // The uint conversions catch overflow from the previous line. + return decodeErrCodeCorrupt + } + x = uint32(src[s-4]) | uint32(src[s-3])<<8 | uint32(src[s-2])<<16 | uint32(src[s-1])<<24 + } + length = int(x) + 1 + if length <= 0 { + return decodeErrCodeUnsupportedLiteralLength + } + if length > len(dst)-d || length > len(src)-s { + return decodeErrCodeCorrupt + } + copy(dst[d:], src[s:s+length]) + d += length + s += length + continue + + case tagCopy1: + s += 2 + if uint(s) > uint(len(src)) { // The uint conversions catch overflow from the previous line. + return decodeErrCodeCorrupt + } + length = 4 + int(src[s-2])>>2&0x7 + offset = int(uint32(src[s-2])&0xe0<<3 | uint32(src[s-1])) + + case tagCopy2: + s += 3 + if uint(s) > uint(len(src)) { // The uint conversions catch overflow from the previous line. + return decodeErrCodeCorrupt + } + length = 1 + int(src[s-3])>>2 + offset = int(uint32(src[s-2]) | uint32(src[s-1])<<8) + + case tagCopy4: + s += 5 + if uint(s) > uint(len(src)) { // The uint conversions catch overflow from the previous line. + return decodeErrCodeCorrupt + } + length = 1 + int(src[s-5])>>2 + offset = int(uint32(src[s-4]) | uint32(src[s-3])<<8 | uint32(src[s-2])<<16 | uint32(src[s-1])<<24) + } + + if offset <= 0 || d < offset || length > len(dst)-d { + return decodeErrCodeCorrupt + } + // Copy from an earlier sub-slice of dst to a later sub-slice. Unlike + // the built-in copy function, this byte-by-byte copy always runs + // forwards, even if the slices overlap. Conceptually, this is: + // + // d += forwardCopy(dst[d:d+length], dst[d-offset:]) + for end := d + length; d != end; d++ { + dst[d] = dst[d-offset] + } + } + if d != len(dst) { + return decodeErrCodeCorrupt + } + return 0 +} diff --git a/_vendor/vendor/github.com/golang/snappy/encode.go b/_vendor/vendor/github.com/golang/snappy/encode.go new file mode 100644 index 0000000..8d393e9 --- /dev/null +++ b/_vendor/vendor/github.com/golang/snappy/encode.go @@ -0,0 +1,285 @@ +// Copyright 2011 The Snappy-Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package snappy + +import ( + "encoding/binary" + "errors" + "io" +) + +// Encode returns the encoded form of src. The returned slice may be a sub- +// slice of dst if dst was large enough to hold the entire encoded block. +// Otherwise, a newly allocated slice will be returned. +// +// The dst and src must not overlap. It is valid to pass a nil dst. +func Encode(dst, src []byte) []byte { + if n := MaxEncodedLen(len(src)); n < 0 { + panic(ErrTooLarge) + } else if len(dst) < n { + dst = make([]byte, n) + } + + // The block starts with the varint-encoded length of the decompressed bytes. + d := binary.PutUvarint(dst, uint64(len(src))) + + for len(src) > 0 { + p := src + src = nil + if len(p) > maxBlockSize { + p, src = p[:maxBlockSize], p[maxBlockSize:] + } + if len(p) < minNonLiteralBlockSize { + d += emitLiteral(dst[d:], p) + } else { + d += encodeBlock(dst[d:], p) + } + } + return dst[:d] +} + +// inputMargin is the minimum number of extra input bytes to keep, inside +// encodeBlock's inner loop. On some architectures, this margin lets us +// implement a fast path for emitLiteral, where the copy of short (<= 16 byte) +// literals can be implemented as a single load to and store from a 16-byte +// register. That literal's actual length can be as short as 1 byte, so this +// can copy up to 15 bytes too much, but that's OK as subsequent iterations of +// the encoding loop will fix up the copy overrun, and this inputMargin ensures +// that we don't overrun the dst and src buffers. +const inputMargin = 16 - 1 + +// minNonLiteralBlockSize is the minimum size of the input to encodeBlock that +// could be encoded with a copy tag. This is the minimum with respect to the +// algorithm used by encodeBlock, not a minimum enforced by the file format. +// +// The encoded output must start with at least a 1 byte literal, as there are +// no previous bytes to copy. A minimal (1 byte) copy after that, generated +// from an emitCopy call in encodeBlock's main loop, would require at least +// another inputMargin bytes, for the reason above: we want any emitLiteral +// calls inside encodeBlock's main loop to use the fast path if possible, which +// requires being able to overrun by inputMargin bytes. Thus, +// minNonLiteralBlockSize equals 1 + 1 + inputMargin. +// +// The C++ code doesn't use this exact threshold, but it could, as discussed at +// https://groups.google.com/d/topic/snappy-compression/oGbhsdIJSJ8/discussion +// The difference between Go (2+inputMargin) and C++ (inputMargin) is purely an +// optimization. It should not affect the encoded form. This is tested by +// TestSameEncodingAsCppShortCopies. +const minNonLiteralBlockSize = 1 + 1 + inputMargin + +// MaxEncodedLen returns the maximum length of a snappy block, given its +// uncompressed length. +// +// It will return a negative value if srcLen is too large to encode. +func MaxEncodedLen(srcLen int) int { + n := uint64(srcLen) + if n > 0xffffffff { + return -1 + } + // Compressed data can be defined as: + // compressed := item* literal* + // item := literal* copy + // + // The trailing literal sequence has a space blowup of at most 62/60 + // since a literal of length 60 needs one tag byte + one extra byte + // for length information. + // + // Item blowup is trickier to measure. Suppose the "copy" op copies + // 4 bytes of data. Because of a special check in the encoding code, + // we produce a 4-byte copy only if the offset is < 65536. Therefore + // the copy op takes 3 bytes to encode, and this type of item leads + // to at most the 62/60 blowup for representing literals. + // + // Suppose the "copy" op copies 5 bytes of data. If the offset is big + // enough, it will take 5 bytes to encode the copy op. Therefore the + // worst case here is a one-byte literal followed by a five-byte copy. + // That is, 6 bytes of input turn into 7 bytes of "compressed" data. + // + // This last factor dominates the blowup, so the final estimate is: + n = 32 + n + n/6 + if n > 0xffffffff { + return -1 + } + return int(n) +} + +var errClosed = errors.New("snappy: Writer is closed") + +// NewWriter returns a new Writer that compresses to w. +// +// The Writer returned does not buffer writes. There is no need to Flush or +// Close such a Writer. +// +// Deprecated: the Writer returned is not suitable for many small writes, only +// for few large writes. Use NewBufferedWriter instead, which is efficient +// regardless of the frequency and shape of the writes, and remember to Close +// that Writer when done. +func NewWriter(w io.Writer) *Writer { + return &Writer{ + w: w, + obuf: make([]byte, obufLen), + } +} + +// NewBufferedWriter returns a new Writer that compresses to w, using the +// framing format described at +// https://github.com/google/snappy/blob/master/framing_format.txt +// +// The Writer returned buffers writes. Users must call Close to guarantee all +// data has been forwarded to the underlying io.Writer. They may also call +// Flush zero or more times before calling Close. +func NewBufferedWriter(w io.Writer) *Writer { + return &Writer{ + w: w, + ibuf: make([]byte, 0, maxBlockSize), + obuf: make([]byte, obufLen), + } +} + +// Writer is an io.Writer that can write Snappy-compressed bytes. +type Writer struct { + w io.Writer + err error + + // ibuf is a buffer for the incoming (uncompressed) bytes. + // + // Its use is optional. For backwards compatibility, Writers created by the + // NewWriter function have ibuf == nil, do not buffer incoming bytes, and + // therefore do not need to be Flush'ed or Close'd. + ibuf []byte + + // obuf is a buffer for the outgoing (compressed) bytes. + obuf []byte + + // wroteStreamHeader is whether we have written the stream header. + wroteStreamHeader bool +} + +// Reset discards the writer's state and switches the Snappy writer to write to +// w. This permits reusing a Writer rather than allocating a new one. +func (w *Writer) Reset(writer io.Writer) { + w.w = writer + w.err = nil + if w.ibuf != nil { + w.ibuf = w.ibuf[:0] + } + w.wroteStreamHeader = false +} + +// Write satisfies the io.Writer interface. +func (w *Writer) Write(p []byte) (nRet int, errRet error) { + if w.ibuf == nil { + // Do not buffer incoming bytes. This does not perform or compress well + // if the caller of Writer.Write writes many small slices. This + // behavior is therefore deprecated, but still supported for backwards + // compatibility with code that doesn't explicitly Flush or Close. + return w.write(p) + } + + // The remainder of this method is based on bufio.Writer.Write from the + // standard library. + + for len(p) > (cap(w.ibuf)-len(w.ibuf)) && w.err == nil { + var n int + if len(w.ibuf) == 0 { + // Large write, empty buffer. + // Write directly from p to avoid copy. + n, _ = w.write(p) + } else { + n = copy(w.ibuf[len(w.ibuf):cap(w.ibuf)], p) + w.ibuf = w.ibuf[:len(w.ibuf)+n] + w.Flush() + } + nRet += n + p = p[n:] + } + if w.err != nil { + return nRet, w.err + } + n := copy(w.ibuf[len(w.ibuf):cap(w.ibuf)], p) + w.ibuf = w.ibuf[:len(w.ibuf)+n] + nRet += n + return nRet, nil +} + +func (w *Writer) write(p []byte) (nRet int, errRet error) { + if w.err != nil { + return 0, w.err + } + for len(p) > 0 { + obufStart := len(magicChunk) + if !w.wroteStreamHeader { + w.wroteStreamHeader = true + copy(w.obuf, magicChunk) + obufStart = 0 + } + + var uncompressed []byte + if len(p) > maxBlockSize { + uncompressed, p = p[:maxBlockSize], p[maxBlockSize:] + } else { + uncompressed, p = p, nil + } + checksum := crc(uncompressed) + + // Compress the buffer, discarding the result if the improvement + // isn't at least 12.5%. + compressed := Encode(w.obuf[obufHeaderLen:], uncompressed) + chunkType := uint8(chunkTypeCompressedData) + chunkLen := 4 + len(compressed) + obufEnd := obufHeaderLen + len(compressed) + if len(compressed) >= len(uncompressed)-len(uncompressed)/8 { + chunkType = chunkTypeUncompressedData + chunkLen = 4 + len(uncompressed) + obufEnd = obufHeaderLen + } + + // Fill in the per-chunk header that comes before the body. + w.obuf[len(magicChunk)+0] = chunkType + w.obuf[len(magicChunk)+1] = uint8(chunkLen >> 0) + w.obuf[len(magicChunk)+2] = uint8(chunkLen >> 8) + w.obuf[len(magicChunk)+3] = uint8(chunkLen >> 16) + w.obuf[len(magicChunk)+4] = uint8(checksum >> 0) + w.obuf[len(magicChunk)+5] = uint8(checksum >> 8) + w.obuf[len(magicChunk)+6] = uint8(checksum >> 16) + w.obuf[len(magicChunk)+7] = uint8(checksum >> 24) + + if _, err := w.w.Write(w.obuf[obufStart:obufEnd]); err != nil { + w.err = err + return nRet, err + } + if chunkType == chunkTypeUncompressedData { + if _, err := w.w.Write(uncompressed); err != nil { + w.err = err + return nRet, err + } + } + nRet += len(uncompressed) + } + return nRet, nil +} + +// Flush flushes the Writer to its underlying io.Writer. +func (w *Writer) Flush() error { + if w.err != nil { + return w.err + } + if len(w.ibuf) == 0 { + return nil + } + w.write(w.ibuf) + w.ibuf = w.ibuf[:0] + return w.err +} + +// Close calls Flush and then closes the Writer. +func (w *Writer) Close() error { + w.Flush() + ret := w.err + if w.err == nil { + w.err = errClosed + } + return ret +} diff --git a/_vendor/vendor/github.com/golang/snappy/encode_amd64.go b/_vendor/vendor/github.com/golang/snappy/encode_amd64.go new file mode 100644 index 0000000..150d91b --- /dev/null +++ b/_vendor/vendor/github.com/golang/snappy/encode_amd64.go @@ -0,0 +1,29 @@ +// Copyright 2016 The Snappy-Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !appengine +// +build gc +// +build !noasm + +package snappy + +// emitLiteral has the same semantics as in encode_other.go. +// +//go:noescape +func emitLiteral(dst, lit []byte) int + +// emitCopy has the same semantics as in encode_other.go. +// +//go:noescape +func emitCopy(dst []byte, offset, length int) int + +// extendMatch has the same semantics as in encode_other.go. +// +//go:noescape +func extendMatch(src []byte, i, j int) int + +// encodeBlock has the same semantics as in encode_other.go. +// +//go:noescape +func encodeBlock(dst, src []byte) (d int) diff --git a/_vendor/vendor/github.com/golang/snappy/encode_amd64.s b/_vendor/vendor/github.com/golang/snappy/encode_amd64.s new file mode 100644 index 0000000..adfd979 --- /dev/null +++ b/_vendor/vendor/github.com/golang/snappy/encode_amd64.s @@ -0,0 +1,730 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !appengine +// +build gc +// +build !noasm + +#include "textflag.h" + +// The XXX lines assemble on Go 1.4, 1.5 and 1.7, but not 1.6, due to a +// Go toolchain regression. See https://github.com/golang/go/issues/15426 and +// https://github.com/golang/snappy/issues/29 +// +// As a workaround, the package was built with a known good assembler, and +// those instructions were disassembled by "objdump -d" to yield the +// 4e 0f b7 7c 5c 78 movzwq 0x78(%rsp,%r11,2),%r15 +// style comments, in AT&T asm syntax. Note that rsp here is a physical +// register, not Go/asm's SP pseudo-register (see https://golang.org/doc/asm). +// The instructions were then encoded as "BYTE $0x.." sequences, which assemble +// fine on Go 1.6. + +// The asm code generally follows the pure Go code in encode_other.go, except +// where marked with a "!!!". + +// ---------------------------------------------------------------------------- + +// func emitLiteral(dst, lit []byte) int +// +// All local variables fit into registers. The register allocation: +// - AX len(lit) +// - BX n +// - DX return value +// - DI &dst[i] +// - R10 &lit[0] +// +// The 24 bytes of stack space is to call runtime·memmove. +// +// The unusual register allocation of local variables, such as R10 for the +// source pointer, matches the allocation used at the call site in encodeBlock, +// which makes it easier to manually inline this function. +TEXT ·emitLiteral(SB), NOSPLIT, $24-56 + MOVQ dst_base+0(FP), DI + MOVQ lit_base+24(FP), R10 + MOVQ lit_len+32(FP), AX + MOVQ AX, DX + MOVL AX, BX + SUBL $1, BX + + CMPL BX, $60 + JLT oneByte + CMPL BX, $256 + JLT twoBytes + +threeBytes: + MOVB $0xf4, 0(DI) + MOVW BX, 1(DI) + ADDQ $3, DI + ADDQ $3, DX + JMP memmove + +twoBytes: + MOVB $0xf0, 0(DI) + MOVB BX, 1(DI) + ADDQ $2, DI + ADDQ $2, DX + JMP memmove + +oneByte: + SHLB $2, BX + MOVB BX, 0(DI) + ADDQ $1, DI + ADDQ $1, DX + +memmove: + MOVQ DX, ret+48(FP) + + // copy(dst[i:], lit) + // + // This means calling runtime·memmove(&dst[i], &lit[0], len(lit)), so we push + // DI, R10 and AX as arguments. + MOVQ DI, 0(SP) + MOVQ R10, 8(SP) + MOVQ AX, 16(SP) + CALL runtime·memmove(SB) + RET + +// ---------------------------------------------------------------------------- + +// func emitCopy(dst []byte, offset, length int) int +// +// All local variables fit into registers. The register allocation: +// - AX length +// - SI &dst[0] +// - DI &dst[i] +// - R11 offset +// +// The unusual register allocation of local variables, such as R11 for the +// offset, matches the allocation used at the call site in encodeBlock, which +// makes it easier to manually inline this function. +TEXT ·emitCopy(SB), NOSPLIT, $0-48 + MOVQ dst_base+0(FP), DI + MOVQ DI, SI + MOVQ offset+24(FP), R11 + MOVQ length+32(FP), AX + +loop0: + // for length >= 68 { etc } + CMPL AX, $68 + JLT step1 + + // Emit a length 64 copy, encoded as 3 bytes. + MOVB $0xfe, 0(DI) + MOVW R11, 1(DI) + ADDQ $3, DI + SUBL $64, AX + JMP loop0 + +step1: + // if length > 64 { etc } + CMPL AX, $64 + JLE step2 + + // Emit a length 60 copy, encoded as 3 bytes. + MOVB $0xee, 0(DI) + MOVW R11, 1(DI) + ADDQ $3, DI + SUBL $60, AX + +step2: + // if length >= 12 || offset >= 2048 { goto step3 } + CMPL AX, $12 + JGE step3 + CMPL R11, $2048 + JGE step3 + + // Emit the remaining copy, encoded as 2 bytes. + MOVB R11, 1(DI) + SHRL $8, R11 + SHLB $5, R11 + SUBB $4, AX + SHLB $2, AX + ORB AX, R11 + ORB $1, R11 + MOVB R11, 0(DI) + ADDQ $2, DI + + // Return the number of bytes written. + SUBQ SI, DI + MOVQ DI, ret+40(FP) + RET + +step3: + // Emit the remaining copy, encoded as 3 bytes. + SUBL $1, AX + SHLB $2, AX + ORB $2, AX + MOVB AX, 0(DI) + MOVW R11, 1(DI) + ADDQ $3, DI + + // Return the number of bytes written. + SUBQ SI, DI + MOVQ DI, ret+40(FP) + RET + +// ---------------------------------------------------------------------------- + +// func extendMatch(src []byte, i, j int) int +// +// All local variables fit into registers. The register allocation: +// - DX &src[0] +// - SI &src[j] +// - R13 &src[len(src) - 8] +// - R14 &src[len(src)] +// - R15 &src[i] +// +// The unusual register allocation of local variables, such as R15 for a source +// pointer, matches the allocation used at the call site in encodeBlock, which +// makes it easier to manually inline this function. +TEXT ·extendMatch(SB), NOSPLIT, $0-48 + MOVQ src_base+0(FP), DX + MOVQ src_len+8(FP), R14 + MOVQ i+24(FP), R15 + MOVQ j+32(FP), SI + ADDQ DX, R14 + ADDQ DX, R15 + ADDQ DX, SI + MOVQ R14, R13 + SUBQ $8, R13 + +cmp8: + // As long as we are 8 or more bytes before the end of src, we can load and + // compare 8 bytes at a time. If those 8 bytes are equal, repeat. + CMPQ SI, R13 + JA cmp1 + MOVQ (R15), AX + MOVQ (SI), BX + CMPQ AX, BX + JNE bsf + ADDQ $8, R15 + ADDQ $8, SI + JMP cmp8 + +bsf: + // If those 8 bytes were not equal, XOR the two 8 byte values, and return + // the index of the first byte that differs. The BSF instruction finds the + // least significant 1 bit, the amd64 architecture is little-endian, and + // the shift by 3 converts a bit index to a byte index. + XORQ AX, BX + BSFQ BX, BX + SHRQ $3, BX + ADDQ BX, SI + + // Convert from &src[ret] to ret. + SUBQ DX, SI + MOVQ SI, ret+40(FP) + RET + +cmp1: + // In src's tail, compare 1 byte at a time. + CMPQ SI, R14 + JAE extendMatchEnd + MOVB (R15), AX + MOVB (SI), BX + CMPB AX, BX + JNE extendMatchEnd + ADDQ $1, R15 + ADDQ $1, SI + JMP cmp1 + +extendMatchEnd: + // Convert from &src[ret] to ret. + SUBQ DX, SI + MOVQ SI, ret+40(FP) + RET + +// ---------------------------------------------------------------------------- + +// func encodeBlock(dst, src []byte) (d int) +// +// All local variables fit into registers, other than "var table". The register +// allocation: +// - AX . . +// - BX . . +// - CX 56 shift (note that amd64 shifts by non-immediates must use CX). +// - DX 64 &src[0], tableSize +// - SI 72 &src[s] +// - DI 80 &dst[d] +// - R9 88 sLimit +// - R10 . &src[nextEmit] +// - R11 96 prevHash, currHash, nextHash, offset +// - R12 104 &src[base], skip +// - R13 . &src[nextS], &src[len(src) - 8] +// - R14 . len(src), bytesBetweenHashLookups, &src[len(src)], x +// - R15 112 candidate +// +// The second column (56, 64, etc) is the stack offset to spill the registers +// when calling other functions. We could pack this slightly tighter, but it's +// simpler to have a dedicated spill map independent of the function called. +// +// "var table [maxTableSize]uint16" takes up 32768 bytes of stack space. An +// extra 56 bytes, to call other functions, and an extra 64 bytes, to spill +// local variables (registers) during calls gives 32768 + 56 + 64 = 32888. +TEXT ·encodeBlock(SB), 0, $32888-56 + MOVQ dst_base+0(FP), DI + MOVQ src_base+24(FP), SI + MOVQ src_len+32(FP), R14 + + // shift, tableSize := uint32(32-8), 1<<8 + MOVQ $24, CX + MOVQ $256, DX + +calcShift: + // for ; tableSize < maxTableSize && tableSize < len(src); tableSize *= 2 { + // shift-- + // } + CMPQ DX, $16384 + JGE varTable + CMPQ DX, R14 + JGE varTable + SUBQ $1, CX + SHLQ $1, DX + JMP calcShift + +varTable: + // var table [maxTableSize]uint16 + // + // In the asm code, unlike the Go code, we can zero-initialize only the + // first tableSize elements. Each uint16 element is 2 bytes and each MOVOU + // writes 16 bytes, so we can do only tableSize/8 writes instead of the + // 2048 writes that would zero-initialize all of table's 32768 bytes. + SHRQ $3, DX + LEAQ table-32768(SP), BX + PXOR X0, X0 + +memclr: + MOVOU X0, 0(BX) + ADDQ $16, BX + SUBQ $1, DX + JNZ memclr + + // !!! DX = &src[0] + MOVQ SI, DX + + // sLimit := len(src) - inputMargin + MOVQ R14, R9 + SUBQ $15, R9 + + // !!! Pre-emptively spill CX, DX and R9 to the stack. Their values don't + // change for the rest of the function. + MOVQ CX, 56(SP) + MOVQ DX, 64(SP) + MOVQ R9, 88(SP) + + // nextEmit := 0 + MOVQ DX, R10 + + // s := 1 + ADDQ $1, SI + + // nextHash := hash(load32(src, s), shift) + MOVL 0(SI), R11 + IMULL $0x1e35a7bd, R11 + SHRL CX, R11 + +outer: + // for { etc } + + // skip := 32 + MOVQ $32, R12 + + // nextS := s + MOVQ SI, R13 + + // candidate := 0 + MOVQ $0, R15 + +inner0: + // for { etc } + + // s := nextS + MOVQ R13, SI + + // bytesBetweenHashLookups := skip >> 5 + MOVQ R12, R14 + SHRQ $5, R14 + + // nextS = s + bytesBetweenHashLookups + ADDQ R14, R13 + + // skip += bytesBetweenHashLookups + ADDQ R14, R12 + + // if nextS > sLimit { goto emitRemainder } + MOVQ R13, AX + SUBQ DX, AX + CMPQ AX, R9 + JA emitRemainder + + // candidate = int(table[nextHash]) + // XXX: MOVWQZX table-32768(SP)(R11*2), R15 + // XXX: 4e 0f b7 7c 5c 78 movzwq 0x78(%rsp,%r11,2),%r15 + BYTE $0x4e + BYTE $0x0f + BYTE $0xb7 + BYTE $0x7c + BYTE $0x5c + BYTE $0x78 + + // table[nextHash] = uint16(s) + MOVQ SI, AX + SUBQ DX, AX + + // XXX: MOVW AX, table-32768(SP)(R11*2) + // XXX: 66 42 89 44 5c 78 mov %ax,0x78(%rsp,%r11,2) + BYTE $0x66 + BYTE $0x42 + BYTE $0x89 + BYTE $0x44 + BYTE $0x5c + BYTE $0x78 + + // nextHash = hash(load32(src, nextS), shift) + MOVL 0(R13), R11 + IMULL $0x1e35a7bd, R11 + SHRL CX, R11 + + // if load32(src, s) != load32(src, candidate) { continue } break + MOVL 0(SI), AX + MOVL (DX)(R15*1), BX + CMPL AX, BX + JNE inner0 + +fourByteMatch: + // As per the encode_other.go code: + // + // A 4-byte match has been found. We'll later see etc. + + // !!! Jump to a fast path for short (<= 16 byte) literals. See the comment + // on inputMargin in encode.go. + MOVQ SI, AX + SUBQ R10, AX + CMPQ AX, $16 + JLE emitLiteralFastPath + + // ---------------------------------------- + // Begin inline of the emitLiteral call. + // + // d += emitLiteral(dst[d:], src[nextEmit:s]) + + MOVL AX, BX + SUBL $1, BX + + CMPL BX, $60 + JLT inlineEmitLiteralOneByte + CMPL BX, $256 + JLT inlineEmitLiteralTwoBytes + +inlineEmitLiteralThreeBytes: + MOVB $0xf4, 0(DI) + MOVW BX, 1(DI) + ADDQ $3, DI + JMP inlineEmitLiteralMemmove + +inlineEmitLiteralTwoBytes: + MOVB $0xf0, 0(DI) + MOVB BX, 1(DI) + ADDQ $2, DI + JMP inlineEmitLiteralMemmove + +inlineEmitLiteralOneByte: + SHLB $2, BX + MOVB BX, 0(DI) + ADDQ $1, DI + +inlineEmitLiteralMemmove: + // Spill local variables (registers) onto the stack; call; unspill. + // + // copy(dst[i:], lit) + // + // This means calling runtime·memmove(&dst[i], &lit[0], len(lit)), so we push + // DI, R10 and AX as arguments. + MOVQ DI, 0(SP) + MOVQ R10, 8(SP) + MOVQ AX, 16(SP) + ADDQ AX, DI // Finish the "d +=" part of "d += emitLiteral(etc)". + MOVQ SI, 72(SP) + MOVQ DI, 80(SP) + MOVQ R15, 112(SP) + CALL runtime·memmove(SB) + MOVQ 56(SP), CX + MOVQ 64(SP), DX + MOVQ 72(SP), SI + MOVQ 80(SP), DI + MOVQ 88(SP), R9 + MOVQ 112(SP), R15 + JMP inner1 + +inlineEmitLiteralEnd: + // End inline of the emitLiteral call. + // ---------------------------------------- + +emitLiteralFastPath: + // !!! Emit the 1-byte encoding "uint8(len(lit)-1)<<2". + MOVB AX, BX + SUBB $1, BX + SHLB $2, BX + MOVB BX, (DI) + ADDQ $1, DI + + // !!! Implement the copy from lit to dst as a 16-byte load and store. + // (Encode's documentation says that dst and src must not overlap.) + // + // This always copies 16 bytes, instead of only len(lit) bytes, but that's + // OK. Subsequent iterations will fix up the overrun. + // + // Note that on amd64, it is legal and cheap to issue unaligned 8-byte or + // 16-byte loads and stores. This technique probably wouldn't be as + // effective on architectures that are fussier about alignment. + MOVOU 0(R10), X0 + MOVOU X0, 0(DI) + ADDQ AX, DI + +inner1: + // for { etc } + + // base := s + MOVQ SI, R12 + + // !!! offset := base - candidate + MOVQ R12, R11 + SUBQ R15, R11 + SUBQ DX, R11 + + // ---------------------------------------- + // Begin inline of the extendMatch call. + // + // s = extendMatch(src, candidate+4, s+4) + + // !!! R14 = &src[len(src)] + MOVQ src_len+32(FP), R14 + ADDQ DX, R14 + + // !!! R13 = &src[len(src) - 8] + MOVQ R14, R13 + SUBQ $8, R13 + + // !!! R15 = &src[candidate + 4] + ADDQ $4, R15 + ADDQ DX, R15 + + // !!! s += 4 + ADDQ $4, SI + +inlineExtendMatchCmp8: + // As long as we are 8 or more bytes before the end of src, we can load and + // compare 8 bytes at a time. If those 8 bytes are equal, repeat. + CMPQ SI, R13 + JA inlineExtendMatchCmp1 + MOVQ (R15), AX + MOVQ (SI), BX + CMPQ AX, BX + JNE inlineExtendMatchBSF + ADDQ $8, R15 + ADDQ $8, SI + JMP inlineExtendMatchCmp8 + +inlineExtendMatchBSF: + // If those 8 bytes were not equal, XOR the two 8 byte values, and return + // the index of the first byte that differs. The BSF instruction finds the + // least significant 1 bit, the amd64 architecture is little-endian, and + // the shift by 3 converts a bit index to a byte index. + XORQ AX, BX + BSFQ BX, BX + SHRQ $3, BX + ADDQ BX, SI + JMP inlineExtendMatchEnd + +inlineExtendMatchCmp1: + // In src's tail, compare 1 byte at a time. + CMPQ SI, R14 + JAE inlineExtendMatchEnd + MOVB (R15), AX + MOVB (SI), BX + CMPB AX, BX + JNE inlineExtendMatchEnd + ADDQ $1, R15 + ADDQ $1, SI + JMP inlineExtendMatchCmp1 + +inlineExtendMatchEnd: + // End inline of the extendMatch call. + // ---------------------------------------- + + // ---------------------------------------- + // Begin inline of the emitCopy call. + // + // d += emitCopy(dst[d:], base-candidate, s-base) + + // !!! length := s - base + MOVQ SI, AX + SUBQ R12, AX + +inlineEmitCopyLoop0: + // for length >= 68 { etc } + CMPL AX, $68 + JLT inlineEmitCopyStep1 + + // Emit a length 64 copy, encoded as 3 bytes. + MOVB $0xfe, 0(DI) + MOVW R11, 1(DI) + ADDQ $3, DI + SUBL $64, AX + JMP inlineEmitCopyLoop0 + +inlineEmitCopyStep1: + // if length > 64 { etc } + CMPL AX, $64 + JLE inlineEmitCopyStep2 + + // Emit a length 60 copy, encoded as 3 bytes. + MOVB $0xee, 0(DI) + MOVW R11, 1(DI) + ADDQ $3, DI + SUBL $60, AX + +inlineEmitCopyStep2: + // if length >= 12 || offset >= 2048 { goto inlineEmitCopyStep3 } + CMPL AX, $12 + JGE inlineEmitCopyStep3 + CMPL R11, $2048 + JGE inlineEmitCopyStep3 + + // Emit the remaining copy, encoded as 2 bytes. + MOVB R11, 1(DI) + SHRL $8, R11 + SHLB $5, R11 + SUBB $4, AX + SHLB $2, AX + ORB AX, R11 + ORB $1, R11 + MOVB R11, 0(DI) + ADDQ $2, DI + JMP inlineEmitCopyEnd + +inlineEmitCopyStep3: + // Emit the remaining copy, encoded as 3 bytes. + SUBL $1, AX + SHLB $2, AX + ORB $2, AX + MOVB AX, 0(DI) + MOVW R11, 1(DI) + ADDQ $3, DI + +inlineEmitCopyEnd: + // End inline of the emitCopy call. + // ---------------------------------------- + + // nextEmit = s + MOVQ SI, R10 + + // if s >= sLimit { goto emitRemainder } + MOVQ SI, AX + SUBQ DX, AX + CMPQ AX, R9 + JAE emitRemainder + + // As per the encode_other.go code: + // + // We could immediately etc. + + // x := load64(src, s-1) + MOVQ -1(SI), R14 + + // prevHash := hash(uint32(x>>0), shift) + MOVL R14, R11 + IMULL $0x1e35a7bd, R11 + SHRL CX, R11 + + // table[prevHash] = uint16(s-1) + MOVQ SI, AX + SUBQ DX, AX + SUBQ $1, AX + + // XXX: MOVW AX, table-32768(SP)(R11*2) + // XXX: 66 42 89 44 5c 78 mov %ax,0x78(%rsp,%r11,2) + BYTE $0x66 + BYTE $0x42 + BYTE $0x89 + BYTE $0x44 + BYTE $0x5c + BYTE $0x78 + + // currHash := hash(uint32(x>>8), shift) + SHRQ $8, R14 + MOVL R14, R11 + IMULL $0x1e35a7bd, R11 + SHRL CX, R11 + + // candidate = int(table[currHash]) + // XXX: MOVWQZX table-32768(SP)(R11*2), R15 + // XXX: 4e 0f b7 7c 5c 78 movzwq 0x78(%rsp,%r11,2),%r15 + BYTE $0x4e + BYTE $0x0f + BYTE $0xb7 + BYTE $0x7c + BYTE $0x5c + BYTE $0x78 + + // table[currHash] = uint16(s) + ADDQ $1, AX + + // XXX: MOVW AX, table-32768(SP)(R11*2) + // XXX: 66 42 89 44 5c 78 mov %ax,0x78(%rsp,%r11,2) + BYTE $0x66 + BYTE $0x42 + BYTE $0x89 + BYTE $0x44 + BYTE $0x5c + BYTE $0x78 + + // if uint32(x>>8) == load32(src, candidate) { continue } + MOVL (DX)(R15*1), BX + CMPL R14, BX + JEQ inner1 + + // nextHash = hash(uint32(x>>16), shift) + SHRQ $8, R14 + MOVL R14, R11 + IMULL $0x1e35a7bd, R11 + SHRL CX, R11 + + // s++ + ADDQ $1, SI + + // break out of the inner1 for loop, i.e. continue the outer loop. + JMP outer + +emitRemainder: + // if nextEmit < len(src) { etc } + MOVQ src_len+32(FP), AX + ADDQ DX, AX + CMPQ R10, AX + JEQ encodeBlockEnd + + // d += emitLiteral(dst[d:], src[nextEmit:]) + // + // Push args. + MOVQ DI, 0(SP) + MOVQ $0, 8(SP) // Unnecessary, as the callee ignores it, but conservative. + MOVQ $0, 16(SP) // Unnecessary, as the callee ignores it, but conservative. + MOVQ R10, 24(SP) + SUBQ R10, AX + MOVQ AX, 32(SP) + MOVQ AX, 40(SP) // Unnecessary, as the callee ignores it, but conservative. + + // Spill local variables (registers) onto the stack; call; unspill. + MOVQ DI, 80(SP) + CALL ·emitLiteral(SB) + MOVQ 80(SP), DI + + // Finish the "d +=" part of "d += emitLiteral(etc)". + ADDQ 48(SP), DI + +encodeBlockEnd: + MOVQ dst_base+0(FP), AX + SUBQ AX, DI + MOVQ DI, d+48(FP) + RET diff --git a/_vendor/vendor/github.com/golang/snappy/encode_other.go b/_vendor/vendor/github.com/golang/snappy/encode_other.go new file mode 100644 index 0000000..dbcae90 --- /dev/null +++ b/_vendor/vendor/github.com/golang/snappy/encode_other.go @@ -0,0 +1,238 @@ +// Copyright 2016 The Snappy-Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !amd64 appengine !gc noasm + +package snappy + +func load32(b []byte, i int) uint32 { + b = b[i : i+4 : len(b)] // Help the compiler eliminate bounds checks on the next line. + return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 +} + +func load64(b []byte, i int) uint64 { + b = b[i : i+8 : len(b)] // Help the compiler eliminate bounds checks on the next line. + return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | + uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 +} + +// emitLiteral writes a literal chunk and returns the number of bytes written. +// +// It assumes that: +// dst is long enough to hold the encoded bytes +// 1 <= len(lit) && len(lit) <= 65536 +func emitLiteral(dst, lit []byte) int { + i, n := 0, uint(len(lit)-1) + switch { + case n < 60: + dst[0] = uint8(n)<<2 | tagLiteral + i = 1 + case n < 1<<8: + dst[0] = 60<<2 | tagLiteral + dst[1] = uint8(n) + i = 2 + default: + dst[0] = 61<<2 | tagLiteral + dst[1] = uint8(n) + dst[2] = uint8(n >> 8) + i = 3 + } + return i + copy(dst[i:], lit) +} + +// emitCopy writes a copy chunk and returns the number of bytes written. +// +// It assumes that: +// dst is long enough to hold the encoded bytes +// 1 <= offset && offset <= 65535 +// 4 <= length && length <= 65535 +func emitCopy(dst []byte, offset, length int) int { + i := 0 + // The maximum length for a single tagCopy1 or tagCopy2 op is 64 bytes. The + // threshold for this loop is a little higher (at 68 = 64 + 4), and the + // length emitted down below is is a little lower (at 60 = 64 - 4), because + // it's shorter to encode a length 67 copy as a length 60 tagCopy2 followed + // by a length 7 tagCopy1 (which encodes as 3+2 bytes) than to encode it as + // a length 64 tagCopy2 followed by a length 3 tagCopy2 (which encodes as + // 3+3 bytes). The magic 4 in the 64±4 is because the minimum length for a + // tagCopy1 op is 4 bytes, which is why a length 3 copy has to be an + // encodes-as-3-bytes tagCopy2 instead of an encodes-as-2-bytes tagCopy1. + for length >= 68 { + // Emit a length 64 copy, encoded as 3 bytes. + dst[i+0] = 63<<2 | tagCopy2 + dst[i+1] = uint8(offset) + dst[i+2] = uint8(offset >> 8) + i += 3 + length -= 64 + } + if length > 64 { + // Emit a length 60 copy, encoded as 3 bytes. + dst[i+0] = 59<<2 | tagCopy2 + dst[i+1] = uint8(offset) + dst[i+2] = uint8(offset >> 8) + i += 3 + length -= 60 + } + if length >= 12 || offset >= 2048 { + // Emit the remaining copy, encoded as 3 bytes. + dst[i+0] = uint8(length-1)<<2 | tagCopy2 + dst[i+1] = uint8(offset) + dst[i+2] = uint8(offset >> 8) + return i + 3 + } + // Emit the remaining copy, encoded as 2 bytes. + dst[i+0] = uint8(offset>>8)<<5 | uint8(length-4)<<2 | tagCopy1 + dst[i+1] = uint8(offset) + return i + 2 +} + +// extendMatch returns the largest k such that k <= len(src) and that +// src[i:i+k-j] and src[j:k] have the same contents. +// +// It assumes that: +// 0 <= i && i < j && j <= len(src) +func extendMatch(src []byte, i, j int) int { + for ; j < len(src) && src[i] == src[j]; i, j = i+1, j+1 { + } + return j +} + +func hash(u, shift uint32) uint32 { + return (u * 0x1e35a7bd) >> shift +} + +// encodeBlock encodes a non-empty src to a guaranteed-large-enough dst. It +// assumes that the varint-encoded length of the decompressed bytes has already +// been written. +// +// It also assumes that: +// len(dst) >= MaxEncodedLen(len(src)) && +// minNonLiteralBlockSize <= len(src) && len(src) <= maxBlockSize +func encodeBlock(dst, src []byte) (d int) { + // Initialize the hash table. Its size ranges from 1<<8 to 1<<14 inclusive. + // The table element type is uint16, as s < sLimit and sLimit < len(src) + // and len(src) <= maxBlockSize and maxBlockSize == 65536. + const ( + maxTableSize = 1 << 14 + // tableMask is redundant, but helps the compiler eliminate bounds + // checks. + tableMask = maxTableSize - 1 + ) + shift := uint32(32 - 8) + for tableSize := 1 << 8; tableSize < maxTableSize && tableSize < len(src); tableSize *= 2 { + shift-- + } + // In Go, all array elements are zero-initialized, so there is no advantage + // to a smaller tableSize per se. However, it matches the C++ algorithm, + // and in the asm versions of this code, we can get away with zeroing only + // the first tableSize elements. + var table [maxTableSize]uint16 + + // sLimit is when to stop looking for offset/length copies. The inputMargin + // lets us use a fast path for emitLiteral in the main loop, while we are + // looking for copies. + sLimit := len(src) - inputMargin + + // nextEmit is where in src the next emitLiteral should start from. + nextEmit := 0 + + // The encoded form must start with a literal, as there are no previous + // bytes to copy, so we start looking for hash matches at s == 1. + s := 1 + nextHash := hash(load32(src, s), shift) + + for { + // Copied from the C++ snappy implementation: + // + // Heuristic match skipping: If 32 bytes are scanned with no matches + // found, start looking only at every other byte. If 32 more bytes are + // scanned (or skipped), look at every third byte, etc.. When a match + // is found, immediately go back to looking at every byte. This is a + // small loss (~5% performance, ~0.1% density) for compressible data + // due to more bookkeeping, but for non-compressible data (such as + // JPEG) it's a huge win since the compressor quickly "realizes" the + // data is incompressible and doesn't bother looking for matches + // everywhere. + // + // The "skip" variable keeps track of how many bytes there are since + // the last match; dividing it by 32 (ie. right-shifting by five) gives + // the number of bytes to move ahead for each iteration. + skip := 32 + + nextS := s + candidate := 0 + for { + s = nextS + bytesBetweenHashLookups := skip >> 5 + nextS = s + bytesBetweenHashLookups + skip += bytesBetweenHashLookups + if nextS > sLimit { + goto emitRemainder + } + candidate = int(table[nextHash&tableMask]) + table[nextHash&tableMask] = uint16(s) + nextHash = hash(load32(src, nextS), shift) + if load32(src, s) == load32(src, candidate) { + break + } + } + + // A 4-byte match has been found. We'll later see if more than 4 bytes + // match. But, prior to the match, src[nextEmit:s] are unmatched. Emit + // them as literal bytes. + d += emitLiteral(dst[d:], src[nextEmit:s]) + + // Call emitCopy, and then see if another emitCopy could be our next + // move. Repeat until we find no match for the input immediately after + // what was consumed by the last emitCopy call. + // + // If we exit this loop normally then we need to call emitLiteral next, + // though we don't yet know how big the literal will be. We handle that + // by proceeding to the next iteration of the main loop. We also can + // exit this loop via goto if we get close to exhausting the input. + for { + // Invariant: we have a 4-byte match at s, and no need to emit any + // literal bytes prior to s. + base := s + + // Extend the 4-byte match as long as possible. + // + // This is an inlined version of: + // s = extendMatch(src, candidate+4, s+4) + s += 4 + for i := candidate + 4; s < len(src) && src[i] == src[s]; i, s = i+1, s+1 { + } + + d += emitCopy(dst[d:], base-candidate, s-base) + nextEmit = s + if s >= sLimit { + goto emitRemainder + } + + // We could immediately start working at s now, but to improve + // compression we first update the hash table at s-1 and at s. If + // another emitCopy is not our next move, also calculate nextHash + // at s+1. At least on GOARCH=amd64, these three hash calculations + // are faster as one load64 call (with some shifts) instead of + // three load32 calls. + x := load64(src, s-1) + prevHash := hash(uint32(x>>0), shift) + table[prevHash&tableMask] = uint16(s - 1) + currHash := hash(uint32(x>>8), shift) + candidate = int(table[currHash&tableMask]) + table[currHash&tableMask] = uint16(s) + if uint32(x>>8) != load32(src, candidate) { + nextHash = hash(uint32(x>>16), shift) + s++ + break + } + } + } + +emitRemainder: + if nextEmit < len(src) { + d += emitLiteral(dst[d:], src[nextEmit:]) + } + return d +} diff --git a/cmd/vendor/github.com/golang/snappy/snappy.go b/_vendor/vendor/github.com/golang/snappy/snappy.go similarity index 69% rename from cmd/vendor/github.com/golang/snappy/snappy.go rename to _vendor/vendor/github.com/golang/snappy/snappy.go index e98653a..0cf5e37 100644 --- a/cmd/vendor/github.com/golang/snappy/snappy.go +++ b/_vendor/vendor/github.com/golang/snappy/snappy.go @@ -6,7 +6,7 @@ // It aims for very high speeds and reasonable compression. // // The C++ snappy implementation is at https://github.com/google/snappy -package snappy +package snappy // import "github.com/golang/snappy" import ( "hash/crc32" @@ -32,7 +32,10 @@ Lempel-Ziv compression algorithms. In particular: - For l == 2, the offset ranges in [0, 1<<16) and the length in [1, 65). The length is 1 + m. The offset is the little-endian unsigned integer denoted by the next 2 bytes. - - For l == 3, this tag is a legacy format that is no longer supported. + - For l == 3, this tag is a legacy format that is no longer issued by most + encoders. Nonetheless, the offset ranges in [0, 1<<32) and the length in + [1, 65). The length is 1 + m. The offset is the little-endian unsigned + integer denoted by the next 4 bytes. */ const ( tagLiteral = 0x00 @@ -46,9 +49,25 @@ const ( chunkHeaderSize = 4 magicChunk = "\xff\x06\x00\x00" + magicBody magicBody = "sNaPpY" + + // maxBlockSize is the maximum size of the input to encodeBlock. It is not + // part of the wire format per se, but some parts of the encoder assume + // that an offset fits into a uint16. + // + // Also, for the framing format (Writer type instead of Encode function), // https://github.com/google/snappy/blob/master/framing_format.txt says - // that "the uncompressed data in a chunk must be no longer than 65536 bytes". - maxUncompressedChunkLen = 65536 + // that "the uncompressed data in a chunk must be no longer than 65536 + // bytes". + maxBlockSize = 65536 + + // maxEncodedLenOfMaxBlockSize equals MaxEncodedLen(maxBlockSize), but is + // hard coded to be a const instead of a variable, so that obufLen can also + // be a const. Their equivalence is confirmed by + // TestMaxEncodedLenOfMaxBlockSize. + maxEncodedLenOfMaxBlockSize = 76490 + + obufHeaderLen = len(magicChunk) + checksumSize + chunkHeaderSize + obufLen = obufHeaderLen + maxEncodedLenOfMaxBlockSize ) const ( diff --git a/cmd/vendor/github.com/peterh/liner/COPYING b/_vendor/vendor/github.com/peterh/liner/COPYING similarity index 100% rename from cmd/vendor/github.com/peterh/liner/COPYING rename to _vendor/vendor/github.com/peterh/liner/COPYING diff --git a/cmd/vendor/github.com/peterh/liner/bsdinput.go b/_vendor/vendor/github.com/peterh/liner/bsdinput.go similarity index 94% rename from cmd/vendor/github.com/peterh/liner/bsdinput.go rename to _vendor/vendor/github.com/peterh/liner/bsdinput.go index 4b552d4..3593398 100644 --- a/cmd/vendor/github.com/peterh/liner/bsdinput.go +++ b/_vendor/vendor/github.com/peterh/liner/bsdinput.go @@ -37,3 +37,5 @@ type termios struct { Ispeed int32 Ospeed int32 } + +const cursorColumn = false diff --git a/cmd/vendor/github.com/peterh/liner/common.go b/_vendor/vendor/github.com/peterh/liner/common.go similarity index 87% rename from cmd/vendor/github.com/peterh/liner/common.go rename to _vendor/vendor/github.com/peterh/liner/common.go index 5f9181a..e5b8fc2 100644 --- a/cmd/vendor/github.com/peterh/liner/common.go +++ b/_vendor/vendor/github.com/peterh/liner/common.go @@ -7,7 +7,6 @@ package liner import ( "bufio" - "bytes" "container/ring" "errors" "fmt" @@ -32,6 +31,8 @@ type commonState struct { multiLineMode bool cursorRows int maxRows int + shouldRestart ShouldRestart + needRefresh bool } // TabStyle is used to select how tab completions are displayed. @@ -58,7 +59,12 @@ var ErrPromptAborted = errors.New("prompt aborted") // platform is normally supported, but stdout has been redirected var ErrNotTerminalOutput = errors.New("standard output is not a terminal") -// Max elements to save on the killring +// ErrInvalidPrompt is returned from Prompt or PasswordPrompt if the +// prompt contains any unprintable runes (including substrings that could +// be colour codes on some platforms). +var ErrInvalidPrompt = errors.New("invalid prompt") + +// KillRingMax is the max number of elements to save on the killring. const KillRingMax = 60 // HistoryLimit is the maximum number of entries saved in the scrollback history. @@ -133,6 +139,13 @@ func (s *State) AppendHistory(item string) { } } +// ClearHistory clears the scroollback history. +func (s *State) ClearHistory() { + s.historyMutex.Lock() + defer s.historyMutex.Unlock() + s.history = nil +} + // Returns the history lines starting with prefix func (s *State) getHistoryByPrefix(prefix string) (ph []string) { for _, h := range s.history { @@ -215,6 +228,16 @@ func (s *State) SetMultiLineMode(mlmode bool) { s.multiLineMode = mlmode } +// ShouldRestart is passed the error generated by readNext and returns true if +// the the read should be restarted or false if the error should be returned. +type ShouldRestart func(err error) bool + +// SetShouldRestart sets the restart function that Liner will call to determine +// whether to retry the call to, or return the error returned by, readNext. +func (s *State) SetShouldRestart(f ShouldRestart) { + s.shouldRestart = f +} + func (s *State) promptUnsupported(p string) (string, error) { if !s.inputRedirected || !s.terminalSupported { fmt.Print(p) @@ -223,5 +246,5 @@ func (s *State) promptUnsupported(p string) (string, error) { if err != nil { return "", err } - return string(bytes.TrimSpace(linebuf)), nil + return string(linebuf), nil } diff --git a/cmd/vendor/github.com/peterh/liner/fallbackinput.go b/_vendor/vendor/github.com/peterh/liner/fallbackinput.go similarity index 100% rename from cmd/vendor/github.com/peterh/liner/fallbackinput.go rename to _vendor/vendor/github.com/peterh/liner/fallbackinput.go diff --git a/cmd/vendor/github.com/peterh/liner/input.go b/_vendor/vendor/github.com/peterh/liner/input.go similarity index 95% rename from cmd/vendor/github.com/peterh/liner/input.go rename to _vendor/vendor/github.com/peterh/liner/input.go index c80c85f..904fbf6 100644 --- a/cmd/vendor/github.com/peterh/liner/input.go +++ b/_vendor/vendor/github.com/peterh/liner/input.go @@ -31,11 +31,6 @@ type State struct { // NewLiner initializes a new *State, and sets the terminal into raw mode. To // restore the terminal to its previous state, call State.Close(). -// -// Note if you are still using Go 1.0: NewLiner handles SIGWINCH, so it will -// leak a channel every time you call it. Therefore, it is recommened that you -// upgrade to a newer release of Go, or ensure that NewLiner is only called -// once. func NewLiner() *State { var s State s.r = bufio.NewReader(os.Stdin) @@ -67,8 +62,7 @@ func NewLiner() *State { } if !s.outputRedirected { - s.getColumns() - s.outputRedirected = s.columns <= 0 + s.outputRedirected = !s.getColumns() } return &s @@ -88,8 +82,12 @@ func (s *State) startPrompt() { s.restartPrompt() } +func (s *State) inputWaiting() bool { + return len(s.next) > 0 +} + func (s *State) restartPrompt() { - next := make(chan nexter) + next := make(chan nexter, 200) go func() { for { var n nexter @@ -127,8 +125,6 @@ func (s *State) nextPending(timeout <-chan time.Time) (rune, error) { s.pending = s.pending[1:] return rv, errTimedOut } - // not reached - return 0, nil } func (s *State) readNext() (interface{}, error) { @@ -350,7 +346,7 @@ func (s *State) readNext() (interface{}, error) { // Close returns the terminal to its previous mode func (s *State) Close() error { - stopSignal(s.winch) + signal.Stop(s.winch) if !s.inputRedirected { s.origMode.ApplyMode() } diff --git a/cmd/vendor/github.com/peterh/liner/input_darwin.go b/_vendor/vendor/github.com/peterh/liner/input_darwin.go similarity index 78% rename from cmd/vendor/github.com/peterh/liner/input_darwin.go rename to _vendor/vendor/github.com/peterh/liner/input_darwin.go index 23c9c5d..e98ab4a 100644 --- a/cmd/vendor/github.com/peterh/liner/input_darwin.go +++ b/_vendor/vendor/github.com/peterh/liner/input_darwin.go @@ -37,3 +37,7 @@ type termios struct { Ispeed uintptr Ospeed uintptr } + +// Terminal.app needs a column for the cursor when the input line is at the +// bottom of the window. +const cursorColumn = true diff --git a/cmd/vendor/github.com/peterh/liner/input_linux.go b/_vendor/vendor/github.com/peterh/liner/input_linux.go similarity index 93% rename from cmd/vendor/github.com/peterh/liner/input_linux.go rename to _vendor/vendor/github.com/peterh/liner/input_linux.go index 6ca8712..56ed185 100644 --- a/cmd/vendor/github.com/peterh/liner/input_linux.go +++ b/_vendor/vendor/github.com/peterh/liner/input_linux.go @@ -24,3 +24,5 @@ const ( type termios struct { syscall.Termios } + +const cursorColumn = false diff --git a/cmd/vendor/github.com/peterh/liner/input_windows.go b/_vendor/vendor/github.com/peterh/liner/input_windows.go similarity index 85% rename from cmd/vendor/github.com/peterh/liner/input_windows.go rename to _vendor/vendor/github.com/peterh/liner/input_windows.go index 9dcc311..a48eb0f 100644 --- a/cmd/vendor/github.com/peterh/liner/input_windows.go +++ b/_vendor/vendor/github.com/peterh/liner/input_windows.go @@ -10,13 +10,14 @@ import ( var ( kernel32 = syscall.NewLazyDLL("kernel32.dll") - procGetStdHandle = kernel32.NewProc("GetStdHandle") - procReadConsoleInput = kernel32.NewProc("ReadConsoleInputW") - procGetConsoleMode = kernel32.NewProc("GetConsoleMode") - procSetConsoleMode = kernel32.NewProc("SetConsoleMode") - procSetConsoleCursorPosition = kernel32.NewProc("SetConsoleCursorPosition") - procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo") - procFillConsoleOutputCharacter = kernel32.NewProc("FillConsoleOutputCharacterW") + procGetStdHandle = kernel32.NewProc("GetStdHandle") + procReadConsoleInput = kernel32.NewProc("ReadConsoleInputW") + procGetNumberOfConsoleInputEvents = kernel32.NewProc("GetNumberOfConsoleInputEvents") + procGetConsoleMode = kernel32.NewProc("GetConsoleMode") + procSetConsoleMode = kernel32.NewProc("SetConsoleMode") + procSetConsoleCursorPosition = kernel32.NewProc("SetConsoleCursorPosition") + procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo") + procFillConsoleOutputCharacter = kernel32.NewProc("FillConsoleOutputCharacterW") ) // These names are from the Win32 api, so they use underscores (contrary to @@ -147,6 +148,21 @@ const ( modKeys = shiftPressed | leftAltPressed | rightAltPressed | leftCtrlPressed | rightCtrlPressed ) +// inputWaiting only returns true if the next call to readNext will return immediately. +func (s *State) inputWaiting() bool { + var num uint32 + ok, _, _ := procGetNumberOfConsoleInputEvents.Call(uintptr(s.handle), uintptr(unsafe.Pointer(&num))) + if ok == 0 { + // call failed, so we cannot guarantee a non-blocking readNext + return false + } + + // during a "paste" input events are always an odd number, and + // the last one results in a blocking readNext, so return false + // when num is 1 or 0. + return num > 1 +} + func (s *State) readNext() (interface{}, error) { if s.repeat > 0 { s.repeat-- @@ -168,6 +184,9 @@ func (s *State) readNext() (interface{}, error) { if input.eventType == window_buffer_size_event { xy := (*coord)(unsafe.Pointer(&input.blob[0])) s.columns = int(xy.x) + if s.columns > 1 { + s.columns-- + } return winch, nil } if input.eventType != key_event { @@ -260,7 +279,6 @@ func (s *State) readNext() (interface{}, error) { } return s.key, nil } - return unknown, nil } // Close returns the terminal to its previous mode diff --git a/cmd/vendor/github.com/peterh/liner/line.go b/_vendor/vendor/github.com/peterh/liner/line.go similarity index 88% rename from cmd/vendor/github.com/peterh/liner/line.go rename to _vendor/vendor/github.com/peterh/liner/line.go index 32f9028..cc147d6 100644 --- a/cmd/vendor/github.com/peterh/liner/line.go +++ b/_vendor/vendor/github.com/peterh/liner/line.go @@ -90,11 +90,11 @@ const ( ) func (s *State) refresh(prompt []rune, buf []rune, pos int) error { + s.needRefresh = false if s.multiLineMode { return s.refreshMultiLine(prompt, buf, pos) - } else { - return s.refreshSingleLine(prompt, buf, pos) } + return s.refreshSingleLine(prompt, buf, pos) } func (s *State) refreshSingleLine(prompt []rune, buf []rune, pos int) error { @@ -387,8 +387,6 @@ func (s *State) tabComplete(p []rune, line []rune, pos int) ([]rune, int, interf } return []rune(head + pick + tail), hl + utf8.RuneCountInString(pick), next, nil } - // Not reached - return line, pos, rune(esc), nil } // reverse intelligent search, implements a bash-like history search. @@ -556,14 +554,26 @@ func (s *State) yank(p []rune, text []rune, pos int) ([]rune, int, interface{}, } } } - - return line, pos, esc, nil } // Prompt displays p and returns a line of user input, not including a trailing // newline character. An io.EOF error is returned if the user signals end-of-file // by pressing Ctrl-D. Prompt allows line editing if the terminal supports it. func (s *State) Prompt(prompt string) (string, error) { + return s.PromptWithSuggestion(prompt, "", 0) +} + +// PromptWithSuggestion displays prompt and an editable text with cursor at +// given position. The cursor will be set to the end of the line if given position +// is negative or greater than length of text. Returns a line of user input, not +// including a trailing newline character. An io.EOF error is returned if the user +// signals end-of-file by pressing Ctrl-D. +func (s *State) PromptWithSuggestion(prompt string, text string, pos int) (string, error) { + for _, r := range prompt { + if unicode.Is(unicode.C, r) { + return "", ErrInvalidPrompt + } + } if s.inputRedirected || !s.terminalSupported { return s.promptUnsupported(prompt) } @@ -574,24 +584,37 @@ func (s *State) Prompt(prompt string) (string, error) { s.historyMutex.RLock() defer s.historyMutex.RUnlock() - s.startPrompt() - defer s.stopPrompt() - s.getColumns() - fmt.Print(prompt) p := []rune(prompt) - var line []rune - pos := 0 + var line = []rune(text) historyEnd := "" - prefixHistory := s.getHistoryByPrefix(string(line)) - historyPos := len(prefixHistory) + var historyPrefix []string + historyPos := 0 + historyStale := true historyAction := false // used to mark history related actions killAction := 0 // used to mark kill related actions + + defer s.stopPrompt() + + if pos < 0 || len(text) < pos { + pos = len(text) + } + if len(line) > 0 { + s.refresh(p, line, pos) + } + +restart: + s.startPrompt() + s.getColumns() + mainLoop: for { next, err := s.readNext() haveNext: if err != nil { + if s.shouldRestart != nil && s.shouldRestart(err) { + goto restart + } return "", err } @@ -600,6 +623,9 @@ mainLoop: case rune: switch v { case cr, lf: + if s.needRefresh { + s.refresh(p, line, pos) + } if s.multiLineMode { s.resetMultiLine(p, line, pos) } @@ -607,21 +633,21 @@ mainLoop: break mainLoop case ctrlA: // Start of line pos = 0 - s.refresh(p, line, pos) + s.needRefresh = true case ctrlE: // End of line pos = len(line) - s.refresh(p, line, pos) + s.needRefresh = true case ctrlB: // left if pos > 0 { pos -= len(getSuffixGlyphs(line[:pos], 1)) - s.refresh(p, line, pos) + s.needRefresh = true } else { fmt.Print(beep) } case ctrlF: // right if pos < len(line) { pos += len(getPrefixGlyphs(line[pos:], 1)) - s.refresh(p, line, pos) + s.needRefresh = true } else { fmt.Print(beep) } @@ -640,7 +666,7 @@ mainLoop: } else { n := len(getPrefixGlyphs(line[pos:], 1)) line = append(line[:pos], line[pos+n:]...) - s.refresh(p, line, pos) + s.needRefresh = true } case ctrlK: // delete remainder of line if pos >= len(line) { @@ -654,32 +680,42 @@ mainLoop: killAction = 2 // Mark that there was a kill action line = line[:pos] - s.refresh(p, line, pos) + s.needRefresh = true } case ctrlP: // up historyAction = true + if historyStale { + historyPrefix = s.getHistoryByPrefix(string(line)) + historyPos = len(historyPrefix) + historyStale = false + } if historyPos > 0 { - if historyPos == len(prefixHistory) { + if historyPos == len(historyPrefix) { historyEnd = string(line) } historyPos-- - line = []rune(prefixHistory[historyPos]) + line = []rune(historyPrefix[historyPos]) pos = len(line) - s.refresh(p, line, pos) + s.needRefresh = true } else { fmt.Print(beep) } case ctrlN: // down historyAction = true - if historyPos < len(prefixHistory) { + if historyStale { + historyPrefix = s.getHistoryByPrefix(string(line)) + historyPos = len(historyPrefix) + historyStale = false + } + if historyPos < len(historyPrefix) { historyPos++ - if historyPos == len(prefixHistory) { + if historyPos == len(historyPrefix) { line = []rune(historyEnd) } else { - line = []rune(prefixHistory[historyPos]) + line = []rune(historyPrefix[historyPos]) } pos = len(line) - s.refresh(p, line, pos) + s.needRefresh = true } else { fmt.Print(beep) } @@ -697,11 +733,11 @@ mainLoop: copy(line[pos-len(prev):], next) copy(line[pos-len(prev)+len(next):], scratch) pos += len(next) - s.refresh(p, line, pos) + s.needRefresh = true } case ctrlL: // clear screen s.eraseScreen() - s.refresh(p, line, pos) + s.needRefresh = true case ctrlC: // reset fmt.Println("^C") if s.multiLineMode { @@ -721,7 +757,7 @@ mainLoop: n := len(getSuffixGlyphs(line[:pos], 1)) line = append(line[:pos-n], line[pos:]...) pos -= n - s.refresh(p, line, pos) + s.needRefresh = true } case ctrlU: // Erase line before cursor if killAction > 0 { @@ -733,7 +769,7 @@ mainLoop: killAction = 2 // Mark that there was some killing line = line[pos:] pos = 0 - s.refresh(p, line, pos) + s.needRefresh = true case ctrlW: // Erase word if pos == 0 { fmt.Print(beep) @@ -770,13 +806,13 @@ mainLoop: } killAction = 2 // Mark that there was some killing - s.refresh(p, line, pos) + s.needRefresh = true case ctrlY: // Paste from Yank buffer line, pos, next, err = s.yank(p, line, pos) goto haveNext case ctrlR: // Reverse Search line, pos, next, err = s.reverseISearch(line, pos) - s.refresh(p, line, pos) + s.needRefresh = true goto haveNext case tab: // Tab completion line, pos, next, err = s.tabComplete(p, line, pos) @@ -791,14 +827,16 @@ mainLoop: case 0, 28, 29, 30, 31: fmt.Print(beep) default: - if pos == len(line) && !s.multiLineMode && countGlyphs(p)+countGlyphs(line) < s.columns-1 { + if pos == len(line) && !s.multiLineMode && + len(p)+len(line) < s.columns*4 && // Avoid countGlyphs on large lines + countGlyphs(p)+countGlyphs(line) < s.columns-1 { line = append(line, v) fmt.Printf("%c", v) pos++ } else { line = append(line[:pos], append([]rune{v}, line[pos:]...)...) pos++ - s.refresh(p, line, pos) + s.needRefresh = true } } case action: @@ -866,24 +904,34 @@ mainLoop: } case up: historyAction = true + if historyStale { + historyPrefix = s.getHistoryByPrefix(string(line)) + historyPos = len(historyPrefix) + historyStale = false + } if historyPos > 0 { - if historyPos == len(prefixHistory) { + if historyPos == len(historyPrefix) { historyEnd = string(line) } historyPos-- - line = []rune(prefixHistory[historyPos]) + line = []rune(historyPrefix[historyPos]) pos = len(line) } else { fmt.Print(beep) } case down: historyAction = true - if historyPos < len(prefixHistory) { + if historyStale { + historyPrefix = s.getHistoryByPrefix(string(line)) + historyPos = len(historyPrefix) + historyStale = false + } + if historyPos < len(historyPrefix) { historyPos++ - if historyPos == len(prefixHistory) { + if historyPos == len(historyPrefix) { line = []rune(historyEnd) } else { - line = []rune(prefixHistory[historyPos]) + line = []rune(historyPrefix[historyPos]) } pos = len(line) } else { @@ -907,11 +955,13 @@ mainLoop: s.cursorRows = 1 } } + s.needRefresh = true + } + if s.needRefresh && !s.inputWaiting() { s.refresh(p, line, pos) } if !historyAction { - prefixHistory = s.getHistoryByPrefix(string(line)) - historyPos = len(prefixHistory) + historyStale = true } if killAction > 0 { killAction-- @@ -923,6 +973,11 @@ mainLoop: // PasswordPrompt displays p, and then waits for user input. The input typed by // the user is not displayed in the terminal. func (s *State) PasswordPrompt(prompt string) (string, error) { + for _, r := range prompt { + if unicode.Is(unicode.C, r) { + return "", ErrInvalidPrompt + } + } if !s.terminalSupported { return "", errors.New("liner: function not supported in this terminal") } @@ -933,8 +988,10 @@ func (s *State) PasswordPrompt(prompt string) (string, error) { return "", ErrNotTerminalOutput } - s.startPrompt() defer s.stopPrompt() + +restart: + s.startPrompt() s.getColumns() fmt.Print(prompt) @@ -946,6 +1003,9 @@ mainLoop: for { next, err := s.readNext() if err != nil { + if s.shouldRestart != nil && s.shouldRestart(err) { + goto restart + } return "", err } @@ -953,6 +1013,9 @@ mainLoop: case rune: switch v { case cr, lf: + if s.needRefresh { + s.refresh(p, line, pos) + } if s.multiLineMode { s.resetMultiLine(p, line, pos) } diff --git a/cmd/vendor/github.com/peterh/liner/output.go b/_vendor/vendor/github.com/peterh/liner/output.go similarity index 91% rename from cmd/vendor/github.com/peterh/liner/output.go rename to _vendor/vendor/github.com/peterh/liner/output.go index 049273b..6d83d4e 100644 --- a/cmd/vendor/github.com/peterh/liner/output.go +++ b/_vendor/vendor/github.com/peterh/liner/output.go @@ -48,14 +48,18 @@ type winSize struct { xpixel, ypixel uint16 } -func (s *State) getColumns() { +func (s *State) getColumns() bool { var ws winSize ok, _, _ := syscall.Syscall(syscall.SYS_IOCTL, uintptr(syscall.Stdout), syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(&ws))) - if ok < 0 { - s.columns = 80 + if int(ok) < 0 { + return false } s.columns = int(ws.col) + if cursorColumn && s.columns > 1 { + s.columns-- + } + return true } func (s *State) checkOutput() { diff --git a/cmd/vendor/github.com/peterh/liner/output_windows.go b/_vendor/vendor/github.com/peterh/liner/output_windows.go similarity index 96% rename from cmd/vendor/github.com/peterh/liner/output_windows.go rename to _vendor/vendor/github.com/peterh/liner/output_windows.go index 45cd978..63c9c5d 100644 --- a/cmd/vendor/github.com/peterh/liner/output_windows.go +++ b/_vendor/vendor/github.com/peterh/liner/output_windows.go @@ -69,4 +69,8 @@ func (s *State) getColumns() { var sbi consoleScreenBufferInfo procGetConsoleScreenBufferInfo.Call(uintptr(s.hOut), uintptr(unsafe.Pointer(&sbi))) s.columns = int(sbi.dwSize.x) + if s.columns > 1 { + // Windows 10 needs a spare column for the cursor + s.columns-- + } } diff --git a/cmd/vendor/github.com/peterh/liner/unixmode.go b/_vendor/vendor/github.com/peterh/liner/unixmode.go similarity index 100% rename from cmd/vendor/github.com/peterh/liner/unixmode.go rename to _vendor/vendor/github.com/peterh/liner/unixmode.go diff --git a/cmd/vendor/github.com/peterh/liner/width.go b/_vendor/vendor/github.com/peterh/liner/width.go similarity index 86% rename from cmd/vendor/github.com/peterh/liner/width.go rename to _vendor/vendor/github.com/peterh/liner/width.go index d8984aa..42e8999 100644 --- a/cmd/vendor/github.com/peterh/liner/width.go +++ b/_vendor/vendor/github.com/peterh/liner/width.go @@ -25,6 +25,12 @@ var doubleWidth = []*unicode.RangeTable{ func countGlyphs(s []rune) int { n := 0 for _, r := range s { + // speed up the common case + if r < 127 { + n++ + continue + } + switch { case unicode.IsOneOf(zeroWidth, r): case unicode.IsOneOf(doubleWidth, r): @@ -39,6 +45,10 @@ func countGlyphs(s []rune) int { func countMultiLineGlyphs(s []rune, columns int, start int) int { n := start for _, r := range s { + if r < 127 { + n++ + continue + } switch { case unicode.IsOneOf(zeroWidth, r): case unicode.IsOneOf(doubleWidth, r): @@ -58,6 +68,11 @@ func countMultiLineGlyphs(s []rune, columns int, start int) int { func getPrefixGlyphs(s []rune, num int) []rune { p := 0 for n := 0; n < num && p < len(s); p++ { + // speed up the common case + if s[p] < 127 { + n++ + continue + } if !unicode.IsOneOf(zeroWidth, s[p]) { n++ } @@ -71,6 +86,11 @@ func getPrefixGlyphs(s []rune, num int) []rune { func getSuffixGlyphs(s []rune, num int) []rune { p := len(s) for n := 0; n < num && p > 0; p-- { + // speed up the common case + if s[p-1] < 127 { + n++ + continue + } if !unicode.IsOneOf(zeroWidth, s[p-1]) { n++ } diff --git a/cmd/vendor/github.com/siddontang/go/LICENSE b/_vendor/vendor/github.com/siddontang/go/LICENSE similarity index 100% rename from cmd/vendor/github.com/siddontang/go/LICENSE rename to _vendor/vendor/github.com/siddontang/go/LICENSE diff --git a/cmd/vendor/github.com/siddontang/go/bson/LICENSE b/_vendor/vendor/github.com/siddontang/go/bson/LICENSE similarity index 100% rename from cmd/vendor/github.com/siddontang/go/bson/LICENSE rename to _vendor/vendor/github.com/siddontang/go/bson/LICENSE diff --git a/cmd/vendor/github.com/siddontang/go/bson/bson.go b/_vendor/vendor/github.com/siddontang/go/bson/bson.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/bson/bson.go rename to _vendor/vendor/github.com/siddontang/go/bson/bson.go diff --git a/cmd/vendor/github.com/siddontang/go/bson/decode.go b/_vendor/vendor/github.com/siddontang/go/bson/decode.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/bson/decode.go rename to _vendor/vendor/github.com/siddontang/go/bson/decode.go diff --git a/cmd/vendor/github.com/siddontang/go/bson/encode.go b/_vendor/vendor/github.com/siddontang/go/bson/encode.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/bson/encode.go rename to _vendor/vendor/github.com/siddontang/go/bson/encode.go diff --git a/cmd/vendor/github.com/siddontang/go/filelock/LICENSE b/_vendor/vendor/github.com/siddontang/go/filelock/LICENSE similarity index 100% rename from cmd/vendor/github.com/siddontang/go/filelock/LICENSE rename to _vendor/vendor/github.com/siddontang/go/filelock/LICENSE diff --git a/cmd/vendor/github.com/siddontang/go/filelock/file_lock_generic.go b/_vendor/vendor/github.com/siddontang/go/filelock/file_lock_generic.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/filelock/file_lock_generic.go rename to _vendor/vendor/github.com/siddontang/go/filelock/file_lock_generic.go diff --git a/cmd/vendor/github.com/siddontang/go/filelock/file_lock_solaris.go b/_vendor/vendor/github.com/siddontang/go/filelock/file_lock_solaris.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/filelock/file_lock_solaris.go rename to _vendor/vendor/github.com/siddontang/go/filelock/file_lock_solaris.go diff --git a/cmd/vendor/github.com/siddontang/go/filelock/file_lock_unix.go b/_vendor/vendor/github.com/siddontang/go/filelock/file_lock_unix.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/filelock/file_lock_unix.go rename to _vendor/vendor/github.com/siddontang/go/filelock/file_lock_unix.go diff --git a/cmd/vendor/github.com/siddontang/go/filelock/file_lock_windows.go b/_vendor/vendor/github.com/siddontang/go/filelock/file_lock_windows.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/filelock/file_lock_windows.go rename to _vendor/vendor/github.com/siddontang/go/filelock/file_lock_windows.go diff --git a/cmd/vendor/github.com/siddontang/go/hack/hack.go b/_vendor/vendor/github.com/siddontang/go/hack/hack.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/hack/hack.go rename to _vendor/vendor/github.com/siddontang/go/hack/hack.go diff --git a/cmd/vendor/github.com/siddontang/go/ioutil2/ioutil.go b/_vendor/vendor/github.com/siddontang/go/ioutil2/ioutil.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/ioutil2/ioutil.go rename to _vendor/vendor/github.com/siddontang/go/ioutil2/ioutil.go diff --git a/cmd/vendor/github.com/siddontang/go/ioutil2/sectionwriter.go b/_vendor/vendor/github.com/siddontang/go/ioutil2/sectionwriter.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/ioutil2/sectionwriter.go rename to _vendor/vendor/github.com/siddontang/go/ioutil2/sectionwriter.go diff --git a/cmd/vendor/github.com/siddontang/go/log/doc.go b/_vendor/vendor/github.com/siddontang/go/log/doc.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/log/doc.go rename to _vendor/vendor/github.com/siddontang/go/log/doc.go diff --git a/cmd/vendor/github.com/siddontang/go/log/filehandler.go b/_vendor/vendor/github.com/siddontang/go/log/filehandler.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/log/filehandler.go rename to _vendor/vendor/github.com/siddontang/go/log/filehandler.go diff --git a/cmd/vendor/github.com/siddontang/go/log/handler.go b/_vendor/vendor/github.com/siddontang/go/log/handler.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/log/handler.go rename to _vendor/vendor/github.com/siddontang/go/log/handler.go diff --git a/cmd/vendor/github.com/siddontang/go/log/log.go b/_vendor/vendor/github.com/siddontang/go/log/log.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/log/log.go rename to _vendor/vendor/github.com/siddontang/go/log/log.go diff --git a/cmd/vendor/github.com/siddontang/go/log/sockethandler.go b/_vendor/vendor/github.com/siddontang/go/log/sockethandler.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/log/sockethandler.go rename to _vendor/vendor/github.com/siddontang/go/log/sockethandler.go diff --git a/cmd/vendor/github.com/siddontang/go/num/bytes.go b/_vendor/vendor/github.com/siddontang/go/num/bytes.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/num/bytes.go rename to _vendor/vendor/github.com/siddontang/go/num/bytes.go diff --git a/cmd/vendor/github.com/siddontang/go/num/cmp.go b/_vendor/vendor/github.com/siddontang/go/num/cmp.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/num/cmp.go rename to _vendor/vendor/github.com/siddontang/go/num/cmp.go diff --git a/cmd/vendor/github.com/siddontang/go/num/str.go b/_vendor/vendor/github.com/siddontang/go/num/str.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/num/str.go rename to _vendor/vendor/github.com/siddontang/go/num/str.go diff --git a/cmd/vendor/github.com/siddontang/go/snappy/LICENSE b/_vendor/vendor/github.com/siddontang/go/snappy/LICENSE similarity index 100% rename from cmd/vendor/github.com/siddontang/go/snappy/LICENSE rename to _vendor/vendor/github.com/siddontang/go/snappy/LICENSE diff --git a/cmd/vendor/github.com/siddontang/go/snappy/decode.go b/_vendor/vendor/github.com/siddontang/go/snappy/decode.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/snappy/decode.go rename to _vendor/vendor/github.com/siddontang/go/snappy/decode.go diff --git a/cmd/vendor/github.com/siddontang/go/snappy/encode.go b/_vendor/vendor/github.com/siddontang/go/snappy/encode.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/snappy/encode.go rename to _vendor/vendor/github.com/siddontang/go/snappy/encode.go diff --git a/cmd/vendor/github.com/siddontang/go/snappy/snappy.go b/_vendor/vendor/github.com/siddontang/go/snappy/snappy.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/snappy/snappy.go rename to _vendor/vendor/github.com/siddontang/go/snappy/snappy.go diff --git a/cmd/vendor/github.com/siddontang/go/sync2/atomic.go b/_vendor/vendor/github.com/siddontang/go/sync2/atomic.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/sync2/atomic.go rename to _vendor/vendor/github.com/siddontang/go/sync2/atomic.go diff --git a/cmd/vendor/github.com/siddontang/go/sync2/semaphore.go b/_vendor/vendor/github.com/siddontang/go/sync2/semaphore.go similarity index 100% rename from cmd/vendor/github.com/siddontang/go/sync2/semaphore.go rename to _vendor/vendor/github.com/siddontang/go/sync2/semaphore.go diff --git a/cmd/vendor/github.com/siddontang/golua/LICENSE b/_vendor/vendor/github.com/siddontang/golua/LICENSE similarity index 100% rename from cmd/vendor/github.com/siddontang/golua/LICENSE rename to _vendor/vendor/github.com/siddontang/golua/LICENSE diff --git a/cmd/vendor/github.com/siddontang/golua/c-golua.c b/_vendor/vendor/github.com/siddontang/golua/c-golua.c similarity index 100% rename from cmd/vendor/github.com/siddontang/golua/c-golua.c rename to _vendor/vendor/github.com/siddontang/golua/c-golua.c diff --git a/cmd/vendor/github.com/siddontang/golua/doc.go b/_vendor/vendor/github.com/siddontang/golua/doc.go similarity index 100% rename from cmd/vendor/github.com/siddontang/golua/doc.go rename to _vendor/vendor/github.com/siddontang/golua/doc.go diff --git a/cmd/vendor/github.com/siddontang/golua/golua.go b/_vendor/vendor/github.com/siddontang/golua/golua.go similarity index 100% rename from cmd/vendor/github.com/siddontang/golua/golua.go rename to _vendor/vendor/github.com/siddontang/golua/golua.go diff --git a/cmd/vendor/github.com/siddontang/golua/golua.h b/_vendor/vendor/github.com/siddontang/golua/golua.h similarity index 100% rename from cmd/vendor/github.com/siddontang/golua/golua.h rename to _vendor/vendor/github.com/siddontang/golua/golua.h diff --git a/cmd/vendor/github.com/siddontang/golua/lauxlib.go b/_vendor/vendor/github.com/siddontang/golua/lauxlib.go similarity index 100% rename from cmd/vendor/github.com/siddontang/golua/lauxlib.go rename to _vendor/vendor/github.com/siddontang/golua/lauxlib.go diff --git a/cmd/vendor/github.com/siddontang/golua/lua.go b/_vendor/vendor/github.com/siddontang/golua/lua.go similarity index 100% rename from cmd/vendor/github.com/siddontang/golua/lua.go rename to _vendor/vendor/github.com/siddontang/golua/lua.go diff --git a/cmd/vendor/github.com/siddontang/golua/lua_cjson.c b/_vendor/vendor/github.com/siddontang/golua/lua_cjson.c similarity index 100% rename from cmd/vendor/github.com/siddontang/golua/lua_cjson.c rename to _vendor/vendor/github.com/siddontang/golua/lua_cjson.c diff --git a/cmd/vendor/github.com/siddontang/golua/lua_cmsgpack.c b/_vendor/vendor/github.com/siddontang/golua/lua_cmsgpack.c similarity index 100% rename from cmd/vendor/github.com/siddontang/golua/lua_cmsgpack.c rename to _vendor/vendor/github.com/siddontang/golua/lua_cmsgpack.c diff --git a/cmd/vendor/github.com/siddontang/golua/lua_defs.go b/_vendor/vendor/github.com/siddontang/golua/lua_defs.go similarity index 100% rename from cmd/vendor/github.com/siddontang/golua/lua_defs.go rename to _vendor/vendor/github.com/siddontang/golua/lua_defs.go diff --git a/cmd/vendor/github.com/siddontang/golua/lua_struct.c b/_vendor/vendor/github.com/siddontang/golua/lua_struct.c similarity index 100% rename from cmd/vendor/github.com/siddontang/golua/lua_struct.c rename to _vendor/vendor/github.com/siddontang/golua/lua_struct.c diff --git a/cmd/vendor/github.com/siddontang/golua/strbuf.c b/_vendor/vendor/github.com/siddontang/golua/strbuf.c similarity index 100% rename from cmd/vendor/github.com/siddontang/golua/strbuf.c rename to _vendor/vendor/github.com/siddontang/golua/strbuf.c diff --git a/cmd/vendor/github.com/siddontang/golua/strbuf.h b/_vendor/vendor/github.com/siddontang/golua/strbuf.h similarity index 100% rename from cmd/vendor/github.com/siddontang/golua/strbuf.h rename to _vendor/vendor/github.com/siddontang/golua/strbuf.h diff --git a/cmd/vendor/github.com/siddontang/goredis/LICENSE b/_vendor/vendor/github.com/siddontang/goredis/LICENSE similarity index 100% rename from cmd/vendor/github.com/siddontang/goredis/LICENSE rename to _vendor/vendor/github.com/siddontang/goredis/LICENSE diff --git a/cmd/vendor/github.com/siddontang/goredis/client.go b/_vendor/vendor/github.com/siddontang/goredis/client.go similarity index 100% rename from cmd/vendor/github.com/siddontang/goredis/client.go rename to _vendor/vendor/github.com/siddontang/goredis/client.go diff --git a/cmd/vendor/github.com/siddontang/goredis/conn.go b/_vendor/vendor/github.com/siddontang/goredis/conn.go similarity index 100% rename from cmd/vendor/github.com/siddontang/goredis/conn.go rename to _vendor/vendor/github.com/siddontang/goredis/conn.go diff --git a/cmd/vendor/github.com/siddontang/goredis/doc.go b/_vendor/vendor/github.com/siddontang/goredis/doc.go similarity index 100% rename from cmd/vendor/github.com/siddontang/goredis/doc.go rename to _vendor/vendor/github.com/siddontang/goredis/doc.go diff --git a/cmd/vendor/github.com/siddontang/goredis/reply.go b/_vendor/vendor/github.com/siddontang/goredis/reply.go similarity index 100% rename from cmd/vendor/github.com/siddontang/goredis/reply.go rename to _vendor/vendor/github.com/siddontang/goredis/reply.go diff --git a/cmd/vendor/github.com/siddontang/goredis/resp.go b/_vendor/vendor/github.com/siddontang/goredis/resp.go similarity index 100% rename from cmd/vendor/github.com/siddontang/goredis/resp.go rename to _vendor/vendor/github.com/siddontang/goredis/resp.go diff --git a/cmd/vendor/github.com/siddontang/rdb/LICENSE b/_vendor/vendor/github.com/siddontang/rdb/LICENSE similarity index 100% rename from cmd/vendor/github.com/siddontang/rdb/LICENSE rename to _vendor/vendor/github.com/siddontang/rdb/LICENSE diff --git a/cmd/vendor/github.com/siddontang/rdb/decode.go b/_vendor/vendor/github.com/siddontang/rdb/decode.go similarity index 100% rename from cmd/vendor/github.com/siddontang/rdb/decode.go rename to _vendor/vendor/github.com/siddontang/rdb/decode.go diff --git a/cmd/vendor/github.com/siddontang/rdb/digest.go b/_vendor/vendor/github.com/siddontang/rdb/digest.go similarity index 100% rename from cmd/vendor/github.com/siddontang/rdb/digest.go rename to _vendor/vendor/github.com/siddontang/rdb/digest.go diff --git a/cmd/vendor/github.com/siddontang/rdb/encode.go b/_vendor/vendor/github.com/siddontang/rdb/encode.go similarity index 100% rename from cmd/vendor/github.com/siddontang/rdb/encode.go rename to _vendor/vendor/github.com/siddontang/rdb/encode.go diff --git a/cmd/vendor/github.com/siddontang/rdb/loader.go b/_vendor/vendor/github.com/siddontang/rdb/loader.go similarity index 100% rename from cmd/vendor/github.com/siddontang/rdb/loader.go rename to _vendor/vendor/github.com/siddontang/rdb/loader.go diff --git a/cmd/vendor/github.com/siddontang/rdb/reader.go b/_vendor/vendor/github.com/siddontang/rdb/reader.go similarity index 100% rename from cmd/vendor/github.com/siddontang/rdb/reader.go rename to _vendor/vendor/github.com/siddontang/rdb/reader.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/LICENSE b/_vendor/vendor/github.com/syndtr/goleveldb/LICENSE similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/LICENSE rename to _vendor/vendor/github.com/syndtr/goleveldb/LICENSE diff --git a/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/batch.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/batch.go new file mode 100644 index 0000000..2259200 --- /dev/null +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/batch.go @@ -0,0 +1,349 @@ +// Copyright (c) 2012, Suryandaru Triandana +// All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package leveldb + +import ( + "encoding/binary" + "fmt" + "io" + + "github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/memdb" + "github.com/syndtr/goleveldb/leveldb/storage" +) + +// ErrBatchCorrupted records reason of batch corruption. This error will be +// wrapped with errors.ErrCorrupted. +type ErrBatchCorrupted struct { + Reason string +} + +func (e *ErrBatchCorrupted) Error() string { + return fmt.Sprintf("leveldb: batch corrupted: %s", e.Reason) +} + +func newErrBatchCorrupted(reason string) error { + return errors.NewErrCorrupted(storage.FileDesc{}, &ErrBatchCorrupted{reason}) +} + +const ( + batchHeaderLen = 8 + 4 + batchGrowRec = 3000 + batchBufioSize = 16 +) + +// BatchReplay wraps basic batch operations. +type BatchReplay interface { + Put(key, value []byte) + Delete(key []byte) +} + +type batchIndex struct { + keyType keyType + keyPos, keyLen int + valuePos, valueLen int +} + +func (index batchIndex) k(data []byte) []byte { + return data[index.keyPos : index.keyPos+index.keyLen] +} + +func (index batchIndex) v(data []byte) []byte { + if index.valueLen != 0 { + return data[index.valuePos : index.valuePos+index.valueLen] + } + return nil +} + +func (index batchIndex) kv(data []byte) (key, value []byte) { + return index.k(data), index.v(data) +} + +// Batch is a write batch. +type Batch struct { + data []byte + index []batchIndex + + // internalLen is sums of key/value pair length plus 8-bytes internal key. + internalLen int +} + +func (b *Batch) grow(n int) { + o := len(b.data) + if cap(b.data)-o < n { + div := 1 + if len(b.index) > batchGrowRec { + div = len(b.index) / batchGrowRec + } + ndata := make([]byte, o, o+n+o/div) + copy(ndata, b.data) + b.data = ndata + } +} + +func (b *Batch) appendRec(kt keyType, key, value []byte) { + n := 1 + binary.MaxVarintLen32 + len(key) + if kt == keyTypeVal { + n += binary.MaxVarintLen32 + len(value) + } + b.grow(n) + index := batchIndex{keyType: kt} + o := len(b.data) + data := b.data[:o+n] + data[o] = byte(kt) + o++ + o += binary.PutUvarint(data[o:], uint64(len(key))) + index.keyPos = o + index.keyLen = len(key) + o += copy(data[o:], key) + if kt == keyTypeVal { + o += binary.PutUvarint(data[o:], uint64(len(value))) + index.valuePos = o + index.valueLen = len(value) + o += copy(data[o:], value) + } + b.data = data[:o] + b.index = append(b.index, index) + b.internalLen += index.keyLen + index.valueLen + 8 +} + +// Put appends 'put operation' of the given key/value pair to the batch. +// It is safe to modify the contents of the argument after Put returns but not +// before. +func (b *Batch) Put(key, value []byte) { + b.appendRec(keyTypeVal, key, value) +} + +// Delete appends 'delete operation' of the given key to the batch. +// It is safe to modify the contents of the argument after Delete returns but +// not before. +func (b *Batch) Delete(key []byte) { + b.appendRec(keyTypeDel, key, nil) +} + +// Dump dumps batch contents. The returned slice can be loaded into the +// batch using Load method. +// The returned slice is not its own copy, so the contents should not be +// modified. +func (b *Batch) Dump() []byte { + return b.data +} + +// Load loads given slice into the batch. Previous contents of the batch +// will be discarded. +// The given slice will not be copied and will be used as batch buffer, so +// it is not safe to modify the contents of the slice. +func (b *Batch) Load(data []byte) error { + return b.decode(data, -1) +} + +// Replay replays batch contents. +func (b *Batch) Replay(r BatchReplay) error { + for _, index := range b.index { + switch index.keyType { + case keyTypeVal: + r.Put(index.k(b.data), index.v(b.data)) + case keyTypeDel: + r.Delete(index.k(b.data)) + } + } + return nil +} + +// Len returns number of records in the batch. +func (b *Batch) Len() int { + return len(b.index) +} + +// Reset resets the batch. +func (b *Batch) Reset() { + b.data = b.data[:0] + b.index = b.index[:0] + b.internalLen = 0 +} + +func (b *Batch) replayInternal(fn func(i int, kt keyType, k, v []byte) error) error { + for i, index := range b.index { + if err := fn(i, index.keyType, index.k(b.data), index.v(b.data)); err != nil { + return err + } + } + return nil +} + +func (b *Batch) append(p *Batch) { + ob := len(b.data) + oi := len(b.index) + b.data = append(b.data, p.data...) + b.index = append(b.index, p.index...) + b.internalLen += p.internalLen + + // Updating index offset. + if ob != 0 { + for ; oi < len(b.index); oi++ { + index := &b.index[oi] + index.keyPos += ob + if index.valueLen != 0 { + index.valuePos += ob + } + } + } +} + +func (b *Batch) decode(data []byte, expectedLen int) error { + b.data = data + b.index = b.index[:0] + b.internalLen = 0 + err := decodeBatch(data, func(i int, index batchIndex) error { + b.index = append(b.index, index) + b.internalLen += index.keyLen + index.valueLen + 8 + return nil + }) + if err != nil { + return err + } + if expectedLen >= 0 && len(b.index) != expectedLen { + return newErrBatchCorrupted(fmt.Sprintf("invalid records length: %d vs %d", expectedLen, len(b.index))) + } + return nil +} + +func (b *Batch) putMem(seq uint64, mdb *memdb.DB) error { + var ik []byte + for i, index := range b.index { + ik = makeInternalKey(ik, index.k(b.data), seq+uint64(i), index.keyType) + if err := mdb.Put(ik, index.v(b.data)); err != nil { + return err + } + } + return nil +} + +func (b *Batch) revertMem(seq uint64, mdb *memdb.DB) error { + var ik []byte + for i, index := range b.index { + ik = makeInternalKey(ik, index.k(b.data), seq+uint64(i), index.keyType) + if err := mdb.Delete(ik); err != nil { + return err + } + } + return nil +} + +func newBatch() interface{} { + return &Batch{} +} + +func decodeBatch(data []byte, fn func(i int, index batchIndex) error) error { + var index batchIndex + for i, o := 0, 0; o < len(data); i++ { + // Key type. + index.keyType = keyType(data[o]) + if index.keyType > keyTypeVal { + return newErrBatchCorrupted(fmt.Sprintf("bad record: invalid type %#x", uint(index.keyType))) + } + o++ + + // Key. + x, n := binary.Uvarint(data[o:]) + o += n + if n <= 0 || o+int(x) > len(data) { + return newErrBatchCorrupted("bad record: invalid key length") + } + index.keyPos = o + index.keyLen = int(x) + o += index.keyLen + + // Value. + if index.keyType == keyTypeVal { + x, n = binary.Uvarint(data[o:]) + o += n + if n <= 0 || o+int(x) > len(data) { + return newErrBatchCorrupted("bad record: invalid value length") + } + index.valuePos = o + index.valueLen = int(x) + o += index.valueLen + } else { + index.valuePos = 0 + index.valueLen = 0 + } + + if err := fn(i, index); err != nil { + return err + } + } + return nil +} + +func decodeBatchToMem(data []byte, expectSeq uint64, mdb *memdb.DB) (seq uint64, batchLen int, err error) { + seq, batchLen, err = decodeBatchHeader(data) + if err != nil { + return 0, 0, err + } + if seq < expectSeq { + return 0, 0, newErrBatchCorrupted("invalid sequence number") + } + data = data[batchHeaderLen:] + var ik []byte + var decodedLen int + err = decodeBatch(data, func(i int, index batchIndex) error { + if i >= batchLen { + return newErrBatchCorrupted("invalid records length") + } + ik = makeInternalKey(ik, index.k(data), seq+uint64(i), index.keyType) + if err := mdb.Put(ik, index.v(data)); err != nil { + return err + } + decodedLen++ + return nil + }) + if err == nil && decodedLen != batchLen { + err = newErrBatchCorrupted(fmt.Sprintf("invalid records length: %d vs %d", batchLen, decodedLen)) + } + return +} + +func encodeBatchHeader(dst []byte, seq uint64, batchLen int) []byte { + dst = ensureBuffer(dst, batchHeaderLen) + binary.LittleEndian.PutUint64(dst, seq) + binary.LittleEndian.PutUint32(dst[8:], uint32(batchLen)) + return dst +} + +func decodeBatchHeader(data []byte) (seq uint64, batchLen int, err error) { + if len(data) < batchHeaderLen { + return 0, 0, newErrBatchCorrupted("too short") + } + + seq = binary.LittleEndian.Uint64(data) + batchLen = int(binary.LittleEndian.Uint32(data[8:])) + if batchLen < 0 { + return 0, 0, newErrBatchCorrupted("invalid records length") + } + return +} + +func batchesLen(batches []*Batch) int { + batchLen := 0 + for _, batch := range batches { + batchLen += batch.Len() + } + return batchLen +} + +func writeBatchesWithHeader(wr io.Writer, batches []*Batch, seq uint64) error { + if _, err := wr.Write(encodeBatchHeader(nil, seq, batchesLen(batches))); err != nil { + return err + } + for _, batch := range batches { + if _, err := wr.Write(batch.data); err != nil { + return err + } + } + return nil +} diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/cache/cache.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/cache/cache.go similarity index 95% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/cache/cache.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/cache/cache.go index a287d0e..c5940b2 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/cache/cache.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/cache/cache.go @@ -16,7 +16,7 @@ import ( ) // Cacher provides interface to implements a caching functionality. -// An implementation must be goroutine-safe. +// An implementation must be safe for concurrent use. type Cacher interface { // Capacity returns cache capacity. Capacity() int @@ -511,18 +511,12 @@ func (r *Cache) EvictAll() { } } -// Close closes the 'cache map' and releases all 'cache node'. +// Close closes the 'cache map' and forcefully releases all 'cache node'. func (r *Cache) Close() error { r.mu.Lock() if !r.closed { r.closed = true - if r.cacher != nil { - if err := r.cacher.Close(); err != nil { - return err - } - } - h := (*mNode)(r.mHead) h.initBuckets() @@ -541,10 +535,37 @@ func (r *Cache) Close() error { for _, f := range n.onDel { f() } + n.onDel = nil } } } r.mu.Unlock() + + // Avoid deadlock. + if r.cacher != nil { + if err := r.cacher.Close(); err != nil { + return err + } + } + return nil +} + +// CloseWeak closes the 'cache map' and evict all 'cache node' from cacher, but +// unlike Close it doesn't forcefully releases 'cache node'. +func (r *Cache) CloseWeak() error { + r.mu.Lock() + if !r.closed { + r.closed = true + } + r.mu.Unlock() + + // Avoid deadlock. + if r.cacher != nil { + r.cacher.EvictAll() + if err := r.cacher.Close(); err != nil { + return err + } + } return nil } diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/cache/lru.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/cache/lru.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/cache/lru.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/cache/lru.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/comparer.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/comparer.go similarity index 59% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/comparer.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/comparer.go index 248bf7c..448402b 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/comparer.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/comparer.go @@ -6,7 +6,9 @@ package leveldb -import "github.com/syndtr/goleveldb/leveldb/comparer" +import ( + "github.com/syndtr/goleveldb/leveldb/comparer" +) type iComparer struct { ucmp comparer.Comparer @@ -33,12 +35,12 @@ func (icmp *iComparer) Name() string { } func (icmp *iComparer) Compare(a, b []byte) int { - x := icmp.ucmp.Compare(internalKey(a).ukey(), internalKey(b).ukey()) + x := icmp.uCompare(internalKey(a).ukey(), internalKey(b).ukey()) if x == 0 { if m, n := internalKey(a).num(), internalKey(b).num(); m > n { - x = -1 + return -1 } else if m < n { - x = 1 + return 1 } } return x @@ -46,30 +48,20 @@ func (icmp *iComparer) Compare(a, b []byte) int { func (icmp *iComparer) Separator(dst, a, b []byte) []byte { ua, ub := internalKey(a).ukey(), internalKey(b).ukey() - dst = icmp.ucmp.Separator(dst, ua, ub) - if dst == nil { - return nil + dst = icmp.uSeparator(dst, ua, ub) + if dst != nil && len(dst) < len(ua) && icmp.uCompare(ua, dst) < 0 { + // Append earliest possible number. + return append(dst, keyMaxNumBytes...) } - if len(dst) < len(ua) && icmp.uCompare(ua, dst) < 0 { - dst = append(dst, keyMaxNumBytes...) - } else { - // Did not close possibilities that n maybe longer than len(ub). - dst = append(dst, a[len(a)-8:]...) - } - return dst + return nil } func (icmp *iComparer) Successor(dst, b []byte) []byte { ub := internalKey(b).ukey() - dst = icmp.ucmp.Successor(dst, ub) - if dst == nil { - return nil + dst = icmp.uSuccessor(dst, ub) + if dst != nil && len(dst) < len(ub) && icmp.uCompare(ub, dst) < 0 { + // Append earliest possible number. + return append(dst, keyMaxNumBytes...) } - if len(dst) < len(ub) && icmp.uCompare(ub, dst) < 0 { - dst = append(dst, keyMaxNumBytes...) - } else { - // Did not close possibilities that n maybe longer than len(ub). - dst = append(dst, b[len(b)-8:]...) - } - return dst + return nil } diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/comparer/bytes_comparer.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/comparer/bytes_comparer.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/comparer/bytes_comparer.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/comparer/bytes_comparer.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/comparer/comparer.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/comparer/comparer.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/comparer/comparer.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/comparer/comparer.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/db.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/db.go similarity index 94% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/db.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/db.go index eb6abd0..a02cb2c 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/db.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/db.go @@ -53,14 +53,13 @@ type DB struct { aliveSnaps, aliveIters int32 // Write. - writeC chan *Batch + batchPool sync.Pool + writeMergeC chan writeMerge writeMergedC chan bool writeLockC chan struct{} writeAckC chan error writeDelay time.Duration writeDelayN int - journalC chan *Batch - journalAckC chan error tr *Transaction // Compaction. @@ -94,12 +93,11 @@ func openDB(s *session) (*DB, error) { // Snapshot snapsList: list.New(), // Write - writeC: make(chan *Batch), + batchPool: sync.Pool{New: newBatch}, + writeMergeC: make(chan writeMerge), writeMergedC: make(chan bool), writeLockC: make(chan struct{}, 1), writeAckC: make(chan error), - journalC: make(chan *Batch), - journalAckC: make(chan error), // Compaction tcompCmdC: make(chan cCmd), tcompPauseC: make(chan chan<- struct{}), @@ -144,10 +142,10 @@ func openDB(s *session) (*DB, error) { if readOnly { db.SetReadOnly() } else { - db.closeW.Add(3) + db.closeW.Add(2) go db.tCompaction() go db.mCompaction() - go db.jWriter() + // go db.jWriter() } s.logf("db@open done T·%v", time.Since(start)) @@ -162,10 +160,10 @@ func openDB(s *session) (*DB, error) { // os.ErrExist error. // // Open will return an error with type of ErrCorrupted if corruption -// detected in the DB. Corrupted DB can be recovered with Recover -// function. +// detected in the DB. Use errors.IsCorrupted to test whether an error is +// due to corruption. Corrupted DB can be recovered with Recover function. // -// The returned DB instance is goroutine-safe. +// The returned DB instance is safe for concurrent use. // The DB must be closed after use, by calling Close method. func Open(stor storage.Storage, o *opt.Options) (db *DB, err error) { s, err := newSession(stor, o) @@ -202,13 +200,13 @@ func Open(stor storage.Storage, o *opt.Options) (db *DB, err error) { // os.ErrExist error. // // OpenFile uses standard file-system backed storage implementation as -// desribed in the leveldb/storage package. +// described in the leveldb/storage package. // // OpenFile will return an error with type of ErrCorrupted if corruption -// detected in the DB. Corrupted DB can be recovered with Recover -// function. +// detected in the DB. Use errors.IsCorrupted to test whether an error is +// due to corruption. Corrupted DB can be recovered with Recover function. // -// The returned DB instance is goroutine-safe. +// The returned DB instance is safe for concurrent use. // The DB must be closed after use, by calling Close method. func OpenFile(path string, o *opt.Options) (db *DB, err error) { stor, err := storage.OpenFile(path, o.GetReadOnly()) @@ -229,7 +227,7 @@ func OpenFile(path string, o *opt.Options) (db *DB, err error) { // The DB must already exist or it will returns an error. // Also, Recover will ignore ErrorIfMissing and ErrorIfExist options. // -// The returned DB instance is goroutine-safe. +// The returned DB instance is safe for concurrent use. // The DB must be closed after use, by calling Close method. func Recover(stor storage.Storage, o *opt.Options) (db *DB, err error) { s, err := newSession(stor, o) @@ -255,10 +253,10 @@ func Recover(stor storage.Storage, o *opt.Options) (db *DB, err error) { // The DB must already exist or it will returns an error. // Also, Recover will ignore ErrorIfMissing and ErrorIfExist options. // -// RecoverFile uses standard file-system backed storage implementation as desribed +// RecoverFile uses standard file-system backed storage implementation as described // in the leveldb/storage package. // -// The returned DB instance is goroutine-safe. +// The returned DB instance is safe for concurrent use. // The DB must be closed after use, by calling Close method. func RecoverFile(path string, o *opt.Options) (db *DB, err error) { stor, err := storage.OpenFile(path, false) @@ -504,10 +502,11 @@ func (db *DB) recoverJournal() error { checksum = db.s.o.GetStrict(opt.StrictJournalChecksum) writeBuffer = db.s.o.GetWriteBuffer() - jr *journal.Reader - mdb = memdb.New(db.s.icmp, writeBuffer) - buf = &util.Buffer{} - batch = &Batch{} + jr *journal.Reader + mdb = memdb.New(db.s.icmp, writeBuffer) + buf = &util.Buffer{} + batchSeq uint64 + batchLen int ) for _, fd := range fds { @@ -526,7 +525,7 @@ func (db *DB) recoverJournal() error { } // Flush memdb and remove obsolete journal file. - if !ofd.Nil() { + if !ofd.Zero() { if mdb.Len() > 0 { if _, err := db.s.flushMemdb(rec, mdb, 0); err != nil { fr.Close() @@ -569,7 +568,8 @@ func (db *DB) recoverJournal() error { fr.Close() return errors.SetFd(err, fd) } - if err := batch.memDecodeAndReplay(db.seq, buf.Bytes(), mdb); err != nil { + batchSeq, batchLen, err = decodeBatchToMem(buf.Bytes(), db.seq, mdb) + if err != nil { if !strict && errors.IsCorrupted(err) { db.s.logf("journal error: %v (skipped)", err) // We won't apply sequence number as it might be corrupted. @@ -581,7 +581,7 @@ func (db *DB) recoverJournal() error { } // Save sequence number. - db.seq = batch.seq + uint64(batch.Len()) + db.seq = batchSeq + uint64(batchLen) // Flush it if large enough. if mdb.Size() >= writeBuffer { @@ -624,7 +624,7 @@ func (db *DB) recoverJournal() error { } // Remove the last obsolete journal file. - if !ofd.Nil() { + if !ofd.Zero() { db.s.stor.Remove(ofd) } @@ -661,9 +661,10 @@ func (db *DB) recoverJournalRO() error { db.logf("journal@recovery RO·Mode F·%d", len(fds)) var ( - jr *journal.Reader - buf = &util.Buffer{} - batch = &Batch{} + jr *journal.Reader + buf = &util.Buffer{} + batchSeq uint64 + batchLen int ) for _, fd := range fds { @@ -703,7 +704,8 @@ func (db *DB) recoverJournalRO() error { fr.Close() return errors.SetFd(err, fd) } - if err := batch.memDecodeAndReplay(db.seq, buf.Bytes(), mdb); err != nil { + batchSeq, batchLen, err = decodeBatchToMem(buf.Bytes(), db.seq, mdb) + if err != nil { if !strict && errors.IsCorrupted(err) { db.s.logf("journal error: %v (skipped)", err) // We won't apply sequence number as it might be corrupted. @@ -715,7 +717,7 @@ func (db *DB) recoverJournalRO() error { } // Save sequence number. - db.seq = batch.seq + uint64(batch.Len()) + db.seq = batchSeq + uint64(batchLen) } fr.Close() @@ -856,7 +858,7 @@ func (db *DB) Has(key []byte, ro *opt.ReadOptions) (ret bool, err error) { // NewIterator returns an iterator for the latest snapshot of the // underlying DB. -// The returned iterator is not goroutine-safe, but it is safe to use +// The returned iterator is not safe for concurrent use, but it is safe to use // multiple iterators concurrently, with each in a dedicated goroutine. // It is also safe to use an iterator concurrently with modifying its // underlying DB. The resultant key/value pairs are guaranteed to be @@ -1062,6 +1064,8 @@ func (db *DB) Close() error { if db.journal != nil { db.journal.Close() db.journalWriter.Close() + db.journal = nil + db.journalWriter = nil } if db.writeDelayN > 0 { @@ -1077,15 +1081,11 @@ func (db *DB) Close() error { if err1 := db.closer.Close(); err == nil { err = err1 } + db.closer = nil } - // NIL'ing pointers. - db.s = nil - db.mem = nil - db.frozenMem = nil - db.journal = nil - db.journalWriter = nil - db.closer = nil + // Clear memdbs. + db.clearMems() return err } diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go similarity index 96% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go index 5553202..b6563e8 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go @@ -96,7 +96,7 @@ noerr: default: goto haserr } - case _, _ = <-db.closeC: + case <-db.closeC: return } } @@ -113,7 +113,7 @@ haserr: goto hasperr default: } - case _, _ = <-db.closeC: + case <-db.closeC: return } } @@ -126,7 +126,7 @@ hasperr: case db.writeLockC <- struct{}{}: // Hold write lock, so that write won't pass-through. db.compWriteLocking = true - case _, _ = <-db.closeC: + case <-db.closeC: if db.compWriteLocking { // We should release the lock or Close will hang. <-db.writeLockC @@ -195,7 +195,7 @@ func (db *DB) compactionTransact(name string, t compactionTransactInterface) { db.logf("%s exiting (persistent error %q)", name, perr) db.compactionExitTransact() } - case _, _ = <-db.closeC: + case <-db.closeC: db.logf("%s exiting", name) db.compactionExitTransact() } @@ -224,7 +224,7 @@ func (db *DB) compactionTransact(name string, t compactionTransactInterface) { } select { case <-backoffT.C: - case _, _ = <-db.closeC: + case <-db.closeC: db.logf("%s exiting", name) db.compactionExitTransact() } @@ -288,8 +288,8 @@ func (db *DB) memCompaction() { case <-db.compPerErrC: close(resumeC) resumeC = nil - case _, _ = <-db.closeC: - return + case <-db.closeC: + db.compactionExitTransact() } var ( @@ -337,8 +337,8 @@ func (db *DB) memCompaction() { select { case <-resumeC: close(resumeC) - case _, _ = <-db.closeC: - return + case <-db.closeC: + db.compactionExitTransact() } } @@ -378,7 +378,7 @@ func (b *tableCompactionBuilder) appendKV(key, value []byte) error { select { case ch := <-b.db.tcompPauseC: b.db.pauseCompaction(ch) - case _, _ = <-b.db.closeC: + case <-b.db.closeC: b.db.compactionExitTransact() default: } @@ -643,7 +643,7 @@ func (db *DB) tableNeedCompaction() bool { func (db *DB) pauseCompaction(ch chan<- struct{}) { select { case ch <- struct{}{}: - case _, _ = <-db.closeC: + case <-db.closeC: db.compactionExitTransact() } } @@ -688,7 +688,7 @@ func (db *DB) compTrigger(compC chan<- cCmd) { } } -// This will trigger auto compation and/or wait for all compaction to be done. +// This will trigger auto compaction and/or wait for all compaction to be done. func (db *DB) compTriggerWait(compC chan<- cCmd) (err error) { ch := make(chan error) defer close(ch) @@ -697,14 +697,14 @@ func (db *DB) compTriggerWait(compC chan<- cCmd) (err error) { case compC <- cAuto{ch}: case err = <-db.compErrC: return - case _, _ = <-db.closeC: + case <-db.closeC: return ErrClosed } // Wait cmd. select { case err = <-ch: case err = <-db.compErrC: - case _, _ = <-db.closeC: + case <-db.closeC: return ErrClosed } return err @@ -719,14 +719,14 @@ func (db *DB) compTriggerRange(compC chan<- cCmd, level int, min, max []byte) (e case compC <- cRange{level, min, max, ch}: case err := <-db.compErrC: return err - case _, _ = <-db.closeC: + case <-db.closeC: return ErrClosed } // Wait cmd. select { case err = <-ch: case err = <-db.compErrC: - case _, _ = <-db.closeC: + case <-db.closeC: return ErrClosed } return err @@ -758,7 +758,7 @@ func (db *DB) mCompaction() { default: panic("leveldb: unknown command") } - case _, _ = <-db.closeC: + case <-db.closeC: return } } @@ -791,7 +791,7 @@ func (db *DB) tCompaction() { case ch := <-db.tcompPauseC: db.pauseCompaction(ch) continue - case _, _ = <-db.closeC: + case <-db.closeC: return default: } @@ -806,7 +806,7 @@ func (db *DB) tCompaction() { case ch := <-db.tcompPauseC: db.pauseCompaction(ch) continue - case _, _ = <-db.closeC: + case <-db.closeC: return } } diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_iter.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_iter.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_iter.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_iter.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_snapshot.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_snapshot.go similarity index 97% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_snapshot.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_snapshot.go index 977f65b..2c69d2e 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_snapshot.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_snapshot.go @@ -59,7 +59,7 @@ func (db *DB) releaseSnapshot(se *snapshotElement) { } } -// Gets minimum sequence that not being snapshoted. +// Gets minimum sequence that not being snapshotted. func (db *DB) minSeq() uint64 { db.snapsMu.Lock() defer db.snapsMu.Unlock() @@ -131,7 +131,7 @@ func (snap *Snapshot) Has(key []byte, ro *opt.ReadOptions) (ret bool, err error) } // NewIterator returns an iterator for the snapshot of the underlying DB. -// The returned iterator is not goroutine-safe, but it is safe to use +// The returned iterator is not safe for concurrent use, but it is safe to use // multiple iterators concurrently, with each in a dedicated goroutine. // It is also safe to use an iterator concurrently with modifying its // underlying DB. The resultant key/value pairs are guaranteed to be diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_state.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_state.go similarity index 87% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_state.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_state.go index 40f454d..65e1c54 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_state.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_state.go @@ -7,6 +7,7 @@ package leveldb import ( + "errors" "sync/atomic" "time" @@ -15,6 +16,10 @@ import ( "github.com/syndtr/goleveldb/leveldb/storage" ) +var ( + errHasFrozenMem = errors.New("has frozen mem") +) + type memDB struct { db *DB *memdb.DB @@ -67,12 +72,11 @@ func (db *DB) sampleSeek(ikey internalKey) { } func (db *DB) mpoolPut(mem *memdb.DB) { - defer func() { - recover() - }() - select { - case db.memPool <- mem: - default: + if !db.isClosed() { + select { + case db.memPool <- mem: + default: + } } } @@ -100,7 +104,13 @@ func (db *DB) mpoolDrain() { case <-db.memPool: default: } - case _, _ = <-db.closeC: + case <-db.closeC: + ticker.Stop() + // Make sure the pool is drained. + select { + case <-db.memPool: + case <-time.After(time.Second): + } close(db.memPool) return } @@ -121,7 +131,7 @@ func (db *DB) newMem(n int) (mem *memDB, err error) { defer db.memMu.Unlock() if db.frozenMem != nil { - panic("still has frozen mem") + return nil, errHasFrozenMem } if db.journal == nil { @@ -148,24 +158,26 @@ func (db *DB) newMem(n int) (mem *memDB, err error) { func (db *DB) getMems() (e, f *memDB) { db.memMu.RLock() defer db.memMu.RUnlock() - if db.mem == nil { + if db.mem != nil { + db.mem.incref() + } else if !db.isClosed() { panic("nil effective mem") } - db.mem.incref() if db.frozenMem != nil { db.frozenMem.incref() } return db.mem, db.frozenMem } -// Get frozen memdb. +// Get effective memdb. func (db *DB) getEffectiveMem() *memDB { db.memMu.RLock() defer db.memMu.RUnlock() - if db.mem == nil { + if db.mem != nil { + db.mem.incref() + } else if !db.isClosed() { panic("nil effective mem") } - db.mem.incref() return db.mem } @@ -200,6 +212,14 @@ func (db *DB) dropFrozenMem() { db.memMu.Unlock() } +// Clear mems ptr; used by DB.Close(). +func (db *DB) clearMems() { + db.memMu.Lock() + db.mem = nil + db.frozenMem = nil + db.memMu.Unlock() +} + // Set closed flag; return true if not already closed. func (db *DB) setClosed() bool { return atomic.CompareAndSwapUint32(&db.closed, 0, 1) diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_transaction.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_transaction.go similarity index 79% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_transaction.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_transaction.go index fca8803..b8f7e7d 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_transaction.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_transaction.go @@ -59,8 +59,8 @@ func (tr *Transaction) Has(key []byte, ro *opt.ReadOptions) (bool, error) { } // NewIterator returns an iterator for the latest snapshot of the transaction. -// The returned iterator is not goroutine-safe, but it is safe to use multiple -// iterators concurrently, with each in a dedicated goroutine. +// The returned iterator is not safe for concurrent use, but it is safe to use +// multiple iterators concurrently, with each in a dedicated goroutine. // It is also safe to use an iterator concurrently while writes to the // transaction. The resultant key/value pairs are guaranteed to be consistent. // @@ -167,8 +167,8 @@ func (tr *Transaction) Write(b *Batch, wo *opt.WriteOptions) error { if tr.closed { return errTransactionDone } - return b.decodeRec(func(i int, kt keyType, key, value []byte) error { - return tr.put(kt, key, value) + return b.replayInternal(func(i int, kt keyType, k, v []byte) error { + return tr.put(kt, k, v) }) } @@ -179,7 +179,8 @@ func (tr *Transaction) setDone() { <-tr.db.writeLockC } -// Commit commits the transaction. +// Commit commits the transaction. If error is not nil, then the transaction is +// not committed, it can then either be retried or discarded. // // Other methods should not be called after transaction has been committed. func (tr *Transaction) Commit() error { @@ -192,24 +193,27 @@ func (tr *Transaction) Commit() error { if tr.closed { return errTransactionDone } - defer tr.setDone() if err := tr.flush(); err != nil { - tr.discard() + // Return error, lets user decide either to retry or discard + // transaction. return err } if len(tr.tables) != 0 { // Committing transaction. tr.rec.setSeqNum(tr.seq) tr.db.compCommitLk.Lock() - defer tr.db.compCommitLk.Unlock() + tr.stats.startTimer() + var cerr error for retry := 0; retry < 3; retry++ { - if err := tr.db.s.commit(&tr.rec); err != nil { - tr.db.logf("transaction@commit error R·%d %q", retry, err) + cerr = tr.db.s.commit(&tr.rec) + if cerr != nil { + tr.db.logf("transaction@commit error R·%d %q", retry, cerr) select { case <-time.After(time.Second): - case _, _ = <-tr.db.closeC: + case <-tr.db.closeC: tr.db.logf("transaction@commit exiting") - return err + tr.db.compCommitLk.Unlock() + return cerr } } else { // Success. Set db.seq. @@ -217,9 +221,26 @@ func (tr *Transaction) Commit() error { break } } + tr.stats.stopTimer() + if cerr != nil { + // Return error, lets user decide either to retry or discard + // transaction. + return cerr + } + + // Update compaction stats. This is safe as long as we hold compCommitLk. + tr.db.compStats.addStat(0, &tr.stats) + // Trigger table auto-compaction. tr.db.compTrigger(tr.db.tcompCmdC) + tr.db.compCommitLk.Unlock() + + // Additionally, wait compaction when certain threshold reached. + // Ignore error, returns error only if transaction can't be committed. + tr.db.waitCompaction() } + // Only mark as done if transaction committed successfully. + tr.setDone() return nil } @@ -245,10 +266,20 @@ func (tr *Transaction) Discard() { tr.lk.Unlock() } +func (db *DB) waitCompaction() error { + if db.s.tLen(0) >= db.s.o.GetWriteL0PauseTrigger() { + return db.compTriggerWait(db.tcompCmdC) + } + return nil +} + // OpenTransaction opens an atomic DB transaction. Only one transaction can be -// opened at a time. Write will be blocked until the transaction is committed or -// discarded. -// The returned transaction handle is goroutine-safe. +// opened at a time. Subsequent call to Write and OpenTransaction will be blocked +// until in-flight transaction is committed or discarded. +// The returned transaction handle is safe for concurrent use. +// +// Transaction is expensive and can overwhelm compaction, especially if +// transaction size is small. Use with caution. // // The transaction must be closed once done, either by committing or discarding // the transaction. @@ -263,7 +294,7 @@ func (db *DB) OpenTransaction() (*Transaction, error) { case db.writeLockC <- struct{}{}: case err := <-db.compPerErrC: return nil, err - case _, _ = <-db.closeC: + case <-db.closeC: return nil, ErrClosed } @@ -278,6 +309,11 @@ func (db *DB) OpenTransaction() (*Transaction, error) { } } + // Wait compaction when certain threshold reached. + if err := db.waitCompaction(); err != nil { + return nil, err + } + tr := &Transaction{ db: db, seq: db.seq, diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_util.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_util.go similarity index 98% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_util.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_util.go index 7fd386c..7ecd960 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_util.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_util.go @@ -62,7 +62,7 @@ func (db *DB) checkAndCleanFiles() error { case storage.TypeManifest: keep = fd.Num >= db.s.manifestFd.Num case storage.TypeJournal: - if !db.frozenJournalFd.Nil() { + if !db.frozenJournalFd.Zero() { keep = fd.Num >= db.frozenJournalFd.Num } else { keep = fd.Num >= db.journalFd.Num diff --git a/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_write.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_write.go new file mode 100644 index 0000000..5b6cb48 --- /dev/null +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/db_write.go @@ -0,0 +1,452 @@ +// Copyright (c) 2012, Suryandaru Triandana +// All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package leveldb + +import ( + "time" + + "github.com/syndtr/goleveldb/leveldb/memdb" + "github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/util" +) + +func (db *DB) writeJournal(batches []*Batch, seq uint64, sync bool) error { + wr, err := db.journal.Next() + if err != nil { + return err + } + if err := writeBatchesWithHeader(wr, batches, seq); err != nil { + return err + } + if err := db.journal.Flush(); err != nil { + return err + } + if sync { + return db.journalWriter.Sync() + } + return nil +} + +func (db *DB) rotateMem(n int, wait bool) (mem *memDB, err error) { + retryLimit := 3 +retry: + // Wait for pending memdb compaction. + err = db.compTriggerWait(db.mcompCmdC) + if err != nil { + return + } + retryLimit-- + + // Create new memdb and journal. + mem, err = db.newMem(n) + if err != nil { + if err == errHasFrozenMem { + if retryLimit <= 0 { + panic("BUG: still has frozen memdb") + } + goto retry + } + return + } + + // Schedule memdb compaction. + if wait { + err = db.compTriggerWait(db.mcompCmdC) + } else { + db.compTrigger(db.mcompCmdC) + } + return +} + +func (db *DB) flush(n int) (mdb *memDB, mdbFree int, err error) { + delayed := false + slowdownTrigger := db.s.o.GetWriteL0SlowdownTrigger() + pauseTrigger := db.s.o.GetWriteL0PauseTrigger() + flush := func() (retry bool) { + mdb = db.getEffectiveMem() + if mdb == nil { + err = ErrClosed + return false + } + defer func() { + if retry { + mdb.decref() + mdb = nil + } + }() + tLen := db.s.tLen(0) + mdbFree = mdb.Free() + switch { + case tLen >= slowdownTrigger && !delayed: + delayed = true + time.Sleep(time.Millisecond) + case mdbFree >= n: + return false + case tLen >= pauseTrigger: + delayed = true + err = db.compTriggerWait(db.tcompCmdC) + if err != nil { + return false + } + default: + // Allow memdb to grow if it has no entry. + if mdb.Len() == 0 { + mdbFree = n + } else { + mdb.decref() + mdb, err = db.rotateMem(n, false) + if err == nil { + mdbFree = mdb.Free() + } else { + mdbFree = 0 + } + } + return false + } + return true + } + start := time.Now() + for flush() { + } + if delayed { + db.writeDelay += time.Since(start) + db.writeDelayN++ + } else if db.writeDelayN > 0 { + db.logf("db@write was delayed N·%d T·%v", db.writeDelayN, db.writeDelay) + db.writeDelay = 0 + db.writeDelayN = 0 + } + return +} + +type writeMerge struct { + sync bool + batch *Batch + keyType keyType + key, value []byte +} + +func (db *DB) unlockWrite(overflow bool, merged int, err error) { + for i := 0; i < merged; i++ { + db.writeAckC <- err + } + if overflow { + // Pass lock to the next write (that failed to merge). + db.writeMergedC <- false + } else { + // Release lock. + <-db.writeLockC + } +} + +// ourBatch if defined should equal with batch. +func (db *DB) writeLocked(batch, ourBatch *Batch, merge, sync bool) error { + // Try to flush memdb. This method would also trying to throttle writes + // if it is too fast and compaction cannot catch-up. + mdb, mdbFree, err := db.flush(batch.internalLen) + if err != nil { + db.unlockWrite(false, 0, err) + return err + } + defer mdb.decref() + + var ( + overflow bool + merged int + batches = []*Batch{batch} + ) + + if merge { + // Merge limit. + var mergeLimit int + if batch.internalLen > 128<<10 { + mergeLimit = (1 << 20) - batch.internalLen + } else { + mergeLimit = 128 << 10 + } + mergeCap := mdbFree - batch.internalLen + if mergeLimit > mergeCap { + mergeLimit = mergeCap + } + + merge: + for mergeLimit > 0 { + select { + case incoming := <-db.writeMergeC: + if incoming.batch != nil { + // Merge batch. + if incoming.batch.internalLen > mergeLimit { + overflow = true + break merge + } + batches = append(batches, incoming.batch) + mergeLimit -= incoming.batch.internalLen + } else { + // Merge put. + internalLen := len(incoming.key) + len(incoming.value) + 8 + if internalLen > mergeLimit { + overflow = true + break merge + } + if ourBatch == nil { + ourBatch = db.batchPool.Get().(*Batch) + ourBatch.Reset() + batches = append(batches, ourBatch) + } + // We can use same batch since concurrent write doesn't + // guarantee write order. + ourBatch.appendRec(incoming.keyType, incoming.key, incoming.value) + mergeLimit -= internalLen + } + sync = sync || incoming.sync + merged++ + db.writeMergedC <- true + + default: + break merge + } + } + } + + // Seq number. + seq := db.seq + 1 + + // Write journal. + if err := db.writeJournal(batches, seq, sync); err != nil { + db.unlockWrite(overflow, merged, err) + return err + } + + // Put batches. + for _, batch := range batches { + if err := batch.putMem(seq, mdb.DB); err != nil { + panic(err) + } + seq += uint64(batch.Len()) + } + + // Incr seq number. + db.addSeq(uint64(batchesLen(batches))) + + // Rotate memdb if it's reach the threshold. + if batch.internalLen >= mdbFree { + db.rotateMem(0, false) + } + + db.unlockWrite(overflow, merged, nil) + return nil +} + +// Write apply the given batch to the DB. The batch records will be applied +// sequentially. Write might be used concurrently, when used concurrently and +// batch is small enough, write will try to merge the batches. Set NoWriteMerge +// option to true to disable write merge. +// +// It is safe to modify the contents of the arguments after Write returns but +// not before. Write will not modify content of the batch. +func (db *DB) Write(batch *Batch, wo *opt.WriteOptions) error { + if err := db.ok(); err != nil || batch == nil || batch.Len() == 0 { + return err + } + + // If the batch size is larger than write buffer, it may justified to write + // using transaction instead. Using transaction the batch will be written + // into tables directly, skipping the journaling. + if batch.internalLen > db.s.o.GetWriteBuffer() && !db.s.o.GetDisableLargeBatchTransaction() { + tr, err := db.OpenTransaction() + if err != nil { + return err + } + if err := tr.Write(batch, wo); err != nil { + tr.Discard() + return err + } + return tr.Commit() + } + + merge := !wo.GetNoWriteMerge() && !db.s.o.GetNoWriteMerge() + sync := wo.GetSync() && !db.s.o.GetNoSync() + + // Acquire write lock. + if merge { + select { + case db.writeMergeC <- writeMerge{sync: sync, batch: batch}: + if <-db.writeMergedC { + // Write is merged. + return <-db.writeAckC + } + // Write is not merged, the write lock is handed to us. Continue. + case db.writeLockC <- struct{}{}: + // Write lock acquired. + case err := <-db.compPerErrC: + // Compaction error. + return err + case <-db.closeC: + // Closed + return ErrClosed + } + } else { + select { + case db.writeLockC <- struct{}{}: + // Write lock acquired. + case err := <-db.compPerErrC: + // Compaction error. + return err + case <-db.closeC: + // Closed + return ErrClosed + } + } + + return db.writeLocked(batch, nil, merge, sync) +} + +func (db *DB) putRec(kt keyType, key, value []byte, wo *opt.WriteOptions) error { + if err := db.ok(); err != nil { + return err + } + + merge := !wo.GetNoWriteMerge() && !db.s.o.GetNoWriteMerge() + sync := wo.GetSync() && !db.s.o.GetNoSync() + + // Acquire write lock. + if merge { + select { + case db.writeMergeC <- writeMerge{sync: sync, keyType: kt, key: key, value: value}: + if <-db.writeMergedC { + // Write is merged. + return <-db.writeAckC + } + // Write is not merged, the write lock is handed to us. Continue. + case db.writeLockC <- struct{}{}: + // Write lock acquired. + case err := <-db.compPerErrC: + // Compaction error. + return err + case <-db.closeC: + // Closed + return ErrClosed + } + } else { + select { + case db.writeLockC <- struct{}{}: + // Write lock acquired. + case err := <-db.compPerErrC: + // Compaction error. + return err + case <-db.closeC: + // Closed + return ErrClosed + } + } + + batch := db.batchPool.Get().(*Batch) + batch.Reset() + batch.appendRec(kt, key, value) + return db.writeLocked(batch, batch, merge, sync) +} + +// Put sets the value for the given key. It overwrites any previous value +// for that key; a DB is not a multi-map. Write merge also applies for Put, see +// Write. +// +// It is safe to modify the contents of the arguments after Put returns but not +// before. +func (db *DB) Put(key, value []byte, wo *opt.WriteOptions) error { + return db.putRec(keyTypeVal, key, value, wo) +} + +// Delete deletes the value for the given key. Delete will not returns error if +// key doesn't exist. Write merge also applies for Delete, see Write. +// +// It is safe to modify the contents of the arguments after Delete returns but +// not before. +func (db *DB) Delete(key []byte, wo *opt.WriteOptions) error { + return db.putRec(keyTypeDel, key, nil, wo) +} + +func isMemOverlaps(icmp *iComparer, mem *memdb.DB, min, max []byte) bool { + iter := mem.NewIterator(nil) + defer iter.Release() + return (max == nil || (iter.First() && icmp.uCompare(max, internalKey(iter.Key()).ukey()) >= 0)) && + (min == nil || (iter.Last() && icmp.uCompare(min, internalKey(iter.Key()).ukey()) <= 0)) +} + +// CompactRange compacts the underlying DB for the given key range. +// In particular, deleted and overwritten versions are discarded, +// and the data is rearranged to reduce the cost of operations +// needed to access the data. This operation should typically only +// be invoked by users who understand the underlying implementation. +// +// A nil Range.Start is treated as a key before all keys in the DB. +// And a nil Range.Limit is treated as a key after all keys in the DB. +// Therefore if both is nil then it will compact entire DB. +func (db *DB) CompactRange(r util.Range) error { + if err := db.ok(); err != nil { + return err + } + + // Lock writer. + select { + case db.writeLockC <- struct{}{}: + case err := <-db.compPerErrC: + return err + case <-db.closeC: + return ErrClosed + } + + // Check for overlaps in memdb. + mdb := db.getEffectiveMem() + if mdb == nil { + return ErrClosed + } + defer mdb.decref() + if isMemOverlaps(db.s.icmp, mdb.DB, r.Start, r.Limit) { + // Memdb compaction. + if _, err := db.rotateMem(0, false); err != nil { + <-db.writeLockC + return err + } + <-db.writeLockC + if err := db.compTriggerWait(db.mcompCmdC); err != nil { + return err + } + } else { + <-db.writeLockC + } + + // Table compaction. + return db.compTriggerRange(db.tcompCmdC, -1, r.Start, r.Limit) +} + +// SetReadOnly makes DB read-only. It will stay read-only until reopened. +func (db *DB) SetReadOnly() error { + if err := db.ok(); err != nil { + return err + } + + // Lock writer. + select { + case db.writeLockC <- struct{}{}: + db.compWriteLocking = true + case err := <-db.compPerErrC: + return err + case <-db.closeC: + return ErrClosed + } + + // Set compaction read-only. + select { + case db.compErrSetC <- ErrReadOnly: + case perr := <-db.compPerErrC: + return perr + case <-db.closeC: + return ErrClosed + } + + return nil +} diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/doc.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/doc.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/doc.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/doc.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/errors.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/errors.go similarity index 96% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/errors.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/errors.go index c8bd66a..de26498 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/errors.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/errors.go @@ -10,6 +10,7 @@ import ( "github.com/syndtr/goleveldb/leveldb/errors" ) +// Common errors. var ( ErrNotFound = errors.ErrNotFound ErrReadOnly = errors.New("leveldb: read-only mode") diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/errors/errors.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/errors/errors.go similarity index 96% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/errors/errors.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/errors/errors.go index 9a0f6e2..8d6146b 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/errors/errors.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/errors/errors.go @@ -15,6 +15,7 @@ import ( "github.com/syndtr/goleveldb/leveldb/util" ) +// Common errors. var ( ErrNotFound = New("leveldb: not found") ErrReleased = util.ErrReleased @@ -34,11 +35,10 @@ type ErrCorrupted struct { } func (e *ErrCorrupted) Error() string { - if !e.Fd.Nil() { + if !e.Fd.Zero() { return fmt.Sprintf("%v [file=%v]", e.Err, e.Fd) - } else { - return e.Err.Error() } + return e.Err.Error() } // NewErrCorrupted creates new ErrCorrupted error. diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/filter.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/filter.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/filter.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/filter.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/filter/bloom.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/filter/bloom.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/filter/bloom.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/filter/bloom.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/filter/filter.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/filter/filter.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/filter/filter.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/filter/filter.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/iterator/iter.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/iterator/iter.go similarity index 88% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/iterator/iter.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/iterator/iter.go index c252286..3b55532 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/iterator/iter.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/iterator/iter.go @@ -21,13 +21,13 @@ var ( // IteratorSeeker is the interface that wraps the 'seeks method'. type IteratorSeeker interface { // First moves the iterator to the first key/value pair. If the iterator - // only contains one key/value pair then First and Last whould moves + // only contains one key/value pair then First and Last would moves // to the same key/value pair. // It returns whether such pair exist. First() bool // Last moves the iterator to the last key/value pair. If the iterator - // only contains one key/value pair then First and Last whould moves + // only contains one key/value pair then First and Last would moves // to the same key/value pair. // It returns whether such pair exist. Last() bool @@ -48,7 +48,7 @@ type IteratorSeeker interface { Prev() bool } -// CommonIterator is the interface that wraps common interator methods. +// CommonIterator is the interface that wraps common iterator methods. type CommonIterator interface { IteratorSeeker @@ -71,14 +71,15 @@ type CommonIterator interface { // Iterator iterates over a DB's key/value pairs in key order. // -// When encouter an error any 'seeks method' will return false and will +// When encounter an error any 'seeks method' will return false and will // yield no key/value pairs. The error can be queried by calling the Error // method. Calling Release is still necessary. // // An iterator must be released after use, but it is not necessary to read // an iterator until exhaustion. -// Also, an iterator is not necessarily goroutine-safe, but it is safe to use -// multiple iterators concurrently, with each in a dedicated goroutine. +// Also, an iterator is not necessarily safe for concurrent use, but it is +// safe to use multiple iterators concurrently, with each in a dedicated +// goroutine. type Iterator interface { CommonIterator @@ -98,7 +99,7 @@ type Iterator interface { // // ErrorCallbackSetter implemented by indexed and merged iterator. type ErrorCallbackSetter interface { - // SetErrorCallback allows set an error callback of the coresponding + // SetErrorCallback allows set an error callback of the corresponding // iterator. Use nil to clear the callback. SetErrorCallback(f func(err error)) } diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/journal/journal.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/journal/journal.go similarity index 93% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/journal/journal.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/journal/journal.go index 891098b..d094c3d 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/journal/journal.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/journal/journal.go @@ -180,34 +180,37 @@ func (r *Reader) nextChunk(first bool) error { checksum := binary.LittleEndian.Uint32(r.buf[r.j+0 : r.j+4]) length := binary.LittleEndian.Uint16(r.buf[r.j+4 : r.j+6]) chunkType := r.buf[r.j+6] - + unprocBlock := r.n - r.j if checksum == 0 && length == 0 && chunkType == 0 { // Drop entire block. - m := r.n - r.j r.i = r.n r.j = r.n - return r.corrupt(m, "zero header", false) - } else { - m := r.n - r.j - r.i = r.j + headerSize - r.j = r.j + headerSize + int(length) - if r.j > r.n { - // Drop entire block. - r.i = r.n - r.j = r.n - return r.corrupt(m, "chunk length overflows block", false) - } else if r.checksum && checksum != util.NewCRC(r.buf[r.i-1:r.j]).Value() { - // Drop entire block. - r.i = r.n - r.j = r.n - return r.corrupt(m, "checksum mismatch", false) - } + return r.corrupt(unprocBlock, "zero header", false) + } + if chunkType < fullChunkType || chunkType > lastChunkType { + // Drop entire block. + r.i = r.n + r.j = r.n + return r.corrupt(unprocBlock, fmt.Sprintf("invalid chunk type %#x", chunkType), false) + } + r.i = r.j + headerSize + r.j = r.j + headerSize + int(length) + if r.j > r.n { + // Drop entire block. + r.i = r.n + r.j = r.n + return r.corrupt(unprocBlock, "chunk length overflows block", false) + } else if r.checksum && checksum != util.NewCRC(r.buf[r.i-1:r.j]).Value() { + // Drop entire block. + r.i = r.n + r.j = r.n + return r.corrupt(unprocBlock, "checksum mismatch", false) } if first && chunkType != fullChunkType && chunkType != firstChunkType { - m := r.j - r.i + chunkLength := (r.j - r.i) + headerSize r.i = r.j // Report the error, but skip it. - return r.corrupt(m+headerSize, "orphan chunk", true) + return r.corrupt(chunkLength, "orphan chunk", true) } r.last = chunkType == fullChunkType || chunkType == lastChunkType return nil diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/key.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/key.go similarity index 95% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/key.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/key.go index d0b80aa..ad8f51e 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/key.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/key.go @@ -37,14 +37,14 @@ func (kt keyType) String() string { case keyTypeVal: return "v" } - return "x" + return fmt.Sprintf("", uint(kt)) } // Value types encoded as the last component of internal keys. // Don't modify; this value are saved to disk. const ( - keyTypeDel keyType = iota - keyTypeVal + keyTypeDel = keyType(0) + keyTypeVal = keyType(1) ) // keyTypeSeek defines the keyType that should be passed when constructing an @@ -79,11 +79,7 @@ func makeInternalKey(dst, ukey []byte, seq uint64, kt keyType) internalKey { panic("leveldb: invalid type") } - if n := len(ukey) + 8; cap(dst) < n { - dst = make([]byte, n) - } else { - dst = dst[:n] - } + dst = ensureBuffer(dst, len(ukey)+8) copy(dst, ukey) binary.LittleEndian.PutUint64(dst[len(ukey):], (seq<<8)|uint64(kt)) return internalKey(dst) @@ -143,5 +139,5 @@ func (ik internalKey) String() string { if ukey, seq, kt, err := parseInternalKey(ik); err == nil { return fmt.Sprintf("%s,%s%d", shorten(string(ukey)), kt, seq) } - return "" + return fmt.Sprintf("", []byte(ik)) } diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go similarity index 96% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go index 1395bd9..18a19ed 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go @@ -17,6 +17,7 @@ import ( "github.com/syndtr/goleveldb/leveldb/util" ) +// Common errors. var ( ErrNotFound = errors.ErrNotFound ErrIterReleased = errors.New("leveldb/memdb: iterator released") @@ -385,7 +386,7 @@ func (p *DB) Find(key []byte) (rkey, value []byte, err error) { } // NewIterator returns an iterator of the DB. -// The returned iterator is not goroutine-safe, but it is safe to use +// The returned iterator is not safe for concurrent use, but it is safe to use // multiple iterators concurrently, with each in a dedicated goroutine. // It is also safe to use an iterator concurrently with modifying its // underlying DB. However, the resultant key/value pairs are not guaranteed @@ -411,7 +412,7 @@ func (p *DB) Capacity() int { } // Size returns sum of keys and values length. Note that deleted -// key/value will not be accouted for, but it will still consume +// key/value will not be accounted for, but it will still consume // the buffer, since the buffer is append only. func (p *DB) Size() int { p.mu.RLock() @@ -453,11 +454,14 @@ func (p *DB) Reset() { p.mu.Unlock() } -// New creates a new initalized in-memory key/value DB. The capacity +// New creates a new initialized in-memory key/value DB. The capacity // is the initial key/value buffer capacity. The capacity is advisory, // not enforced. // -// The returned DB instance is goroutine-safe. +// This DB is append-only, deleting an entry would remove entry node but not +// reclaim KV buffer. +// +// The returned DB instance is safe for concurrent use. func New(cmp comparer.BasicComparer, capacity int) *DB { p := &DB{ cmp: cmp, diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/opt/options.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/opt/options.go similarity index 97% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/opt/options.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/opt/options.go index 3d2bf1c..44e7d9a 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/opt/options.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/opt/options.go @@ -312,6 +312,11 @@ type Options struct { // The default is false. NoSync bool + // NoWriteMerge allows disabling write merge. + // + // The default is false. + NoWriteMerge bool + // OpenFilesCacher provides cache algorithm for open files caching. // Specify NoCacher to disable caching algorithm. // @@ -543,6 +548,13 @@ func (o *Options) GetNoSync() bool { return o.NoSync } +func (o *Options) GetNoWriteMerge() bool { + if o == nil { + return false + } + return o.NoWriteMerge +} + func (o *Options) GetOpenFilesCacher() Cacher { if o == nil || o.OpenFilesCacher == nil { return DefaultOpenFilesCacher @@ -629,6 +641,11 @@ func (ro *ReadOptions) GetStrict(strict Strict) bool { // WriteOptions holds the optional parameters for 'write operation'. The // 'write operation' includes Write, Put and Delete. type WriteOptions struct { + // NoWriteMerge allows disabling write merge. + // + // The default is false. + NoWriteMerge bool + // Sync is whether to sync underlying writes from the OS buffer cache // through to actual disk, if applicable. Setting Sync can result in // slower writes. @@ -644,6 +661,13 @@ type WriteOptions struct { Sync bool } +func (wo *WriteOptions) GetNoWriteMerge() bool { + if wo == nil { + return false + } + return wo.NoWriteMerge +} + func (wo *WriteOptions) GetSync() bool { if wo == nil { return false diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/options.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/options.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/options.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/options.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/session.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/session.go similarity index 95% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/session.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/session.go index b0d3fef..ad68a87 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/session.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/session.go @@ -18,7 +18,8 @@ import ( "github.com/syndtr/goleveldb/leveldb/storage" ) -// ErrManifestCorrupted records manifest corruption. +// ErrManifestCorrupted records manifest corruption. This error will be +// wrapped with errors.ErrCorrupted. type ErrManifestCorrupted struct { Field string Reason string @@ -42,10 +43,11 @@ type session struct { stSeqNum uint64 // last mem compacted seq; need external synchronization stor storage.Storage - storLock storage.Lock + storLock storage.Locker o *cachedOptions icmp *iComparer tops *tOps + fileRef map[int64]int manifest *journal.Writer manifestWriter storage.Writer @@ -68,6 +70,7 @@ func newSession(stor storage.Storage, o *opt.Options) (s *session, err error) { s = &session{ stor: stor, storLock: storLock, + fileRef: make(map[int64]int), } s.setOptions(o) s.tops = newTableOps(s) @@ -87,12 +90,12 @@ func (s *session) close() { } s.manifest = nil s.manifestWriter = nil - s.stVersion = nil + s.setVersion(&version{s: s, closing: true}) } // Release session lock. func (s *session) release() { - s.storLock.Release() + s.storLock.Unlock() } // Create a new database session; need external synchronization. diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/session_compaction.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/session_compaction.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/session_compaction.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/session_compaction.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/session_record.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/session_record.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/session_record.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/session_record.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/session_util.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/session_util.go similarity index 88% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/session_util.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/session_util.go index 674182f..9232893 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/session_util.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/session_util.go @@ -39,6 +39,18 @@ func (s *session) newTemp() storage.FileDesc { return storage.FileDesc{storage.TypeTemp, num} } +func (s *session) addFileRef(fd storage.FileDesc, ref int) int { + ref += s.fileRef[fd.Num] + if ref > 0 { + s.fileRef[fd.Num] = ref + } else if ref == 0 { + delete(s.fileRef, fd.Num) + } else { + panic(fmt.Sprintf("negative ref: %v", fd)) + } + return ref +} + // Session state. // Get current version. This will incr version ref, must call @@ -46,21 +58,28 @@ func (s *session) newTemp() storage.FileDesc { func (s *session) version() *version { s.vmu.Lock() defer s.vmu.Unlock() - s.stVersion.ref++ + s.stVersion.incref() return s.stVersion } +func (s *session) tLen(level int) int { + s.vmu.Lock() + defer s.vmu.Unlock() + return s.stVersion.tLen(level) +} + // Set current version to v. func (s *session) setVersion(v *version) { s.vmu.Lock() - v.ref = 1 // Holds by session. - if old := s.stVersion; old != nil { - v.ref++ // Holds by old version. - old.next = v - old.releaseNB() + defer s.vmu.Unlock() + // Hold by session. It is important to call this first before releasing + // current version, otherwise the still used files might get released. + v.incref() + if s.stVersion != nil { + // Release current version. + s.stVersion.releaseNB() } s.stVersion = v - s.vmu.Unlock() } // Get current unused file number. @@ -197,7 +216,7 @@ func (s *session) newManifest(rec *sessionRecord, v *version) (err error) { if s.manifestWriter != nil { s.manifestWriter.Close() } - if !s.manifestFd.Nil() { + if !s.manifestFd.Zero() { s.stor.Remove(s.manifestFd) } s.manifestFd = fd diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go similarity index 99% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go index cbe1dc1..e53434c 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go @@ -32,7 +32,7 @@ type fileStorageLock struct { fs *fileStorage } -func (lock *fileStorageLock) Release() { +func (lock *fileStorageLock) Unlock() { if lock.fs != nil { lock.fs.mu.Lock() defer lock.fs.mu.Unlock() @@ -116,7 +116,7 @@ func OpenFile(path string, readOnly bool) (Storage, error) { return fs, nil } -func (fs *fileStorage) Lock() (Lock, error) { +func (fs *fileStorage) Lock() (Locker, error) { fs.mu.Lock() defer fs.mu.Unlock() if fs.open < 0 { @@ -323,7 +323,7 @@ func (fs *fileStorage) GetMeta() (fd FileDesc, err error) { } } // Don't remove any files if there is no valid CURRENT file. - if fd.Nil() { + if fd.Zero() { if cerr != nil { err = cerr } else { diff --git a/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_nacl.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_nacl.go new file mode 100644 index 0000000..5545aee --- /dev/null +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_nacl.go @@ -0,0 +1,34 @@ +// Copyright (c) 2012, Suryandaru Triandana +// All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// +build nacl + +package storage + +import ( + "os" + "syscall" +) + +func newFileLock(path string, readOnly bool) (fl fileLock, err error) { + return nil, syscall.ENOTSUP +} + +func setFileLock(f *os.File, readOnly, lock bool) error { + return syscall.ENOTSUP +} + +func rename(oldpath, newpath string) error { + return syscall.ENOTSUP +} + +func isErrInvalid(err error) bool { + return false +} + +func syncDir(name string) error { + return syscall.ENOTSUP +} diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_plan9.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_plan9.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_plan9.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_plan9.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_solaris.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_solaris.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_solaris.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_solaris.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_unix.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_unix.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_unix.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_unix.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_windows.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_windows.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_windows.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_windows.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go similarity index 96% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go index 9b70e15..9b0421f 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go @@ -18,7 +18,7 @@ type memStorageLock struct { ms *memStorage } -func (lock *memStorageLock) Release() { +func (lock *memStorageLock) Unlock() { ms := lock.ms ms.mu.Lock() defer ms.mu.Unlock() @@ -43,7 +43,7 @@ func NewMemStorage() Storage { } } -func (ms *memStorage) Lock() (Lock, error) { +func (ms *memStorage) Lock() (Locker, error) { ms.mu.Lock() defer ms.mu.Unlock() if ms.slock != nil { @@ -69,7 +69,7 @@ func (ms *memStorage) SetMeta(fd FileDesc) error { func (ms *memStorage) GetMeta() (FileDesc, error) { ms.mu.Lock() defer ms.mu.Unlock() - if ms.meta.Nil() { + if ms.meta.Zero() { return FileDesc{}, os.ErrNotExist } return ms.meta, nil @@ -78,7 +78,7 @@ func (ms *memStorage) GetMeta() (FileDesc, error) { func (ms *memStorage) List(ft FileType) ([]FileDesc, error) { ms.mu.Lock() var fds []FileDesc - for x, _ := range ms.files { + for x := range ms.files { fd := unpackFile(x) if fd.Type&ft != 0 { fds = append(fds, fd) diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/storage/storage.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/storage.go similarity index 74% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/storage/storage.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/storage.go index 9b30b67..c16bce6 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/storage/storage.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/storage/storage.go @@ -11,12 +11,12 @@ import ( "errors" "fmt" "io" - - "github.com/syndtr/goleveldb/leveldb/util" ) +// FileType represent a file type. type FileType int +// File types. const ( TypeManifest FileType = 1 << iota TypeJournal @@ -40,6 +40,7 @@ func (t FileType) String() string { return fmt.Sprintf("", t) } +// Common error. var ( ErrInvalidFile = errors.New("leveldb/storage: invalid file for argument") ErrLocked = errors.New("leveldb/storage: already locked") @@ -55,11 +56,10 @@ type ErrCorrupted struct { } func (e *ErrCorrupted) Error() string { - if !e.Fd.Nil() { + if !e.Fd.Zero() { return fmt.Sprintf("%v [file=%v]", e.Err, e.Fd) - } else { - return e.Err.Error() } + return e.Err.Error() } // Syncer is the interface that wraps basic Sync method. @@ -83,11 +83,12 @@ type Writer interface { Syncer } -type Lock interface { - util.Releaser +// Locker is the interface that wraps Unlock method. +type Locker interface { + Unlock() } -// FileDesc is a file descriptor. +// FileDesc is a 'file descriptor'. type FileDesc struct { Type FileType Num int64 @@ -108,12 +109,12 @@ func (fd FileDesc) String() string { } } -// Nil returns true if fd == (FileDesc{}). -func (fd FileDesc) Nil() bool { +// Zero returns true if fd == (FileDesc{}). +func (fd FileDesc) Zero() bool { return fd == (FileDesc{}) } -// FileDescOk returns true if fd is a valid file descriptor. +// FileDescOk returns true if fd is a valid 'file descriptor'. func FileDescOk(fd FileDesc) bool { switch fd.Type { case TypeManifest: @@ -126,43 +127,44 @@ func FileDescOk(fd FileDesc) bool { return fd.Num >= 0 } -// Storage is the storage. A storage instance must be goroutine-safe. +// Storage is the storage. A storage instance must be safe for concurrent use. type Storage interface { // Lock locks the storage. Any subsequent attempt to call Lock will fail // until the last lock released. - // After use the caller should call the Release method. - Lock() (Lock, error) + // Caller should call Unlock method after use. + Lock() (Locker, error) // Log logs a string. This is used for logging. // An implementation may write to a file, stdout or simply do nothing. Log(str string) - // SetMeta sets to point to the given fd, which then can be acquired using - // GetMeta method. - // SetMeta should be implemented in such way that changes should happened + // SetMeta store 'file descriptor' that can later be acquired using GetMeta + // method. The 'file descriptor' should point to a valid file. + // SetMeta should be implemented in such way that changes should happen // atomically. SetMeta(fd FileDesc) error - // GetManifest returns a manifest file. - // Returns os.ErrNotExist if meta doesn't point to any fd, or point to fd - // that doesn't exist. + // GetMeta returns 'file descriptor' stored in meta. The 'file descriptor' + // can be updated using SetMeta method. + // Returns os.ErrNotExist if meta doesn't store any 'file descriptor', or + // 'file descriptor' point to nonexistent file. GetMeta() (FileDesc, error) - // List returns fds that match the given file types. + // List returns file descriptors that match the given file types. // The file types may be OR'ed together. List(ft FileType) ([]FileDesc, error) - // Open opens file with the given fd read-only. + // Open opens file with the given 'file descriptor' read-only. // Returns os.ErrNotExist error if the file does not exist. // Returns ErrClosed if the underlying storage is closed. Open(fd FileDesc) (Reader, error) - // Create creates file with the given fd, truncate if already exist and - // opens write-only. + // Create creates file with the given 'file descriptor', truncate if already + // exist and opens write-only. // Returns ErrClosed if the underlying storage is closed. Create(fd FileDesc) (Writer, error) - // Remove removes file with the given fd. + // Remove removes file with the given 'file descriptor'. // Returns ErrClosed if the underlying storage is closed. Remove(fd FileDesc) error diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/table.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/table.go similarity index 99% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/table.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/table.go index 310ba6c..81d18a5 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/table.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/table.go @@ -434,7 +434,7 @@ func (t *tOps) close() { t.bpool.Close() t.cache.Close() if t.bcache != nil { - t.bcache.Close() + t.bcache.CloseWeak() } } diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/table/reader.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/table/reader.go similarity index 95% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/table/reader.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/table/reader.go index ae61bec..16cfbaa 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/table/reader.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/table/reader.go @@ -26,12 +26,15 @@ import ( "github.com/syndtr/goleveldb/leveldb/util" ) +// Reader errors. var ( ErrNotFound = errors.ErrNotFound ErrReaderReleased = errors.New("leveldb/table: reader released") ErrIterReleased = errors.New("leveldb/table: iterator released") ) +// ErrCorrupted describes error due to corruption. This error will be wrapped +// with errors.ErrCorrupted. type ErrCorrupted struct { Pos int64 Size int64 @@ -61,7 +64,7 @@ type block struct { func (b *block) seek(cmp comparer.Comparer, rstart, rlimit int, key []byte) (index, offset int, err error) { index = sort.Search(b.restartsLen-rstart-(b.restartsLen-rlimit), func(i int) bool { offset := int(binary.LittleEndian.Uint32(b.data[b.restartsOffset+4*(rstart+i):])) - offset += 1 // shared always zero, since this is a restart point + offset++ // shared always zero, since this is a restart point v1, n1 := binary.Uvarint(b.data[offset:]) // key length _, n2 := binary.Uvarint(b.data[offset+n1:]) // value length m := offset + n1 + n2 @@ -356,7 +359,7 @@ func (i *blockIter) Prev() bool { i.value = nil offset := i.block.restartOffset(ri) if offset == i.offset { - ri -= 1 + ri-- if ri < 0 { i.dir = dirSOI return false @@ -578,6 +581,7 @@ func (r *Reader) readRawBlock(bh blockHandle, verifyChecksum bool) ([]byte, erro case blockTypeSnappyCompression: decLen, err := snappy.DecodedLen(data[:bh.length]) if err != nil { + r.bpool.Put(data) return nil, r.newErrCorruptedBH(bh, err.Error()) } decData := r.bpool.Get(decLen) @@ -783,8 +787,8 @@ func (r *Reader) getDataIterErr(dataBH blockHandle, slice *util.Range, verifyChe // table. And a nil Range.Limit is treated as a key after all keys in // the table. // -// The returned iterator is not goroutine-safe and should be released -// when not used. +// The returned iterator is not safe for concurrent use and should be released +// after use. // // Also read Iterator documentation of the leveldb/iterator package. func (r *Reader) NewIterator(slice *util.Range, ro *opt.ReadOptions) iterator.Iterator { @@ -826,18 +830,21 @@ func (r *Reader) find(key []byte, filtered bool, ro *opt.ReadOptions, noValue bo index := r.newBlockIter(indexBlock, nil, nil, true) defer index.Release() + if !index.Seek(key) { - err = index.Error() - if err == nil { + if err = index.Error(); err == nil { err = ErrNotFound } return } + dataBH, n := decodeBlockHandle(index.Value()) if n == 0 { r.err = r.newErrCorruptedBH(r.indexBH, "bad data block handle") - return + return nil, nil, r.err } + + // The filter should only used for exact match. if filtered && r.filter != nil { filterBlock, frel, ferr := r.getFilterBlock(true) if ferr == nil { @@ -847,30 +854,53 @@ func (r *Reader) find(key []byte, filtered bool, ro *opt.ReadOptions, noValue bo } frel.Release() } else if !errors.IsCorrupted(ferr) { - err = ferr + return nil, nil, ferr + } + } + + data := r.getDataIter(dataBH, nil, r.verifyChecksum, !ro.GetDontFillCache()) + if !data.Seek(key) { + data.Release() + if err = data.Error(); err != nil { + return + } + + // The nearest greater-than key is the first key of the next block. + if !index.Next() { + if err = index.Error(); err == nil { + err = ErrNotFound + } + return + } + + dataBH, n = decodeBlockHandle(index.Value()) + if n == 0 { + r.err = r.newErrCorruptedBH(r.indexBH, "bad data block handle") + return nil, nil, r.err + } + + data = r.getDataIter(dataBH, nil, r.verifyChecksum, !ro.GetDontFillCache()) + if !data.Next() { + data.Release() + if err = data.Error(); err == nil { + err = ErrNotFound + } return } } - data := r.getDataIter(dataBH, nil, r.verifyChecksum, !ro.GetDontFillCache()) - defer data.Release() - if !data.Seek(key) { - err = data.Error() - if err == nil { - err = ErrNotFound - } - return - } - // Don't use block buffer, no need to copy the buffer. + + // Key doesn't use block buffer, no need to copy the buffer. rkey = data.Key() if !noValue { if r.bpool == nil { value = data.Value() } else { - // Use block buffer, and since the buffer will be recycled, the buffer - // need to be copied. + // Value does use block buffer, and since the buffer will be + // recycled, it need to be copied. value = append([]byte{}, data.Value()...) } } + data.Release() return } @@ -888,7 +918,7 @@ func (r *Reader) Find(key []byte, filtered bool, ro *opt.ReadOptions) (rkey, val return r.find(key, filtered, ro, false) } -// Find finds key that is greater than or equal to the given key. +// FindKey finds key that is greater than or equal to the given key. // It returns ErrNotFound if the table doesn't contain such key. // If filtered is true then the nearest 'block' will be checked against // 'filter data' (if present) and will immediately return ErrNotFound if @@ -987,7 +1017,7 @@ func (r *Reader) Release() { // NewReader creates a new initialized table reader for the file. // The fi, cache and bpool is optional and can be nil. // -// The returned table reader instance is goroutine-safe. +// The returned table reader instance is safe for concurrent use. func NewReader(f io.ReaderAt, size int64, fd storage.FileDesc, cache *cache.NamespaceGetter, bpool *util.BufferPool, o *opt.Options) (*Reader, error) { if f == nil { return nil, errors.New("leveldb/table: nil file") @@ -1039,9 +1069,8 @@ func NewReader(f io.ReaderAt, size int64, fd storage.FileDesc, cache *cache.Name if errors.IsCorrupted(err) { r.err = err return r, nil - } else { - return nil, err } + return nil, err } // Set data end. @@ -1086,9 +1115,8 @@ func NewReader(f io.ReaderAt, size int64, fd storage.FileDesc, cache *cache.Name if errors.IsCorrupted(err) { r.err = err return r, nil - } else { - return nil, err } + return nil, err } if r.filter != nil { r.filterBlock, err = r.readFilterBlock(r.filterBH) diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/table/table.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/table/table.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/table/table.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/table/table.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/table/writer.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/table/writer.go similarity index 99% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/table/writer.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/table/writer.go index 274dee6..b96b271 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/table/writer.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/table/writer.go @@ -349,7 +349,7 @@ func (w *Writer) Close() error { // NewWriter creates a new initialized table writer for the file. // -// Table writer is not goroutine-safe. +// Table writer is not safe for concurrent use. func NewWriter(f io.Writer, o *opt.Options) *Writer { w := &Writer{ writer: f, diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/util.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/util.go similarity index 92% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/util.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/util.go index 3b663d1..e572a32 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/util.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/util.go @@ -89,3 +89,10 @@ func (p fdSorter) Swap(i, j int) { func sortFds(fds []storage.FileDesc) { sort.Sort(fdSorter(fds)) } + +func ensureBuffer(b []byte, n int) []byte { + if cap(b) < n { + return make([]byte, n) + } + return b[:n] +} diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/util/buffer.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/util/buffer.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/util/buffer.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/util/buffer.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/util/crc32.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/util/crc32.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/util/crc32.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/util/crc32.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/util/hash.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/util/hash.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/util/hash.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/util/hash.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/util/range.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/util/range.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/util/range.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/util/range.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/util/util.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/util/util.go similarity index 100% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/util/util.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/util/util.go diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/version.go b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/version.go similarity index 96% rename from cmd/vendor/github.com/syndtr/goleveldb/leveldb/version.go rename to _vendor/vendor/github.com/syndtr/goleveldb/leveldb/version.go index d274eef..73f272a 100644 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/version.go +++ b/_vendor/vendor/github.com/syndtr/goleveldb/leveldb/version.go @@ -34,43 +34,48 @@ type version struct { cSeek unsafe.Pointer - ref int - // Succeeding version. - next *version + closing bool + ref int + released bool } func newVersion(s *session) *version { return &version{s: s} } +func (v *version) incref() { + if v.released { + panic("already released") + } + + v.ref++ + if v.ref == 1 { + // Incr file ref. + for _, tt := range v.levels { + for _, t := range tt { + v.s.addFileRef(t.fd, 1) + } + } + } +} + func (v *version) releaseNB() { v.ref-- if v.ref > 0 { return - } - if v.ref < 0 { + } else if v.ref < 0 { panic("negative version ref") } - nextTables := make(map[int64]bool) - for _, tt := range v.next.levels { - for _, t := range tt { - num := t.fd.Num - nextTables[num] = true - } - } - for _, tt := range v.levels { for _, t := range tt { - num := t.fd.Num - if _, ok := nextTables[num]; !ok { + if v.s.addFileRef(t.fd, -1) == 0 { v.s.tops.remove(t) } } } - v.next.releaseNB() - v.next = nil + v.released = true } func (v *version) release() { @@ -131,6 +136,10 @@ func (v *version) walkOverlapping(aux tFiles, ikey internalKey, f func(level int } func (v *version) get(aux tFiles, ikey internalKey, ro *opt.ReadOptions, noValue bool) (value []byte, tcomp bool, err error) { + if v.closing { + return nil, false, ErrClosed + } + ukey := ikey.ukey() var ( diff --git a/cmd/vendor/github.com/ugorji/go/LICENSE b/_vendor/vendor/github.com/ugorji/go/LICENSE similarity index 100% rename from cmd/vendor/github.com/ugorji/go/LICENSE rename to _vendor/vendor/github.com/ugorji/go/LICENSE diff --git a/cmd/vendor/github.com/ugorji/go/codec/0doc.go b/_vendor/vendor/github.com/ugorji/go/codec/0doc.go similarity index 69% rename from cmd/vendor/github.com/ugorji/go/codec/0doc.go rename to _vendor/vendor/github.com/ugorji/go/codec/0doc.go index dd8b589..bd7361c 100644 --- a/cmd/vendor/github.com/ugorji/go/codec/0doc.go +++ b/_vendor/vendor/github.com/ugorji/go/codec/0doc.go @@ -64,6 +64,7 @@ Rich Feature Set includes: - 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. + - Detect and error when encoding a cyclic reference (instead of stack overflow shutdown) - 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. @@ -98,7 +99,21 @@ with the standard net/rpc package. Usage -Typical usage model: +The Handle is SAFE for concurrent READ, but NOT SAFE for concurrent modification. + +The Encoder and Decoder are NOT safe for concurrent use. + +Consequently, the usage model is basically: + + - Create and initialize the Handle before any use. + Once created, DO NOT modify it. + - Multiple Encoders or Decoders can now use the Handle concurrently. + They only read information off the Handle (never write). + - However, each Encoder or Decoder MUST not be used concurrently + - To re-use an Encoder/Decoder, call Reset(...) on it first. + This allows you use state maintained on the Encoder/Decoder. + +Sample usage model: // create and configure Handle var ( @@ -148,3 +163,37 @@ Typical usage model: */ package codec +// Benefits of go-codec: +// +// - encoding/json always reads whole file into memory first. +// This makes it unsuitable for parsing very large files. +// - encoding/xml cannot parse into a map[string]interface{} +// I found this out on reading https://github.com/clbanning/mxj + +// TODO: +// +// - optimization for codecgen: +// if len of entity is <= 3 words, then support a value receiver for encode. +// - (En|De)coder should store an error when it occurs. +// Until reset, subsequent calls return that error that was stored. +// This means that free panics must go away. +// All errors must be raised through errorf method. +// - Decoding using a chan is good, but incurs concurrency costs. +// This is because there's no fast way to use a channel without it +// having to switch goroutines constantly. +// Callback pattern is still the best. Maybe cnsider supporting something like: +// type X struct { +// Name string +// Ys []Y +// Ys chan <- Y +// Ys func(Y) -> call this function for each entry +// } +// - Consider adding a isZeroer interface { isZero() bool } +// It is used within isEmpty, for omitEmpty support. +// - Consider making Handle used AS-IS within the encoding/decoding session. +// This means that we don't cache Handle information within the (En|De)coder, +// except we really need it at Reset(...) +// - Consider adding math/big support +// - Consider reducing the size of the generated functions: +// Maybe use one loop, and put the conditionals in the loop. +// for ... { if cLen > 0 { if j == cLen { break } } else if dd.CheckBreak() { break } } diff --git a/cmd/vendor/github.com/ugorji/go/codec/binc.go b/_vendor/vendor/github.com/ugorji/go/codec/binc.go similarity index 89% rename from cmd/vendor/github.com/ugorji/go/codec/binc.go rename to _vendor/vendor/github.com/ugorji/go/codec/binc.go index 9dadb0a..766d26c 100644 --- a/cmd/vendor/github.com/ugorji/go/codec/binc.go +++ b/_vendor/vendor/github.com/ugorji/go/codec/binc.go @@ -5,6 +5,7 @@ package codec import ( "math" + "reflect" "time" ) @@ -58,8 +59,8 @@ type bincEncDriver struct { e *Encoder w encWriter m map[string]uint16 // symbols - s uint16 // symbols sequencer b [scratchByteArrayLen]byte + s uint16 // symbols sequencer encNoSeparator } @@ -69,7 +70,15 @@ func (e *bincEncDriver) IsBuiltinType(rt uintptr) bool { func (e *bincEncDriver) EncodeBuiltin(rt uintptr, v interface{}) { if rt == timeTypId { - bs := encodeTime(v.(time.Time)) + var bs []byte + switch x := v.(type) { + case time.Time: + bs = encodeTime(x) + case *time.Time: + bs = encodeTime(*x) + default: + e.e.errorf("binc error encoding builtin: expect time.Time, received %T", v) + } e.w.writen1(bincVdTimestamp<<4 | uint8(len(bs))) e.w.writeb(bs) } @@ -309,9 +318,9 @@ func (e *bincEncDriver) encLenNumber(bd byte, v uint64) { //------------------------------------ type bincDecSymbol struct { - i uint16 s string b []byte + i uint16 } type bincDecDriver struct { @@ -320,7 +329,6 @@ type bincDecDriver struct { r decReader br bool // bytes reader bdRead bool - bdType valueType bd byte vd byte vs byte @@ -338,24 +346,23 @@ func (d *bincDecDriver) readNextBd() { d.vd = d.bd >> 4 d.vs = d.bd & 0x0f d.bdRead = true - d.bdType = valueTypeUnset } -func (d *bincDecDriver) IsContainerType(vt valueType) (b bool) { - switch vt { - case valueTypeNil: - return d.vd == bincVdSpecial && d.vs == bincSpNil - case valueTypeBytes: - return d.vd == bincVdByteArray - case valueTypeString: - return d.vd == bincVdString - case valueTypeArray: - return d.vd == bincVdArray - case valueTypeMap: - return d.vd == bincVdMap +func (d *bincDecDriver) ContainerType() (vt valueType) { + if d.vd == bincVdSpecial && d.vs == bincSpNil { + return valueTypeNil + } else if d.vd == bincVdByteArray { + return valueTypeBytes + } else if d.vd == bincVdString { + return valueTypeString + } else if d.vd == bincVdArray { + return valueTypeArray + } else if d.vd == bincVdMap { + return valueTypeMap + } else { + // d.d.errorf("isContainerType: unsupported parameter: %v", vt) } - d.d.errorf("isContainerType: unsupported parameter: %v", vt) - return // "unreachable" + return valueTypeUnset } func (d *bincDecDriver) TryDecodeAsNil() bool { @@ -686,7 +693,7 @@ func (d *bincDecDriver) decStringAndBytes(bs []byte, withString, zerocopy bool) if withString { s = string(bs2) } - d.s = append(d.s, bincDecSymbol{symbol, s, bs2}) + d.s = append(d.s, bincDecSymbol{i: symbol, s: s, b: bs2}) } default: d.d.errorf("Invalid d.vd. Expecting string:0x%x, bytearray:0x%x or symbol: 0x%x. Got: 0x%x", @@ -775,97 +782,95 @@ func (d *bincDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs []b return } -func (d *bincDecDriver) DecodeNaked() (v interface{}, vt valueType, decodeFurther bool) { +func (d *bincDecDriver) DecodeNaked() { if !d.bdRead { d.readNextBd() } + n := &d.d.n + var decodeFurther bool + switch d.vd { case bincVdSpecial: switch d.vs { case bincSpNil: - vt = valueTypeNil + n.v = valueTypeNil case bincSpFalse: - vt = valueTypeBool - v = false + n.v = valueTypeBool + n.b = false case bincSpTrue: - vt = valueTypeBool - v = true + n.v = valueTypeBool + n.b = true case bincSpNan: - vt = valueTypeFloat - v = math.NaN() + n.v = valueTypeFloat + n.f = math.NaN() case bincSpPosInf: - vt = valueTypeFloat - v = math.Inf(1) + n.v = valueTypeFloat + n.f = math.Inf(1) case bincSpNegInf: - vt = valueTypeFloat - v = math.Inf(-1) + n.v = valueTypeFloat + n.f = math.Inf(-1) case bincSpZeroFloat: - vt = valueTypeFloat - v = float64(0) + n.v = valueTypeFloat + n.f = float64(0) case bincSpZero: - vt = valueTypeUint - v = uint64(0) // int8(0) + n.v = valueTypeUint + n.u = uint64(0) // int8(0) case bincSpNegOne: - vt = valueTypeInt - v = int64(-1) // int8(-1) + n.v = valueTypeInt + n.i = int64(-1) // int8(-1) default: d.d.errorf("decodeNaked: Unrecognized special value 0x%x", d.vs) - return } case bincVdSmallInt: - vt = valueTypeUint - v = uint64(int8(d.vs)) + 1 // int8(d.vs) + 1 + n.v = valueTypeUint + n.u = uint64(int8(d.vs)) + 1 // int8(d.vs) + 1 case bincVdPosInt: - vt = valueTypeUint - v = d.decUint() + n.v = valueTypeUint + n.u = d.decUint() case bincVdNegInt: - vt = valueTypeInt - v = -(int64(d.decUint())) + n.v = valueTypeInt + n.i = -(int64(d.decUint())) case bincVdFloat: - vt = valueTypeFloat - v = d.decFloat() + n.v = valueTypeFloat + n.f = d.decFloat() case bincVdSymbol: - vt = valueTypeSymbol - v = d.DecodeString() + n.v = valueTypeSymbol + n.s = d.DecodeString() case bincVdString: - vt = valueTypeString - v = d.DecodeString() + n.v = valueTypeString + n.s = d.DecodeString() case bincVdByteArray: - vt = valueTypeBytes - v = d.DecodeBytes(nil, false, false) + n.v = valueTypeBytes + n.l = d.DecodeBytes(nil, false, false) case bincVdTimestamp: - vt = valueTypeTimestamp + n.v = valueTypeTimestamp tt, err := decodeTime(d.r.readx(int(d.vs))) if err != nil { panic(err) } - v = tt + n.t = tt case bincVdCustomExt: - vt = valueTypeExt + n.v = valueTypeExt l := d.decLen() - var re RawExt - re.Tag = uint64(d.r.readn1()) - re.Data = d.r.readx(l) - v = &re - vt = valueTypeExt + n.u = uint64(d.r.readn1()) + n.l = d.r.readx(l) case bincVdArray: - vt = valueTypeArray + n.v = valueTypeArray decodeFurther = true case bincVdMap: - vt = valueTypeMap + n.v = valueTypeMap decodeFurther = true default: d.d.errorf("decodeNaked: Unrecognized d.vd: 0x%x", d.vd) - return } if !decodeFurther { d.bdRead = false } - if vt == valueTypeUint && d.h.SignedInteger { - d.bdType = valueTypeInt - v = int64(v.(uint64)) + if n.v == valueTypeUint && d.h.SignedInteger { + n.v = valueTypeInt + n.i = int64(n.u) } return } @@ -889,6 +894,10 @@ type BincHandle struct { binaryEncodingType } +func (h *BincHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) { + return h.SetExt(rt, tag, &setExtWrapper{b: ext}) +} + func (h *BincHandle) newEncDriver(e *Encoder) encDriver { return &bincEncDriver{e: e, w: e.w} } @@ -897,5 +906,17 @@ func (h *BincHandle) newDecDriver(d *Decoder) decDriver { return &bincDecDriver{d: d, r: d.r, h: h, br: d.bytes} } +func (e *bincEncDriver) reset() { + e.w = e.e.w + e.s = 0 + e.m = nil +} + +func (d *bincDecDriver) reset() { + d.r = d.d.r + d.s = nil + d.bd, d.bdRead, d.vd, d.vs = 0, false, 0, 0 +} + var _ decDriver = (*bincDecDriver)(nil) var _ encDriver = (*bincEncDriver)(nil) diff --git a/cmd/vendor/github.com/ugorji/go/codec/cbor.go b/_vendor/vendor/github.com/ugorji/go/codec/cbor.go similarity index 85% rename from cmd/vendor/github.com/ugorji/go/codec/cbor.go rename to _vendor/vendor/github.com/ugorji/go/codec/cbor.go index c3b88da..a224cd3 100644 --- a/cmd/vendor/github.com/ugorji/go/codec/cbor.go +++ b/_vendor/vendor/github.com/ugorji/go/codec/cbor.go @@ -3,7 +3,10 @@ package codec -import "math" +import ( + "math" + "reflect" +) const ( cborMajorUint byte = iota @@ -57,11 +60,11 @@ const ( // ------------------- type cborEncDriver struct { + noBuiltInTypes + encNoSeparator e *Encoder w encWriter h *CborHandle - noBuiltInTypes - encNoSeparator x [8]byte } @@ -158,7 +161,11 @@ func (e *cborEncDriver) EncodeSymbol(v string) { } func (e *cborEncDriver) EncodeStringBytes(c charEncoding, v []byte) { - e.encLen(cborBaseBytes, len(v)) + if c == c_RAW { + e.encLen(cborBaseBytes, len(v)) + } else { + e.encLen(cborBaseString, len(v)) + } e.w.writeb(v) } @@ -168,11 +175,10 @@ type cborDecDriver struct { d *Decoder h *CborHandle r decReader + b [scratchByteArrayLen]byte br bool // bytes reader bdRead bool - bdType valueType bd byte - b [scratchByteArrayLen]byte noBuiltInTypes decNoSeparator } @@ -180,24 +186,23 @@ type cborDecDriver struct { func (d *cborDecDriver) readNextBd() { d.bd = d.r.readn1() d.bdRead = true - d.bdType = valueTypeUnset } -func (d *cborDecDriver) IsContainerType(vt valueType) (bv bool) { - switch vt { - case valueTypeNil: - return d.bd == cborBdNil - case valueTypeBytes: - return d.bd == cborBdIndefiniteBytes || (d.bd >= cborBaseBytes && d.bd < cborBaseString) - case valueTypeString: - return d.bd == cborBdIndefiniteString || (d.bd >= cborBaseString && d.bd < cborBaseArray) - case valueTypeArray: - return d.bd == cborBdIndefiniteArray || (d.bd >= cborBaseArray && d.bd < cborBaseMap) - case valueTypeMap: - return d.bd == cborBdIndefiniteMap || (d.bd >= cborBaseMap && d.bd < cborBaseTag) +func (d *cborDecDriver) ContainerType() (vt valueType) { + if d.bd == cborBdNil { + return valueTypeNil + } else if d.bd == cborBdIndefiniteBytes || (d.bd >= cborBaseBytes && d.bd < cborBaseString) { + return valueTypeBytes + } else if d.bd == cborBdIndefiniteString || (d.bd >= cborBaseString && d.bd < cborBaseArray) { + return valueTypeString + } else if d.bd == cborBdIndefiniteArray || (d.bd >= cborBaseArray && d.bd < cborBaseMap) { + return valueTypeArray + } else if d.bd == cborBdIndefiniteMap || (d.bd >= cborBaseMap && d.bd < cborBaseTag) { + return valueTypeMap + } else { + // d.d.errorf("isContainerType: unsupported parameter: %v", vt) } - d.d.errorf("isContainerType: unsupported parameter: %v", vt) - return // "unreachable" + return valueTypeUnset } func (d *cborDecDriver) TryDecodeAsNil() bool { @@ -439,71 +444,72 @@ func (d *cborDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxta return } -func (d *cborDecDriver) DecodeNaked() (v interface{}, vt valueType, decodeFurther bool) { +func (d *cborDecDriver) DecodeNaked() { if !d.bdRead { d.readNextBd() } + n := &d.d.n + var decodeFurther bool + switch d.bd { case cborBdNil: - vt = valueTypeNil + n.v = valueTypeNil case cborBdFalse: - vt = valueTypeBool - v = false + n.v = valueTypeBool + n.b = false case cborBdTrue: - vt = valueTypeBool - v = true + n.v = valueTypeBool + n.b = true case cborBdFloat16, cborBdFloat32: - vt = valueTypeFloat - v = d.DecodeFloat(true) + n.v = valueTypeFloat + n.f = d.DecodeFloat(true) case cborBdFloat64: - vt = valueTypeFloat - v = d.DecodeFloat(false) + n.v = valueTypeFloat + n.f = d.DecodeFloat(false) case cborBdIndefiniteBytes: - vt = valueTypeBytes - v = d.DecodeBytes(nil, false, false) + n.v = valueTypeBytes + n.l = d.DecodeBytes(nil, false, false) case cborBdIndefiniteString: - vt = valueTypeString - v = d.DecodeString() + n.v = valueTypeString + n.s = d.DecodeString() case cborBdIndefiniteArray: - vt = valueTypeArray + n.v = valueTypeArray decodeFurther = true case cborBdIndefiniteMap: - vt = valueTypeMap + n.v = valueTypeMap decodeFurther = true default: switch { case d.bd >= cborBaseUint && d.bd < cborBaseNegInt: if d.h.SignedInteger { - vt = valueTypeInt - v = d.DecodeInt(64) + n.v = valueTypeInt + n.i = d.DecodeInt(64) } else { - vt = valueTypeUint - v = d.DecodeUint(64) + n.v = valueTypeUint + n.u = d.DecodeUint(64) } case d.bd >= cborBaseNegInt && d.bd < cborBaseBytes: - vt = valueTypeInt - v = d.DecodeInt(64) + n.v = valueTypeInt + n.i = d.DecodeInt(64) case d.bd >= cborBaseBytes && d.bd < cborBaseString: - vt = valueTypeBytes - v = d.DecodeBytes(nil, false, false) + n.v = valueTypeBytes + n.l = d.DecodeBytes(nil, false, false) case d.bd >= cborBaseString && d.bd < cborBaseArray: - vt = valueTypeString - v = d.DecodeString() + n.v = valueTypeString + n.s = d.DecodeString() case d.bd >= cborBaseArray && d.bd < cborBaseMap: - vt = valueTypeArray + n.v = valueTypeArray decodeFurther = true case d.bd >= cborBaseMap && d.bd < cborBaseTag: - vt = valueTypeMap + n.v = valueTypeMap decodeFurther = true case d.bd >= cborBaseTag && d.bd < cborBaseSimple: - vt = valueTypeExt - var re RawExt - ui := d.decUint() - d.bdRead = false - re.Tag = ui - d.d.decode(&re.Value) - v = &re + n.v = valueTypeExt + n.u = d.decUint() + n.l = nil + // 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) @@ -550,8 +556,12 @@ func (d *cborDecDriver) DecodeNaked() (v interface{}, vt valueType, decodeFurthe // // Now, vv contains the same string "one-byte" // type CborHandle struct { - BasicHandle binaryEncodingType + BasicHandle +} + +func (h *CborHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) { + return h.SetExt(rt, tag, &setExtWrapper{i: ext}) } func (h *CborHandle) newEncDriver(e *Encoder) encDriver { @@ -562,5 +572,14 @@ func (h *CborHandle) newDecDriver(d *Decoder) decDriver { return &cborDecDriver{d: d, r: d.r, h: h, br: d.bytes} } +func (e *cborEncDriver) reset() { + e.w = e.e.w +} + +func (d *cborDecDriver) reset() { + d.r = d.d.r + d.bd, d.bdRead = 0, false +} + var _ decDriver = (*cborDecDriver)(nil) var _ encDriver = (*cborEncDriver)(nil) diff --git a/_vendor/vendor/github.com/ugorji/go/codec/decode.go b/_vendor/vendor/github.com/ugorji/go/codec/decode.go new file mode 100644 index 0000000..b87ea63 --- /dev/null +++ b/_vendor/vendor/github.com/ugorji/go/codec/decode.go @@ -0,0 +1,2019 @@ +// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Use of this source code is governed by a MIT license found in the LICENSE file. + +package codec + +import ( + "encoding" + "errors" + "fmt" + "io" + "reflect" + "time" +) + +// Some tagging information for error messages. +const ( + msgBadDesc = "Unrecognized descriptor byte" + msgDecCannotExpandArr = "cannot expand go array from %v to stream length: %v" +) + +var ( + onlyMapOrArrayCanDecodeIntoStructErr = errors.New("only encoded map or array can be decoded into a struct") + cannotDecodeIntoNilErr = errors.New("cannot decode into nil") +) + +// 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 int) []byte + readb([]byte) + readn1() uint8 + readn1eof() (v uint8, eof bool) + numread() int // number of bytes read + track() + stopTrack() []byte +} + +type decReaderByteScanner interface { + io.Reader + io.ByteScanner +} + +type decDriver interface { + // this will check if the next token is a break. + CheckBreak() bool + TryDecodeAsNil() bool + // vt is one of: Bytes, String, Nil, Slice or Map. Return unSet if not known. + ContainerType() (vt valueType) + IsBuiltinType(rt uintptr) bool + DecodeBuiltin(rt uintptr, v interface{}) + + // DecodeNaked will decode primitives (number, bool, string, []byte) and RawExt. + // For maps and arrays, it will not do the decoding in-band, but will signal + // the decoder, so that is done later, by setting the decNaked.valueType field. + // + // Note: Numbers are decoded as int64, uint64, float64 only (no smaller sized number types). + // for extensions, DecodeNaked must read the tag and the []byte if it exists. + // if the []byte is not read, then kInterfaceNaked will treat it as a Handle + // that stores the subsequent value in-band, and complete reading the RawExt. + // + // extensions should also use readx to decode them, for efficiency. + // kInterface will extract the detached byte slice if it has to pass it outside its realm. + DecodeNaked() + DecodeInt(bitsize uint8) (i int64) + DecodeUint(bitsize uint8) (ui uint64) + DecodeFloat(chkOverflow32 bool) (f float64) + DecodeBool() (b bool) + // 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) + + // DecodeBytes may be called directly, without going through reflection. + // Consequently, it must be designed to handle possible nil. + 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) (realxtag uint64) + // decodeExt(verifyTag bool, tag byte) (xtag byte, xbs []byte) + ReadMapStart() int + ReadArrayStart() int + + reset() + uncacheRead() +} + +type decNoSeparator struct{} + +func (_ decNoSeparator) ReadEnd() {} +func (_ decNoSeparator) uncacheRead() {} + +type DecodeOptions struct { + // MapType specifies type to use during schema-less decoding of a map in the stream. + // If nil, we use map[interface{}]interface{} + MapType reflect.Type + + // SliceType specifies type to use during schema-less decoding of an array in the stream. + // If nil, we use []interface{} + SliceType reflect.Type + + // MaxInitLen defines the initial length that we "make" a collection (slice, chan or map) with. + // If 0 or negative, we default to a sensible value based on the size of an element in the collection. + // + // For example, when decoding, a stream may say that it has MAX_UINT elements. + // We should not auto-matically provision a slice of that length, to prevent Out-Of-Memory crash. + // Instead, we provision up to MaxInitLen, fill that up, and start appending after that. + MaxInitLen int + + // If ErrorIfNoField, return an error when decoding a map + // from a codec stream into a struct, and no matching struct field is found. + ErrorIfNoField bool + + // If ErrorIfNoArrayExpand, return an error when decoding a slice/array that cannot be expanded. + // For example, the stream contains an array of 8 items, but you are decoding into a [4]T array, + // or you are decoding into a slice of length 4 which is non-addressable (and so cannot be set). + ErrorIfNoArrayExpand bool + + // If SignedInteger, use the int64 during schema-less decoding of unsigned values (not uint64). + SignedInteger bool + + // MapValueReset controls how we decode into a map value. + // + // By default, we MAY retrieve the mapping for a key, and then decode into that. + // However, especially with big maps, that retrieval may be expensive and unnecessary + // if the stream already contains all that is necessary to recreate the value. + // + // If true, we will never retrieve the previous mapping, + // but rather decode into a new value and set that in the map. + // + // If false, we will retrieve the previous mapping if necessary e.g. + // the previous mapping is a pointer, or is a struct or array with pre-set state, + // or is an interface. + MapValueReset bool + + // InterfaceReset controls how we decode into an interface. + // + // By default, when we see a field that is an interface{...}, + // or a map with interface{...} value, we will attempt decoding into the + // "contained" value. + // + // However, this prevents us from reading a string into an interface{} + // that formerly contained a number. + // + // If true, we will decode into a new "blank" value, and set that in the interface. + // If false, we will decode into whatever is contained in the interface. + InterfaceReset bool + + // InternString controls interning of strings during decoding. + // + // Some handles, e.g. json, typically will read map keys as strings. + // If the set of keys are finite, it may help reduce allocation to + // look them up from a map (than to allocate them afresh). + // + // Note: Handles will be smart when using the intern functionality. + // So everything will not be interned. + InternString bool +} + +// ------------------------------------ + +// ioDecByteScanner implements Read(), ReadByte(...), UnreadByte(...) methods +// of io.Reader, io.ByteScanner. +type ioDecByteScanner struct { + r io.Reader + l byte // last byte + ls byte // last byte status. 0: init-canDoNothing, 1: canRead, 2: canUnread + b [1]byte // tiny buffer for reading single bytes +} + +func (z *ioDecByteScanner) Read(p []byte) (n int, err error) { + var firstByte bool + if z.ls == 1 { + z.ls = 2 + 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 = 2 + } + if firstByte { + n++ + } + return +} + +func (z *ioDecByteScanner) ReadByte() (c byte, err error) { + n, err := z.Read(z.b[:]) + 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 *ioDecByteScanner) UnreadByte() (err error) { + x := z.ls + if x == 0 { + err = errors.New("cannot unread - nothing has been read") + } else if x == 1 { + err = errors.New("cannot unread - last byte has not been read") + } else if x == 2 { + z.ls = 1 + } + return +} + +// ioDecReader is a decReader that reads off an io.Reader +type ioDecReader struct { + br decReaderByteScanner + // temp byte array re-used internally for efficiency during read. + // shares buffer with Decoder, so we keep size of struct within 8 words. + x *[scratchByteArrayLen]byte + bs ioDecByteScanner + n int // num read + tr []byte // tracking bytes read + trb bool +} + +func (z *ioDecReader) numread() int { + return z.n +} + +func (z *ioDecReader) readx(n int) (bs []byte) { + if n <= 0 { + return + } + if n < len(z.x) { + bs = z.x[:n] + } else { + bs = make([]byte, n) + } + if _, err := io.ReadAtLeast(z.br, bs, n); err != nil { + panic(err) + } + z.n += len(bs) + if z.trb { + z.tr = append(z.tr, bs...) + } + return +} + +func (z *ioDecReader) readb(bs []byte) { + if len(bs) == 0 { + return + } + n, err := io.ReadAtLeast(z.br, bs, len(bs)) + z.n += n + if err != nil { + panic(err) + } + if z.trb { + z.tr = append(z.tr, bs...) + } +} + +func (z *ioDecReader) readn1() (b uint8) { + b, err := z.br.ReadByte() + if err != nil { + panic(err) + } + z.n++ + if z.trb { + z.tr = append(z.tr, b) + } + return b +} + +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) 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] + } + } +} + +func (z *ioDecReader) track() { + if z.tr != nil { + z.tr = z.tr[:0] + } + z.trb = true +} + +func (z *ioDecReader) stopTrack() (bs []byte) { + z.trb = false + return z.tr +} + +// ------------------------------------ + +var bytesDecReaderCannotUnreadErr = 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 int // cursor + a int // available + t int // track start +} + +func (z *bytesDecReader) reset(in []byte) { + z.b = in + z.a = len(in) + z.c = 0 + z.t = 0 +} + +func (z *bytesDecReader) numread() int { + return z.c +} + +func (z *bytesDecReader) unreadn1() { + if z.c == 0 || len(z.b) == 0 { + panic(bytesDecReaderCannotUnreadErr) + } + z.c-- + z.a++ + return +} + +func (z *bytesDecReader) readx(n int) (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 +} + +func (z *bytesDecReader) readn1() (v uint8) { + if z.a == 0 { + panic(io.EOF) + } + v = z.b[z.c] + z.c++ + z.a-- + return +} + +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) readb(bs []byte) { + copy(bs, z.readx(len(bs))) +} + +func (z *bytesDecReader) track() { + z.t = z.c +} + +func (z *bytesDecReader) stopTrack() (bs []byte) { + return z.b[z.t:z.c] +} + +// ------------------------------------ + +type decFnInfo struct { + d *Decoder + ti *typeInfo + xfFn Ext + xfTag uint64 + seq seqType +} + +// ---------------------------------------- + +type decFn struct { + i decFnInfo + f func(*decFnInfo, reflect.Value) +} + +func (f *decFnInfo) builtin(rv reflect.Value) { + f.d.d.DecodeBuiltin(f.ti.rtid, rv.Addr().Interface()) +} + +func (f *decFnInfo) rawExt(rv reflect.Value) { + f.d.d.DecodeExt(rv.Addr().Interface(), 0, nil) +} + +func (f *decFnInfo) ext(rv reflect.Value) { + f.d.d.DecodeExt(rv.Addr().Interface(), f.xfTag, f.xfFn) +} + +func (f *decFnInfo) getValueForUnmarshalInterface(rv reflect.Value, indir int8) (v interface{}) { + if indir == -1 { + v = rv.Addr().Interface() + } else if indir == 0 { + v = rv.Interface() + } else { + for j := int8(0); j < indir; j++ { + if rv.IsNil() { + rv.Set(reflect.New(rv.Type().Elem())) + } + rv = rv.Elem() + } + v = rv.Interface() + } + return +} + +func (f *decFnInfo) selferUnmarshal(rv reflect.Value) { + f.getValueForUnmarshalInterface(rv, f.ti.csIndir).(Selfer).CodecDecodeSelf(f.d) +} + +func (f *decFnInfo) binaryUnmarshal(rv reflect.Value) { + bm := f.getValueForUnmarshalInterface(rv, f.ti.bunmIndir).(encoding.BinaryUnmarshaler) + xbs := f.d.d.DecodeBytes(nil, false, true) + if fnerr := bm.UnmarshalBinary(xbs); fnerr != nil { + panic(fnerr) + } +} + +func (f *decFnInfo) textUnmarshal(rv reflect.Value) { + tm := f.getValueForUnmarshalInterface(rv, f.ti.tunmIndir).(encoding.TextUnmarshaler) + fnerr := tm.UnmarshalText(f.d.d.DecodeBytes(f.d.b[:], true, true)) + if fnerr != nil { + panic(fnerr) + } +} + +func (f *decFnInfo) jsonUnmarshal(rv reflect.Value) { + tm := f.getValueForUnmarshalInterface(rv, f.ti.junmIndir).(jsonUnmarshaler) + // bs := f.d.d.DecodeBytes(f.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(f.d.nextValueBytes()) + if fnerr != nil { + panic(fnerr) + } +} + +func (f *decFnInfo) kErr(rv reflect.Value) { + f.d.errorf("no decoding function defined for kind %v", rv.Kind()) +} + +func (f *decFnInfo) kString(rv reflect.Value) { + rv.SetString(f.d.d.DecodeString()) +} + +func (f *decFnInfo) kBool(rv reflect.Value) { + rv.SetBool(f.d.d.DecodeBool()) +} + +func (f *decFnInfo) kInt(rv reflect.Value) { + rv.SetInt(f.d.d.DecodeInt(intBitsize)) +} + +func (f *decFnInfo) kInt64(rv reflect.Value) { + rv.SetInt(f.d.d.DecodeInt(64)) +} + +func (f *decFnInfo) kInt32(rv reflect.Value) { + rv.SetInt(f.d.d.DecodeInt(32)) +} + +func (f *decFnInfo) kInt8(rv reflect.Value) { + rv.SetInt(f.d.d.DecodeInt(8)) +} + +func (f *decFnInfo) kInt16(rv reflect.Value) { + rv.SetInt(f.d.d.DecodeInt(16)) +} + +func (f *decFnInfo) kFloat32(rv reflect.Value) { + rv.SetFloat(f.d.d.DecodeFloat(true)) +} + +func (f *decFnInfo) kFloat64(rv reflect.Value) { + rv.SetFloat(f.d.d.DecodeFloat(false)) +} + +func (f *decFnInfo) kUint8(rv reflect.Value) { + rv.SetUint(f.d.d.DecodeUint(8)) +} + +func (f *decFnInfo) kUint64(rv reflect.Value) { + rv.SetUint(f.d.d.DecodeUint(64)) +} + +func (f *decFnInfo) kUint(rv reflect.Value) { + rv.SetUint(f.d.d.DecodeUint(uintBitsize)) +} + +func (f *decFnInfo) kUintptr(rv reflect.Value) { + rv.SetUint(f.d.d.DecodeUint(uintBitsize)) +} + +func (f *decFnInfo) kUint32(rv reflect.Value) { + rv.SetUint(f.d.d.DecodeUint(32)) +} + +func (f *decFnInfo) kUint16(rv reflect.Value) { + rv.SetUint(f.d.d.DecodeUint(16)) +} + +// func (f *decFnInfo) kPtr(rv reflect.Value) { +// debugf(">>>>>>> ??? decode kPtr called - shouldn't get called") +// if rv.IsNil() { +// rv.Set(reflect.New(rv.Type().Elem())) +// } +// f.d.decodeValue(rv.Elem()) +// } + +// var kIntfCtr uint64 + +func (f *decFnInfo) kInterfaceNaked() (rvn reflect.Value) { + // nil interface: + // use some hieristics to decode it appropriately + // based on the detected next value in the stream. + d := f.d + d.d.DecodeNaked() + n := &d.n + if n.v == valueTypeNil { + return + } + // We cannot decode non-nil stream value into nil interface with methods (e.g. io.Reader). + // if num := f.ti.rt.NumMethod(); num > 0 { + if f.ti.numMeth > 0 { + d.errorf("cannot decode non-nil codec value into nil %v (%v methods)", f.ti.rt, f.ti.numMeth) + return + } + // var useRvn bool + switch n.v { + case valueTypeMap: + // if d.h.MapType == nil || d.h.MapType == mapIntfIntfTyp { + // } else if d.h.MapType == mapStrIntfTyp { // for json performance + // } + if d.mtid == 0 || d.mtid == mapIntfIntfTypId { + l := len(n.ms) + n.ms = append(n.ms, nil) + var v2 interface{} = &n.ms[l] + d.decode(v2) + rvn = reflect.ValueOf(v2).Elem() + n.ms = n.ms[:l] + } else if d.mtid == mapStrIntfTypId { // for json performance + l := len(n.ns) + n.ns = append(n.ns, nil) + var v2 interface{} = &n.ns[l] + d.decode(v2) + rvn = reflect.ValueOf(v2).Elem() + n.ns = n.ns[:l] + } else { + rvn = reflect.New(d.h.MapType).Elem() + d.decodeValue(rvn, nil) + } + case valueTypeArray: + // if d.h.SliceType == nil || d.h.SliceType == intfSliceTyp { + if d.stid == 0 || d.stid == intfSliceTypId { + l := len(n.ss) + n.ss = append(n.ss, nil) + var v2 interface{} = &n.ss[l] + d.decode(v2) + rvn = reflect.ValueOf(v2).Elem() + n.ss = n.ss[:l] + } else { + rvn = reflect.New(d.h.SliceType).Elem() + d.decodeValue(rvn, nil) + } + case valueTypeExt: + var v interface{} + tag, bytes := n.u, n.l // calling decode below might taint the values + if bytes == nil { + l := len(n.is) + n.is = append(n.is, nil) + v2 := &n.is[l] + d.decode(v2) + v = *v2 + n.is = n.is[:l] + } + bfn := d.h.getExtForTag(tag) + if bfn == nil { + var re RawExt + re.Tag = tag + re.Data = detachZeroCopyBytes(d.bytes, nil, bytes) + rvn = reflect.ValueOf(re) + } else { + rvnA := reflect.New(bfn.rt) + rvn = rvnA.Elem() + if bytes != nil { + bfn.ext.ReadExt(rvnA.Interface(), bytes) + } else { + bfn.ext.UpdateExt(rvnA.Interface(), v) + } + } + case valueTypeNil: + // no-op + case valueTypeInt: + rvn = reflect.ValueOf(&n.i).Elem() + case valueTypeUint: + rvn = reflect.ValueOf(&n.u).Elem() + case valueTypeFloat: + rvn = reflect.ValueOf(&n.f).Elem() + case valueTypeBool: + rvn = reflect.ValueOf(&n.b).Elem() + case valueTypeString, valueTypeSymbol: + rvn = reflect.ValueOf(&n.s).Elem() + case valueTypeBytes: + rvn = reflect.ValueOf(&n.l).Elem() + case valueTypeTimestamp: + rvn = reflect.ValueOf(&n.t).Elem() + default: + panic(fmt.Errorf("kInterfaceNaked: unexpected valueType: %d", n.v)) + } + return +} + +func (f *decFnInfo) kInterface(rv reflect.Value) { + // debugf("\t===> kInterface") + + // Note: + // A consequence of how kInterface works, is that + // if an interface already contains something, we try + // to decode into what was there before. + // We do not replace with a generic value (as got from decodeNaked). + + var rvn reflect.Value + if rv.IsNil() { + rvn = f.kInterfaceNaked() + if rvn.IsValid() { + rv.Set(rvn) + } + } else if f.d.h.InterfaceReset { + rvn = f.kInterfaceNaked() + if rvn.IsValid() { + rv.Set(rvn) + } else { + // reset to zero value based on current type in there. + rv.Set(reflect.Zero(rv.Elem().Type())) + } + } else { + rvn = rv.Elem() + // Note: interface{} is settable, but underlying type may not be. + // Consequently, we have to set the reflect.Value directly. + // if underlying type is settable (e.g. ptr or interface), + // we just decode into it. + // Else we create a settable value, decode into it, and set on the interface. + if rvn.CanSet() { + f.d.decodeValue(rvn, nil) + } else { + rvn2 := reflect.New(rvn.Type()).Elem() + rvn2.Set(rvn) + f.d.decodeValue(rvn2, nil) + rv.Set(rvn2) + } + } +} + +func (f *decFnInfo) kStruct(rv reflect.Value) { + fti := f.ti + d := f.d + dd := d.d + cr := d.cr + ctyp := dd.ContainerType() + if ctyp == valueTypeMap { + containerLen := dd.ReadMapStart() + if containerLen == 0 { + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return + } + tisfi := fti.sfi + hasLen := containerLen >= 0 + if hasLen { + for j := 0; j < containerLen; j++ { + // rvkencname := dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + rvkencname := stringView(dd.DecodeBytes(f.d.b[:], true, true)) + // rvksi := ti.getForEncName(rvkencname) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if k := fti.indexForEncName(rvkencname); k > -1 { + si := tisfi[k] + if dd.TryDecodeAsNil() { + si.setToZeroValue(rv) + } else { + d.decodeValue(si.field(rv, true), nil) + } + } else { + d.structFieldNotFound(-1, rvkencname) + } + } + } else { + for j := 0; !dd.CheckBreak(); j++ { + // rvkencname := dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + rvkencname := stringView(dd.DecodeBytes(f.d.b[:], true, true)) + // rvksi := ti.getForEncName(rvkencname) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if k := fti.indexForEncName(rvkencname); k > -1 { + si := tisfi[k] + if dd.TryDecodeAsNil() { + si.setToZeroValue(rv) + } else { + d.decodeValue(si.field(rv, true), nil) + } + } else { + d.structFieldNotFound(-1, rvkencname) + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + } else if ctyp == valueTypeArray { + containerLen := dd.ReadArrayStart() + if containerLen == 0 { + if cr != nil { + cr.sendContainerState(containerArrayEnd) + } + return + } + // Not much gain from doing it two ways for array. + // Arrays are not used as much for structs. + hasLen := containerLen >= 0 + for j, si := range fti.sfip { + if hasLen { + if j == containerLen { + break + } + } else if dd.CheckBreak() { + break + } + if cr != nil { + cr.sendContainerState(containerArrayElem) + } + if dd.TryDecodeAsNil() { + si.setToZeroValue(rv) + } else { + d.decodeValue(si.field(rv, true), nil) + } + } + if containerLen > len(fti.sfip) { + // read remaining values and throw away + for j := len(fti.sfip); j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerArrayElem) + } + d.structFieldNotFound(j, "") + } + } + if cr != nil { + cr.sendContainerState(containerArrayEnd) + } + } else { + f.d.error(onlyMapOrArrayCanDecodeIntoStructErr) + return + } +} + +func (f *decFnInfo) kSlice(rv reflect.Value) { + // A slice can be set from a map or array in stream. + // This way, the order can be kept (as order is lost with map). + ti := f.ti + d := f.d + dd := d.d + rtelem0 := ti.rt.Elem() + ctyp := dd.ContainerType() + if ctyp == valueTypeBytes || ctyp == valueTypeString { + // you can only decode bytes or string in the stream into a slice or array of bytes + if !(ti.rtid == uint8SliceTypId || rtelem0.Kind() == reflect.Uint8) { + f.d.errorf("bytes or string in the stream must be decoded into a slice or array of bytes, not %v", ti.rt) + } + if f.seq == seqTypeChan { + bs2 := dd.DecodeBytes(nil, false, true) + ch := rv.Interface().(chan<- byte) + for _, b := range bs2 { + ch <- b + } + } else { + rvbs := rv.Bytes() + bs2 := dd.DecodeBytes(rvbs, false, false) + if rvbs == nil && bs2 != nil || rvbs != nil && bs2 == nil || len(bs2) != len(rvbs) { + if rv.CanSet() { + rv.SetBytes(bs2) + } else { + copy(rvbs, bs2) + } + } + } + return + } + + // 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 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 + } + + rtelem := rtelem0 + for rtelem.Kind() == reflect.Ptr { + rtelem = rtelem.Elem() + } + fn := d.getDecFn(rtelem, true, true) + + var rv0, rv9 reflect.Value + rv0 = rv + rvChanged := false + + // for j := 0; j < containerLenS; j++ { + var rvlen int + if containerLenS > 0 { // hasLen + if f.seq == seqTypeChan { + if rv.IsNil() { + rvlen, _ = decInferLen(containerLenS, f.d.h.MaxInitLen, int(rtelem0.Size())) + rv.Set(reflect.MakeChan(ti.rt, rvlen)) + } + // handle chan specially: + for j := 0; j < containerLenS; j++ { + rv9 = reflect.New(rtelem0).Elem() + slh.ElemContainerState(j) + d.decodeValue(rv9, fn) + rv.Send(rv9) + } + } else { // slice or array + var truncated bool // says len of sequence is not same as expected number of elements + numToRead := containerLenS // if truncated, reset numToRead + + rvcap := rv.Cap() + rvlen = rv.Len() + if containerLenS > rvcap { + if f.seq == seqTypeArray { + d.arrayCannotExpand(rvlen, containerLenS) + } else { + oldRvlenGtZero := rvlen > 0 + rvlen, truncated = decInferLen(containerLenS, f.d.h.MaxInitLen, int(rtelem0.Size())) + if truncated { + if rvlen <= rvcap { + rv.SetLen(rvlen) + } else { + rv = reflect.MakeSlice(ti.rt, rvlen, rvlen) + rvChanged = true + } + } else { + rv = reflect.MakeSlice(ti.rt, rvlen, rvlen) + rvChanged = true + } + if rvChanged && oldRvlenGtZero && !isImmutableKind(rtelem0.Kind()) { + reflect.Copy(rv, rv0) // only copy up to length NOT cap i.e. rv0.Slice(0, rvcap) + } + rvcap = rvlen + } + numToRead = rvlen + } else if containerLenS != rvlen { + if f.seq == seqTypeSlice { + rv.SetLen(containerLenS) + rvlen = containerLenS + } + } + j := 0 + // we read up to the numToRead + for ; j < numToRead; j++ { + slh.ElemContainerState(j) + d.decodeValue(rv.Index(j), fn) + } + + // if slice, expand and read up to containerLenS (or EOF) iff truncated + // if array, swallow all the rest. + + if f.seq == seqTypeArray { + for ; j < containerLenS; j++ { + slh.ElemContainerState(j) + d.swallow() + } + } else if truncated { // slice was truncated, as chan NOT in this block + for ; j < containerLenS; j++ { + rv = expandSliceValue(rv, 1) + rv9 = rv.Index(j) + if resetSliceElemToZeroValue { + rv9.Set(reflect.Zero(rtelem0)) + } + slh.ElemContainerState(j) + d.decodeValue(rv9, fn) + } + } + } + } else { + rvlen = rv.Len() + j := 0 + for ; !dd.CheckBreak(); j++ { + if f.seq == seqTypeChan { + slh.ElemContainerState(j) + rv9 = reflect.New(rtelem0).Elem() + d.decodeValue(rv9, fn) + 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)) // uses append logic, plus varargs + rv = expandSliceValue(rv, 1) + rv9 = rv.Index(j) + // rv.Index(rv.Len() - 1).Set(reflect.Zero(rtelem0)) + if resetSliceElemToZeroValue { + rv9.Set(reflect.Zero(rtelem0)) + } + rvlen++ + rvChanged = true + } + } else { // slice or array + rv9 = rv.Index(j) + } + slh.ElemContainerState(j) + if decodeIntoBlank { + d.swallow() + } else { // seqTypeSlice + d.decodeValue(rv9, fn) + } + } + } + if f.seq == seqTypeSlice { + if j < rvlen { + rv.SetLen(j) + } else if j == 0 && rv.IsNil() { + rv = reflect.MakeSlice(ti.rt, 0, 0) + rvChanged = true + } + } + } + slh.End() + + if rvChanged { + rv0.Set(rv) + } +} + +func (f *decFnInfo) kArray(rv reflect.Value) { + // f.d.decodeValue(rv.Slice(0, rv.Len())) + f.kSlice(rv.Slice(0, rv.Len())) +} + +func (f *decFnInfo) kMap(rv reflect.Value) { + d := f.d + dd := d.d + containerLen := dd.ReadMapStart() + cr := d.cr + ti := f.ti + if rv.IsNil() { + rv.Set(reflect.MakeMap(ti.rt)) + } + + if containerLen == 0 { + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return + } + + ktype, vtype := ti.rt.Key(), ti.rt.Elem() + ktypeId := reflect.ValueOf(ktype).Pointer() + vtypeKind := vtype.Kind() + var keyFn, valFn *decFn + var xtyp reflect.Type + for xtyp = ktype; xtyp.Kind() == reflect.Ptr; xtyp = xtyp.Elem() { + } + keyFn = d.getDecFn(xtyp, true, true) + for xtyp = vtype; xtyp.Kind() == reflect.Ptr; xtyp = xtyp.Elem() { + } + valFn = d.getDecFn(xtyp, true, true) + var mapGet, mapSet bool + if !f.d.h.MapValueReset { + // 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 !f.d.h.InterfaceReset { + mapGet = true + } + } else if !isImmutableKind(vtypeKind) { + mapGet = true + } + } + + var rvk, rvv, rvz reflect.Value + + // for j := 0; j < containerLen; j++ { + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + rvk = reflect.New(ktype).Elem() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + d.decodeValue(rvk, keyFn) + + // special case if a byte array. + if ktypeId == intfTypId { + rvk = rvk.Elem() + if rvk.Type() == uint8SliceTyp { + rvk = reflect.ValueOf(d.string(rvk.Bytes())) + } + } + mapSet = true // set to false if u do a get, and its a pointer, and exists + if mapGet { + rvv = rv.MapIndex(rvk) + if rvv.IsValid() { + if vtypeKind == reflect.Ptr { + mapSet = false + } + } else { + if rvz.IsValid() { + rvz.Set(reflect.Zero(vtype)) + } else { + rvz = reflect.New(vtype).Elem() + } + rvv = rvz + } + } else { + if rvz.IsValid() { + rvz.Set(reflect.Zero(vtype)) + } else { + rvz = reflect.New(vtype).Elem() + } + rvv = rvz + } + if cr != nil { + cr.sendContainerState(containerMapValue) + } + d.decodeValue(rvv, valFn) + if mapSet { + rv.SetMapIndex(rvk, rvv) + } + } + } else { + for j := 0; !dd.CheckBreak(); j++ { + rvk = reflect.New(ktype).Elem() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + d.decodeValue(rvk, keyFn) + + // special case if a byte array. + if ktypeId == intfTypId { + rvk = rvk.Elem() + if rvk.Type() == uint8SliceTyp { + rvk = reflect.ValueOf(d.string(rvk.Bytes())) + } + } + mapSet = true // set to false if u do a get, and its a pointer, and exists + if mapGet { + rvv = rv.MapIndex(rvk) + if rvv.IsValid() { + if vtypeKind == reflect.Ptr { + mapSet = false + } + } else { + if rvz.IsValid() { + rvz.Set(reflect.Zero(vtype)) + } else { + rvz = reflect.New(vtype).Elem() + } + rvv = rvz + } + } else { + if rvz.IsValid() { + rvz.Set(reflect.Zero(vtype)) + } else { + rvz = reflect.New(vtype).Elem() + } + rvv = rvz + } + if cr != nil { + cr.sendContainerState(containerMapValue) + } + d.decodeValue(rvv, valFn) + if mapSet { + rv.SetMapIndex(rvk, rvv) + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +type decRtidFn struct { + rtid uintptr + fn decFn +} + +// decNaked is used to keep track of the primitives decoded. +// Without it, we would have to decode each primitive and wrap it +// in an interface{}, causing an allocation. +// In this model, the primitives are decoded in a "pseudo-atomic" fashion, +// so we can rest assured that no other decoding happens while these +// primitives are being decoded. +// +// maps and arrays are not handled by this mechanism. +// However, RawExt is, and we accomodate for extensions that decode +// RawExt from DecodeNaked, but need to decode the value subsequently. +// kInterfaceNaked and swallow, which call DecodeNaked, handle this caveat. +// +// However, decNaked also keeps some arrays of default maps and slices +// used in DecodeNaked. This way, we can get a pointer to it +// without causing a new heap allocation. +// +// kInterfaceNaked will ensure that there is no allocation for the common +// uses. +type decNaked struct { + // r RawExt // used for RawExt, uint, []byte. + u uint64 + i int64 + f float64 + l []byte + s string + t time.Time + b bool + v valueType + + // stacks for reducing allocation + is []interface{} + ms []map[interface{}]interface{} + ns []map[string]interface{} + ss [][]interface{} + // rs []RawExt + + // keep arrays at the bottom? Chance is that they are not used much. + ia [4]interface{} + ma [4]map[interface{}]interface{} + na [4]map[string]interface{} + sa [4][]interface{} + // ra [2]RawExt +} + +func (n *decNaked) reset() { + if n.ss != nil { + n.ss = n.ss[:0] + } + if n.is != nil { + n.is = n.is[:0] + } + if n.ms != nil { + n.ms = n.ms[:0] + } + if n.ns != nil { + n.ns = n.ns[:0] + } +} + +// A Decoder reads and decodes an object from an input stream in the codec format. +type Decoder struct { + // hopefully, reduce derefencing cost by laying the decReader inside the Decoder. + // Try to put things that go together to fit within a cache line (8 words). + + d decDriver + // NOTE: Decoder shouldn't call it's read methods, + // as the handler MAY need to do some coordination. + r decReader + // sa [initCollectionCap]decRtidFn + h *BasicHandle + hh Handle + + be bool // is binary encoding + bytes bool // is bytes reader + js bool // is json handle + + rb bytesDecReader + ri ioDecReader + cr containerStateRecv + + s []decRtidFn + f map[uintptr]*decFn + + // _ uintptr // for alignment purposes, so next one starts from a cache line + + // cache the mapTypeId and sliceTypeId for faster comparisons + mtid uintptr + stid uintptr + + n decNaked + b [scratchByteArrayLen]byte + is map[string]string // used for interning strings +} + +// NewDecoder returns a Decoder for decoding a stream of bytes from an io.Reader. +// +// For efficiency, Users are encouraged to pass in a memory buffered reader +// (eg bufio.Reader, bytes.Buffer). +func NewDecoder(r io.Reader, h Handle) *Decoder { + d := newDecoder(h) + d.Reset(r) + return d +} + +// NewDecoderBytes returns a Decoder which efficiently decodes directly +// from a byte slice with zero copying. +func NewDecoderBytes(in []byte, h Handle) *Decoder { + d := newDecoder(h) + d.ResetBytes(in) + return d +} + +func newDecoder(h Handle) *Decoder { + d := &Decoder{hh: h, h: h.getBasicHandle(), be: h.isBinary()} + n := &d.n + // n.rs = n.ra[:0] + n.ms = n.ma[:0] + n.is = n.ia[:0] + n.ns = n.na[:0] + n.ss = n.sa[:0] + _, d.js = h.(*JsonHandle) + if d.h.InternString { + d.is = make(map[string]string, 32) + } + d.d = h.newDecDriver(d) + d.cr, _ = d.d.(containerStateRecv) + // d.d = h.newDecDriver(decReaderT{true, &d.rb, &d.ri}) + return d +} + +func (d *Decoder) resetCommon() { + d.n.reset() + d.d.reset() + // reset all things which were cached from the Handle, + // but could be changed. + d.mtid, d.stid = 0, 0 + if d.h.MapType != nil { + d.mtid = reflect.ValueOf(d.h.MapType).Pointer() + } + if d.h.SliceType != nil { + d.stid = reflect.ValueOf(d.h.SliceType).Pointer() + } +} + +func (d *Decoder) Reset(r io.Reader) { + d.ri.x = &d.b + // d.s = d.sa[:0] + d.ri.bs.r = r + var ok bool + d.ri.br, ok = r.(decReaderByteScanner) + if !ok { + d.ri.br = &d.ri.bs + } + d.r = &d.ri + d.resetCommon() +} + +func (d *Decoder) ResetBytes(in []byte) { + // d.s = d.sa[:0] + d.rb.reset(in) + d.r = &d.rb + d.resetCommon() +} + +// func (d *Decoder) sendContainerState(c containerState) { +// if d.cr != nil { +// d.cr.sendContainerState(c) +// } +// } + +// Decode decodes the stream from reader and stores the result in the +// value pointed to by v. v cannot be a nil pointer. v can also be +// a reflect.Value of a pointer. +// +// Note that a pointer to a nil interface is not a nil pointer. +// If you do not know what type of stream it is, pass in a pointer to a nil interface. +// We will decode and store a value in that nil interface. +// +// Sample usages: +// // Decoding into a non-nil typed value +// var f float32 +// err = codec.NewDecoder(r, handle).Decode(&f) +// +// // Decoding into nil interface +// var v interface{} +// dec := codec.NewDecoder(r, handle) +// err = dec.Decode(&v) +// +// When decoding into a nil interface{}, we will decode into an appropriate value based +// on the contents of the stream: +// - Numbers are decoded as float64, int64 or uint64. +// - Other values are decoded appropriately depending on the type: +// bool, string, []byte, time.Time, etc +// - Extensions are decoded as RawExt (if no ext function registered for the tag) +// Configurations exist on the Handle to override defaults +// (e.g. for MapType, SliceType and how to decode raw bytes). +// +// When decoding into a non-nil interface{} value, the mode of encoding is based on the +// type of the value. When a value is seen: +// - If an extension is registered for it, call that extension function +// - If it implements BinaryUnmarshaler, call its UnmarshalBinary(data []byte) error +// - Else decode it based on its reflect.Kind +// +// There are some special rules when decoding into containers (slice/array/map/struct). +// Decode will typically use the stream contents to UPDATE the container. +// - A map can be decoded from a stream map, by updating matching keys. +// - A slice can be decoded from a stream array, +// by updating the first n elements, where n is length of the stream. +// - A slice can be decoded from a stream map, by decoding as if +// it contains a sequence of key-value pairs. +// - A struct can be decoded from a stream map, by updating matching fields. +// - A struct can be decoded from a stream array, +// by updating fields as they occur in the struct (by index). +// +// When decoding a stream map or array with length of 0 into a nil map or slice, +// we reset the destination map or slice to a zero-length value. +// +// However, when decoding a stream nil, we reset the destination container +// to its "zero" value (e.g. nil for slice/map, etc). +// +func (d *Decoder) Decode(v interface{}) (err error) { + defer panicToErr(&err) + d.decode(v) + return +} + +// this is not a smart swallow, as it allocates objects and does unnecessary work. +func (d *Decoder) swallowViaHammer() { + var blank interface{} + d.decodeValue(reflect.ValueOf(&blank).Elem(), nil) +} + +func (d *Decoder) swallow() { + // smarter decode that just swallows the content + dd := d.d + if dd.TryDecodeAsNil() { + return + } + cr := d.cr + switch dd.ContainerType() { + case valueTypeMap: + containerLen := dd.ReadMapStart() + clenGtEqualZero := containerLen >= 0 + for j := 0; ; j++ { + if clenGtEqualZero { + if j >= containerLen { + break + } + } else if dd.CheckBreak() { + break + } + if cr != nil { + cr.sendContainerState(containerMapKey) + } + d.swallow() + if cr != nil { + cr.sendContainerState(containerMapValue) + } + d.swallow() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + case valueTypeArray: + containerLenS := dd.ReadArrayStart() + clenGtEqualZero := containerLenS >= 0 + for j := 0; ; j++ { + if clenGtEqualZero { + if j >= containerLenS { + break + } + } else if dd.CheckBreak() { + break + } + if cr != nil { + cr.sendContainerState(containerArrayElem) + } + d.swallow() + } + if cr != nil { + cr.sendContainerState(containerArrayEnd) + } + case valueTypeBytes: + dd.DecodeBytes(d.b[:], false, true) + case valueTypeString: + dd.DecodeBytes(d.b[:], true, true) + // dd.DecodeStringAsBytes(d.b[:]) + default: + // these are all primitives, which we can get from decodeNaked + // if RawExt using Value, complete the processing. + dd.DecodeNaked() + if n := &d.n; n.v == valueTypeExt && n.l == nil { + l := len(n.is) + n.is = append(n.is, nil) + v2 := &n.is[l] + d.decode(v2) + n.is = n.is[:l] + } + } +} + +// 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{}) { + d.decode(v) +} + +func (d *Decoder) decode(iv interface{}) { + // if ics, ok := iv.(Selfer); ok { + // ics.CodecDecodeSelf(d) + // return + // } + + if d.d.TryDecodeAsNil() { + switch v := iv.(type) { + case nil: + case *string: + *v = "" + case *bool: + *v = false + case *int: + *v = 0 + case *int8: + *v = 0 + case *int16: + *v = 0 + case *int32: + *v = 0 + case *int64: + *v = 0 + case *uint: + *v = 0 + case *uint8: + *v = 0 + case *uint16: + *v = 0 + case *uint32: + *v = 0 + case *uint64: + *v = 0 + case *float32: + *v = 0 + case *float64: + *v = 0 + case *[]uint8: + *v = nil + case reflect.Value: + if v.Kind() != reflect.Ptr || v.IsNil() { + d.errNotValidPtrValue(v) + } + // d.chkPtrValue(v) + v = v.Elem() + if v.IsValid() { + v.Set(reflect.Zero(v.Type())) + } + default: + rv := reflect.ValueOf(iv) + if rv.Kind() != reflect.Ptr || rv.IsNil() { + d.errNotValidPtrValue(rv) + } + // d.chkPtrValue(rv) + rv = rv.Elem() + if rv.IsValid() { + rv.Set(reflect.Zero(rv.Type())) + } + } + return + } + + switch v := iv.(type) { + case nil: + d.error(cannotDecodeIntoNilErr) + return + + case Selfer: + v.CodecDecodeSelf(d) + + case reflect.Value: + if v.Kind() != reflect.Ptr || v.IsNil() { + d.errNotValidPtrValue(v) + } + // d.chkPtrValue(v) + d.decodeValueNotNil(v.Elem(), nil) + + case *string: + *v = d.d.DecodeString() + case *bool: + *v = d.d.DecodeBool() + case *int: + *v = int(d.d.DecodeInt(intBitsize)) + case *int8: + *v = int8(d.d.DecodeInt(8)) + case *int16: + *v = int16(d.d.DecodeInt(16)) + case *int32: + *v = int32(d.d.DecodeInt(32)) + case *int64: + *v = d.d.DecodeInt(64) + case *uint: + *v = uint(d.d.DecodeUint(uintBitsize)) + case *uint8: + *v = uint8(d.d.DecodeUint(8)) + case *uint16: + *v = uint16(d.d.DecodeUint(16)) + case *uint32: + *v = uint32(d.d.DecodeUint(32)) + case *uint64: + *v = d.d.DecodeUint(64) + case *float32: + *v = float32(d.d.DecodeFloat(true)) + case *float64: + *v = d.d.DecodeFloat(false) + case *[]uint8: + *v = d.d.DecodeBytes(*v, false, false) + + case *interface{}: + d.decodeValueNotNil(reflect.ValueOf(iv).Elem(), nil) + + default: + if !fastpathDecodeTypeSwitch(iv, d) { + d.decodeI(iv, true, false, false, false) + } + } +} + +func (d *Decoder) preDecodeValue(rv reflect.Value, tryNil bool) (rv2 reflect.Value, proceed bool) { + if tryNil && d.d.TryDecodeAsNil() { + // No need to check if a ptr, recursively, to determine + // whether to set value to nil. + // Just always set value to its zero type. + if rv.IsValid() { // rv.CanSet() // always settable, except it's invalid + rv.Set(reflect.Zero(rv.Type())) + } + return + } + + // If stream is not containing a nil value, then we can deref to the base + // non-pointer value, and decode into that. + for rv.Kind() == reflect.Ptr { + if rv.IsNil() { + rv.Set(reflect.New(rv.Type().Elem())) + } + rv = rv.Elem() + } + return rv, true +} + +func (d *Decoder) decodeI(iv interface{}, checkPtr, tryNil, checkFastpath, checkCodecSelfer bool) { + rv := reflect.ValueOf(iv) + if checkPtr { + if rv.Kind() != reflect.Ptr || rv.IsNil() { + d.errNotValidPtrValue(rv) + } + // d.chkPtrValue(rv) + } + rv, proceed := d.preDecodeValue(rv, tryNil) + if proceed { + fn := d.getDecFn(rv.Type(), checkFastpath, checkCodecSelfer) + fn.f(&fn.i, rv) + } +} + +func (d *Decoder) decodeValue(rv reflect.Value, fn *decFn) { + if rv, proceed := d.preDecodeValue(rv, true); proceed { + if fn == nil { + fn = d.getDecFn(rv.Type(), true, true) + } + fn.f(&fn.i, rv) + } +} + +func (d *Decoder) decodeValueNotNil(rv reflect.Value, fn *decFn) { + if rv, proceed := d.preDecodeValue(rv, false); proceed { + if fn == nil { + fn = d.getDecFn(rv.Type(), true, true) + } + fn.f(&fn.i, rv) + } +} + +func (d *Decoder) getDecFn(rt reflect.Type, checkFastpath, checkCodecSelfer bool) (fn *decFn) { + rtid := reflect.ValueOf(rt).Pointer() + + // retrieve or register a focus'ed function for this type + // to eliminate need to do the retrieval multiple times + + // if d.f == nil && d.s == nil { debugf("---->Creating new dec f map for type: %v\n", rt) } + var ok bool + if useMapForCodecCache { + fn, ok = d.f[rtid] + } else { + for i := range d.s { + v := &(d.s[i]) + if v.rtid == rtid { + fn, ok = &(v.fn), true + break + } + } + } + if ok { + return + } + + if useMapForCodecCache { + if d.f == nil { + d.f = make(map[uintptr]*decFn, initCollectionCap) + } + fn = new(decFn) + d.f[rtid] = fn + } else { + if d.s == nil { + d.s = make([]decRtidFn, 0, initCollectionCap) + } + d.s = append(d.s, decRtidFn{rtid: rtid}) + fn = &(d.s[len(d.s)-1]).fn + } + + // debugf("\tCreating new dec fn for type: %v\n", rt) + ti := d.h.getTypeInfo(rtid, rt) + fi := &(fn.i) + fi.d = d + fi.ti = ti + + // An extension can be registered for any type, regardless of the Kind + // (e.g. type BitSet int64, type MyStruct { / * unexported fields * / }, type X []int, etc. + // + // We can't check if it's an extension byte here first, because the user may have + // registered a pointer or non-pointer type, meaning we may have to recurse first + // before matching a mapped type, even though the extension byte is already detected. + // + // NOTE: if decoding into a nil interface{}, we return a non-nil + // value except even if the container registers a length of 0. + if checkCodecSelfer && ti.cs { + fn.f = (*decFnInfo).selferUnmarshal + } else if rtid == rawExtTypId { + fn.f = (*decFnInfo).rawExt + } else if d.d.IsBuiltinType(rtid) { + fn.f = (*decFnInfo).builtin + } else if xfFn := d.h.getExt(rtid); xfFn != nil { + fi.xfTag, fi.xfFn = xfFn.tag, xfFn.ext + fn.f = (*decFnInfo).ext + } else if supportMarshalInterfaces && d.be && ti.bunm { + fn.f = (*decFnInfo).binaryUnmarshal + } else if supportMarshalInterfaces && !d.be && d.js && ti.junm { + //If JSON, we should check JSONUnmarshal before textUnmarshal + fn.f = (*decFnInfo).jsonUnmarshal + } else if supportMarshalInterfaces && !d.be && ti.tunm { + fn.f = (*decFnInfo).textUnmarshal + } else { + rk := rt.Kind() + if fastpathEnabled && checkFastpath && (rk == reflect.Map || rk == reflect.Slice) { + if rt.PkgPath() == "" { + if idx := fastpathAV.index(rtid); idx != -1 { + fn.f = fastpathAV[idx].decfn + } + } else { + // use mapping for underlying type if there + ok = false + var rtu reflect.Type + if rk == reflect.Map { + rtu = reflect.MapOf(rt.Key(), rt.Elem()) + } else { + rtu = reflect.SliceOf(rt.Elem()) + } + rtuid := reflect.ValueOf(rtu).Pointer() + if idx := fastpathAV.index(rtuid); idx != -1 { + xfnf := fastpathAV[idx].decfn + xrt := fastpathAV[idx].rt + fn.f = func(xf *decFnInfo, xrv reflect.Value) { + // xfnf(xf, xrv.Convert(xrt)) + xfnf(xf, xrv.Addr().Convert(reflect.PtrTo(xrt)).Elem()) + } + } + } + } + if fn.f == nil { + switch rk { + case reflect.String: + fn.f = (*decFnInfo).kString + case reflect.Bool: + fn.f = (*decFnInfo).kBool + case reflect.Int: + fn.f = (*decFnInfo).kInt + case reflect.Int64: + fn.f = (*decFnInfo).kInt64 + case reflect.Int32: + fn.f = (*decFnInfo).kInt32 + case reflect.Int8: + fn.f = (*decFnInfo).kInt8 + case reflect.Int16: + fn.f = (*decFnInfo).kInt16 + case reflect.Float32: + fn.f = (*decFnInfo).kFloat32 + case reflect.Float64: + fn.f = (*decFnInfo).kFloat64 + case reflect.Uint8: + fn.f = (*decFnInfo).kUint8 + case reflect.Uint64: + fn.f = (*decFnInfo).kUint64 + case reflect.Uint: + fn.f = (*decFnInfo).kUint + case reflect.Uint32: + fn.f = (*decFnInfo).kUint32 + case reflect.Uint16: + fn.f = (*decFnInfo).kUint16 + // case reflect.Ptr: + // fn.f = (*decFnInfo).kPtr + case reflect.Uintptr: + fn.f = (*decFnInfo).kUintptr + case reflect.Interface: + fn.f = (*decFnInfo).kInterface + case reflect.Struct: + fn.f = (*decFnInfo).kStruct + case reflect.Chan: + fi.seq = seqTypeChan + fn.f = (*decFnInfo).kSlice + case reflect.Slice: + fi.seq = seqTypeSlice + fn.f = (*decFnInfo).kSlice + case reflect.Array: + fi.seq = seqTypeArray + fn.f = (*decFnInfo).kArray + case reflect.Map: + fn.f = (*decFnInfo).kMap + default: + fn.f = (*decFnInfo).kErr + } + } + } + + return +} + +func (d *Decoder) structFieldNotFound(index int, rvkencname string) { + // NOTE: rvkencname may be a stringView, so don't pass it to another function. + if d.h.ErrorIfNoField { + if index >= 0 { + d.errorf("no matching struct field found when decoding stream array at index %v", index) + return + } else if rvkencname != "" { + d.errorf("no matching struct field found when decoding stream map with key " + rvkencname) + return + } + } + d.swallow() +} + +func (d *Decoder) arrayCannotExpand(sliceLen, streamLen int) { + if d.h.ErrorIfNoArrayExpand { + d.errorf("cannot expand array len during decode from %v to %v", sliceLen, streamLen) + } +} + +func (d *Decoder) chkPtrValue(rv reflect.Value) { + // We can only decode into a non-nil pointer + if rv.Kind() == reflect.Ptr && !rv.IsNil() { + return + } + d.errNotValidPtrValue(rv) +} + +func (d *Decoder) errNotValidPtrValue(rv reflect.Value) { + if !rv.IsValid() { + d.error(cannotDecodeIntoNilErr) + return + } + if !rv.CanInterface() { + d.errorf("cannot decode into a value without an interface: %v", rv) + return + } + rvi := rv.Interface() + d.errorf("cannot decode into non-pointer or nil pointer. Got: %v, %T, %v", rv.Kind(), rvi, rvi) +} + +func (d *Decoder) error(err error) { + panic(err) +} + +func (d *Decoder) errorf(format string, params ...interface{}) { + params2 := make([]interface{}, len(params)+1) + params2[0] = d.r.numread() + copy(params2[1:], params) + err := fmt.Errorf("[pos %d]: "+format, params2...) + panic(err) +} + +func (d *Decoder) string(v []byte) (s string) { + if d.is != nil { + s, ok := d.is[string(v)] // no allocation here. + if !ok { + s = string(v) + d.is[s] = s + } + return s + } + return string(v) // don't return stringView, as we need a real string here. +} + +func (d *Decoder) intern(s string) { + if d.is != nil { + d.is[s] = s + } +} + +// nextValueBytes returns the next value in the stream as a set of bytes. +func (d *Decoder) nextValueBytes() []byte { + d.d.uncacheRead() + d.r.track() + d.swallow() + return d.r.stopTrack() +} + +// -------------------------------------------------- + +// 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. +type decSliceHelper struct { + d *Decoder + // ct valueType + array bool +} + +func (d *Decoder) decSliceHelperStart() (x decSliceHelper, clen int) { + dd := d.d + ctyp := dd.ContainerType() + if ctyp == valueTypeArray { + x.array = true + clen = dd.ReadArrayStart() + } else if ctyp == valueTypeMap { + clen = dd.ReadMapStart() * 2 + } else { + 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() { + cr := x.d.cr + if cr == nil { + return + } + if x.array { + cr.sendContainerState(containerArrayEnd) + } else { + cr.sendContainerState(containerMapEnd) + } +} + +func (x decSliceHelper) ElemContainerState(index int) { + cr := x.d.cr + if cr == nil { + return + } + if x.array { + cr.sendContainerState(containerArrayElem) + } else { + if index%2 == 0 { + cr.sendContainerState(containerMapKey) + } else { + cr.sendContainerState(containerMapValue) + } + } +} + +func decByteSlice(r decReader, clen int, bs []byte) (bsOut []byte) { + if clen == 0 { + return zeroByteSlice + } + if len(bs) == clen { + bsOut = bs + } else if cap(bs) >= clen { + bsOut = bs[:clen] + } else { + bsOut = make([]byte, clen) + } + r.readb(bsOut) + return +} + +func detachZeroCopyBytes(isBytesReader bool, dest []byte, in []byte) (out []byte) { + 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 + } + } + return in +} + +// decInferLen will infer a sensible length, given the following: +// - clen: length wanted. +// - maxlen: max length to be returned. +// 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, truncated bool) { + // handle when maxlen is not set i.e. <= 0 + if clen <= 0 { + return + } + if maxlen <= 0 { + // no maxlen defined. Use maximum of 256K memory, with a floor of 4K items. + // maxlen = 256 * 1024 / unit + // if maxlen < (4 * 1024) { + // maxlen = 4 * 1024 + // } + if unit < (256 / 4) { + maxlen = 256 * 1024 / unit + } else { + maxlen = 4 * 1024 + } + } + if clen > maxlen { + rvlen = maxlen + truncated = true + } else { + rvlen = clen + } + return + // if clen <= 0 { + // rvlen = 0 + // } else if maxlen > 0 && clen > maxlen { + // rvlen = maxlen + // truncated = true + // } else { + // rvlen = clen + // } + // return +} + +// // implement overall decReader wrapping both, for possible use inline: +// type decReaderT struct { +// bytes bool +// rb *bytesDecReader +// ri *ioDecReader +// } +// +// // implement *Decoder as a decReader. +// // Using decReaderT (defined just above) caused performance degradation +// // possibly because of constant copying the value, +// // and some value->interface conversion causing allocation. +// func (d *Decoder) unreadn1() { +// if d.bytes { +// d.rb.unreadn1() +// } else { +// d.ri.unreadn1() +// } +// } +// ... for other methods of decReader. +// Testing showed that performance improvement was negligible. diff --git a/cmd/vendor/github.com/ugorji/go/codec/encode.go b/_vendor/vendor/github.com/ugorji/go/codec/encode.go similarity index 54% rename from cmd/vendor/github.com/ugorji/go/codec/encode.go rename to _vendor/vendor/github.com/ugorji/go/codec/encode.go index 38c55be..25f426c 100644 --- a/cmd/vendor/github.com/ugorji/go/codec/encode.go +++ b/_vendor/vendor/github.com/ugorji/go/codec/encode.go @@ -4,9 +4,7 @@ package codec import ( - "bytes" "encoding" - "errors" "fmt" "io" "reflect" @@ -63,38 +61,24 @@ type encDriver interface { EncodeRawExt(re *RawExt, e *Encoder) EncodeExt(v interface{}, xtag uint64, ext Ext, e *Encoder) EncodeArrayStart(length int) - EncodeArrayEnd() - EncodeArrayEntrySeparator() EncodeMapStart(length int) - EncodeMapEnd() - EncodeMapEntrySeparator() - EncodeMapKVSeparator() EncodeString(c charEncoding, v string) EncodeSymbol(v string) EncodeStringBytes(c charEncoding, v []byte) //TODO //encBignum(f *big.Int) //encStringRunes(c charEncoding, v []rune) + + reset() +} + +type encDriverAsis interface { + EncodeAsis(v []byte) } type encNoSeparator struct{} -func (_ encNoSeparator) EncodeMapEnd() {} -func (_ encNoSeparator) EncodeArrayEnd() {} -func (_ encNoSeparator) EncodeArrayEntrySeparator() {} -func (_ encNoSeparator) EncodeMapEntrySeparator() {} -func (_ encNoSeparator) EncodeMapKVSeparator() {} - -type encStructFieldBytesV struct { - b []byte - v reflect.Value -} - -type encStructFieldBytesVslice []encStructFieldBytesV - -func (p encStructFieldBytesVslice) Len() int { return len(p) } -func (p encStructFieldBytesVslice) Less(i, j int) bool { return bytes.Compare(p[i].b, p[j].b) == -1 } -func (p encStructFieldBytesVslice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } +func (_ encNoSeparator) EncodeEnd() {} type ioEncWriterWriter interface { WriteByte(c byte) error @@ -113,10 +97,28 @@ type EncodeOptions struct { // Canonical representation means that encoding a value will always result in the same // sequence of bytes. // - // This mostly will apply to maps. In this case, codec will do more work to encode the - // map keys out of band, and then sort them, before writing out the map to the stream. + // This only affects maps, as the iteration order for maps is random. + // + // The implementation MAY use the natural sort order for the map keys if possible: + // + // - If there is a natural sort order (ie for number, bool, string or []byte keys), + // then the map keys are first sorted in natural order and then written + // with corresponding map values to the strema. + // - If there is no natural sort order, then the map keys will first be + // encoded into []byte, and then sorted, + // before writing the sorted keys and the corresponding map values to the stream. + // Canonical bool + // CheckCircularRef controls whether we check for circular references + // and error fast during an encode. + // + // If enabled, an error is received if a pointer to a struct + // references itself either directly or through one of its fields (iteratively). + // + // This is opt-in, as there may be a performance hit to checking circular references. + CheckCircularRef bool + // AsSymbols defines what should be encoded as symbols. // // Encoding as symbols can reduce the encoded size significantly. @@ -139,13 +141,16 @@ type simpleIoEncWriterWriter struct { w io.Writer bw io.ByteWriter sw ioEncStringWriter + bs [1]byte } func (o *simpleIoEncWriterWriter) WriteByte(c byte) (err error) { if o.bw != nil { return o.bw.WriteByte(c) } - _, err = o.w.Write([]byte{c}) + // _, err = o.w.Write([]byte{c}) + o.bs[0] = c + _, err = o.w.Write(o.bs[:]) return } @@ -166,6 +171,7 @@ func (o *simpleIoEncWriterWriter) Write(p []byte) (n int, err error) { // ioEncWriter implements encWriter and can write to an io.Writer implementation type ioEncWriter struct { w ioEncWriterWriter + s simpleIoEncWriterWriter // x [8]byte // temp byte array re-used internally for efficiency } @@ -236,8 +242,8 @@ func (z *bytesEncWriter) writen1(b1 byte) { func (z *bytesEncWriter) writen2(b1 byte, b2 byte) { c := z.grow(2) - z.b[c] = b1 z.b[c+1] = b2 + z.b[c] = b1 } func (z *bytesEncWriter) atEndOfEncode() { @@ -249,10 +255,10 @@ func (z *bytesEncWriter) grow(n int) (oldcursor int) { z.c = oldcursor + n if z.c > len(z.b) { if z.c > cap(z.b) { - // Tried using appendslice logic: (if cap < 1024, *2, else *1.25). - // However, it was too expensive, causing too many iterations of copy. - // Using bytes.Buffer model was much better (2*cap + n) - bs := make([]byte, 2*cap(z.b)+n) + // appendslice logic (if cap < 1024, *2, else *1.25): more expensive. many copy calls. + // bytes.Buffer model (2*cap + n): much better + // bs := make([]byte, 2*cap(z.b)+n) + bs := make([]byte, growCap(cap(z.b), 1, n)) copy(bs, z.b[:oldcursor]) z.b = bs } else { @@ -264,7 +270,7 @@ func (z *bytesEncWriter) grow(n int) (oldcursor int) { // --------------------------------------------- -type encFnInfoX struct { +type encFnInfo struct { e *Encoder ti *typeInfo xfFn Ext @@ -272,25 +278,13 @@ type encFnInfoX struct { seq seqType } -type encFnInfo struct { - // use encFnInfo as a value receiver. - // keep most of it less-used variables accessible via a pointer (*encFnInfoX). - // As sweet spot for value-receiver is 3 words, keep everything except - // encDriver (which everyone needs) directly accessible. - // ensure encFnInfoX is set for everyone who needs it i.e. - // rawExt, ext, builtin, (selfer|binary|text)Marshal, kSlice, kStruct, kMap, kInterface, fastpath - - ee encDriver - *encFnInfoX +func (f *encFnInfo) builtin(rv reflect.Value) { + f.e.e.EncodeBuiltin(f.ti.rtid, rv.Interface()) } -func (f encFnInfo) builtin(rv reflect.Value) { - f.ee.EncodeBuiltin(f.ti.rtid, rv.Interface()) -} - -func (f encFnInfo) rawExt(rv reflect.Value) { +func (f *encFnInfo) rawExt(rv reflect.Value) { // rev := rv.Interface().(RawExt) - // f.ee.EncodeRawExt(&rev, f.e) + // f.e.e.EncodeRawExt(&rev, f.e) var re *RawExt if rv.CanAddr() { re = rv.Addr().Interface().(*RawExt) @@ -298,26 +292,35 @@ func (f encFnInfo) rawExt(rv reflect.Value) { rev := rv.Interface().(RawExt) re = &rev } - f.ee.EncodeRawExt(re, f.e) + f.e.e.EncodeRawExt(re, f.e) } -func (f encFnInfo) ext(rv reflect.Value) { - // if this is a struct and it was addressable, then pass the address directly (not the value) - if rv.CanAddr() && rv.Kind() == reflect.Struct { +func (f *encFnInfo) ext(rv reflect.Value) { + // if this is a struct|array and it was addressable, then pass the address directly (not the value) + if k := rv.Kind(); (k == reflect.Struct || k == reflect.Array) && rv.CanAddr() { rv = rv.Addr() } - f.ee.EncodeExt(rv.Interface(), f.xfTag, f.xfFn, f.e) + f.e.e.EncodeExt(rv.Interface(), f.xfTag, f.xfFn, f.e) } -func (f encFnInfo) getValueForMarshalInterface(rv reflect.Value, indir int8) (v interface{}, proceed bool) { +func (f *encFnInfo) getValueForMarshalInterface(rv reflect.Value, indir int8) (v interface{}, proceed bool) { if indir == 0 { v = rv.Interface() } else if indir == -1 { - v = rv.Addr().Interface() + // If a non-pointer was passed to Encode(), then that value is not addressable. + // Take addr if addresable, else copy value to an addressable value. + if rv.CanAddr() { + v = rv.Addr().Interface() + } else { + rv2 := reflect.New(rv.Type()) + rv2.Elem().Set(rv) + v = rv2.Interface() + // fmt.Printf("rv.Type: %v, rv2.Type: %v, v: %v\n", rv.Type(), rv2.Type(), v) + } } else { for j := int8(0); j < indir; j++ { if rv.IsNil() { - f.ee.EncodeNil() + f.e.e.EncodeNil() return } rv = rv.Elem() @@ -327,103 +330,98 @@ func (f encFnInfo) getValueForMarshalInterface(rv reflect.Value, indir int8) (v return v, true } -func (f encFnInfo) selferMarshal(rv reflect.Value) { +func (f *encFnInfo) selferMarshal(rv reflect.Value) { if v, proceed := f.getValueForMarshalInterface(rv, f.ti.csIndir); proceed { v.(Selfer).CodecEncodeSelf(f.e) } } -func (f encFnInfo) binaryMarshal(rv reflect.Value) { +func (f *encFnInfo) binaryMarshal(rv reflect.Value) { if v, proceed := f.getValueForMarshalInterface(rv, f.ti.bmIndir); proceed { bs, fnerr := v.(encoding.BinaryMarshaler).MarshalBinary() - if fnerr != nil { - panic(fnerr) - } - if bs == nil { - f.ee.EncodeNil() - } else { - f.ee.EncodeStringBytes(c_RAW, bs) - } + f.e.marshal(bs, fnerr, false, c_RAW) } } -func (f encFnInfo) textMarshal(rv reflect.Value) { +func (f *encFnInfo) textMarshal(rv reflect.Value) { if v, proceed := f.getValueForMarshalInterface(rv, f.ti.tmIndir); proceed { // debugf(">>>> encoding.TextMarshaler: %T", rv.Interface()) bs, fnerr := v.(encoding.TextMarshaler).MarshalText() - if fnerr != nil { - panic(fnerr) - } - if bs == nil { - f.ee.EncodeNil() - } else { - f.ee.EncodeStringBytes(c_UTF8, bs) - } + f.e.marshal(bs, fnerr, false, c_UTF8) } } -func (f encFnInfo) kBool(rv reflect.Value) { - f.ee.EncodeBool(rv.Bool()) +func (f *encFnInfo) jsonMarshal(rv reflect.Value) { + if v, proceed := f.getValueForMarshalInterface(rv, f.ti.jmIndir); proceed { + bs, fnerr := v.(jsonMarshaler).MarshalJSON() + f.e.marshal(bs, fnerr, true, c_UTF8) + } } -func (f encFnInfo) kString(rv reflect.Value) { - f.ee.EncodeString(c_UTF8, rv.String()) +func (f *encFnInfo) kBool(rv reflect.Value) { + f.e.e.EncodeBool(rv.Bool()) } -func (f encFnInfo) kFloat64(rv reflect.Value) { - f.ee.EncodeFloat64(rv.Float()) +func (f *encFnInfo) kString(rv reflect.Value) { + f.e.e.EncodeString(c_UTF8, rv.String()) } -func (f encFnInfo) kFloat32(rv reflect.Value) { - f.ee.EncodeFloat32(float32(rv.Float())) +func (f *encFnInfo) kFloat64(rv reflect.Value) { + f.e.e.EncodeFloat64(rv.Float()) } -func (f encFnInfo) kInt(rv reflect.Value) { - f.ee.EncodeInt(rv.Int()) +func (f *encFnInfo) kFloat32(rv reflect.Value) { + f.e.e.EncodeFloat32(float32(rv.Float())) } -func (f encFnInfo) kUint(rv reflect.Value) { - f.ee.EncodeUint(rv.Uint()) +func (f *encFnInfo) kInt(rv reflect.Value) { + f.e.e.EncodeInt(rv.Int()) } -func (f encFnInfo) kInvalid(rv reflect.Value) { - f.ee.EncodeNil() +func (f *encFnInfo) kUint(rv reflect.Value) { + f.e.e.EncodeUint(rv.Uint()) } -func (f encFnInfo) kErr(rv reflect.Value) { +func (f *encFnInfo) kInvalid(rv reflect.Value) { + f.e.e.EncodeNil() +} + +func (f *encFnInfo) kErr(rv reflect.Value) { f.e.errorf("unsupported kind %s, for %#v", rv.Kind(), rv) } -func (f encFnInfo) kSlice(rv reflect.Value) { +func (f *encFnInfo) kSlice(rv reflect.Value) { ti := f.ti // 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". + e := f.e if f.seq != seqTypeArray { if rv.IsNil() { - f.ee.EncodeNil() + e.e.EncodeNil() return } // If in this method, then there was no extension function defined. // So it's okay to treat as []byte. if ti.rtid == uint8SliceTypId { - f.ee.EncodeStringBytes(c_RAW, rv.Bytes()) + e.e.EncodeStringBytes(c_RAW, rv.Bytes()) return } } + cr := e.cr rtelem := ti.rt.Elem() l := rv.Len() - if rtelem.Kind() == reflect.Uint8 { + if ti.rtid == uint8SliceTypId || rtelem.Kind() == reflect.Uint8 { switch f.seq { case seqTypeArray: - // if l == 0 { f.ee.encodeStringBytes(c_RAW, nil) } else + // if l == 0 { e.e.encodeStringBytes(c_RAW, nil) } else if rv.CanAddr() { - f.ee.EncodeStringBytes(c_RAW, rv.Slice(0, l).Bytes()) + e.e.EncodeStringBytes(c_RAW, rv.Slice(0, l).Bytes()) } else { var bs []byte - if l <= cap(f.e.b) { - bs = f.e.b[:l] + if l <= cap(e.b) { + bs = e.b[:l] } else { bs = make([]byte, l) } @@ -432,12 +430,12 @@ func (f encFnInfo) kSlice(rv reflect.Value) { // for i := 0; i < l; i++ { // bs[i] = byte(rv.Index(i).Uint()) // } - f.ee.EncodeStringBytes(c_RAW, bs) + e.e.EncodeStringBytes(c_RAW, bs) } case seqTypeSlice: - f.ee.EncodeStringBytes(c_RAW, rv.Bytes()) + e.e.EncodeStringBytes(c_RAW, rv.Bytes()) case seqTypeChan: - bs := f.e.b[:0] + bs := e.b[:0] // do not use range, so that the number of elements encoded // does not change, and encoding does not hang waiting on someone to close chan. // for b := range rv.Interface().(<-chan byte) { @@ -447,23 +445,21 @@ func (f encFnInfo) kSlice(rv reflect.Value) { for i := 0; i < l; i++ { bs = append(bs, <-ch) } - f.ee.EncodeStringBytes(c_RAW, bs) + e.e.EncodeStringBytes(c_RAW, bs) } return } if ti.mbs { if l%2 == 1 { - f.e.errorf("mapBySlice requires even slice length, but got %v", l) + e.errorf("mapBySlice requires even slice length, but got %v", l) return } - f.ee.EncodeMapStart(l / 2) + e.e.EncodeMapStart(l / 2) } else { - f.ee.EncodeArrayStart(l) + e.e.EncodeArrayStart(l) } - e := f.e - sep := !e.be if l > 0 { for rtelem.Kind() == reflect.Ptr { rtelem = rtelem.Elem() @@ -471,114 +467,78 @@ func (f encFnInfo) kSlice(rv reflect.Value) { // 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 fn encFn + var fn *encFn if rtelem.Kind() != reflect.Interface { rtelemid := reflect.ValueOf(rtelem).Pointer() fn = e.getEncFn(rtelemid, rtelem, true, true) } // TODO: Consider perf implication of encoding odd index values as symbols if type is string - if sep { - for j := 0; j < l; j++ { - if j > 0 { - if ti.mbs { - if j%2 == 0 { - f.ee.EncodeMapEntrySeparator() - } else { - f.ee.EncodeMapKVSeparator() - } + for j := 0; j < l; j++ { + if cr != nil { + if ti.mbs { + if j%2 == 0 { + cr.sendContainerState(containerMapKey) } else { - f.ee.EncodeArrayEntrySeparator() - } - } - if f.seq == seqTypeChan { - if rv2, ok2 := rv.Recv(); ok2 { - e.encodeValue(rv2, fn) + cr.sendContainerState(containerMapValue) } } else { - e.encodeValue(rv.Index(j), fn) + cr.sendContainerState(containerArrayElem) } } - } else { - for j := 0; j < l; j++ { - if f.seq == seqTypeChan { - if rv2, ok2 := rv.Recv(); ok2 { - e.encodeValue(rv2, fn) - } + if f.seq == seqTypeChan { + if rv2, ok2 := rv.Recv(); ok2 { + e.encodeValue(rv2, fn) } else { - e.encodeValue(rv.Index(j), fn) + e.encode(nil) // WE HAVE TO DO SOMETHING, so nil if nothing received. } + } else { + e.encodeValue(rv.Index(j), fn) } } } - if sep { + if cr != nil { if ti.mbs { - f.ee.EncodeMapEnd() + cr.sendContainerState(containerMapEnd) } else { - f.ee.EncodeArrayEnd() + cr.sendContainerState(containerArrayEnd) } } } -func (f encFnInfo) kStruct(rv reflect.Value) { +func (f *encFnInfo) kStruct(rv reflect.Value) { fti := f.ti e := f.e + cr := e.cr tisfi := fti.sfip toMap := !(fti.toArray || e.h.StructToArray) newlen := len(fti.sfi) - // Use sync.Pool to reduce allocating slices unnecessarily. - // The cost of the occasional locking is less than the cost of locking. - var fkvs []encStructFieldKV - var pool *sync.Pool - var poolv interface{} - idxpool := newlen / 8 - if encStructPoolLen != 4 { - panic(errors.New("encStructPoolLen must be equal to 4")) // defensive, in case it is changed - } - if idxpool < encStructPoolLen { - pool = &encStructPool[idxpool] - poolv = pool.Get() - switch vv := poolv.(type) { - case *[8]encStructFieldKV: - fkvs = vv[:newlen] - case *[16]encStructFieldKV: - fkvs = vv[:newlen] - case *[32]encStructFieldKV: - fkvs = vv[:newlen] - case *[64]encStructFieldKV: - fkvs = vv[:newlen] - } - } - if fkvs == nil { - fkvs = make([]encStructFieldKV, newlen) - } + // Use sync.Pool to reduce allocating slices unnecessarily. + // The cost of sync.Pool is less than the cost of new allocation. + pool, poolv, fkvs := encStructPoolGet(newlen) + // if toMap, use the sorted array. If toArray, use unsorted array (to match sequence in struct) if toMap { tisfi = fti.sfi } newlen = 0 - var kv encStructFieldKV + var kv stringRv for _, si := range tisfi { - kv.v = si.field(rv, false) - // if si.i != -1 { - // rvals[newlen] = rv.Field(int(si.i)) - // } else { - // rvals[newlen] = rv.FieldByIndex(si.is) - // } + kv.r = si.field(rv, false) if toMap { - if si.omitEmpty && isEmptyValue(kv.v) { + if si.omitEmpty && isEmptyValue(kv.r) { continue } - kv.k = si.encName + kv.v = si.encName } else { // use the zero value. // if a reference or struct, set to nil (so you do not output too much) - if si.omitEmpty && isEmptyValue(kv.v) { - switch kv.v.Kind() { + if si.omitEmpty && isEmptyValue(kv.r) { + switch kv.r.Kind() { case reflect.Struct, reflect.Interface, reflect.Ptr, reflect.Array, reflect.Map, reflect.Slice: - kv.v = reflect.Value{} //encode as nil + kv.r = reflect.Value{} //encode as nil } } } @@ -587,58 +547,42 @@ func (f encFnInfo) kStruct(rv reflect.Value) { } // debugf(">>>> kStruct: newlen: %v", newlen) - sep := !e.be - ee := f.ee //don't dereference everytime - if sep { - if toMap { - ee.EncodeMapStart(newlen) - // asSymbols := e.h.AsSymbols&AsSymbolStructFieldNameFlag != 0 - asSymbols := e.h.AsSymbols == AsSymbolDefault || e.h.AsSymbols&AsSymbolStructFieldNameFlag != 0 - for j := 0; j < newlen; j++ { - kv = fkvs[j] - if j > 0 { - ee.EncodeMapEntrySeparator() - } - if asSymbols { - ee.EncodeSymbol(kv.k) - } else { - ee.EncodeString(c_UTF8, kv.k) - } - ee.EncodeMapKVSeparator() - e.encodeValue(kv.v, encFn{}) + // sep := !e.be + ee := e.e //don't dereference everytime + + if toMap { + ee.EncodeMapStart(newlen) + // asSymbols := e.h.AsSymbols&AsSymbolStructFieldNameFlag != 0 + asSymbols := e.h.AsSymbols == AsSymbolDefault || e.h.AsSymbols&AsSymbolStructFieldNameFlag != 0 + for j := 0; j < newlen; j++ { + kv = fkvs[j] + if cr != nil { + cr.sendContainerState(containerMapKey) } - ee.EncodeMapEnd() - } else { - ee.EncodeArrayStart(newlen) - for j := 0; j < newlen; j++ { - kv = fkvs[j] - if j > 0 { - ee.EncodeArrayEntrySeparator() - } - e.encodeValue(kv.v, encFn{}) + if asSymbols { + ee.EncodeSymbol(kv.v) + } else { + ee.EncodeString(c_UTF8, kv.v) } - ee.EncodeArrayEnd() + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encodeValue(kv.r, nil) + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } else { - if toMap { - ee.EncodeMapStart(newlen) - // asSymbols := e.h.AsSymbols&AsSymbolStructFieldNameFlag != 0 - asSymbols := e.h.AsSymbols == AsSymbolDefault || e.h.AsSymbols&AsSymbolStructFieldNameFlag != 0 - for j := 0; j < newlen; j++ { - kv = fkvs[j] - if asSymbols { - ee.EncodeSymbol(kv.k) - } else { - ee.EncodeString(c_UTF8, kv.k) - } - e.encodeValue(kv.v, encFn{}) - } - } else { - ee.EncodeArrayStart(newlen) - for j := 0; j < newlen; j++ { - kv = fkvs[j] - e.encodeValue(kv.v, encFn{}) + ee.EncodeArrayStart(newlen) + for j := 0; j < newlen; j++ { + kv = fkvs[j] + if cr != nil { + cr.sendContainerState(containerArrayElem) } + e.encodeValue(kv.r, nil) + } + if cr != nil { + cr.sendContainerState(containerArrayEnd) } } @@ -650,36 +594,39 @@ func (f encFnInfo) kStruct(rv reflect.Value) { } } -// func (f encFnInfo) kPtr(rv reflect.Value) { +// func (f *encFnInfo) kPtr(rv reflect.Value) { // debugf(">>>>>>> ??? encode kPtr called - shouldn't get called") // if rv.IsNil() { -// f.ee.encodeNil() +// f.e.e.encodeNil() // return // } // f.e.encodeValue(rv.Elem()) // } -func (f encFnInfo) kInterface(rv reflect.Value) { - if rv.IsNil() { - f.ee.EncodeNil() - return - } - f.e.encodeValue(rv.Elem(), encFn{}) -} +// func (f *encFnInfo) kInterface(rv reflect.Value) { +// println("kInterface called") +// debug.PrintStack() +// if rv.IsNil() { +// f.e.e.EncodeNil() +// return +// } +// f.e.encodeValue(rv.Elem(), nil) +// } -func (f encFnInfo) kMap(rv reflect.Value) { +func (f *encFnInfo) kMap(rv reflect.Value) { + ee := f.e.e if rv.IsNil() { - f.ee.EncodeNil() + ee.EncodeNil() return } l := rv.Len() - f.ee.EncodeMapStart(l) + ee.EncodeMapStart(l) e := f.e - sep := !e.be + cr := e.cr if l == 0 { - if sep { - f.ee.EncodeMapEnd() + if cr != nil { + cr.sendContainerState(containerMapEnd) } return } @@ -691,7 +638,7 @@ func (f encFnInfo) kMap(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 encFn + var keyFn, valFn *encFn ti := f.ti rtkey := ti.rt.Key() rtval := ti.rt.Elem() @@ -718,49 +665,14 @@ func (f encFnInfo) kMap(rv reflect.Value) { } mks := rv.MapKeys() // for j, lmks := 0, len(mks); j < lmks; j++ { - ee := f.ee //don't dereference everytime + if e.h.Canonical { - // first encode each key to a []byte first, then sort them, then record - // println(">>>>>>>> CANONICAL <<<<<<<<") - var mksv []byte // temporary byte slice for the encoding - e2 := NewEncoderBytes(&mksv, e.hh) - mksbv := make([]encStructFieldBytesV, len(mks)) - for i, k := range mks { - l := len(mksv) - e2.MustEncode(k) - mksbv[i].v = k - mksbv[i].b = mksv[l:] - } - sort.Sort(encStructFieldBytesVslice(mksbv)) - for j := range mksbv { - if j > 0 { - ee.EncodeMapEntrySeparator() - } - e.w.writeb(mksbv[j].b) - ee.EncodeMapKVSeparator() - e.encodeValue(rv.MapIndex(mksbv[j].v), valFn) - } - ee.EncodeMapEnd() - } else if sep { - for j := range mks { - if j > 0 { - ee.EncodeMapEntrySeparator() - } - if keyTypeIsString { - if asSymbols { - ee.EncodeSymbol(mks[j].String()) - } else { - ee.EncodeString(c_UTF8, mks[j].String()) - } - } else { - e.encodeValue(mks[j], keyFn) - } - ee.EncodeMapKVSeparator() - e.encodeValue(rv.MapIndex(mks[j]), valFn) - } - ee.EncodeMapEnd() + e.kMapCanonical(rtkeyid, rtkey, rv, mks, valFn, asSymbols) } else { for j := range mks { + if cr != nil { + cr.sendContainerState(containerMapKey) + } if keyTypeIsString { if asSymbols { ee.EncodeSymbol(mks[j].String()) @@ -770,9 +682,182 @@ func (f encFnInfo) kMap(rv reflect.Value) { } else { e.encodeValue(mks[j], keyFn) } + if cr != nil { + cr.sendContainerState(containerMapValue) + } e.encodeValue(rv.MapIndex(mks[j]), valFn) } } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (e *Encoder) kMapCanonical(rtkeyid uintptr, rtkey reflect.Type, rv reflect.Value, mks []reflect.Value, valFn *encFn, asSymbols bool) { + ee := e.e + cr := e.cr + // we previously did out-of-band if an extension was registered. + // This is not necessary, as the natural kind is sufficient for ordering. + + if rtkeyid == uint8SliceTypId { + mksv := make([]bytesRv, len(mks)) + for i, k := range mks { + v := &mksv[i] + v.r = k + v.v = k.Bytes() + } + sort.Sort(bytesRvSlice(mksv)) + for i := range mksv { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeStringBytes(c_RAW, mksv[i].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encodeValue(rv.MapIndex(mksv[i].r), valFn) + } + } else { + switch rtkey.Kind() { + case reflect.Bool: + mksv := make([]boolRv, len(mks)) + for i, k := range mks { + v := &mksv[i] + v.r = k + v.v = k.Bool() + } + sort.Sort(boolRvSlice(mksv)) + for i := range mksv { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeBool(mksv[i].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encodeValue(rv.MapIndex(mksv[i].r), valFn) + } + case reflect.String: + mksv := make([]stringRv, len(mks)) + for i, k := range mks { + v := &mksv[i] + v.r = k + v.v = k.String() + } + sort.Sort(stringRvSlice(mksv)) + for i := range mksv { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + if asSymbols { + ee.EncodeSymbol(mksv[i].v) + } else { + ee.EncodeString(c_UTF8, mksv[i].v) + } + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encodeValue(rv.MapIndex(mksv[i].r), valFn) + } + case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint, reflect.Uintptr: + mksv := make([]uintRv, len(mks)) + for i, k := range mks { + v := &mksv[i] + v.r = k + v.v = k.Uint() + } + sort.Sort(uintRvSlice(mksv)) + for i := range mksv { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(mksv[i].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encodeValue(rv.MapIndex(mksv[i].r), valFn) + } + case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: + mksv := make([]intRv, len(mks)) + for i, k := range mks { + v := &mksv[i] + v.r = k + v.v = k.Int() + } + sort.Sort(intRvSlice(mksv)) + for i := range mksv { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(mksv[i].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encodeValue(rv.MapIndex(mksv[i].r), valFn) + } + case reflect.Float32: + mksv := make([]floatRv, len(mks)) + for i, k := range mks { + v := &mksv[i] + v.r = k + v.v = k.Float() + } + sort.Sort(floatRvSlice(mksv)) + for i := range mksv { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat32(float32(mksv[i].v)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encodeValue(rv.MapIndex(mksv[i].r), valFn) + } + case reflect.Float64: + mksv := make([]floatRv, len(mks)) + for i, k := range mks { + v := &mksv[i] + v.r = k + v.v = k.Float() + } + sort.Sort(floatRvSlice(mksv)) + for i := range mksv { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat64(mksv[i].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encodeValue(rv.MapIndex(mksv[i].r), valFn) + } + default: + // out-of-band + // first encode each key to a []byte first, then sort them, then record + 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 { + v := &mksbv[i] + l := len(mksv) + e2.MustEncode(k) + v.r = k + v.v = mksv[l:] + // fmt.Printf(">>>>> %s\n", mksv[l:]) + } + sort.Sort(bytesRvSlice(mksbv)) + for j := range mksbv { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.asis(mksbv[j].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encodeValue(rv.MapIndex(mksbv[j].r), valFn) + } + } + } } // -------------------------------------------------- @@ -783,12 +868,12 @@ func (f encFnInfo) kMap(rv reflect.Value) { // instead of executing the checks every time. type encFn struct { i encFnInfo - f func(encFnInfo, reflect.Value) + f func(*encFnInfo, reflect.Value) } // -------------------------------------------------- -type rtidEncFn struct { +type encRtidFn struct { rtid uintptr fn encFn } @@ -796,18 +881,26 @@ type rtidEncFn struct { // An Encoder writes an object to an output stream in the codec format. type Encoder struct { // hopefully, reduce derefencing cost by laying the encWriter inside the Encoder - e encDriver + e encDriver + // NOTE: Encoder shouldn't call it's write methods, + // as the handler MAY need to do some coordination. w encWriter - s []rtidEncFn + s []encRtidFn + ci set be bool // is binary encoding + js bool // is json handle wi ioEncWriter wb bytesEncWriter - h *BasicHandle + h *BasicHandle hh Handle - f map[uintptr]encFn - b [scratchByteArrayLen]byte + + cr containerStateRecv + as encDriverAsis + + f map[uintptr]*encFn + b [scratchByteArrayLen]byte } // NewEncoder returns an Encoder for encoding into an io.Writer. @@ -815,18 +908,8 @@ type Encoder struct { // For efficiency, Users are encouraged to pass in a memory buffered writer // (eg bufio.Writer, bytes.Buffer). func NewEncoder(w io.Writer, h Handle) *Encoder { - e := &Encoder{hh: h, h: h.getBasicHandle(), be: h.isBinary()} - ww, ok := w.(ioEncWriterWriter) - if !ok { - sww := simpleIoEncWriterWriter{w: w} - sww.bw, _ = w.(io.ByteWriter) - sww.sw, _ = w.(ioEncStringWriter) - ww = &sww - //ww = bufio.NewWriterSize(w, defEncByteBufSize) - } - e.wi.w = ww - e.w = &e.wi - e.e = h.newEncDriver(e) + e := newEncoder(h) + e.Reset(w) return e } @@ -836,17 +919,56 @@ 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 := newEncoder(h) + e.ResetBytes(out) + return e +} + +func newEncoder(h Handle) *Encoder { e := &Encoder{hh: h, h: h.getBasicHandle(), be: h.isBinary()} + _, e.js = h.(*JsonHandle) + e.e = h.newEncDriver(e) + e.as, _ = e.e.(encDriverAsis) + e.cr, _ = e.e.(containerStateRecv) + return e +} + +// Reset the Encoder with a new output stream. +// +// This accomodates using the state of the Encoder, +// where it has "cached" information about sub-engines. +func (e *Encoder) Reset(w io.Writer) { + ww, ok := w.(ioEncWriterWriter) + if ok { + e.wi.w = ww + } else { + sww := &e.wi.s + sww.w = w + sww.bw, _ = w.(io.ByteWriter) + sww.sw, _ = w.(ioEncStringWriter) + e.wi.w = sww + //ww = bufio.NewWriterSize(w, defEncByteBufSize) + } + e.w = &e.wi + e.e.reset() +} + +func (e *Encoder) ResetBytes(out *[]byte) { in := *out if in == nil { in = make([]byte, defEncByteBufSize) } - e.wb.b, e.wb.out = in, out + e.wb.b, e.wb.out, e.wb.c = in, out, 0 e.w = &e.wb - e.e = h.newEncDriver(e) - return e + e.e.reset() } +// func (e *Encoder) sendContainerState(c containerState) { +// if e.cr != nil { +// e.cr.sendContainerState(c) +// } +// } + // Encode writes an object into a stream. // // Encoding can be configured via the struct tag for the fields. @@ -873,8 +995,9 @@ func NewEncoderBytes(out *[]byte, h Handle) *Encoder { // The empty values (for omitempty option) are false, 0, any nil pointer // or interface value, and any array, slice, map, or string of length zero. // -// Anonymous fields are encoded inline if no struct tag is present. -// Else they are encoded as regular fields. +// Anonymous fields are encoded inline except: +// - the struct tag specifies a replacement name (first value) +// - the field is of an interface type // // Examples: // @@ -885,6 +1008,9 @@ func NewEncoderBytes(out *[]byte, h Handle) *Encoder { // Field2 int `codec:"myName"` //Use key "myName" in encode stream // Field3 int32 `codec:",omitempty"` //use key "Field3". Omit if empty. // Field4 bool `codec:"f4,omitempty"` //use key "f4". Omit if empty. +// io.Reader //use key "Reader". +// MyStruct `codec:"my1" //use key "my1". +// MyStruct //inline it // ... // } // @@ -894,8 +1020,9 @@ func NewEncoderBytes(out *[]byte, h Handle) *Encoder { // } // // The mode of encoding is based on the type of the value. When a value is seen: +// - If a Selfer, call its CodecEncodeSelf method // - If an extension is registered for it, call that extension function -// - If it implements BinaryMarshaler, call its MarshalBinary() (data []byte, err error) +// - If it implements encoding.(Binary|Text|JSON)Marshaler, call its Marshal(Binary|Text|JSON) method // - Else encode it based on its reflect.Kind // // Note that struct field names and keys in map[string]XXX will be treated as symbols. @@ -942,7 +1069,7 @@ func (e *Encoder) encode(iv interface{}) { v.CodecEncodeSelf(e) case reflect.Value: - e.encodeValue(v, encFn{}) + e.encodeValue(v, nil) case string: e.e.EncodeString(c_UTF8, v) @@ -1009,73 +1136,93 @@ func (e *Encoder) encode(iv interface{}) { e.e.EncodeStringBytes(c_RAW, *v) default: - // canonical mode is not supported for fastpath of maps (but is fine for slices) - if e.h.Canonical { - if !fastpathEncodeTypeSwitchSlice(iv, e) { - e.encodeI(iv, false, false) - } - } else if !fastpathEncodeTypeSwitch(iv, e) { - e.encodeI(iv, false, false) + const checkCodecSelfer1 = true // in case T is passed, where *T is a Selfer, still checkCodecSelfer + if !fastpathEncodeTypeSwitch(iv, e) { + e.encodeI(iv, false, checkCodecSelfer1) } } } +func (e *Encoder) preEncodeValue(rv reflect.Value) (rv2 reflect.Value, sptr uintptr, proceed bool) { + // use a goto statement instead of a recursive function for ptr/interface. +TOP: + switch rv.Kind() { + case reflect.Ptr: + if rv.IsNil() { + e.e.EncodeNil() + return + } + rv = rv.Elem() + if e.h.CheckCircularRef && rv.Kind() == reflect.Struct { + // TODO: Movable pointers will be an issue here. Future problem. + sptr = rv.UnsafeAddr() + break TOP + } + goto TOP + case reflect.Interface: + if rv.IsNil() { + e.e.EncodeNil() + return + } + rv = rv.Elem() + goto TOP + case reflect.Slice, reflect.Map: + if rv.IsNil() { + e.e.EncodeNil() + return + } + case reflect.Invalid, reflect.Func: + e.e.EncodeNil() + return + } + + proceed = true + rv2 = rv + return +} + +func (e *Encoder) doEncodeValue(rv reflect.Value, fn *encFn, sptr uintptr, + checkFastpath, checkCodecSelfer bool) { + if sptr != 0 { + if (&e.ci).add(sptr) { + e.errorf("circular reference found: # %d", sptr) + } + } + if fn == nil { + rt := rv.Type() + rtid := reflect.ValueOf(rt).Pointer() + // fn = e.getEncFn(rtid, rt, true, true) + fn = e.getEncFn(rtid, rt, checkFastpath, checkCodecSelfer) + } + fn.f(&fn.i, rv) + if sptr != 0 { + (&e.ci).remove(sptr) + } +} + func (e *Encoder) encodeI(iv interface{}, checkFastpath, checkCodecSelfer bool) { - if rv, proceed := e.preEncodeValue(reflect.ValueOf(iv)); proceed { - rt := rv.Type() - rtid := reflect.ValueOf(rt).Pointer() - fn := e.getEncFn(rtid, rt, checkFastpath, checkCodecSelfer) - fn.f(fn.i, rv) + if rv, sptr, proceed := e.preEncodeValue(reflect.ValueOf(iv)); proceed { + e.doEncodeValue(rv, nil, sptr, checkFastpath, checkCodecSelfer) } } -func (e *Encoder) preEncodeValue(rv reflect.Value) (rv2 reflect.Value, proceed bool) { -LOOP: - for { - switch rv.Kind() { - case reflect.Ptr, reflect.Interface: - if rv.IsNil() { - e.e.EncodeNil() - return - } - rv = rv.Elem() - continue LOOP - case reflect.Slice, reflect.Map: - if rv.IsNil() { - e.e.EncodeNil() - return - } - case reflect.Invalid, reflect.Func: - e.e.EncodeNil() - return - } - break - } - - return rv, true -} - -func (e *Encoder) encodeValue(rv reflect.Value, fn encFn) { +func (e *Encoder) encodeValue(rv reflect.Value, fn *encFn) { // if a valid fn is passed, it MUST BE for the dereferenced type of rv - if rv, proceed := e.preEncodeValue(rv); proceed { - if fn.f == nil { - rt := rv.Type() - rtid := reflect.ValueOf(rt).Pointer() - fn = e.getEncFn(rtid, rt, true, true) - } - fn.f(fn.i, rv) + if rv, sptr, proceed := e.preEncodeValue(rv); proceed { + e.doEncodeValue(rv, fn, sptr, true, true) } } -func (e *Encoder) getEncFn(rtid uintptr, rt reflect.Type, checkFastpath, checkCodecSelfer bool) (fn encFn) { +func (e *Encoder) getEncFn(rtid uintptr, rt reflect.Type, checkFastpath, checkCodecSelfer bool) (fn *encFn) { // rtid := reflect.ValueOf(rt).Pointer() var ok bool if useMapForCodecCache { fn, ok = e.f[rtid] } else { - for _, v := range e.s { + for i := range e.s { + v := &(e.s[i]) if v.rtid == rtid { - fn, ok = v.fn, true + fn, ok = &(v.fn), true break } } @@ -1083,37 +1230,47 @@ func (e *Encoder) getEncFn(rtid uintptr, rt reflect.Type, checkFastpath, checkCo if ok { return } - // fi.encFnInfoX = new(encFnInfoX) - ti := getTypeInfo(rtid, rt) - var fi encFnInfo - fi.ee = e.e + + if useMapForCodecCache { + if e.f == nil { + e.f = make(map[uintptr]*encFn, initCollectionCap) + } + fn = new(encFn) + e.f[rtid] = fn + } else { + if e.s == nil { + e.s = make([]encRtidFn, 0, initCollectionCap) + } + e.s = append(e.s, encRtidFn{rtid: rtid}) + fn = &(e.s[len(e.s)-1]).fn + } + + ti := e.h.getTypeInfo(rtid, rt) + fi := &(fn.i) + fi.e = e + fi.ti = ti if checkCodecSelfer && ti.cs { - fi.encFnInfoX = &encFnInfoX{e: e, ti: ti} - fn.f = (encFnInfo).selferMarshal + fn.f = (*encFnInfo).selferMarshal } else if rtid == rawExtTypId { - fi.encFnInfoX = &encFnInfoX{e: e, ti: ti} - fn.f = (encFnInfo).rawExt + fn.f = (*encFnInfo).rawExt } else if e.e.IsBuiltinType(rtid) { - fi.encFnInfoX = &encFnInfoX{e: e, ti: ti} - fn.f = (encFnInfo).builtin + fn.f = (*encFnInfo).builtin } else if xfFn := e.h.getExt(rtid); xfFn != nil { - // fi.encFnInfoX = new(encFnInfoX) - fi.encFnInfoX = &encFnInfoX{e: e, ti: ti} fi.xfTag, fi.xfFn = xfFn.tag, xfFn.ext - fn.f = (encFnInfo).ext + fn.f = (*encFnInfo).ext } else if supportMarshalInterfaces && e.be && ti.bm { - fi.encFnInfoX = &encFnInfoX{e: e, ti: ti} - fn.f = (encFnInfo).binaryMarshal + fn.f = (*encFnInfo).binaryMarshal + } else if supportMarshalInterfaces && !e.be && e.js && ti.jm { + //If JSON, we should check JSONMarshal before textMarshal + fn.f = (*encFnInfo).jsonMarshal } else if supportMarshalInterfaces && !e.be && ti.tm { - fi.encFnInfoX = &encFnInfoX{e: e, ti: ti} - fn.f = (encFnInfo).textMarshal + fn.f = (*encFnInfo).textMarshal } else { rk := rt.Kind() if fastpathEnabled && checkFastpath && (rk == reflect.Map || rk == reflect.Slice) { - if rt.PkgPath() == "" { + if rt.PkgPath() == "" { // un-named slice or map if idx := fastpathAV.index(rtid); idx != -1 { - fi.encFnInfoX = &encFnInfoX{e: e, ti: ti} fn.f = fastpathAV[idx].encfn } } else { @@ -1129,8 +1286,7 @@ func (e *Encoder) getEncFn(rtid uintptr, rt reflect.Type, checkFastpath, checkCo if idx := fastpathAV.index(rtuid); idx != -1 { xfnf := fastpathAV[idx].encfn xrt := fastpathAV[idx].rt - fi.encFnInfoX = &encFnInfoX{e: e, ti: ti} - fn.f = func(xf encFnInfo, xrv reflect.Value) { + fn.f = func(xf *encFnInfo, xrv reflect.Value) { xfnf(xf, xrv.Convert(xrt)) } } @@ -1139,60 +1295,67 @@ func (e *Encoder) getEncFn(rtid uintptr, rt reflect.Type, checkFastpath, checkCo if fn.f == nil { switch rk { case reflect.Bool: - fn.f = (encFnInfo).kBool + fn.f = (*encFnInfo).kBool case reflect.String: - fn.f = (encFnInfo).kString + fn.f = (*encFnInfo).kString case reflect.Float64: - fn.f = (encFnInfo).kFloat64 + fn.f = (*encFnInfo).kFloat64 case reflect.Float32: - fn.f = (encFnInfo).kFloat32 + fn.f = (*encFnInfo).kFloat32 case reflect.Int, reflect.Int8, reflect.Int64, reflect.Int32, reflect.Int16: - fn.f = (encFnInfo).kInt - case reflect.Uint8, reflect.Uint64, reflect.Uint, reflect.Uint32, reflect.Uint16: - fn.f = (encFnInfo).kUint + fn.f = (*encFnInfo).kInt + case reflect.Uint8, reflect.Uint64, reflect.Uint, reflect.Uint32, reflect.Uint16, reflect.Uintptr: + fn.f = (*encFnInfo).kUint case reflect.Invalid: - fn.f = (encFnInfo).kInvalid + fn.f = (*encFnInfo).kInvalid case reflect.Chan: - fi.encFnInfoX = &encFnInfoX{e: e, ti: ti, seq: seqTypeChan} - fn.f = (encFnInfo).kSlice + fi.seq = seqTypeChan + fn.f = (*encFnInfo).kSlice case reflect.Slice: - fi.encFnInfoX = &encFnInfoX{e: e, ti: ti, seq: seqTypeSlice} - fn.f = (encFnInfo).kSlice + fi.seq = seqTypeSlice + fn.f = (*encFnInfo).kSlice case reflect.Array: - fi.encFnInfoX = &encFnInfoX{e: e, ti: ti, seq: seqTypeArray} - fn.f = (encFnInfo).kSlice + fi.seq = seqTypeArray + fn.f = (*encFnInfo).kSlice case reflect.Struct: - fi.encFnInfoX = &encFnInfoX{e: e, ti: ti} - fn.f = (encFnInfo).kStruct + fn.f = (*encFnInfo).kStruct + // reflect.Ptr and reflect.Interface are handled already by preEncodeValue // case reflect.Ptr: - // fn.f = (encFnInfo).kPtr - case reflect.Interface: - fi.encFnInfoX = &encFnInfoX{e: e, ti: ti} - fn.f = (encFnInfo).kInterface + // fn.f = (*encFnInfo).kPtr + // case reflect.Interface: + // fn.f = (*encFnInfo).kInterface case reflect.Map: - fi.encFnInfoX = &encFnInfoX{e: e, ti: ti} - fn.f = (encFnInfo).kMap + fn.f = (*encFnInfo).kMap default: - fn.f = (encFnInfo).kErr + fn.f = (*encFnInfo).kErr } } } - fn.i = fi - if useMapForCodecCache { - if e.f == nil { - e.f = make(map[uintptr]encFn, 32) - } - e.f[rtid] = fn - } else { - if e.s == nil { - e.s = make([]rtidEncFn, 0, 32) - } - e.s = append(e.s, rtidEncFn{rtid, fn}) - } return } +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.EncodeStringBytes(c, bs) + } +} + +func (e *Encoder) asis(v []byte) { + if e.as == nil { + e.w.writeb(v) + } else { + e.as.EncodeAsis(v) + } +} + func (e *Encoder) errorf(format string, params ...interface{}) { err := fmt.Errorf(format, params...) panic(err) @@ -1200,12 +1363,7 @@ func (e *Encoder) errorf(format string, params ...interface{}) { // ---------------------------------------- -type encStructFieldKV struct { - k string - v reflect.Value -} - -const encStructPoolLen = 4 +const encStructPoolLen = 5 // encStructPool is an array of sync.Pool. // Each element of the array pools one of encStructPool(8|16|32|64). @@ -1219,10 +1377,42 @@ const encStructPoolLen = 4 var encStructPool [encStructPoolLen]sync.Pool func init() { - encStructPool[0].New = func() interface{} { return new([8]encStructFieldKV) } - encStructPool[1].New = func() interface{} { return new([16]encStructFieldKV) } - encStructPool[2].New = func() interface{} { return new([32]encStructFieldKV) } - encStructPool[3].New = func() interface{} { return new([64]encStructFieldKV) } + encStructPool[0].New = func() interface{} { return new([8]stringRv) } + encStructPool[1].New = func() interface{} { return new([16]stringRv) } + encStructPool[2].New = func() interface{} { return new([32]stringRv) } + encStructPool[3].New = func() interface{} { return new([64]stringRv) } + encStructPool[4].New = func() interface{} { return new([128]stringRv) } +} + +func encStructPoolGet(newlen int) (p *sync.Pool, v interface{}, s []stringRv) { + // if encStructPoolLen != 5 { // constant chec, so removed at build time. + // panic(errors.New("encStructPoolLen must be equal to 4")) // defensive, in case it is changed + // } + // idxpool := newlen / 8 + if newlen <= 8 { + p = &encStructPool[0] + v = p.Get() + s = v.(*[8]stringRv)[:newlen] + } else if newlen <= 16 { + p = &encStructPool[1] + v = p.Get() + s = v.(*[16]stringRv)[:newlen] + } else if newlen <= 32 { + p = &encStructPool[2] + v = p.Get() + s = v.(*[32]stringRv)[:newlen] + } else if newlen <= 64 { + p = &encStructPool[3] + v = p.Get() + s = v.(*[64]stringRv)[:newlen] + } else if newlen <= 128 { + p = &encStructPool[4] + v = p.Get() + s = v.(*[128]stringRv)[:newlen] + } else { + s = make([]stringRv, newlen) + } + return } // ---------------------------------------- diff --git a/cmd/vendor/github.com/ugorji/go/codec/fast-path.generated.go b/_vendor/vendor/github.com/ugorji/go/codec/fast-path.generated.go similarity index 53% rename from cmd/vendor/github.com/ugorji/go/codec/fast-path.generated.go rename to _vendor/vendor/github.com/ugorji/go/codec/fast-path.generated.go index b0f7f80..67b6423 100644 --- a/cmd/vendor/github.com/ugorji/go/codec/fast-path.generated.go +++ b/_vendor/vendor/github.com/ugorji/go/codec/fast-path.generated.go @@ -1,4 +1,4 @@ -// //+build ignore +// +build !notfastpath // Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. @@ -38,6 +38,8 @@ import ( "sort" ) +const fastpathEnabled = true + const fastpathCheckNilFalse = false // for reflect const fastpathCheckNilTrue = true // for type switch @@ -48,15 +50,15 @@ var fastpathTV fastpathT type fastpathE struct { rtid uintptr rt reflect.Type - encfn func(encFnInfo, reflect.Value) - decfn func(decFnInfo, reflect.Value) + encfn func(*encFnInfo, reflect.Value) + decfn func(*decFnInfo, reflect.Value) } -type fastpathA [239]fastpathE +type fastpathA [271]fastpathE func (x *fastpathA) index(rtid uintptr) int { // use binary search to grab the index (adapted from sort/search.go) - h, i, j := 0, 0, 239 // len(x) + h, i, j := 0, 0, 271 // len(x) for i < j { h = i + (j-i)/2 if x[h].rtid < rtid { @@ -65,7 +67,7 @@ func (x *fastpathA) index(rtid uintptr) int { j = h } } - if i < 239 && x[i].rtid == rtid { + if i < 271 && x[i].rtid == rtid { return i } return -1 @@ -81,11 +83,8 @@ var fastpathAV fastpathA // due to possible initialization loop error, make fastpath in an init() func init() { - if !fastpathEnabled { - return - } i := 0 - fn := func(v interface{}, fe func(encFnInfo, reflect.Value), fd func(decFnInfo, reflect.Value)) (f fastpathE) { + fn := func(v interface{}, fe func(*encFnInfo, reflect.Value), fd func(*decFnInfo, reflect.Value)) (f fastpathE) { xrt := reflect.TypeOf(v) xptr := reflect.ValueOf(xrt).Pointer() fastpathAV[i] = fastpathE{xptr, xrt, fe, fd} @@ -93,246 +92,278 @@ func init() { return } - fn([]interface{}(nil), (encFnInfo).fastpathEncSliceIntfR, (decFnInfo).fastpathDecSliceIntfR) - fn([]string(nil), (encFnInfo).fastpathEncSliceStringR, (decFnInfo).fastpathDecSliceStringR) - fn([]float32(nil), (encFnInfo).fastpathEncSliceFloat32R, (decFnInfo).fastpathDecSliceFloat32R) - fn([]float64(nil), (encFnInfo).fastpathEncSliceFloat64R, (decFnInfo).fastpathDecSliceFloat64R) - fn([]uint(nil), (encFnInfo).fastpathEncSliceUintR, (decFnInfo).fastpathDecSliceUintR) - fn([]uint16(nil), (encFnInfo).fastpathEncSliceUint16R, (decFnInfo).fastpathDecSliceUint16R) - fn([]uint32(nil), (encFnInfo).fastpathEncSliceUint32R, (decFnInfo).fastpathDecSliceUint32R) - fn([]uint64(nil), (encFnInfo).fastpathEncSliceUint64R, (decFnInfo).fastpathDecSliceUint64R) - fn([]int(nil), (encFnInfo).fastpathEncSliceIntR, (decFnInfo).fastpathDecSliceIntR) - fn([]int8(nil), (encFnInfo).fastpathEncSliceInt8R, (decFnInfo).fastpathDecSliceInt8R) - fn([]int16(nil), (encFnInfo).fastpathEncSliceInt16R, (decFnInfo).fastpathDecSliceInt16R) - fn([]int32(nil), (encFnInfo).fastpathEncSliceInt32R, (decFnInfo).fastpathDecSliceInt32R) - fn([]int64(nil), (encFnInfo).fastpathEncSliceInt64R, (decFnInfo).fastpathDecSliceInt64R) - fn([]bool(nil), (encFnInfo).fastpathEncSliceBoolR, (decFnInfo).fastpathDecSliceBoolR) + fn([]interface{}(nil), (*encFnInfo).fastpathEncSliceIntfR, (*decFnInfo).fastpathDecSliceIntfR) + fn([]string(nil), (*encFnInfo).fastpathEncSliceStringR, (*decFnInfo).fastpathDecSliceStringR) + fn([]float32(nil), (*encFnInfo).fastpathEncSliceFloat32R, (*decFnInfo).fastpathDecSliceFloat32R) + fn([]float64(nil), (*encFnInfo).fastpathEncSliceFloat64R, (*decFnInfo).fastpathDecSliceFloat64R) + fn([]uint(nil), (*encFnInfo).fastpathEncSliceUintR, (*decFnInfo).fastpathDecSliceUintR) + fn([]uint16(nil), (*encFnInfo).fastpathEncSliceUint16R, (*decFnInfo).fastpathDecSliceUint16R) + fn([]uint32(nil), (*encFnInfo).fastpathEncSliceUint32R, (*decFnInfo).fastpathDecSliceUint32R) + fn([]uint64(nil), (*encFnInfo).fastpathEncSliceUint64R, (*decFnInfo).fastpathDecSliceUint64R) + fn([]uintptr(nil), (*encFnInfo).fastpathEncSliceUintptrR, (*decFnInfo).fastpathDecSliceUintptrR) + fn([]int(nil), (*encFnInfo).fastpathEncSliceIntR, (*decFnInfo).fastpathDecSliceIntR) + fn([]int8(nil), (*encFnInfo).fastpathEncSliceInt8R, (*decFnInfo).fastpathDecSliceInt8R) + fn([]int16(nil), (*encFnInfo).fastpathEncSliceInt16R, (*decFnInfo).fastpathDecSliceInt16R) + fn([]int32(nil), (*encFnInfo).fastpathEncSliceInt32R, (*decFnInfo).fastpathDecSliceInt32R) + fn([]int64(nil), (*encFnInfo).fastpathEncSliceInt64R, (*decFnInfo).fastpathDecSliceInt64R) + fn([]bool(nil), (*encFnInfo).fastpathEncSliceBoolR, (*decFnInfo).fastpathDecSliceBoolR) - fn(map[interface{}]interface{}(nil), (encFnInfo).fastpathEncMapIntfIntfR, (decFnInfo).fastpathDecMapIntfIntfR) - fn(map[interface{}]string(nil), (encFnInfo).fastpathEncMapIntfStringR, (decFnInfo).fastpathDecMapIntfStringR) - fn(map[interface{}]uint(nil), (encFnInfo).fastpathEncMapIntfUintR, (decFnInfo).fastpathDecMapIntfUintR) - fn(map[interface{}]uint8(nil), (encFnInfo).fastpathEncMapIntfUint8R, (decFnInfo).fastpathDecMapIntfUint8R) - fn(map[interface{}]uint16(nil), (encFnInfo).fastpathEncMapIntfUint16R, (decFnInfo).fastpathDecMapIntfUint16R) - fn(map[interface{}]uint32(nil), (encFnInfo).fastpathEncMapIntfUint32R, (decFnInfo).fastpathDecMapIntfUint32R) - fn(map[interface{}]uint64(nil), (encFnInfo).fastpathEncMapIntfUint64R, (decFnInfo).fastpathDecMapIntfUint64R) - fn(map[interface{}]int(nil), (encFnInfo).fastpathEncMapIntfIntR, (decFnInfo).fastpathDecMapIntfIntR) - fn(map[interface{}]int8(nil), (encFnInfo).fastpathEncMapIntfInt8R, (decFnInfo).fastpathDecMapIntfInt8R) - fn(map[interface{}]int16(nil), (encFnInfo).fastpathEncMapIntfInt16R, (decFnInfo).fastpathDecMapIntfInt16R) - fn(map[interface{}]int32(nil), (encFnInfo).fastpathEncMapIntfInt32R, (decFnInfo).fastpathDecMapIntfInt32R) - fn(map[interface{}]int64(nil), (encFnInfo).fastpathEncMapIntfInt64R, (decFnInfo).fastpathDecMapIntfInt64R) - fn(map[interface{}]float32(nil), (encFnInfo).fastpathEncMapIntfFloat32R, (decFnInfo).fastpathDecMapIntfFloat32R) - fn(map[interface{}]float64(nil), (encFnInfo).fastpathEncMapIntfFloat64R, (decFnInfo).fastpathDecMapIntfFloat64R) - fn(map[interface{}]bool(nil), (encFnInfo).fastpathEncMapIntfBoolR, (decFnInfo).fastpathDecMapIntfBoolR) - fn(map[string]interface{}(nil), (encFnInfo).fastpathEncMapStringIntfR, (decFnInfo).fastpathDecMapStringIntfR) - fn(map[string]string(nil), (encFnInfo).fastpathEncMapStringStringR, (decFnInfo).fastpathDecMapStringStringR) - fn(map[string]uint(nil), (encFnInfo).fastpathEncMapStringUintR, (decFnInfo).fastpathDecMapStringUintR) - fn(map[string]uint8(nil), (encFnInfo).fastpathEncMapStringUint8R, (decFnInfo).fastpathDecMapStringUint8R) - fn(map[string]uint16(nil), (encFnInfo).fastpathEncMapStringUint16R, (decFnInfo).fastpathDecMapStringUint16R) - fn(map[string]uint32(nil), (encFnInfo).fastpathEncMapStringUint32R, (decFnInfo).fastpathDecMapStringUint32R) - fn(map[string]uint64(nil), (encFnInfo).fastpathEncMapStringUint64R, (decFnInfo).fastpathDecMapStringUint64R) - fn(map[string]int(nil), (encFnInfo).fastpathEncMapStringIntR, (decFnInfo).fastpathDecMapStringIntR) - fn(map[string]int8(nil), (encFnInfo).fastpathEncMapStringInt8R, (decFnInfo).fastpathDecMapStringInt8R) - fn(map[string]int16(nil), (encFnInfo).fastpathEncMapStringInt16R, (decFnInfo).fastpathDecMapStringInt16R) - fn(map[string]int32(nil), (encFnInfo).fastpathEncMapStringInt32R, (decFnInfo).fastpathDecMapStringInt32R) - fn(map[string]int64(nil), (encFnInfo).fastpathEncMapStringInt64R, (decFnInfo).fastpathDecMapStringInt64R) - fn(map[string]float32(nil), (encFnInfo).fastpathEncMapStringFloat32R, (decFnInfo).fastpathDecMapStringFloat32R) - fn(map[string]float64(nil), (encFnInfo).fastpathEncMapStringFloat64R, (decFnInfo).fastpathDecMapStringFloat64R) - fn(map[string]bool(nil), (encFnInfo).fastpathEncMapStringBoolR, (decFnInfo).fastpathDecMapStringBoolR) - fn(map[float32]interface{}(nil), (encFnInfo).fastpathEncMapFloat32IntfR, (decFnInfo).fastpathDecMapFloat32IntfR) - fn(map[float32]string(nil), (encFnInfo).fastpathEncMapFloat32StringR, (decFnInfo).fastpathDecMapFloat32StringR) - fn(map[float32]uint(nil), (encFnInfo).fastpathEncMapFloat32UintR, (decFnInfo).fastpathDecMapFloat32UintR) - fn(map[float32]uint8(nil), (encFnInfo).fastpathEncMapFloat32Uint8R, (decFnInfo).fastpathDecMapFloat32Uint8R) - fn(map[float32]uint16(nil), (encFnInfo).fastpathEncMapFloat32Uint16R, (decFnInfo).fastpathDecMapFloat32Uint16R) - fn(map[float32]uint32(nil), (encFnInfo).fastpathEncMapFloat32Uint32R, (decFnInfo).fastpathDecMapFloat32Uint32R) - fn(map[float32]uint64(nil), (encFnInfo).fastpathEncMapFloat32Uint64R, (decFnInfo).fastpathDecMapFloat32Uint64R) - fn(map[float32]int(nil), (encFnInfo).fastpathEncMapFloat32IntR, (decFnInfo).fastpathDecMapFloat32IntR) - fn(map[float32]int8(nil), (encFnInfo).fastpathEncMapFloat32Int8R, (decFnInfo).fastpathDecMapFloat32Int8R) - fn(map[float32]int16(nil), (encFnInfo).fastpathEncMapFloat32Int16R, (decFnInfo).fastpathDecMapFloat32Int16R) - fn(map[float32]int32(nil), (encFnInfo).fastpathEncMapFloat32Int32R, (decFnInfo).fastpathDecMapFloat32Int32R) - fn(map[float32]int64(nil), (encFnInfo).fastpathEncMapFloat32Int64R, (decFnInfo).fastpathDecMapFloat32Int64R) - fn(map[float32]float32(nil), (encFnInfo).fastpathEncMapFloat32Float32R, (decFnInfo).fastpathDecMapFloat32Float32R) - fn(map[float32]float64(nil), (encFnInfo).fastpathEncMapFloat32Float64R, (decFnInfo).fastpathDecMapFloat32Float64R) - fn(map[float32]bool(nil), (encFnInfo).fastpathEncMapFloat32BoolR, (decFnInfo).fastpathDecMapFloat32BoolR) - fn(map[float64]interface{}(nil), (encFnInfo).fastpathEncMapFloat64IntfR, (decFnInfo).fastpathDecMapFloat64IntfR) - fn(map[float64]string(nil), (encFnInfo).fastpathEncMapFloat64StringR, (decFnInfo).fastpathDecMapFloat64StringR) - fn(map[float64]uint(nil), (encFnInfo).fastpathEncMapFloat64UintR, (decFnInfo).fastpathDecMapFloat64UintR) - fn(map[float64]uint8(nil), (encFnInfo).fastpathEncMapFloat64Uint8R, (decFnInfo).fastpathDecMapFloat64Uint8R) - fn(map[float64]uint16(nil), (encFnInfo).fastpathEncMapFloat64Uint16R, (decFnInfo).fastpathDecMapFloat64Uint16R) - fn(map[float64]uint32(nil), (encFnInfo).fastpathEncMapFloat64Uint32R, (decFnInfo).fastpathDecMapFloat64Uint32R) - fn(map[float64]uint64(nil), (encFnInfo).fastpathEncMapFloat64Uint64R, (decFnInfo).fastpathDecMapFloat64Uint64R) - fn(map[float64]int(nil), (encFnInfo).fastpathEncMapFloat64IntR, (decFnInfo).fastpathDecMapFloat64IntR) - fn(map[float64]int8(nil), (encFnInfo).fastpathEncMapFloat64Int8R, (decFnInfo).fastpathDecMapFloat64Int8R) - fn(map[float64]int16(nil), (encFnInfo).fastpathEncMapFloat64Int16R, (decFnInfo).fastpathDecMapFloat64Int16R) - fn(map[float64]int32(nil), (encFnInfo).fastpathEncMapFloat64Int32R, (decFnInfo).fastpathDecMapFloat64Int32R) - fn(map[float64]int64(nil), (encFnInfo).fastpathEncMapFloat64Int64R, (decFnInfo).fastpathDecMapFloat64Int64R) - fn(map[float64]float32(nil), (encFnInfo).fastpathEncMapFloat64Float32R, (decFnInfo).fastpathDecMapFloat64Float32R) - fn(map[float64]float64(nil), (encFnInfo).fastpathEncMapFloat64Float64R, (decFnInfo).fastpathDecMapFloat64Float64R) - fn(map[float64]bool(nil), (encFnInfo).fastpathEncMapFloat64BoolR, (decFnInfo).fastpathDecMapFloat64BoolR) - fn(map[uint]interface{}(nil), (encFnInfo).fastpathEncMapUintIntfR, (decFnInfo).fastpathDecMapUintIntfR) - fn(map[uint]string(nil), (encFnInfo).fastpathEncMapUintStringR, (decFnInfo).fastpathDecMapUintStringR) - fn(map[uint]uint(nil), (encFnInfo).fastpathEncMapUintUintR, (decFnInfo).fastpathDecMapUintUintR) - fn(map[uint]uint8(nil), (encFnInfo).fastpathEncMapUintUint8R, (decFnInfo).fastpathDecMapUintUint8R) - fn(map[uint]uint16(nil), (encFnInfo).fastpathEncMapUintUint16R, (decFnInfo).fastpathDecMapUintUint16R) - fn(map[uint]uint32(nil), (encFnInfo).fastpathEncMapUintUint32R, (decFnInfo).fastpathDecMapUintUint32R) - fn(map[uint]uint64(nil), (encFnInfo).fastpathEncMapUintUint64R, (decFnInfo).fastpathDecMapUintUint64R) - fn(map[uint]int(nil), (encFnInfo).fastpathEncMapUintIntR, (decFnInfo).fastpathDecMapUintIntR) - fn(map[uint]int8(nil), (encFnInfo).fastpathEncMapUintInt8R, (decFnInfo).fastpathDecMapUintInt8R) - fn(map[uint]int16(nil), (encFnInfo).fastpathEncMapUintInt16R, (decFnInfo).fastpathDecMapUintInt16R) - fn(map[uint]int32(nil), (encFnInfo).fastpathEncMapUintInt32R, (decFnInfo).fastpathDecMapUintInt32R) - fn(map[uint]int64(nil), (encFnInfo).fastpathEncMapUintInt64R, (decFnInfo).fastpathDecMapUintInt64R) - fn(map[uint]float32(nil), (encFnInfo).fastpathEncMapUintFloat32R, (decFnInfo).fastpathDecMapUintFloat32R) - fn(map[uint]float64(nil), (encFnInfo).fastpathEncMapUintFloat64R, (decFnInfo).fastpathDecMapUintFloat64R) - fn(map[uint]bool(nil), (encFnInfo).fastpathEncMapUintBoolR, (decFnInfo).fastpathDecMapUintBoolR) - fn(map[uint8]interface{}(nil), (encFnInfo).fastpathEncMapUint8IntfR, (decFnInfo).fastpathDecMapUint8IntfR) - fn(map[uint8]string(nil), (encFnInfo).fastpathEncMapUint8StringR, (decFnInfo).fastpathDecMapUint8StringR) - fn(map[uint8]uint(nil), (encFnInfo).fastpathEncMapUint8UintR, (decFnInfo).fastpathDecMapUint8UintR) - fn(map[uint8]uint8(nil), (encFnInfo).fastpathEncMapUint8Uint8R, (decFnInfo).fastpathDecMapUint8Uint8R) - fn(map[uint8]uint16(nil), (encFnInfo).fastpathEncMapUint8Uint16R, (decFnInfo).fastpathDecMapUint8Uint16R) - fn(map[uint8]uint32(nil), (encFnInfo).fastpathEncMapUint8Uint32R, (decFnInfo).fastpathDecMapUint8Uint32R) - fn(map[uint8]uint64(nil), (encFnInfo).fastpathEncMapUint8Uint64R, (decFnInfo).fastpathDecMapUint8Uint64R) - fn(map[uint8]int(nil), (encFnInfo).fastpathEncMapUint8IntR, (decFnInfo).fastpathDecMapUint8IntR) - fn(map[uint8]int8(nil), (encFnInfo).fastpathEncMapUint8Int8R, (decFnInfo).fastpathDecMapUint8Int8R) - fn(map[uint8]int16(nil), (encFnInfo).fastpathEncMapUint8Int16R, (decFnInfo).fastpathDecMapUint8Int16R) - fn(map[uint8]int32(nil), (encFnInfo).fastpathEncMapUint8Int32R, (decFnInfo).fastpathDecMapUint8Int32R) - fn(map[uint8]int64(nil), (encFnInfo).fastpathEncMapUint8Int64R, (decFnInfo).fastpathDecMapUint8Int64R) - fn(map[uint8]float32(nil), (encFnInfo).fastpathEncMapUint8Float32R, (decFnInfo).fastpathDecMapUint8Float32R) - fn(map[uint8]float64(nil), (encFnInfo).fastpathEncMapUint8Float64R, (decFnInfo).fastpathDecMapUint8Float64R) - fn(map[uint8]bool(nil), (encFnInfo).fastpathEncMapUint8BoolR, (decFnInfo).fastpathDecMapUint8BoolR) - fn(map[uint16]interface{}(nil), (encFnInfo).fastpathEncMapUint16IntfR, (decFnInfo).fastpathDecMapUint16IntfR) - fn(map[uint16]string(nil), (encFnInfo).fastpathEncMapUint16StringR, (decFnInfo).fastpathDecMapUint16StringR) - fn(map[uint16]uint(nil), (encFnInfo).fastpathEncMapUint16UintR, (decFnInfo).fastpathDecMapUint16UintR) - fn(map[uint16]uint8(nil), (encFnInfo).fastpathEncMapUint16Uint8R, (decFnInfo).fastpathDecMapUint16Uint8R) - fn(map[uint16]uint16(nil), (encFnInfo).fastpathEncMapUint16Uint16R, (decFnInfo).fastpathDecMapUint16Uint16R) - fn(map[uint16]uint32(nil), (encFnInfo).fastpathEncMapUint16Uint32R, (decFnInfo).fastpathDecMapUint16Uint32R) - fn(map[uint16]uint64(nil), (encFnInfo).fastpathEncMapUint16Uint64R, (decFnInfo).fastpathDecMapUint16Uint64R) - fn(map[uint16]int(nil), (encFnInfo).fastpathEncMapUint16IntR, (decFnInfo).fastpathDecMapUint16IntR) - fn(map[uint16]int8(nil), (encFnInfo).fastpathEncMapUint16Int8R, (decFnInfo).fastpathDecMapUint16Int8R) - fn(map[uint16]int16(nil), (encFnInfo).fastpathEncMapUint16Int16R, (decFnInfo).fastpathDecMapUint16Int16R) - fn(map[uint16]int32(nil), (encFnInfo).fastpathEncMapUint16Int32R, (decFnInfo).fastpathDecMapUint16Int32R) - fn(map[uint16]int64(nil), (encFnInfo).fastpathEncMapUint16Int64R, (decFnInfo).fastpathDecMapUint16Int64R) - fn(map[uint16]float32(nil), (encFnInfo).fastpathEncMapUint16Float32R, (decFnInfo).fastpathDecMapUint16Float32R) - fn(map[uint16]float64(nil), (encFnInfo).fastpathEncMapUint16Float64R, (decFnInfo).fastpathDecMapUint16Float64R) - fn(map[uint16]bool(nil), (encFnInfo).fastpathEncMapUint16BoolR, (decFnInfo).fastpathDecMapUint16BoolR) - fn(map[uint32]interface{}(nil), (encFnInfo).fastpathEncMapUint32IntfR, (decFnInfo).fastpathDecMapUint32IntfR) - fn(map[uint32]string(nil), (encFnInfo).fastpathEncMapUint32StringR, (decFnInfo).fastpathDecMapUint32StringR) - fn(map[uint32]uint(nil), (encFnInfo).fastpathEncMapUint32UintR, (decFnInfo).fastpathDecMapUint32UintR) - fn(map[uint32]uint8(nil), (encFnInfo).fastpathEncMapUint32Uint8R, (decFnInfo).fastpathDecMapUint32Uint8R) - fn(map[uint32]uint16(nil), (encFnInfo).fastpathEncMapUint32Uint16R, (decFnInfo).fastpathDecMapUint32Uint16R) - fn(map[uint32]uint32(nil), (encFnInfo).fastpathEncMapUint32Uint32R, (decFnInfo).fastpathDecMapUint32Uint32R) - fn(map[uint32]uint64(nil), (encFnInfo).fastpathEncMapUint32Uint64R, (decFnInfo).fastpathDecMapUint32Uint64R) - fn(map[uint32]int(nil), (encFnInfo).fastpathEncMapUint32IntR, (decFnInfo).fastpathDecMapUint32IntR) - fn(map[uint32]int8(nil), (encFnInfo).fastpathEncMapUint32Int8R, (decFnInfo).fastpathDecMapUint32Int8R) - fn(map[uint32]int16(nil), (encFnInfo).fastpathEncMapUint32Int16R, (decFnInfo).fastpathDecMapUint32Int16R) - fn(map[uint32]int32(nil), (encFnInfo).fastpathEncMapUint32Int32R, (decFnInfo).fastpathDecMapUint32Int32R) - fn(map[uint32]int64(nil), (encFnInfo).fastpathEncMapUint32Int64R, (decFnInfo).fastpathDecMapUint32Int64R) - fn(map[uint32]float32(nil), (encFnInfo).fastpathEncMapUint32Float32R, (decFnInfo).fastpathDecMapUint32Float32R) - fn(map[uint32]float64(nil), (encFnInfo).fastpathEncMapUint32Float64R, (decFnInfo).fastpathDecMapUint32Float64R) - fn(map[uint32]bool(nil), (encFnInfo).fastpathEncMapUint32BoolR, (decFnInfo).fastpathDecMapUint32BoolR) - fn(map[uint64]interface{}(nil), (encFnInfo).fastpathEncMapUint64IntfR, (decFnInfo).fastpathDecMapUint64IntfR) - fn(map[uint64]string(nil), (encFnInfo).fastpathEncMapUint64StringR, (decFnInfo).fastpathDecMapUint64StringR) - fn(map[uint64]uint(nil), (encFnInfo).fastpathEncMapUint64UintR, (decFnInfo).fastpathDecMapUint64UintR) - fn(map[uint64]uint8(nil), (encFnInfo).fastpathEncMapUint64Uint8R, (decFnInfo).fastpathDecMapUint64Uint8R) - fn(map[uint64]uint16(nil), (encFnInfo).fastpathEncMapUint64Uint16R, (decFnInfo).fastpathDecMapUint64Uint16R) - fn(map[uint64]uint32(nil), (encFnInfo).fastpathEncMapUint64Uint32R, (decFnInfo).fastpathDecMapUint64Uint32R) - fn(map[uint64]uint64(nil), (encFnInfo).fastpathEncMapUint64Uint64R, (decFnInfo).fastpathDecMapUint64Uint64R) - fn(map[uint64]int(nil), (encFnInfo).fastpathEncMapUint64IntR, (decFnInfo).fastpathDecMapUint64IntR) - fn(map[uint64]int8(nil), (encFnInfo).fastpathEncMapUint64Int8R, (decFnInfo).fastpathDecMapUint64Int8R) - fn(map[uint64]int16(nil), (encFnInfo).fastpathEncMapUint64Int16R, (decFnInfo).fastpathDecMapUint64Int16R) - fn(map[uint64]int32(nil), (encFnInfo).fastpathEncMapUint64Int32R, (decFnInfo).fastpathDecMapUint64Int32R) - fn(map[uint64]int64(nil), (encFnInfo).fastpathEncMapUint64Int64R, (decFnInfo).fastpathDecMapUint64Int64R) - fn(map[uint64]float32(nil), (encFnInfo).fastpathEncMapUint64Float32R, (decFnInfo).fastpathDecMapUint64Float32R) - fn(map[uint64]float64(nil), (encFnInfo).fastpathEncMapUint64Float64R, (decFnInfo).fastpathDecMapUint64Float64R) - fn(map[uint64]bool(nil), (encFnInfo).fastpathEncMapUint64BoolR, (decFnInfo).fastpathDecMapUint64BoolR) - fn(map[int]interface{}(nil), (encFnInfo).fastpathEncMapIntIntfR, (decFnInfo).fastpathDecMapIntIntfR) - fn(map[int]string(nil), (encFnInfo).fastpathEncMapIntStringR, (decFnInfo).fastpathDecMapIntStringR) - fn(map[int]uint(nil), (encFnInfo).fastpathEncMapIntUintR, (decFnInfo).fastpathDecMapIntUintR) - fn(map[int]uint8(nil), (encFnInfo).fastpathEncMapIntUint8R, (decFnInfo).fastpathDecMapIntUint8R) - fn(map[int]uint16(nil), (encFnInfo).fastpathEncMapIntUint16R, (decFnInfo).fastpathDecMapIntUint16R) - fn(map[int]uint32(nil), (encFnInfo).fastpathEncMapIntUint32R, (decFnInfo).fastpathDecMapIntUint32R) - fn(map[int]uint64(nil), (encFnInfo).fastpathEncMapIntUint64R, (decFnInfo).fastpathDecMapIntUint64R) - fn(map[int]int(nil), (encFnInfo).fastpathEncMapIntIntR, (decFnInfo).fastpathDecMapIntIntR) - fn(map[int]int8(nil), (encFnInfo).fastpathEncMapIntInt8R, (decFnInfo).fastpathDecMapIntInt8R) - fn(map[int]int16(nil), (encFnInfo).fastpathEncMapIntInt16R, (decFnInfo).fastpathDecMapIntInt16R) - fn(map[int]int32(nil), (encFnInfo).fastpathEncMapIntInt32R, (decFnInfo).fastpathDecMapIntInt32R) - fn(map[int]int64(nil), (encFnInfo).fastpathEncMapIntInt64R, (decFnInfo).fastpathDecMapIntInt64R) - fn(map[int]float32(nil), (encFnInfo).fastpathEncMapIntFloat32R, (decFnInfo).fastpathDecMapIntFloat32R) - fn(map[int]float64(nil), (encFnInfo).fastpathEncMapIntFloat64R, (decFnInfo).fastpathDecMapIntFloat64R) - fn(map[int]bool(nil), (encFnInfo).fastpathEncMapIntBoolR, (decFnInfo).fastpathDecMapIntBoolR) - fn(map[int8]interface{}(nil), (encFnInfo).fastpathEncMapInt8IntfR, (decFnInfo).fastpathDecMapInt8IntfR) - fn(map[int8]string(nil), (encFnInfo).fastpathEncMapInt8StringR, (decFnInfo).fastpathDecMapInt8StringR) - fn(map[int8]uint(nil), (encFnInfo).fastpathEncMapInt8UintR, (decFnInfo).fastpathDecMapInt8UintR) - fn(map[int8]uint8(nil), (encFnInfo).fastpathEncMapInt8Uint8R, (decFnInfo).fastpathDecMapInt8Uint8R) - fn(map[int8]uint16(nil), (encFnInfo).fastpathEncMapInt8Uint16R, (decFnInfo).fastpathDecMapInt8Uint16R) - fn(map[int8]uint32(nil), (encFnInfo).fastpathEncMapInt8Uint32R, (decFnInfo).fastpathDecMapInt8Uint32R) - fn(map[int8]uint64(nil), (encFnInfo).fastpathEncMapInt8Uint64R, (decFnInfo).fastpathDecMapInt8Uint64R) - fn(map[int8]int(nil), (encFnInfo).fastpathEncMapInt8IntR, (decFnInfo).fastpathDecMapInt8IntR) - fn(map[int8]int8(nil), (encFnInfo).fastpathEncMapInt8Int8R, (decFnInfo).fastpathDecMapInt8Int8R) - fn(map[int8]int16(nil), (encFnInfo).fastpathEncMapInt8Int16R, (decFnInfo).fastpathDecMapInt8Int16R) - fn(map[int8]int32(nil), (encFnInfo).fastpathEncMapInt8Int32R, (decFnInfo).fastpathDecMapInt8Int32R) - fn(map[int8]int64(nil), (encFnInfo).fastpathEncMapInt8Int64R, (decFnInfo).fastpathDecMapInt8Int64R) - fn(map[int8]float32(nil), (encFnInfo).fastpathEncMapInt8Float32R, (decFnInfo).fastpathDecMapInt8Float32R) - fn(map[int8]float64(nil), (encFnInfo).fastpathEncMapInt8Float64R, (decFnInfo).fastpathDecMapInt8Float64R) - fn(map[int8]bool(nil), (encFnInfo).fastpathEncMapInt8BoolR, (decFnInfo).fastpathDecMapInt8BoolR) - fn(map[int16]interface{}(nil), (encFnInfo).fastpathEncMapInt16IntfR, (decFnInfo).fastpathDecMapInt16IntfR) - fn(map[int16]string(nil), (encFnInfo).fastpathEncMapInt16StringR, (decFnInfo).fastpathDecMapInt16StringR) - fn(map[int16]uint(nil), (encFnInfo).fastpathEncMapInt16UintR, (decFnInfo).fastpathDecMapInt16UintR) - fn(map[int16]uint8(nil), (encFnInfo).fastpathEncMapInt16Uint8R, (decFnInfo).fastpathDecMapInt16Uint8R) - fn(map[int16]uint16(nil), (encFnInfo).fastpathEncMapInt16Uint16R, (decFnInfo).fastpathDecMapInt16Uint16R) - fn(map[int16]uint32(nil), (encFnInfo).fastpathEncMapInt16Uint32R, (decFnInfo).fastpathDecMapInt16Uint32R) - fn(map[int16]uint64(nil), (encFnInfo).fastpathEncMapInt16Uint64R, (decFnInfo).fastpathDecMapInt16Uint64R) - fn(map[int16]int(nil), (encFnInfo).fastpathEncMapInt16IntR, (decFnInfo).fastpathDecMapInt16IntR) - fn(map[int16]int8(nil), (encFnInfo).fastpathEncMapInt16Int8R, (decFnInfo).fastpathDecMapInt16Int8R) - fn(map[int16]int16(nil), (encFnInfo).fastpathEncMapInt16Int16R, (decFnInfo).fastpathDecMapInt16Int16R) - fn(map[int16]int32(nil), (encFnInfo).fastpathEncMapInt16Int32R, (decFnInfo).fastpathDecMapInt16Int32R) - fn(map[int16]int64(nil), (encFnInfo).fastpathEncMapInt16Int64R, (decFnInfo).fastpathDecMapInt16Int64R) - fn(map[int16]float32(nil), (encFnInfo).fastpathEncMapInt16Float32R, (decFnInfo).fastpathDecMapInt16Float32R) - fn(map[int16]float64(nil), (encFnInfo).fastpathEncMapInt16Float64R, (decFnInfo).fastpathDecMapInt16Float64R) - fn(map[int16]bool(nil), (encFnInfo).fastpathEncMapInt16BoolR, (decFnInfo).fastpathDecMapInt16BoolR) - fn(map[int32]interface{}(nil), (encFnInfo).fastpathEncMapInt32IntfR, (decFnInfo).fastpathDecMapInt32IntfR) - fn(map[int32]string(nil), (encFnInfo).fastpathEncMapInt32StringR, (decFnInfo).fastpathDecMapInt32StringR) - fn(map[int32]uint(nil), (encFnInfo).fastpathEncMapInt32UintR, (decFnInfo).fastpathDecMapInt32UintR) - fn(map[int32]uint8(nil), (encFnInfo).fastpathEncMapInt32Uint8R, (decFnInfo).fastpathDecMapInt32Uint8R) - fn(map[int32]uint16(nil), (encFnInfo).fastpathEncMapInt32Uint16R, (decFnInfo).fastpathDecMapInt32Uint16R) - fn(map[int32]uint32(nil), (encFnInfo).fastpathEncMapInt32Uint32R, (decFnInfo).fastpathDecMapInt32Uint32R) - fn(map[int32]uint64(nil), (encFnInfo).fastpathEncMapInt32Uint64R, (decFnInfo).fastpathDecMapInt32Uint64R) - fn(map[int32]int(nil), (encFnInfo).fastpathEncMapInt32IntR, (decFnInfo).fastpathDecMapInt32IntR) - fn(map[int32]int8(nil), (encFnInfo).fastpathEncMapInt32Int8R, (decFnInfo).fastpathDecMapInt32Int8R) - fn(map[int32]int16(nil), (encFnInfo).fastpathEncMapInt32Int16R, (decFnInfo).fastpathDecMapInt32Int16R) - fn(map[int32]int32(nil), (encFnInfo).fastpathEncMapInt32Int32R, (decFnInfo).fastpathDecMapInt32Int32R) - fn(map[int32]int64(nil), (encFnInfo).fastpathEncMapInt32Int64R, (decFnInfo).fastpathDecMapInt32Int64R) - fn(map[int32]float32(nil), (encFnInfo).fastpathEncMapInt32Float32R, (decFnInfo).fastpathDecMapInt32Float32R) - fn(map[int32]float64(nil), (encFnInfo).fastpathEncMapInt32Float64R, (decFnInfo).fastpathDecMapInt32Float64R) - fn(map[int32]bool(nil), (encFnInfo).fastpathEncMapInt32BoolR, (decFnInfo).fastpathDecMapInt32BoolR) - fn(map[int64]interface{}(nil), (encFnInfo).fastpathEncMapInt64IntfR, (decFnInfo).fastpathDecMapInt64IntfR) - fn(map[int64]string(nil), (encFnInfo).fastpathEncMapInt64StringR, (decFnInfo).fastpathDecMapInt64StringR) - fn(map[int64]uint(nil), (encFnInfo).fastpathEncMapInt64UintR, (decFnInfo).fastpathDecMapInt64UintR) - fn(map[int64]uint8(nil), (encFnInfo).fastpathEncMapInt64Uint8R, (decFnInfo).fastpathDecMapInt64Uint8R) - fn(map[int64]uint16(nil), (encFnInfo).fastpathEncMapInt64Uint16R, (decFnInfo).fastpathDecMapInt64Uint16R) - fn(map[int64]uint32(nil), (encFnInfo).fastpathEncMapInt64Uint32R, (decFnInfo).fastpathDecMapInt64Uint32R) - fn(map[int64]uint64(nil), (encFnInfo).fastpathEncMapInt64Uint64R, (decFnInfo).fastpathDecMapInt64Uint64R) - fn(map[int64]int(nil), (encFnInfo).fastpathEncMapInt64IntR, (decFnInfo).fastpathDecMapInt64IntR) - fn(map[int64]int8(nil), (encFnInfo).fastpathEncMapInt64Int8R, (decFnInfo).fastpathDecMapInt64Int8R) - fn(map[int64]int16(nil), (encFnInfo).fastpathEncMapInt64Int16R, (decFnInfo).fastpathDecMapInt64Int16R) - fn(map[int64]int32(nil), (encFnInfo).fastpathEncMapInt64Int32R, (decFnInfo).fastpathDecMapInt64Int32R) - fn(map[int64]int64(nil), (encFnInfo).fastpathEncMapInt64Int64R, (decFnInfo).fastpathDecMapInt64Int64R) - fn(map[int64]float32(nil), (encFnInfo).fastpathEncMapInt64Float32R, (decFnInfo).fastpathDecMapInt64Float32R) - fn(map[int64]float64(nil), (encFnInfo).fastpathEncMapInt64Float64R, (decFnInfo).fastpathDecMapInt64Float64R) - fn(map[int64]bool(nil), (encFnInfo).fastpathEncMapInt64BoolR, (decFnInfo).fastpathDecMapInt64BoolR) - fn(map[bool]interface{}(nil), (encFnInfo).fastpathEncMapBoolIntfR, (decFnInfo).fastpathDecMapBoolIntfR) - fn(map[bool]string(nil), (encFnInfo).fastpathEncMapBoolStringR, (decFnInfo).fastpathDecMapBoolStringR) - fn(map[bool]uint(nil), (encFnInfo).fastpathEncMapBoolUintR, (decFnInfo).fastpathDecMapBoolUintR) - fn(map[bool]uint8(nil), (encFnInfo).fastpathEncMapBoolUint8R, (decFnInfo).fastpathDecMapBoolUint8R) - fn(map[bool]uint16(nil), (encFnInfo).fastpathEncMapBoolUint16R, (decFnInfo).fastpathDecMapBoolUint16R) - fn(map[bool]uint32(nil), (encFnInfo).fastpathEncMapBoolUint32R, (decFnInfo).fastpathDecMapBoolUint32R) - fn(map[bool]uint64(nil), (encFnInfo).fastpathEncMapBoolUint64R, (decFnInfo).fastpathDecMapBoolUint64R) - fn(map[bool]int(nil), (encFnInfo).fastpathEncMapBoolIntR, (decFnInfo).fastpathDecMapBoolIntR) - fn(map[bool]int8(nil), (encFnInfo).fastpathEncMapBoolInt8R, (decFnInfo).fastpathDecMapBoolInt8R) - fn(map[bool]int16(nil), (encFnInfo).fastpathEncMapBoolInt16R, (decFnInfo).fastpathDecMapBoolInt16R) - fn(map[bool]int32(nil), (encFnInfo).fastpathEncMapBoolInt32R, (decFnInfo).fastpathDecMapBoolInt32R) - fn(map[bool]int64(nil), (encFnInfo).fastpathEncMapBoolInt64R, (decFnInfo).fastpathDecMapBoolInt64R) - fn(map[bool]float32(nil), (encFnInfo).fastpathEncMapBoolFloat32R, (decFnInfo).fastpathDecMapBoolFloat32R) - fn(map[bool]float64(nil), (encFnInfo).fastpathEncMapBoolFloat64R, (decFnInfo).fastpathDecMapBoolFloat64R) - fn(map[bool]bool(nil), (encFnInfo).fastpathEncMapBoolBoolR, (decFnInfo).fastpathDecMapBoolBoolR) + fn(map[interface{}]interface{}(nil), (*encFnInfo).fastpathEncMapIntfIntfR, (*decFnInfo).fastpathDecMapIntfIntfR) + fn(map[interface{}]string(nil), (*encFnInfo).fastpathEncMapIntfStringR, (*decFnInfo).fastpathDecMapIntfStringR) + fn(map[interface{}]uint(nil), (*encFnInfo).fastpathEncMapIntfUintR, (*decFnInfo).fastpathDecMapIntfUintR) + fn(map[interface{}]uint8(nil), (*encFnInfo).fastpathEncMapIntfUint8R, (*decFnInfo).fastpathDecMapIntfUint8R) + fn(map[interface{}]uint16(nil), (*encFnInfo).fastpathEncMapIntfUint16R, (*decFnInfo).fastpathDecMapIntfUint16R) + fn(map[interface{}]uint32(nil), (*encFnInfo).fastpathEncMapIntfUint32R, (*decFnInfo).fastpathDecMapIntfUint32R) + fn(map[interface{}]uint64(nil), (*encFnInfo).fastpathEncMapIntfUint64R, (*decFnInfo).fastpathDecMapIntfUint64R) + fn(map[interface{}]uintptr(nil), (*encFnInfo).fastpathEncMapIntfUintptrR, (*decFnInfo).fastpathDecMapIntfUintptrR) + fn(map[interface{}]int(nil), (*encFnInfo).fastpathEncMapIntfIntR, (*decFnInfo).fastpathDecMapIntfIntR) + fn(map[interface{}]int8(nil), (*encFnInfo).fastpathEncMapIntfInt8R, (*decFnInfo).fastpathDecMapIntfInt8R) + fn(map[interface{}]int16(nil), (*encFnInfo).fastpathEncMapIntfInt16R, (*decFnInfo).fastpathDecMapIntfInt16R) + fn(map[interface{}]int32(nil), (*encFnInfo).fastpathEncMapIntfInt32R, (*decFnInfo).fastpathDecMapIntfInt32R) + fn(map[interface{}]int64(nil), (*encFnInfo).fastpathEncMapIntfInt64R, (*decFnInfo).fastpathDecMapIntfInt64R) + fn(map[interface{}]float32(nil), (*encFnInfo).fastpathEncMapIntfFloat32R, (*decFnInfo).fastpathDecMapIntfFloat32R) + fn(map[interface{}]float64(nil), (*encFnInfo).fastpathEncMapIntfFloat64R, (*decFnInfo).fastpathDecMapIntfFloat64R) + fn(map[interface{}]bool(nil), (*encFnInfo).fastpathEncMapIntfBoolR, (*decFnInfo).fastpathDecMapIntfBoolR) + fn(map[string]interface{}(nil), (*encFnInfo).fastpathEncMapStringIntfR, (*decFnInfo).fastpathDecMapStringIntfR) + fn(map[string]string(nil), (*encFnInfo).fastpathEncMapStringStringR, (*decFnInfo).fastpathDecMapStringStringR) + fn(map[string]uint(nil), (*encFnInfo).fastpathEncMapStringUintR, (*decFnInfo).fastpathDecMapStringUintR) + fn(map[string]uint8(nil), (*encFnInfo).fastpathEncMapStringUint8R, (*decFnInfo).fastpathDecMapStringUint8R) + fn(map[string]uint16(nil), (*encFnInfo).fastpathEncMapStringUint16R, (*decFnInfo).fastpathDecMapStringUint16R) + fn(map[string]uint32(nil), (*encFnInfo).fastpathEncMapStringUint32R, (*decFnInfo).fastpathDecMapStringUint32R) + fn(map[string]uint64(nil), (*encFnInfo).fastpathEncMapStringUint64R, (*decFnInfo).fastpathDecMapStringUint64R) + fn(map[string]uintptr(nil), (*encFnInfo).fastpathEncMapStringUintptrR, (*decFnInfo).fastpathDecMapStringUintptrR) + fn(map[string]int(nil), (*encFnInfo).fastpathEncMapStringIntR, (*decFnInfo).fastpathDecMapStringIntR) + fn(map[string]int8(nil), (*encFnInfo).fastpathEncMapStringInt8R, (*decFnInfo).fastpathDecMapStringInt8R) + fn(map[string]int16(nil), (*encFnInfo).fastpathEncMapStringInt16R, (*decFnInfo).fastpathDecMapStringInt16R) + fn(map[string]int32(nil), (*encFnInfo).fastpathEncMapStringInt32R, (*decFnInfo).fastpathDecMapStringInt32R) + fn(map[string]int64(nil), (*encFnInfo).fastpathEncMapStringInt64R, (*decFnInfo).fastpathDecMapStringInt64R) + fn(map[string]float32(nil), (*encFnInfo).fastpathEncMapStringFloat32R, (*decFnInfo).fastpathDecMapStringFloat32R) + fn(map[string]float64(nil), (*encFnInfo).fastpathEncMapStringFloat64R, (*decFnInfo).fastpathDecMapStringFloat64R) + fn(map[string]bool(nil), (*encFnInfo).fastpathEncMapStringBoolR, (*decFnInfo).fastpathDecMapStringBoolR) + fn(map[float32]interface{}(nil), (*encFnInfo).fastpathEncMapFloat32IntfR, (*decFnInfo).fastpathDecMapFloat32IntfR) + fn(map[float32]string(nil), (*encFnInfo).fastpathEncMapFloat32StringR, (*decFnInfo).fastpathDecMapFloat32StringR) + fn(map[float32]uint(nil), (*encFnInfo).fastpathEncMapFloat32UintR, (*decFnInfo).fastpathDecMapFloat32UintR) + fn(map[float32]uint8(nil), (*encFnInfo).fastpathEncMapFloat32Uint8R, (*decFnInfo).fastpathDecMapFloat32Uint8R) + fn(map[float32]uint16(nil), (*encFnInfo).fastpathEncMapFloat32Uint16R, (*decFnInfo).fastpathDecMapFloat32Uint16R) + fn(map[float32]uint32(nil), (*encFnInfo).fastpathEncMapFloat32Uint32R, (*decFnInfo).fastpathDecMapFloat32Uint32R) + fn(map[float32]uint64(nil), (*encFnInfo).fastpathEncMapFloat32Uint64R, (*decFnInfo).fastpathDecMapFloat32Uint64R) + fn(map[float32]uintptr(nil), (*encFnInfo).fastpathEncMapFloat32UintptrR, (*decFnInfo).fastpathDecMapFloat32UintptrR) + fn(map[float32]int(nil), (*encFnInfo).fastpathEncMapFloat32IntR, (*decFnInfo).fastpathDecMapFloat32IntR) + fn(map[float32]int8(nil), (*encFnInfo).fastpathEncMapFloat32Int8R, (*decFnInfo).fastpathDecMapFloat32Int8R) + fn(map[float32]int16(nil), (*encFnInfo).fastpathEncMapFloat32Int16R, (*decFnInfo).fastpathDecMapFloat32Int16R) + fn(map[float32]int32(nil), (*encFnInfo).fastpathEncMapFloat32Int32R, (*decFnInfo).fastpathDecMapFloat32Int32R) + fn(map[float32]int64(nil), (*encFnInfo).fastpathEncMapFloat32Int64R, (*decFnInfo).fastpathDecMapFloat32Int64R) + fn(map[float32]float32(nil), (*encFnInfo).fastpathEncMapFloat32Float32R, (*decFnInfo).fastpathDecMapFloat32Float32R) + fn(map[float32]float64(nil), (*encFnInfo).fastpathEncMapFloat32Float64R, (*decFnInfo).fastpathDecMapFloat32Float64R) + fn(map[float32]bool(nil), (*encFnInfo).fastpathEncMapFloat32BoolR, (*decFnInfo).fastpathDecMapFloat32BoolR) + fn(map[float64]interface{}(nil), (*encFnInfo).fastpathEncMapFloat64IntfR, (*decFnInfo).fastpathDecMapFloat64IntfR) + fn(map[float64]string(nil), (*encFnInfo).fastpathEncMapFloat64StringR, (*decFnInfo).fastpathDecMapFloat64StringR) + fn(map[float64]uint(nil), (*encFnInfo).fastpathEncMapFloat64UintR, (*decFnInfo).fastpathDecMapFloat64UintR) + fn(map[float64]uint8(nil), (*encFnInfo).fastpathEncMapFloat64Uint8R, (*decFnInfo).fastpathDecMapFloat64Uint8R) + fn(map[float64]uint16(nil), (*encFnInfo).fastpathEncMapFloat64Uint16R, (*decFnInfo).fastpathDecMapFloat64Uint16R) + fn(map[float64]uint32(nil), (*encFnInfo).fastpathEncMapFloat64Uint32R, (*decFnInfo).fastpathDecMapFloat64Uint32R) + fn(map[float64]uint64(nil), (*encFnInfo).fastpathEncMapFloat64Uint64R, (*decFnInfo).fastpathDecMapFloat64Uint64R) + fn(map[float64]uintptr(nil), (*encFnInfo).fastpathEncMapFloat64UintptrR, (*decFnInfo).fastpathDecMapFloat64UintptrR) + fn(map[float64]int(nil), (*encFnInfo).fastpathEncMapFloat64IntR, (*decFnInfo).fastpathDecMapFloat64IntR) + fn(map[float64]int8(nil), (*encFnInfo).fastpathEncMapFloat64Int8R, (*decFnInfo).fastpathDecMapFloat64Int8R) + fn(map[float64]int16(nil), (*encFnInfo).fastpathEncMapFloat64Int16R, (*decFnInfo).fastpathDecMapFloat64Int16R) + fn(map[float64]int32(nil), (*encFnInfo).fastpathEncMapFloat64Int32R, (*decFnInfo).fastpathDecMapFloat64Int32R) + fn(map[float64]int64(nil), (*encFnInfo).fastpathEncMapFloat64Int64R, (*decFnInfo).fastpathDecMapFloat64Int64R) + fn(map[float64]float32(nil), (*encFnInfo).fastpathEncMapFloat64Float32R, (*decFnInfo).fastpathDecMapFloat64Float32R) + fn(map[float64]float64(nil), (*encFnInfo).fastpathEncMapFloat64Float64R, (*decFnInfo).fastpathDecMapFloat64Float64R) + fn(map[float64]bool(nil), (*encFnInfo).fastpathEncMapFloat64BoolR, (*decFnInfo).fastpathDecMapFloat64BoolR) + fn(map[uint]interface{}(nil), (*encFnInfo).fastpathEncMapUintIntfR, (*decFnInfo).fastpathDecMapUintIntfR) + fn(map[uint]string(nil), (*encFnInfo).fastpathEncMapUintStringR, (*decFnInfo).fastpathDecMapUintStringR) + fn(map[uint]uint(nil), (*encFnInfo).fastpathEncMapUintUintR, (*decFnInfo).fastpathDecMapUintUintR) + fn(map[uint]uint8(nil), (*encFnInfo).fastpathEncMapUintUint8R, (*decFnInfo).fastpathDecMapUintUint8R) + fn(map[uint]uint16(nil), (*encFnInfo).fastpathEncMapUintUint16R, (*decFnInfo).fastpathDecMapUintUint16R) + fn(map[uint]uint32(nil), (*encFnInfo).fastpathEncMapUintUint32R, (*decFnInfo).fastpathDecMapUintUint32R) + fn(map[uint]uint64(nil), (*encFnInfo).fastpathEncMapUintUint64R, (*decFnInfo).fastpathDecMapUintUint64R) + fn(map[uint]uintptr(nil), (*encFnInfo).fastpathEncMapUintUintptrR, (*decFnInfo).fastpathDecMapUintUintptrR) + fn(map[uint]int(nil), (*encFnInfo).fastpathEncMapUintIntR, (*decFnInfo).fastpathDecMapUintIntR) + fn(map[uint]int8(nil), (*encFnInfo).fastpathEncMapUintInt8R, (*decFnInfo).fastpathDecMapUintInt8R) + fn(map[uint]int16(nil), (*encFnInfo).fastpathEncMapUintInt16R, (*decFnInfo).fastpathDecMapUintInt16R) + fn(map[uint]int32(nil), (*encFnInfo).fastpathEncMapUintInt32R, (*decFnInfo).fastpathDecMapUintInt32R) + fn(map[uint]int64(nil), (*encFnInfo).fastpathEncMapUintInt64R, (*decFnInfo).fastpathDecMapUintInt64R) + fn(map[uint]float32(nil), (*encFnInfo).fastpathEncMapUintFloat32R, (*decFnInfo).fastpathDecMapUintFloat32R) + fn(map[uint]float64(nil), (*encFnInfo).fastpathEncMapUintFloat64R, (*decFnInfo).fastpathDecMapUintFloat64R) + fn(map[uint]bool(nil), (*encFnInfo).fastpathEncMapUintBoolR, (*decFnInfo).fastpathDecMapUintBoolR) + fn(map[uint8]interface{}(nil), (*encFnInfo).fastpathEncMapUint8IntfR, (*decFnInfo).fastpathDecMapUint8IntfR) + fn(map[uint8]string(nil), (*encFnInfo).fastpathEncMapUint8StringR, (*decFnInfo).fastpathDecMapUint8StringR) + fn(map[uint8]uint(nil), (*encFnInfo).fastpathEncMapUint8UintR, (*decFnInfo).fastpathDecMapUint8UintR) + fn(map[uint8]uint8(nil), (*encFnInfo).fastpathEncMapUint8Uint8R, (*decFnInfo).fastpathDecMapUint8Uint8R) + fn(map[uint8]uint16(nil), (*encFnInfo).fastpathEncMapUint8Uint16R, (*decFnInfo).fastpathDecMapUint8Uint16R) + fn(map[uint8]uint32(nil), (*encFnInfo).fastpathEncMapUint8Uint32R, (*decFnInfo).fastpathDecMapUint8Uint32R) + fn(map[uint8]uint64(nil), (*encFnInfo).fastpathEncMapUint8Uint64R, (*decFnInfo).fastpathDecMapUint8Uint64R) + fn(map[uint8]uintptr(nil), (*encFnInfo).fastpathEncMapUint8UintptrR, (*decFnInfo).fastpathDecMapUint8UintptrR) + fn(map[uint8]int(nil), (*encFnInfo).fastpathEncMapUint8IntR, (*decFnInfo).fastpathDecMapUint8IntR) + fn(map[uint8]int8(nil), (*encFnInfo).fastpathEncMapUint8Int8R, (*decFnInfo).fastpathDecMapUint8Int8R) + fn(map[uint8]int16(nil), (*encFnInfo).fastpathEncMapUint8Int16R, (*decFnInfo).fastpathDecMapUint8Int16R) + fn(map[uint8]int32(nil), (*encFnInfo).fastpathEncMapUint8Int32R, (*decFnInfo).fastpathDecMapUint8Int32R) + fn(map[uint8]int64(nil), (*encFnInfo).fastpathEncMapUint8Int64R, (*decFnInfo).fastpathDecMapUint8Int64R) + fn(map[uint8]float32(nil), (*encFnInfo).fastpathEncMapUint8Float32R, (*decFnInfo).fastpathDecMapUint8Float32R) + fn(map[uint8]float64(nil), (*encFnInfo).fastpathEncMapUint8Float64R, (*decFnInfo).fastpathDecMapUint8Float64R) + fn(map[uint8]bool(nil), (*encFnInfo).fastpathEncMapUint8BoolR, (*decFnInfo).fastpathDecMapUint8BoolR) + fn(map[uint16]interface{}(nil), (*encFnInfo).fastpathEncMapUint16IntfR, (*decFnInfo).fastpathDecMapUint16IntfR) + fn(map[uint16]string(nil), (*encFnInfo).fastpathEncMapUint16StringR, (*decFnInfo).fastpathDecMapUint16StringR) + fn(map[uint16]uint(nil), (*encFnInfo).fastpathEncMapUint16UintR, (*decFnInfo).fastpathDecMapUint16UintR) + fn(map[uint16]uint8(nil), (*encFnInfo).fastpathEncMapUint16Uint8R, (*decFnInfo).fastpathDecMapUint16Uint8R) + fn(map[uint16]uint16(nil), (*encFnInfo).fastpathEncMapUint16Uint16R, (*decFnInfo).fastpathDecMapUint16Uint16R) + fn(map[uint16]uint32(nil), (*encFnInfo).fastpathEncMapUint16Uint32R, (*decFnInfo).fastpathDecMapUint16Uint32R) + fn(map[uint16]uint64(nil), (*encFnInfo).fastpathEncMapUint16Uint64R, (*decFnInfo).fastpathDecMapUint16Uint64R) + fn(map[uint16]uintptr(nil), (*encFnInfo).fastpathEncMapUint16UintptrR, (*decFnInfo).fastpathDecMapUint16UintptrR) + fn(map[uint16]int(nil), (*encFnInfo).fastpathEncMapUint16IntR, (*decFnInfo).fastpathDecMapUint16IntR) + fn(map[uint16]int8(nil), (*encFnInfo).fastpathEncMapUint16Int8R, (*decFnInfo).fastpathDecMapUint16Int8R) + fn(map[uint16]int16(nil), (*encFnInfo).fastpathEncMapUint16Int16R, (*decFnInfo).fastpathDecMapUint16Int16R) + fn(map[uint16]int32(nil), (*encFnInfo).fastpathEncMapUint16Int32R, (*decFnInfo).fastpathDecMapUint16Int32R) + fn(map[uint16]int64(nil), (*encFnInfo).fastpathEncMapUint16Int64R, (*decFnInfo).fastpathDecMapUint16Int64R) + fn(map[uint16]float32(nil), (*encFnInfo).fastpathEncMapUint16Float32R, (*decFnInfo).fastpathDecMapUint16Float32R) + fn(map[uint16]float64(nil), (*encFnInfo).fastpathEncMapUint16Float64R, (*decFnInfo).fastpathDecMapUint16Float64R) + fn(map[uint16]bool(nil), (*encFnInfo).fastpathEncMapUint16BoolR, (*decFnInfo).fastpathDecMapUint16BoolR) + fn(map[uint32]interface{}(nil), (*encFnInfo).fastpathEncMapUint32IntfR, (*decFnInfo).fastpathDecMapUint32IntfR) + fn(map[uint32]string(nil), (*encFnInfo).fastpathEncMapUint32StringR, (*decFnInfo).fastpathDecMapUint32StringR) + fn(map[uint32]uint(nil), (*encFnInfo).fastpathEncMapUint32UintR, (*decFnInfo).fastpathDecMapUint32UintR) + fn(map[uint32]uint8(nil), (*encFnInfo).fastpathEncMapUint32Uint8R, (*decFnInfo).fastpathDecMapUint32Uint8R) + fn(map[uint32]uint16(nil), (*encFnInfo).fastpathEncMapUint32Uint16R, (*decFnInfo).fastpathDecMapUint32Uint16R) + fn(map[uint32]uint32(nil), (*encFnInfo).fastpathEncMapUint32Uint32R, (*decFnInfo).fastpathDecMapUint32Uint32R) + fn(map[uint32]uint64(nil), (*encFnInfo).fastpathEncMapUint32Uint64R, (*decFnInfo).fastpathDecMapUint32Uint64R) + fn(map[uint32]uintptr(nil), (*encFnInfo).fastpathEncMapUint32UintptrR, (*decFnInfo).fastpathDecMapUint32UintptrR) + fn(map[uint32]int(nil), (*encFnInfo).fastpathEncMapUint32IntR, (*decFnInfo).fastpathDecMapUint32IntR) + fn(map[uint32]int8(nil), (*encFnInfo).fastpathEncMapUint32Int8R, (*decFnInfo).fastpathDecMapUint32Int8R) + fn(map[uint32]int16(nil), (*encFnInfo).fastpathEncMapUint32Int16R, (*decFnInfo).fastpathDecMapUint32Int16R) + fn(map[uint32]int32(nil), (*encFnInfo).fastpathEncMapUint32Int32R, (*decFnInfo).fastpathDecMapUint32Int32R) + fn(map[uint32]int64(nil), (*encFnInfo).fastpathEncMapUint32Int64R, (*decFnInfo).fastpathDecMapUint32Int64R) + fn(map[uint32]float32(nil), (*encFnInfo).fastpathEncMapUint32Float32R, (*decFnInfo).fastpathDecMapUint32Float32R) + fn(map[uint32]float64(nil), (*encFnInfo).fastpathEncMapUint32Float64R, (*decFnInfo).fastpathDecMapUint32Float64R) + fn(map[uint32]bool(nil), (*encFnInfo).fastpathEncMapUint32BoolR, (*decFnInfo).fastpathDecMapUint32BoolR) + fn(map[uint64]interface{}(nil), (*encFnInfo).fastpathEncMapUint64IntfR, (*decFnInfo).fastpathDecMapUint64IntfR) + fn(map[uint64]string(nil), (*encFnInfo).fastpathEncMapUint64StringR, (*decFnInfo).fastpathDecMapUint64StringR) + fn(map[uint64]uint(nil), (*encFnInfo).fastpathEncMapUint64UintR, (*decFnInfo).fastpathDecMapUint64UintR) + fn(map[uint64]uint8(nil), (*encFnInfo).fastpathEncMapUint64Uint8R, (*decFnInfo).fastpathDecMapUint64Uint8R) + fn(map[uint64]uint16(nil), (*encFnInfo).fastpathEncMapUint64Uint16R, (*decFnInfo).fastpathDecMapUint64Uint16R) + fn(map[uint64]uint32(nil), (*encFnInfo).fastpathEncMapUint64Uint32R, (*decFnInfo).fastpathDecMapUint64Uint32R) + fn(map[uint64]uint64(nil), (*encFnInfo).fastpathEncMapUint64Uint64R, (*decFnInfo).fastpathDecMapUint64Uint64R) + fn(map[uint64]uintptr(nil), (*encFnInfo).fastpathEncMapUint64UintptrR, (*decFnInfo).fastpathDecMapUint64UintptrR) + fn(map[uint64]int(nil), (*encFnInfo).fastpathEncMapUint64IntR, (*decFnInfo).fastpathDecMapUint64IntR) + fn(map[uint64]int8(nil), (*encFnInfo).fastpathEncMapUint64Int8R, (*decFnInfo).fastpathDecMapUint64Int8R) + fn(map[uint64]int16(nil), (*encFnInfo).fastpathEncMapUint64Int16R, (*decFnInfo).fastpathDecMapUint64Int16R) + fn(map[uint64]int32(nil), (*encFnInfo).fastpathEncMapUint64Int32R, (*decFnInfo).fastpathDecMapUint64Int32R) + fn(map[uint64]int64(nil), (*encFnInfo).fastpathEncMapUint64Int64R, (*decFnInfo).fastpathDecMapUint64Int64R) + fn(map[uint64]float32(nil), (*encFnInfo).fastpathEncMapUint64Float32R, (*decFnInfo).fastpathDecMapUint64Float32R) + fn(map[uint64]float64(nil), (*encFnInfo).fastpathEncMapUint64Float64R, (*decFnInfo).fastpathDecMapUint64Float64R) + fn(map[uint64]bool(nil), (*encFnInfo).fastpathEncMapUint64BoolR, (*decFnInfo).fastpathDecMapUint64BoolR) + fn(map[uintptr]interface{}(nil), (*encFnInfo).fastpathEncMapUintptrIntfR, (*decFnInfo).fastpathDecMapUintptrIntfR) + fn(map[uintptr]string(nil), (*encFnInfo).fastpathEncMapUintptrStringR, (*decFnInfo).fastpathDecMapUintptrStringR) + fn(map[uintptr]uint(nil), (*encFnInfo).fastpathEncMapUintptrUintR, (*decFnInfo).fastpathDecMapUintptrUintR) + fn(map[uintptr]uint8(nil), (*encFnInfo).fastpathEncMapUintptrUint8R, (*decFnInfo).fastpathDecMapUintptrUint8R) + fn(map[uintptr]uint16(nil), (*encFnInfo).fastpathEncMapUintptrUint16R, (*decFnInfo).fastpathDecMapUintptrUint16R) + fn(map[uintptr]uint32(nil), (*encFnInfo).fastpathEncMapUintptrUint32R, (*decFnInfo).fastpathDecMapUintptrUint32R) + fn(map[uintptr]uint64(nil), (*encFnInfo).fastpathEncMapUintptrUint64R, (*decFnInfo).fastpathDecMapUintptrUint64R) + fn(map[uintptr]uintptr(nil), (*encFnInfo).fastpathEncMapUintptrUintptrR, (*decFnInfo).fastpathDecMapUintptrUintptrR) + fn(map[uintptr]int(nil), (*encFnInfo).fastpathEncMapUintptrIntR, (*decFnInfo).fastpathDecMapUintptrIntR) + fn(map[uintptr]int8(nil), (*encFnInfo).fastpathEncMapUintptrInt8R, (*decFnInfo).fastpathDecMapUintptrInt8R) + fn(map[uintptr]int16(nil), (*encFnInfo).fastpathEncMapUintptrInt16R, (*decFnInfo).fastpathDecMapUintptrInt16R) + fn(map[uintptr]int32(nil), (*encFnInfo).fastpathEncMapUintptrInt32R, (*decFnInfo).fastpathDecMapUintptrInt32R) + fn(map[uintptr]int64(nil), (*encFnInfo).fastpathEncMapUintptrInt64R, (*decFnInfo).fastpathDecMapUintptrInt64R) + fn(map[uintptr]float32(nil), (*encFnInfo).fastpathEncMapUintptrFloat32R, (*decFnInfo).fastpathDecMapUintptrFloat32R) + fn(map[uintptr]float64(nil), (*encFnInfo).fastpathEncMapUintptrFloat64R, (*decFnInfo).fastpathDecMapUintptrFloat64R) + fn(map[uintptr]bool(nil), (*encFnInfo).fastpathEncMapUintptrBoolR, (*decFnInfo).fastpathDecMapUintptrBoolR) + fn(map[int]interface{}(nil), (*encFnInfo).fastpathEncMapIntIntfR, (*decFnInfo).fastpathDecMapIntIntfR) + fn(map[int]string(nil), (*encFnInfo).fastpathEncMapIntStringR, (*decFnInfo).fastpathDecMapIntStringR) + fn(map[int]uint(nil), (*encFnInfo).fastpathEncMapIntUintR, (*decFnInfo).fastpathDecMapIntUintR) + fn(map[int]uint8(nil), (*encFnInfo).fastpathEncMapIntUint8R, (*decFnInfo).fastpathDecMapIntUint8R) + fn(map[int]uint16(nil), (*encFnInfo).fastpathEncMapIntUint16R, (*decFnInfo).fastpathDecMapIntUint16R) + fn(map[int]uint32(nil), (*encFnInfo).fastpathEncMapIntUint32R, (*decFnInfo).fastpathDecMapIntUint32R) + fn(map[int]uint64(nil), (*encFnInfo).fastpathEncMapIntUint64R, (*decFnInfo).fastpathDecMapIntUint64R) + fn(map[int]uintptr(nil), (*encFnInfo).fastpathEncMapIntUintptrR, (*decFnInfo).fastpathDecMapIntUintptrR) + fn(map[int]int(nil), (*encFnInfo).fastpathEncMapIntIntR, (*decFnInfo).fastpathDecMapIntIntR) + fn(map[int]int8(nil), (*encFnInfo).fastpathEncMapIntInt8R, (*decFnInfo).fastpathDecMapIntInt8R) + fn(map[int]int16(nil), (*encFnInfo).fastpathEncMapIntInt16R, (*decFnInfo).fastpathDecMapIntInt16R) + fn(map[int]int32(nil), (*encFnInfo).fastpathEncMapIntInt32R, (*decFnInfo).fastpathDecMapIntInt32R) + fn(map[int]int64(nil), (*encFnInfo).fastpathEncMapIntInt64R, (*decFnInfo).fastpathDecMapIntInt64R) + fn(map[int]float32(nil), (*encFnInfo).fastpathEncMapIntFloat32R, (*decFnInfo).fastpathDecMapIntFloat32R) + fn(map[int]float64(nil), (*encFnInfo).fastpathEncMapIntFloat64R, (*decFnInfo).fastpathDecMapIntFloat64R) + fn(map[int]bool(nil), (*encFnInfo).fastpathEncMapIntBoolR, (*decFnInfo).fastpathDecMapIntBoolR) + fn(map[int8]interface{}(nil), (*encFnInfo).fastpathEncMapInt8IntfR, (*decFnInfo).fastpathDecMapInt8IntfR) + fn(map[int8]string(nil), (*encFnInfo).fastpathEncMapInt8StringR, (*decFnInfo).fastpathDecMapInt8StringR) + fn(map[int8]uint(nil), (*encFnInfo).fastpathEncMapInt8UintR, (*decFnInfo).fastpathDecMapInt8UintR) + fn(map[int8]uint8(nil), (*encFnInfo).fastpathEncMapInt8Uint8R, (*decFnInfo).fastpathDecMapInt8Uint8R) + fn(map[int8]uint16(nil), (*encFnInfo).fastpathEncMapInt8Uint16R, (*decFnInfo).fastpathDecMapInt8Uint16R) + fn(map[int8]uint32(nil), (*encFnInfo).fastpathEncMapInt8Uint32R, (*decFnInfo).fastpathDecMapInt8Uint32R) + fn(map[int8]uint64(nil), (*encFnInfo).fastpathEncMapInt8Uint64R, (*decFnInfo).fastpathDecMapInt8Uint64R) + fn(map[int8]uintptr(nil), (*encFnInfo).fastpathEncMapInt8UintptrR, (*decFnInfo).fastpathDecMapInt8UintptrR) + fn(map[int8]int(nil), (*encFnInfo).fastpathEncMapInt8IntR, (*decFnInfo).fastpathDecMapInt8IntR) + fn(map[int8]int8(nil), (*encFnInfo).fastpathEncMapInt8Int8R, (*decFnInfo).fastpathDecMapInt8Int8R) + fn(map[int8]int16(nil), (*encFnInfo).fastpathEncMapInt8Int16R, (*decFnInfo).fastpathDecMapInt8Int16R) + fn(map[int8]int32(nil), (*encFnInfo).fastpathEncMapInt8Int32R, (*decFnInfo).fastpathDecMapInt8Int32R) + fn(map[int8]int64(nil), (*encFnInfo).fastpathEncMapInt8Int64R, (*decFnInfo).fastpathDecMapInt8Int64R) + fn(map[int8]float32(nil), (*encFnInfo).fastpathEncMapInt8Float32R, (*decFnInfo).fastpathDecMapInt8Float32R) + fn(map[int8]float64(nil), (*encFnInfo).fastpathEncMapInt8Float64R, (*decFnInfo).fastpathDecMapInt8Float64R) + fn(map[int8]bool(nil), (*encFnInfo).fastpathEncMapInt8BoolR, (*decFnInfo).fastpathDecMapInt8BoolR) + fn(map[int16]interface{}(nil), (*encFnInfo).fastpathEncMapInt16IntfR, (*decFnInfo).fastpathDecMapInt16IntfR) + fn(map[int16]string(nil), (*encFnInfo).fastpathEncMapInt16StringR, (*decFnInfo).fastpathDecMapInt16StringR) + fn(map[int16]uint(nil), (*encFnInfo).fastpathEncMapInt16UintR, (*decFnInfo).fastpathDecMapInt16UintR) + fn(map[int16]uint8(nil), (*encFnInfo).fastpathEncMapInt16Uint8R, (*decFnInfo).fastpathDecMapInt16Uint8R) + fn(map[int16]uint16(nil), (*encFnInfo).fastpathEncMapInt16Uint16R, (*decFnInfo).fastpathDecMapInt16Uint16R) + fn(map[int16]uint32(nil), (*encFnInfo).fastpathEncMapInt16Uint32R, (*decFnInfo).fastpathDecMapInt16Uint32R) + fn(map[int16]uint64(nil), (*encFnInfo).fastpathEncMapInt16Uint64R, (*decFnInfo).fastpathDecMapInt16Uint64R) + fn(map[int16]uintptr(nil), (*encFnInfo).fastpathEncMapInt16UintptrR, (*decFnInfo).fastpathDecMapInt16UintptrR) + fn(map[int16]int(nil), (*encFnInfo).fastpathEncMapInt16IntR, (*decFnInfo).fastpathDecMapInt16IntR) + fn(map[int16]int8(nil), (*encFnInfo).fastpathEncMapInt16Int8R, (*decFnInfo).fastpathDecMapInt16Int8R) + fn(map[int16]int16(nil), (*encFnInfo).fastpathEncMapInt16Int16R, (*decFnInfo).fastpathDecMapInt16Int16R) + fn(map[int16]int32(nil), (*encFnInfo).fastpathEncMapInt16Int32R, (*decFnInfo).fastpathDecMapInt16Int32R) + fn(map[int16]int64(nil), (*encFnInfo).fastpathEncMapInt16Int64R, (*decFnInfo).fastpathDecMapInt16Int64R) + fn(map[int16]float32(nil), (*encFnInfo).fastpathEncMapInt16Float32R, (*decFnInfo).fastpathDecMapInt16Float32R) + fn(map[int16]float64(nil), (*encFnInfo).fastpathEncMapInt16Float64R, (*decFnInfo).fastpathDecMapInt16Float64R) + fn(map[int16]bool(nil), (*encFnInfo).fastpathEncMapInt16BoolR, (*decFnInfo).fastpathDecMapInt16BoolR) + fn(map[int32]interface{}(nil), (*encFnInfo).fastpathEncMapInt32IntfR, (*decFnInfo).fastpathDecMapInt32IntfR) + fn(map[int32]string(nil), (*encFnInfo).fastpathEncMapInt32StringR, (*decFnInfo).fastpathDecMapInt32StringR) + fn(map[int32]uint(nil), (*encFnInfo).fastpathEncMapInt32UintR, (*decFnInfo).fastpathDecMapInt32UintR) + fn(map[int32]uint8(nil), (*encFnInfo).fastpathEncMapInt32Uint8R, (*decFnInfo).fastpathDecMapInt32Uint8R) + fn(map[int32]uint16(nil), (*encFnInfo).fastpathEncMapInt32Uint16R, (*decFnInfo).fastpathDecMapInt32Uint16R) + fn(map[int32]uint32(nil), (*encFnInfo).fastpathEncMapInt32Uint32R, (*decFnInfo).fastpathDecMapInt32Uint32R) + fn(map[int32]uint64(nil), (*encFnInfo).fastpathEncMapInt32Uint64R, (*decFnInfo).fastpathDecMapInt32Uint64R) + fn(map[int32]uintptr(nil), (*encFnInfo).fastpathEncMapInt32UintptrR, (*decFnInfo).fastpathDecMapInt32UintptrR) + fn(map[int32]int(nil), (*encFnInfo).fastpathEncMapInt32IntR, (*decFnInfo).fastpathDecMapInt32IntR) + fn(map[int32]int8(nil), (*encFnInfo).fastpathEncMapInt32Int8R, (*decFnInfo).fastpathDecMapInt32Int8R) + fn(map[int32]int16(nil), (*encFnInfo).fastpathEncMapInt32Int16R, (*decFnInfo).fastpathDecMapInt32Int16R) + fn(map[int32]int32(nil), (*encFnInfo).fastpathEncMapInt32Int32R, (*decFnInfo).fastpathDecMapInt32Int32R) + fn(map[int32]int64(nil), (*encFnInfo).fastpathEncMapInt32Int64R, (*decFnInfo).fastpathDecMapInt32Int64R) + fn(map[int32]float32(nil), (*encFnInfo).fastpathEncMapInt32Float32R, (*decFnInfo).fastpathDecMapInt32Float32R) + fn(map[int32]float64(nil), (*encFnInfo).fastpathEncMapInt32Float64R, (*decFnInfo).fastpathDecMapInt32Float64R) + fn(map[int32]bool(nil), (*encFnInfo).fastpathEncMapInt32BoolR, (*decFnInfo).fastpathDecMapInt32BoolR) + fn(map[int64]interface{}(nil), (*encFnInfo).fastpathEncMapInt64IntfR, (*decFnInfo).fastpathDecMapInt64IntfR) + fn(map[int64]string(nil), (*encFnInfo).fastpathEncMapInt64StringR, (*decFnInfo).fastpathDecMapInt64StringR) + fn(map[int64]uint(nil), (*encFnInfo).fastpathEncMapInt64UintR, (*decFnInfo).fastpathDecMapInt64UintR) + fn(map[int64]uint8(nil), (*encFnInfo).fastpathEncMapInt64Uint8R, (*decFnInfo).fastpathDecMapInt64Uint8R) + fn(map[int64]uint16(nil), (*encFnInfo).fastpathEncMapInt64Uint16R, (*decFnInfo).fastpathDecMapInt64Uint16R) + fn(map[int64]uint32(nil), (*encFnInfo).fastpathEncMapInt64Uint32R, (*decFnInfo).fastpathDecMapInt64Uint32R) + fn(map[int64]uint64(nil), (*encFnInfo).fastpathEncMapInt64Uint64R, (*decFnInfo).fastpathDecMapInt64Uint64R) + fn(map[int64]uintptr(nil), (*encFnInfo).fastpathEncMapInt64UintptrR, (*decFnInfo).fastpathDecMapInt64UintptrR) + fn(map[int64]int(nil), (*encFnInfo).fastpathEncMapInt64IntR, (*decFnInfo).fastpathDecMapInt64IntR) + fn(map[int64]int8(nil), (*encFnInfo).fastpathEncMapInt64Int8R, (*decFnInfo).fastpathDecMapInt64Int8R) + fn(map[int64]int16(nil), (*encFnInfo).fastpathEncMapInt64Int16R, (*decFnInfo).fastpathDecMapInt64Int16R) + fn(map[int64]int32(nil), (*encFnInfo).fastpathEncMapInt64Int32R, (*decFnInfo).fastpathDecMapInt64Int32R) + fn(map[int64]int64(nil), (*encFnInfo).fastpathEncMapInt64Int64R, (*decFnInfo).fastpathDecMapInt64Int64R) + fn(map[int64]float32(nil), (*encFnInfo).fastpathEncMapInt64Float32R, (*decFnInfo).fastpathDecMapInt64Float32R) + fn(map[int64]float64(nil), (*encFnInfo).fastpathEncMapInt64Float64R, (*decFnInfo).fastpathDecMapInt64Float64R) + fn(map[int64]bool(nil), (*encFnInfo).fastpathEncMapInt64BoolR, (*decFnInfo).fastpathDecMapInt64BoolR) + fn(map[bool]interface{}(nil), (*encFnInfo).fastpathEncMapBoolIntfR, (*decFnInfo).fastpathDecMapBoolIntfR) + fn(map[bool]string(nil), (*encFnInfo).fastpathEncMapBoolStringR, (*decFnInfo).fastpathDecMapBoolStringR) + fn(map[bool]uint(nil), (*encFnInfo).fastpathEncMapBoolUintR, (*decFnInfo).fastpathDecMapBoolUintR) + fn(map[bool]uint8(nil), (*encFnInfo).fastpathEncMapBoolUint8R, (*decFnInfo).fastpathDecMapBoolUint8R) + fn(map[bool]uint16(nil), (*encFnInfo).fastpathEncMapBoolUint16R, (*decFnInfo).fastpathDecMapBoolUint16R) + fn(map[bool]uint32(nil), (*encFnInfo).fastpathEncMapBoolUint32R, (*decFnInfo).fastpathDecMapBoolUint32R) + fn(map[bool]uint64(nil), (*encFnInfo).fastpathEncMapBoolUint64R, (*decFnInfo).fastpathDecMapBoolUint64R) + fn(map[bool]uintptr(nil), (*encFnInfo).fastpathEncMapBoolUintptrR, (*decFnInfo).fastpathDecMapBoolUintptrR) + fn(map[bool]int(nil), (*encFnInfo).fastpathEncMapBoolIntR, (*decFnInfo).fastpathDecMapBoolIntR) + fn(map[bool]int8(nil), (*encFnInfo).fastpathEncMapBoolInt8R, (*decFnInfo).fastpathDecMapBoolInt8R) + fn(map[bool]int16(nil), (*encFnInfo).fastpathEncMapBoolInt16R, (*decFnInfo).fastpathDecMapBoolInt16R) + fn(map[bool]int32(nil), (*encFnInfo).fastpathEncMapBoolInt32R, (*decFnInfo).fastpathDecMapBoolInt32R) + fn(map[bool]int64(nil), (*encFnInfo).fastpathEncMapBoolInt64R, (*decFnInfo).fastpathDecMapBoolInt64R) + fn(map[bool]float32(nil), (*encFnInfo).fastpathEncMapBoolFloat32R, (*decFnInfo).fastpathDecMapBoolFloat32R) + fn(map[bool]float64(nil), (*encFnInfo).fastpathEncMapBoolFloat64R, (*decFnInfo).fastpathDecMapBoolFloat64R) + fn(map[bool]bool(nil), (*encFnInfo).fastpathEncMapBoolBoolR, (*decFnInfo).fastpathDecMapBoolBoolR) sort.Sort(fastpathAslice(fastpathAV[:])) } @@ -383,6 +414,11 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { case *map[interface{}]uint64: fastpathTV.EncMapIntfUint64V(*v, fastpathCheckNilTrue, e) + case map[interface{}]uintptr: + fastpathTV.EncMapIntfUintptrV(v, fastpathCheckNilTrue, e) + case *map[interface{}]uintptr: + fastpathTV.EncMapIntfUintptrV(*v, fastpathCheckNilTrue, e) + case map[interface{}]int: fastpathTV.EncMapIntfIntV(v, fastpathCheckNilTrue, e) case *map[interface{}]int: @@ -463,6 +499,11 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { case *map[string]uint64: fastpathTV.EncMapStringUint64V(*v, fastpathCheckNilTrue, e) + case map[string]uintptr: + fastpathTV.EncMapStringUintptrV(v, fastpathCheckNilTrue, e) + case *map[string]uintptr: + fastpathTV.EncMapStringUintptrV(*v, fastpathCheckNilTrue, e) + case map[string]int: fastpathTV.EncMapStringIntV(v, fastpathCheckNilTrue, e) case *map[string]int: @@ -543,6 +584,11 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { case *map[float32]uint64: fastpathTV.EncMapFloat32Uint64V(*v, fastpathCheckNilTrue, e) + case map[float32]uintptr: + fastpathTV.EncMapFloat32UintptrV(v, fastpathCheckNilTrue, e) + case *map[float32]uintptr: + fastpathTV.EncMapFloat32UintptrV(*v, fastpathCheckNilTrue, e) + case map[float32]int: fastpathTV.EncMapFloat32IntV(v, fastpathCheckNilTrue, e) case *map[float32]int: @@ -623,6 +669,11 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { case *map[float64]uint64: fastpathTV.EncMapFloat64Uint64V(*v, fastpathCheckNilTrue, e) + case map[float64]uintptr: + fastpathTV.EncMapFloat64UintptrV(v, fastpathCheckNilTrue, e) + case *map[float64]uintptr: + fastpathTV.EncMapFloat64UintptrV(*v, fastpathCheckNilTrue, e) + case map[float64]int: fastpathTV.EncMapFloat64IntV(v, fastpathCheckNilTrue, e) case *map[float64]int: @@ -703,6 +754,11 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { case *map[uint]uint64: fastpathTV.EncMapUintUint64V(*v, fastpathCheckNilTrue, e) + case map[uint]uintptr: + fastpathTV.EncMapUintUintptrV(v, fastpathCheckNilTrue, e) + case *map[uint]uintptr: + fastpathTV.EncMapUintUintptrV(*v, fastpathCheckNilTrue, e) + case map[uint]int: fastpathTV.EncMapUintIntV(v, fastpathCheckNilTrue, e) case *map[uint]int: @@ -778,6 +834,11 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { case *map[uint8]uint64: fastpathTV.EncMapUint8Uint64V(*v, fastpathCheckNilTrue, e) + case map[uint8]uintptr: + fastpathTV.EncMapUint8UintptrV(v, fastpathCheckNilTrue, e) + case *map[uint8]uintptr: + fastpathTV.EncMapUint8UintptrV(*v, fastpathCheckNilTrue, e) + case map[uint8]int: fastpathTV.EncMapUint8IntV(v, fastpathCheckNilTrue, e) case *map[uint8]int: @@ -858,6 +919,11 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { case *map[uint16]uint64: fastpathTV.EncMapUint16Uint64V(*v, fastpathCheckNilTrue, e) + case map[uint16]uintptr: + fastpathTV.EncMapUint16UintptrV(v, fastpathCheckNilTrue, e) + case *map[uint16]uintptr: + fastpathTV.EncMapUint16UintptrV(*v, fastpathCheckNilTrue, e) + case map[uint16]int: fastpathTV.EncMapUint16IntV(v, fastpathCheckNilTrue, e) case *map[uint16]int: @@ -938,6 +1004,11 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { case *map[uint32]uint64: fastpathTV.EncMapUint32Uint64V(*v, fastpathCheckNilTrue, e) + case map[uint32]uintptr: + fastpathTV.EncMapUint32UintptrV(v, fastpathCheckNilTrue, e) + case *map[uint32]uintptr: + fastpathTV.EncMapUint32UintptrV(*v, fastpathCheckNilTrue, e) + case map[uint32]int: fastpathTV.EncMapUint32IntV(v, fastpathCheckNilTrue, e) case *map[uint32]int: @@ -1018,6 +1089,11 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { case *map[uint64]uint64: fastpathTV.EncMapUint64Uint64V(*v, fastpathCheckNilTrue, e) + case map[uint64]uintptr: + fastpathTV.EncMapUint64UintptrV(v, fastpathCheckNilTrue, e) + case *map[uint64]uintptr: + fastpathTV.EncMapUint64UintptrV(*v, fastpathCheckNilTrue, e) + case map[uint64]int: fastpathTV.EncMapUint64IntV(v, fastpathCheckNilTrue, e) case *map[uint64]int: @@ -1058,6 +1134,91 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { case *map[uint64]bool: fastpathTV.EncMapUint64BoolV(*v, fastpathCheckNilTrue, e) + case []uintptr: + fastpathTV.EncSliceUintptrV(v, fastpathCheckNilTrue, e) + case *[]uintptr: + fastpathTV.EncSliceUintptrV(*v, fastpathCheckNilTrue, e) + + case map[uintptr]interface{}: + fastpathTV.EncMapUintptrIntfV(v, fastpathCheckNilTrue, e) + case *map[uintptr]interface{}: + fastpathTV.EncMapUintptrIntfV(*v, fastpathCheckNilTrue, e) + + case map[uintptr]string: + fastpathTV.EncMapUintptrStringV(v, fastpathCheckNilTrue, e) + case *map[uintptr]string: + fastpathTV.EncMapUintptrStringV(*v, fastpathCheckNilTrue, e) + + case map[uintptr]uint: + fastpathTV.EncMapUintptrUintV(v, fastpathCheckNilTrue, e) + case *map[uintptr]uint: + fastpathTV.EncMapUintptrUintV(*v, fastpathCheckNilTrue, e) + + case map[uintptr]uint8: + fastpathTV.EncMapUintptrUint8V(v, fastpathCheckNilTrue, e) + case *map[uintptr]uint8: + fastpathTV.EncMapUintptrUint8V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]uint16: + fastpathTV.EncMapUintptrUint16V(v, fastpathCheckNilTrue, e) + case *map[uintptr]uint16: + fastpathTV.EncMapUintptrUint16V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]uint32: + fastpathTV.EncMapUintptrUint32V(v, fastpathCheckNilTrue, e) + case *map[uintptr]uint32: + fastpathTV.EncMapUintptrUint32V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]uint64: + fastpathTV.EncMapUintptrUint64V(v, fastpathCheckNilTrue, e) + case *map[uintptr]uint64: + fastpathTV.EncMapUintptrUint64V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]uintptr: + fastpathTV.EncMapUintptrUintptrV(v, fastpathCheckNilTrue, e) + case *map[uintptr]uintptr: + fastpathTV.EncMapUintptrUintptrV(*v, fastpathCheckNilTrue, e) + + case map[uintptr]int: + fastpathTV.EncMapUintptrIntV(v, fastpathCheckNilTrue, e) + case *map[uintptr]int: + fastpathTV.EncMapUintptrIntV(*v, fastpathCheckNilTrue, e) + + case map[uintptr]int8: + fastpathTV.EncMapUintptrInt8V(v, fastpathCheckNilTrue, e) + case *map[uintptr]int8: + fastpathTV.EncMapUintptrInt8V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]int16: + fastpathTV.EncMapUintptrInt16V(v, fastpathCheckNilTrue, e) + case *map[uintptr]int16: + fastpathTV.EncMapUintptrInt16V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]int32: + fastpathTV.EncMapUintptrInt32V(v, fastpathCheckNilTrue, e) + case *map[uintptr]int32: + fastpathTV.EncMapUintptrInt32V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]int64: + fastpathTV.EncMapUintptrInt64V(v, fastpathCheckNilTrue, e) + case *map[uintptr]int64: + fastpathTV.EncMapUintptrInt64V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]float32: + fastpathTV.EncMapUintptrFloat32V(v, fastpathCheckNilTrue, e) + case *map[uintptr]float32: + fastpathTV.EncMapUintptrFloat32V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]float64: + fastpathTV.EncMapUintptrFloat64V(v, fastpathCheckNilTrue, e) + case *map[uintptr]float64: + fastpathTV.EncMapUintptrFloat64V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]bool: + fastpathTV.EncMapUintptrBoolV(v, fastpathCheckNilTrue, e) + case *map[uintptr]bool: + fastpathTV.EncMapUintptrBoolV(*v, fastpathCheckNilTrue, e) + case []int: fastpathTV.EncSliceIntV(v, fastpathCheckNilTrue, e) case *[]int: @@ -1098,6 +1259,11 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { case *map[int]uint64: fastpathTV.EncMapIntUint64V(*v, fastpathCheckNilTrue, e) + case map[int]uintptr: + fastpathTV.EncMapIntUintptrV(v, fastpathCheckNilTrue, e) + case *map[int]uintptr: + fastpathTV.EncMapIntUintptrV(*v, fastpathCheckNilTrue, e) + case map[int]int: fastpathTV.EncMapIntIntV(v, fastpathCheckNilTrue, e) case *map[int]int: @@ -1178,6 +1344,11 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { case *map[int8]uint64: fastpathTV.EncMapInt8Uint64V(*v, fastpathCheckNilTrue, e) + case map[int8]uintptr: + fastpathTV.EncMapInt8UintptrV(v, fastpathCheckNilTrue, e) + case *map[int8]uintptr: + fastpathTV.EncMapInt8UintptrV(*v, fastpathCheckNilTrue, e) + case map[int8]int: fastpathTV.EncMapInt8IntV(v, fastpathCheckNilTrue, e) case *map[int8]int: @@ -1258,6 +1429,11 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { case *map[int16]uint64: fastpathTV.EncMapInt16Uint64V(*v, fastpathCheckNilTrue, e) + case map[int16]uintptr: + fastpathTV.EncMapInt16UintptrV(v, fastpathCheckNilTrue, e) + case *map[int16]uintptr: + fastpathTV.EncMapInt16UintptrV(*v, fastpathCheckNilTrue, e) + case map[int16]int: fastpathTV.EncMapInt16IntV(v, fastpathCheckNilTrue, e) case *map[int16]int: @@ -1338,6 +1514,11 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { case *map[int32]uint64: fastpathTV.EncMapInt32Uint64V(*v, fastpathCheckNilTrue, e) + case map[int32]uintptr: + fastpathTV.EncMapInt32UintptrV(v, fastpathCheckNilTrue, e) + case *map[int32]uintptr: + fastpathTV.EncMapInt32UintptrV(*v, fastpathCheckNilTrue, e) + case map[int32]int: fastpathTV.EncMapInt32IntV(v, fastpathCheckNilTrue, e) case *map[int32]int: @@ -1418,6 +1599,11 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { case *map[int64]uint64: fastpathTV.EncMapInt64Uint64V(*v, fastpathCheckNilTrue, e) + case map[int64]uintptr: + fastpathTV.EncMapInt64UintptrV(v, fastpathCheckNilTrue, e) + case *map[int64]uintptr: + fastpathTV.EncMapInt64UintptrV(*v, fastpathCheckNilTrue, e) + case map[int64]int: fastpathTV.EncMapInt64IntV(v, fastpathCheckNilTrue, e) case *map[int64]int: @@ -1498,6 +1684,11 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { case *map[bool]uint64: fastpathTV.EncMapBoolUint64V(*v, fastpathCheckNilTrue, e) + case map[bool]uintptr: + fastpathTV.EncMapBoolUintptrV(v, fastpathCheckNilTrue, e) + case *map[bool]uintptr: + fastpathTV.EncMapBoolUintptrV(*v, fastpathCheckNilTrue, e) + case map[bool]int: fastpathTV.EncMapBoolIntV(v, fastpathCheckNilTrue, e) case *map[bool]int: @@ -1539,6 +1730,7 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { fastpathTV.EncMapBoolBoolV(*v, fastpathCheckNilTrue, e) default: + _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) return false } return true @@ -1587,6 +1779,11 @@ func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { case *[]uint64: fastpathTV.EncSliceUint64V(*v, fastpathCheckNilTrue, e) + case []uintptr: + fastpathTV.EncSliceUintptrV(v, fastpathCheckNilTrue, e) + case *[]uintptr: + fastpathTV.EncSliceUintptrV(*v, fastpathCheckNilTrue, e) + case []int: fastpathTV.EncSliceIntV(v, fastpathCheckNilTrue, e) case *[]int: @@ -1618,6 +1815,7 @@ func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { fastpathTV.EncSliceBoolV(*v, fastpathCheckNilTrue, e) default: + _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) return false } return true @@ -1661,6 +1859,11 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { case *map[interface{}]uint64: fastpathTV.EncMapIntfUint64V(*v, fastpathCheckNilTrue, e) + case map[interface{}]uintptr: + fastpathTV.EncMapIntfUintptrV(v, fastpathCheckNilTrue, e) + case *map[interface{}]uintptr: + fastpathTV.EncMapIntfUintptrV(*v, fastpathCheckNilTrue, e) + case map[interface{}]int: fastpathTV.EncMapIntfIntV(v, fastpathCheckNilTrue, e) case *map[interface{}]int: @@ -1736,6 +1939,11 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { case *map[string]uint64: fastpathTV.EncMapStringUint64V(*v, fastpathCheckNilTrue, e) + case map[string]uintptr: + fastpathTV.EncMapStringUintptrV(v, fastpathCheckNilTrue, e) + case *map[string]uintptr: + fastpathTV.EncMapStringUintptrV(*v, fastpathCheckNilTrue, e) + case map[string]int: fastpathTV.EncMapStringIntV(v, fastpathCheckNilTrue, e) case *map[string]int: @@ -1811,6 +2019,11 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { case *map[float32]uint64: fastpathTV.EncMapFloat32Uint64V(*v, fastpathCheckNilTrue, e) + case map[float32]uintptr: + fastpathTV.EncMapFloat32UintptrV(v, fastpathCheckNilTrue, e) + case *map[float32]uintptr: + fastpathTV.EncMapFloat32UintptrV(*v, fastpathCheckNilTrue, e) + case map[float32]int: fastpathTV.EncMapFloat32IntV(v, fastpathCheckNilTrue, e) case *map[float32]int: @@ -1886,6 +2099,11 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { case *map[float64]uint64: fastpathTV.EncMapFloat64Uint64V(*v, fastpathCheckNilTrue, e) + case map[float64]uintptr: + fastpathTV.EncMapFloat64UintptrV(v, fastpathCheckNilTrue, e) + case *map[float64]uintptr: + fastpathTV.EncMapFloat64UintptrV(*v, fastpathCheckNilTrue, e) + case map[float64]int: fastpathTV.EncMapFloat64IntV(v, fastpathCheckNilTrue, e) case *map[float64]int: @@ -1961,6 +2179,11 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { case *map[uint]uint64: fastpathTV.EncMapUintUint64V(*v, fastpathCheckNilTrue, e) + case map[uint]uintptr: + fastpathTV.EncMapUintUintptrV(v, fastpathCheckNilTrue, e) + case *map[uint]uintptr: + fastpathTV.EncMapUintUintptrV(*v, fastpathCheckNilTrue, e) + case map[uint]int: fastpathTV.EncMapUintIntV(v, fastpathCheckNilTrue, e) case *map[uint]int: @@ -2036,6 +2259,11 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { case *map[uint8]uint64: fastpathTV.EncMapUint8Uint64V(*v, fastpathCheckNilTrue, e) + case map[uint8]uintptr: + fastpathTV.EncMapUint8UintptrV(v, fastpathCheckNilTrue, e) + case *map[uint8]uintptr: + fastpathTV.EncMapUint8UintptrV(*v, fastpathCheckNilTrue, e) + case map[uint8]int: fastpathTV.EncMapUint8IntV(v, fastpathCheckNilTrue, e) case *map[uint8]int: @@ -2111,6 +2339,11 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { case *map[uint16]uint64: fastpathTV.EncMapUint16Uint64V(*v, fastpathCheckNilTrue, e) + case map[uint16]uintptr: + fastpathTV.EncMapUint16UintptrV(v, fastpathCheckNilTrue, e) + case *map[uint16]uintptr: + fastpathTV.EncMapUint16UintptrV(*v, fastpathCheckNilTrue, e) + case map[uint16]int: fastpathTV.EncMapUint16IntV(v, fastpathCheckNilTrue, e) case *map[uint16]int: @@ -2186,6 +2419,11 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { case *map[uint32]uint64: fastpathTV.EncMapUint32Uint64V(*v, fastpathCheckNilTrue, e) + case map[uint32]uintptr: + fastpathTV.EncMapUint32UintptrV(v, fastpathCheckNilTrue, e) + case *map[uint32]uintptr: + fastpathTV.EncMapUint32UintptrV(*v, fastpathCheckNilTrue, e) + case map[uint32]int: fastpathTV.EncMapUint32IntV(v, fastpathCheckNilTrue, e) case *map[uint32]int: @@ -2261,6 +2499,11 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { case *map[uint64]uint64: fastpathTV.EncMapUint64Uint64V(*v, fastpathCheckNilTrue, e) + case map[uint64]uintptr: + fastpathTV.EncMapUint64UintptrV(v, fastpathCheckNilTrue, e) + case *map[uint64]uintptr: + fastpathTV.EncMapUint64UintptrV(*v, fastpathCheckNilTrue, e) + case map[uint64]int: fastpathTV.EncMapUint64IntV(v, fastpathCheckNilTrue, e) case *map[uint64]int: @@ -2301,6 +2544,86 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { case *map[uint64]bool: fastpathTV.EncMapUint64BoolV(*v, fastpathCheckNilTrue, e) + case map[uintptr]interface{}: + fastpathTV.EncMapUintptrIntfV(v, fastpathCheckNilTrue, e) + case *map[uintptr]interface{}: + fastpathTV.EncMapUintptrIntfV(*v, fastpathCheckNilTrue, e) + + case map[uintptr]string: + fastpathTV.EncMapUintptrStringV(v, fastpathCheckNilTrue, e) + case *map[uintptr]string: + fastpathTV.EncMapUintptrStringV(*v, fastpathCheckNilTrue, e) + + case map[uintptr]uint: + fastpathTV.EncMapUintptrUintV(v, fastpathCheckNilTrue, e) + case *map[uintptr]uint: + fastpathTV.EncMapUintptrUintV(*v, fastpathCheckNilTrue, e) + + case map[uintptr]uint8: + fastpathTV.EncMapUintptrUint8V(v, fastpathCheckNilTrue, e) + case *map[uintptr]uint8: + fastpathTV.EncMapUintptrUint8V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]uint16: + fastpathTV.EncMapUintptrUint16V(v, fastpathCheckNilTrue, e) + case *map[uintptr]uint16: + fastpathTV.EncMapUintptrUint16V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]uint32: + fastpathTV.EncMapUintptrUint32V(v, fastpathCheckNilTrue, e) + case *map[uintptr]uint32: + fastpathTV.EncMapUintptrUint32V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]uint64: + fastpathTV.EncMapUintptrUint64V(v, fastpathCheckNilTrue, e) + case *map[uintptr]uint64: + fastpathTV.EncMapUintptrUint64V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]uintptr: + fastpathTV.EncMapUintptrUintptrV(v, fastpathCheckNilTrue, e) + case *map[uintptr]uintptr: + fastpathTV.EncMapUintptrUintptrV(*v, fastpathCheckNilTrue, e) + + case map[uintptr]int: + fastpathTV.EncMapUintptrIntV(v, fastpathCheckNilTrue, e) + case *map[uintptr]int: + fastpathTV.EncMapUintptrIntV(*v, fastpathCheckNilTrue, e) + + case map[uintptr]int8: + fastpathTV.EncMapUintptrInt8V(v, fastpathCheckNilTrue, e) + case *map[uintptr]int8: + fastpathTV.EncMapUintptrInt8V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]int16: + fastpathTV.EncMapUintptrInt16V(v, fastpathCheckNilTrue, e) + case *map[uintptr]int16: + fastpathTV.EncMapUintptrInt16V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]int32: + fastpathTV.EncMapUintptrInt32V(v, fastpathCheckNilTrue, e) + case *map[uintptr]int32: + fastpathTV.EncMapUintptrInt32V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]int64: + fastpathTV.EncMapUintptrInt64V(v, fastpathCheckNilTrue, e) + case *map[uintptr]int64: + fastpathTV.EncMapUintptrInt64V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]float32: + fastpathTV.EncMapUintptrFloat32V(v, fastpathCheckNilTrue, e) + case *map[uintptr]float32: + fastpathTV.EncMapUintptrFloat32V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]float64: + fastpathTV.EncMapUintptrFloat64V(v, fastpathCheckNilTrue, e) + case *map[uintptr]float64: + fastpathTV.EncMapUintptrFloat64V(*v, fastpathCheckNilTrue, e) + + case map[uintptr]bool: + fastpathTV.EncMapUintptrBoolV(v, fastpathCheckNilTrue, e) + case *map[uintptr]bool: + fastpathTV.EncMapUintptrBoolV(*v, fastpathCheckNilTrue, e) + case map[int]interface{}: fastpathTV.EncMapIntIntfV(v, fastpathCheckNilTrue, e) case *map[int]interface{}: @@ -2336,6 +2659,11 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { case *map[int]uint64: fastpathTV.EncMapIntUint64V(*v, fastpathCheckNilTrue, e) + case map[int]uintptr: + fastpathTV.EncMapIntUintptrV(v, fastpathCheckNilTrue, e) + case *map[int]uintptr: + fastpathTV.EncMapIntUintptrV(*v, fastpathCheckNilTrue, e) + case map[int]int: fastpathTV.EncMapIntIntV(v, fastpathCheckNilTrue, e) case *map[int]int: @@ -2411,6 +2739,11 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { case *map[int8]uint64: fastpathTV.EncMapInt8Uint64V(*v, fastpathCheckNilTrue, e) + case map[int8]uintptr: + fastpathTV.EncMapInt8UintptrV(v, fastpathCheckNilTrue, e) + case *map[int8]uintptr: + fastpathTV.EncMapInt8UintptrV(*v, fastpathCheckNilTrue, e) + case map[int8]int: fastpathTV.EncMapInt8IntV(v, fastpathCheckNilTrue, e) case *map[int8]int: @@ -2486,6 +2819,11 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { case *map[int16]uint64: fastpathTV.EncMapInt16Uint64V(*v, fastpathCheckNilTrue, e) + case map[int16]uintptr: + fastpathTV.EncMapInt16UintptrV(v, fastpathCheckNilTrue, e) + case *map[int16]uintptr: + fastpathTV.EncMapInt16UintptrV(*v, fastpathCheckNilTrue, e) + case map[int16]int: fastpathTV.EncMapInt16IntV(v, fastpathCheckNilTrue, e) case *map[int16]int: @@ -2561,6 +2899,11 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { case *map[int32]uint64: fastpathTV.EncMapInt32Uint64V(*v, fastpathCheckNilTrue, e) + case map[int32]uintptr: + fastpathTV.EncMapInt32UintptrV(v, fastpathCheckNilTrue, e) + case *map[int32]uintptr: + fastpathTV.EncMapInt32UintptrV(*v, fastpathCheckNilTrue, e) + case map[int32]int: fastpathTV.EncMapInt32IntV(v, fastpathCheckNilTrue, e) case *map[int32]int: @@ -2636,6 +2979,11 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { case *map[int64]uint64: fastpathTV.EncMapInt64Uint64V(*v, fastpathCheckNilTrue, e) + case map[int64]uintptr: + fastpathTV.EncMapInt64UintptrV(v, fastpathCheckNilTrue, e) + case *map[int64]uintptr: + fastpathTV.EncMapInt64UintptrV(*v, fastpathCheckNilTrue, e) + case map[int64]int: fastpathTV.EncMapInt64IntV(v, fastpathCheckNilTrue, e) case *map[int64]int: @@ -2711,6 +3059,11 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { case *map[bool]uint64: fastpathTV.EncMapBoolUint64V(*v, fastpathCheckNilTrue, e) + case map[bool]uintptr: + fastpathTV.EncMapBoolUintptrV(v, fastpathCheckNilTrue, e) + case *map[bool]uintptr: + fastpathTV.EncMapBoolUintptrV(*v, fastpathCheckNilTrue, e) + case map[bool]int: fastpathTV.EncMapBoolIntV(v, fastpathCheckNilTrue, e) case *map[bool]int: @@ -2752,6 +3105,7 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { fastpathTV.EncMapBoolBoolV(*v, fastpathCheckNilTrue, e) default: + _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) return false } return true @@ -2759,7448 +3113,12830 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { // -- -- fast path functions -func (f encFnInfo) fastpathEncSliceIntfR(rv reflect.Value) { - fastpathTV.EncSliceIntfV(rv.Interface().([]interface{}), fastpathCheckNilFalse, f.e) +func (f *encFnInfo) fastpathEncSliceIntfR(rv reflect.Value) { + if f.ti.mbs { + fastpathTV.EncAsMapSliceIntfV(rv.Interface().([]interface{}), fastpathCheckNilFalse, f.e) + } else { + fastpathTV.EncSliceIntfV(rv.Interface().([]interface{}), fastpathCheckNilFalse, f.e) + } } func (_ fastpathT) EncSliceIntfV(v []interface{}, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeArrayStart(len(v)) - if e.be { - for _, v2 := range v { - e.encode(v2) + for _, v2 := range v { + if cr != nil { + cr.sendContainerState(containerArrayElem) } - } else { - for j, v2 := range v { - if j > 0 { - ee.EncodeArrayEntrySeparator() - } - e.encode(v2) - } - ee.EncodeArrayEnd() + e.encode(v2) + } + if cr != nil { + cr.sendContainerState(containerArrayEnd) } } -func (f encFnInfo) fastpathEncSliceStringR(rv reflect.Value) { - fastpathTV.EncSliceStringV(rv.Interface().([]string), fastpathCheckNilFalse, f.e) +func (_ fastpathT) EncAsMapSliceIntfV(v []interface{}, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + if len(v)%2 == 1 { + e.errorf("mapBySlice requires even slice length, but got %v", len(v)) + return + } + ee.EncodeMapStart(len(v) / 2) + for j, v2 := range v { + if cr != nil { + if j%2 == 0 { + cr.sendContainerState(containerMapKey) + } else { + cr.sendContainerState(containerMapValue) + } + } + e.encode(v2) + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncSliceStringR(rv reflect.Value) { + if f.ti.mbs { + fastpathTV.EncAsMapSliceStringV(rv.Interface().([]string), fastpathCheckNilFalse, f.e) + } else { + fastpathTV.EncSliceStringV(rv.Interface().([]string), fastpathCheckNilFalse, f.e) + } } func (_ fastpathT) EncSliceStringV(v []string, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeArrayStart(len(v)) - if e.be { - for _, v2 := range v { - ee.EncodeString(c_UTF8, v2) + for _, v2 := range v { + if cr != nil { + cr.sendContainerState(containerArrayElem) } - } else { - for j, v2 := range v { - if j > 0 { - ee.EncodeArrayEntrySeparator() - } - ee.EncodeString(c_UTF8, v2) - } - ee.EncodeArrayEnd() + ee.EncodeString(c_UTF8, v2) + } + if cr != nil { + cr.sendContainerState(containerArrayEnd) } } -func (f encFnInfo) fastpathEncSliceFloat32R(rv reflect.Value) { - fastpathTV.EncSliceFloat32V(rv.Interface().([]float32), fastpathCheckNilFalse, f.e) +func (_ fastpathT) EncAsMapSliceStringV(v []string, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + if len(v)%2 == 1 { + e.errorf("mapBySlice requires even slice length, but got %v", len(v)) + return + } + ee.EncodeMapStart(len(v) / 2) + for j, v2 := range v { + if cr != nil { + if j%2 == 0 { + cr.sendContainerState(containerMapKey) + } else { + cr.sendContainerState(containerMapValue) + } + } + ee.EncodeString(c_UTF8, v2) + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncSliceFloat32R(rv reflect.Value) { + if f.ti.mbs { + fastpathTV.EncAsMapSliceFloat32V(rv.Interface().([]float32), fastpathCheckNilFalse, f.e) + } else { + fastpathTV.EncSliceFloat32V(rv.Interface().([]float32), fastpathCheckNilFalse, f.e) + } } func (_ fastpathT) EncSliceFloat32V(v []float32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeArrayStart(len(v)) - if e.be { - for _, v2 := range v { - ee.EncodeFloat32(v2) + for _, v2 := range v { + if cr != nil { + cr.sendContainerState(containerArrayElem) } - } else { - for j, v2 := range v { - if j > 0 { - ee.EncodeArrayEntrySeparator() - } - ee.EncodeFloat32(v2) - } - ee.EncodeArrayEnd() + ee.EncodeFloat32(v2) + } + if cr != nil { + cr.sendContainerState(containerArrayEnd) } } -func (f encFnInfo) fastpathEncSliceFloat64R(rv reflect.Value) { - fastpathTV.EncSliceFloat64V(rv.Interface().([]float64), fastpathCheckNilFalse, f.e) +func (_ fastpathT) EncAsMapSliceFloat32V(v []float32, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + if len(v)%2 == 1 { + e.errorf("mapBySlice requires even slice length, but got %v", len(v)) + return + } + ee.EncodeMapStart(len(v) / 2) + for j, v2 := range v { + if cr != nil { + if j%2 == 0 { + cr.sendContainerState(containerMapKey) + } else { + cr.sendContainerState(containerMapValue) + } + } + ee.EncodeFloat32(v2) + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncSliceFloat64R(rv reflect.Value) { + if f.ti.mbs { + fastpathTV.EncAsMapSliceFloat64V(rv.Interface().([]float64), fastpathCheckNilFalse, f.e) + } else { + fastpathTV.EncSliceFloat64V(rv.Interface().([]float64), fastpathCheckNilFalse, f.e) + } } func (_ fastpathT) EncSliceFloat64V(v []float64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeArrayStart(len(v)) - if e.be { - for _, v2 := range v { - ee.EncodeFloat64(v2) + for _, v2 := range v { + if cr != nil { + cr.sendContainerState(containerArrayElem) } - } else { - for j, v2 := range v { - if j > 0 { - ee.EncodeArrayEntrySeparator() - } - ee.EncodeFloat64(v2) - } - ee.EncodeArrayEnd() + ee.EncodeFloat64(v2) + } + if cr != nil { + cr.sendContainerState(containerArrayEnd) } } -func (f encFnInfo) fastpathEncSliceUintR(rv reflect.Value) { - fastpathTV.EncSliceUintV(rv.Interface().([]uint), fastpathCheckNilFalse, f.e) +func (_ fastpathT) EncAsMapSliceFloat64V(v []float64, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + if len(v)%2 == 1 { + e.errorf("mapBySlice requires even slice length, but got %v", len(v)) + return + } + ee.EncodeMapStart(len(v) / 2) + for j, v2 := range v { + if cr != nil { + if j%2 == 0 { + cr.sendContainerState(containerMapKey) + } else { + cr.sendContainerState(containerMapValue) + } + } + ee.EncodeFloat64(v2) + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncSliceUintR(rv reflect.Value) { + if f.ti.mbs { + fastpathTV.EncAsMapSliceUintV(rv.Interface().([]uint), fastpathCheckNilFalse, f.e) + } else { + fastpathTV.EncSliceUintV(rv.Interface().([]uint), fastpathCheckNilFalse, f.e) + } } func (_ fastpathT) EncSliceUintV(v []uint, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeArrayStart(len(v)) - if e.be { - for _, v2 := range v { - ee.EncodeUint(uint64(v2)) + for _, v2 := range v { + if cr != nil { + cr.sendContainerState(containerArrayElem) } - } else { - for j, v2 := range v { - if j > 0 { - ee.EncodeArrayEntrySeparator() - } - ee.EncodeUint(uint64(v2)) - } - ee.EncodeArrayEnd() + ee.EncodeUint(uint64(v2)) + } + if cr != nil { + cr.sendContainerState(containerArrayEnd) } } -func (f encFnInfo) fastpathEncSliceUint16R(rv reflect.Value) { - fastpathTV.EncSliceUint16V(rv.Interface().([]uint16), fastpathCheckNilFalse, f.e) +func (_ fastpathT) EncAsMapSliceUintV(v []uint, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + if len(v)%2 == 1 { + e.errorf("mapBySlice requires even slice length, but got %v", len(v)) + return + } + ee.EncodeMapStart(len(v) / 2) + for j, v2 := range v { + if cr != nil { + if j%2 == 0 { + cr.sendContainerState(containerMapKey) + } else { + cr.sendContainerState(containerMapValue) + } + } + ee.EncodeUint(uint64(v2)) + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncSliceUint16R(rv reflect.Value) { + if f.ti.mbs { + fastpathTV.EncAsMapSliceUint16V(rv.Interface().([]uint16), fastpathCheckNilFalse, f.e) + } else { + fastpathTV.EncSliceUint16V(rv.Interface().([]uint16), fastpathCheckNilFalse, f.e) + } } func (_ fastpathT) EncSliceUint16V(v []uint16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeArrayStart(len(v)) - if e.be { - for _, v2 := range v { - ee.EncodeUint(uint64(v2)) + for _, v2 := range v { + if cr != nil { + cr.sendContainerState(containerArrayElem) } - } else { - for j, v2 := range v { - if j > 0 { - ee.EncodeArrayEntrySeparator() - } - ee.EncodeUint(uint64(v2)) - } - ee.EncodeArrayEnd() + ee.EncodeUint(uint64(v2)) + } + if cr != nil { + cr.sendContainerState(containerArrayEnd) } } -func (f encFnInfo) fastpathEncSliceUint32R(rv reflect.Value) { - fastpathTV.EncSliceUint32V(rv.Interface().([]uint32), fastpathCheckNilFalse, f.e) +func (_ fastpathT) EncAsMapSliceUint16V(v []uint16, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + if len(v)%2 == 1 { + e.errorf("mapBySlice requires even slice length, but got %v", len(v)) + return + } + ee.EncodeMapStart(len(v) / 2) + for j, v2 := range v { + if cr != nil { + if j%2 == 0 { + cr.sendContainerState(containerMapKey) + } else { + cr.sendContainerState(containerMapValue) + } + } + ee.EncodeUint(uint64(v2)) + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncSliceUint32R(rv reflect.Value) { + if f.ti.mbs { + fastpathTV.EncAsMapSliceUint32V(rv.Interface().([]uint32), fastpathCheckNilFalse, f.e) + } else { + fastpathTV.EncSliceUint32V(rv.Interface().([]uint32), fastpathCheckNilFalse, f.e) + } } func (_ fastpathT) EncSliceUint32V(v []uint32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeArrayStart(len(v)) - if e.be { - for _, v2 := range v { - ee.EncodeUint(uint64(v2)) + for _, v2 := range v { + if cr != nil { + cr.sendContainerState(containerArrayElem) } - } else { - for j, v2 := range v { - if j > 0 { - ee.EncodeArrayEntrySeparator() - } - ee.EncodeUint(uint64(v2)) - } - ee.EncodeArrayEnd() + ee.EncodeUint(uint64(v2)) + } + if cr != nil { + cr.sendContainerState(containerArrayEnd) } } -func (f encFnInfo) fastpathEncSliceUint64R(rv reflect.Value) { - fastpathTV.EncSliceUint64V(rv.Interface().([]uint64), fastpathCheckNilFalse, f.e) +func (_ fastpathT) EncAsMapSliceUint32V(v []uint32, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + if len(v)%2 == 1 { + e.errorf("mapBySlice requires even slice length, but got %v", len(v)) + return + } + ee.EncodeMapStart(len(v) / 2) + for j, v2 := range v { + if cr != nil { + if j%2 == 0 { + cr.sendContainerState(containerMapKey) + } else { + cr.sendContainerState(containerMapValue) + } + } + ee.EncodeUint(uint64(v2)) + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncSliceUint64R(rv reflect.Value) { + if f.ti.mbs { + fastpathTV.EncAsMapSliceUint64V(rv.Interface().([]uint64), fastpathCheckNilFalse, f.e) + } else { + fastpathTV.EncSliceUint64V(rv.Interface().([]uint64), fastpathCheckNilFalse, f.e) + } } func (_ fastpathT) EncSliceUint64V(v []uint64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeArrayStart(len(v)) - if e.be { - for _, v2 := range v { - ee.EncodeUint(uint64(v2)) + for _, v2 := range v { + if cr != nil { + cr.sendContainerState(containerArrayElem) } - } else { - for j, v2 := range v { - if j > 0 { - ee.EncodeArrayEntrySeparator() - } - ee.EncodeUint(uint64(v2)) - } - ee.EncodeArrayEnd() + ee.EncodeUint(uint64(v2)) + } + if cr != nil { + cr.sendContainerState(containerArrayEnd) } } -func (f encFnInfo) fastpathEncSliceIntR(rv reflect.Value) { - fastpathTV.EncSliceIntV(rv.Interface().([]int), fastpathCheckNilFalse, f.e) +func (_ fastpathT) EncAsMapSliceUint64V(v []uint64, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + if len(v)%2 == 1 { + e.errorf("mapBySlice requires even slice length, but got %v", len(v)) + return + } + ee.EncodeMapStart(len(v) / 2) + for j, v2 := range v { + if cr != nil { + if j%2 == 0 { + cr.sendContainerState(containerMapKey) + } else { + cr.sendContainerState(containerMapValue) + } + } + ee.EncodeUint(uint64(v2)) + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncSliceUintptrR(rv reflect.Value) { + if f.ti.mbs { + fastpathTV.EncAsMapSliceUintptrV(rv.Interface().([]uintptr), fastpathCheckNilFalse, f.e) + } else { + fastpathTV.EncSliceUintptrV(rv.Interface().([]uintptr), fastpathCheckNilFalse, f.e) + } +} +func (_ fastpathT) EncSliceUintptrV(v []uintptr, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeArrayStart(len(v)) + for _, v2 := range v { + if cr != nil { + cr.sendContainerState(containerArrayElem) + } + e.encode(v2) + } + if cr != nil { + cr.sendContainerState(containerArrayEnd) + } +} + +func (_ fastpathT) EncAsMapSliceUintptrV(v []uintptr, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + if len(v)%2 == 1 { + e.errorf("mapBySlice requires even slice length, but got %v", len(v)) + return + } + ee.EncodeMapStart(len(v) / 2) + for j, v2 := range v { + if cr != nil { + if j%2 == 0 { + cr.sendContainerState(containerMapKey) + } else { + cr.sendContainerState(containerMapValue) + } + } + e.encode(v2) + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncSliceIntR(rv reflect.Value) { + if f.ti.mbs { + fastpathTV.EncAsMapSliceIntV(rv.Interface().([]int), fastpathCheckNilFalse, f.e) + } else { + fastpathTV.EncSliceIntV(rv.Interface().([]int), fastpathCheckNilFalse, f.e) + } } func (_ fastpathT) EncSliceIntV(v []int, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeArrayStart(len(v)) - if e.be { - for _, v2 := range v { - ee.EncodeInt(int64(v2)) + for _, v2 := range v { + if cr != nil { + cr.sendContainerState(containerArrayElem) } - } else { - for j, v2 := range v { - if j > 0 { - ee.EncodeArrayEntrySeparator() - } - ee.EncodeInt(int64(v2)) - } - ee.EncodeArrayEnd() + ee.EncodeInt(int64(v2)) + } + if cr != nil { + cr.sendContainerState(containerArrayEnd) } } -func (f encFnInfo) fastpathEncSliceInt8R(rv reflect.Value) { - fastpathTV.EncSliceInt8V(rv.Interface().([]int8), fastpathCheckNilFalse, f.e) +func (_ fastpathT) EncAsMapSliceIntV(v []int, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + if len(v)%2 == 1 { + e.errorf("mapBySlice requires even slice length, but got %v", len(v)) + return + } + ee.EncodeMapStart(len(v) / 2) + for j, v2 := range v { + if cr != nil { + if j%2 == 0 { + cr.sendContainerState(containerMapKey) + } else { + cr.sendContainerState(containerMapValue) + } + } + ee.EncodeInt(int64(v2)) + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncSliceInt8R(rv reflect.Value) { + if f.ti.mbs { + fastpathTV.EncAsMapSliceInt8V(rv.Interface().([]int8), fastpathCheckNilFalse, f.e) + } else { + fastpathTV.EncSliceInt8V(rv.Interface().([]int8), fastpathCheckNilFalse, f.e) + } } func (_ fastpathT) EncSliceInt8V(v []int8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeArrayStart(len(v)) - if e.be { - for _, v2 := range v { - ee.EncodeInt(int64(v2)) + for _, v2 := range v { + if cr != nil { + cr.sendContainerState(containerArrayElem) } - } else { - for j, v2 := range v { - if j > 0 { - ee.EncodeArrayEntrySeparator() - } - ee.EncodeInt(int64(v2)) - } - ee.EncodeArrayEnd() + ee.EncodeInt(int64(v2)) + } + if cr != nil { + cr.sendContainerState(containerArrayEnd) } } -func (f encFnInfo) fastpathEncSliceInt16R(rv reflect.Value) { - fastpathTV.EncSliceInt16V(rv.Interface().([]int16), fastpathCheckNilFalse, f.e) +func (_ fastpathT) EncAsMapSliceInt8V(v []int8, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + if len(v)%2 == 1 { + e.errorf("mapBySlice requires even slice length, but got %v", len(v)) + return + } + ee.EncodeMapStart(len(v) / 2) + for j, v2 := range v { + if cr != nil { + if j%2 == 0 { + cr.sendContainerState(containerMapKey) + } else { + cr.sendContainerState(containerMapValue) + } + } + ee.EncodeInt(int64(v2)) + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncSliceInt16R(rv reflect.Value) { + if f.ti.mbs { + fastpathTV.EncAsMapSliceInt16V(rv.Interface().([]int16), fastpathCheckNilFalse, f.e) + } else { + fastpathTV.EncSliceInt16V(rv.Interface().([]int16), fastpathCheckNilFalse, f.e) + } } func (_ fastpathT) EncSliceInt16V(v []int16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeArrayStart(len(v)) - if e.be { - for _, v2 := range v { - ee.EncodeInt(int64(v2)) + for _, v2 := range v { + if cr != nil { + cr.sendContainerState(containerArrayElem) } - } else { - for j, v2 := range v { - if j > 0 { - ee.EncodeArrayEntrySeparator() - } - ee.EncodeInt(int64(v2)) - } - ee.EncodeArrayEnd() + ee.EncodeInt(int64(v2)) + } + if cr != nil { + cr.sendContainerState(containerArrayEnd) } } -func (f encFnInfo) fastpathEncSliceInt32R(rv reflect.Value) { - fastpathTV.EncSliceInt32V(rv.Interface().([]int32), fastpathCheckNilFalse, f.e) +func (_ fastpathT) EncAsMapSliceInt16V(v []int16, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + if len(v)%2 == 1 { + e.errorf("mapBySlice requires even slice length, but got %v", len(v)) + return + } + ee.EncodeMapStart(len(v) / 2) + for j, v2 := range v { + if cr != nil { + if j%2 == 0 { + cr.sendContainerState(containerMapKey) + } else { + cr.sendContainerState(containerMapValue) + } + } + ee.EncodeInt(int64(v2)) + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncSliceInt32R(rv reflect.Value) { + if f.ti.mbs { + fastpathTV.EncAsMapSliceInt32V(rv.Interface().([]int32), fastpathCheckNilFalse, f.e) + } else { + fastpathTV.EncSliceInt32V(rv.Interface().([]int32), fastpathCheckNilFalse, f.e) + } } func (_ fastpathT) EncSliceInt32V(v []int32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeArrayStart(len(v)) - if e.be { - for _, v2 := range v { - ee.EncodeInt(int64(v2)) + for _, v2 := range v { + if cr != nil { + cr.sendContainerState(containerArrayElem) } - } else { - for j, v2 := range v { - if j > 0 { - ee.EncodeArrayEntrySeparator() - } - ee.EncodeInt(int64(v2)) - } - ee.EncodeArrayEnd() + ee.EncodeInt(int64(v2)) + } + if cr != nil { + cr.sendContainerState(containerArrayEnd) } } -func (f encFnInfo) fastpathEncSliceInt64R(rv reflect.Value) { - fastpathTV.EncSliceInt64V(rv.Interface().([]int64), fastpathCheckNilFalse, f.e) +func (_ fastpathT) EncAsMapSliceInt32V(v []int32, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + if len(v)%2 == 1 { + e.errorf("mapBySlice requires even slice length, but got %v", len(v)) + return + } + ee.EncodeMapStart(len(v) / 2) + for j, v2 := range v { + if cr != nil { + if j%2 == 0 { + cr.sendContainerState(containerMapKey) + } else { + cr.sendContainerState(containerMapValue) + } + } + ee.EncodeInt(int64(v2)) + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncSliceInt64R(rv reflect.Value) { + if f.ti.mbs { + fastpathTV.EncAsMapSliceInt64V(rv.Interface().([]int64), fastpathCheckNilFalse, f.e) + } else { + fastpathTV.EncSliceInt64V(rv.Interface().([]int64), fastpathCheckNilFalse, f.e) + } } func (_ fastpathT) EncSliceInt64V(v []int64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeArrayStart(len(v)) - if e.be { - for _, v2 := range v { - ee.EncodeInt(int64(v2)) + for _, v2 := range v { + if cr != nil { + cr.sendContainerState(containerArrayElem) } - } else { - for j, v2 := range v { - if j > 0 { - ee.EncodeArrayEntrySeparator() - } - ee.EncodeInt(int64(v2)) - } - ee.EncodeArrayEnd() + ee.EncodeInt(int64(v2)) + } + if cr != nil { + cr.sendContainerState(containerArrayEnd) } } -func (f encFnInfo) fastpathEncSliceBoolR(rv reflect.Value) { - fastpathTV.EncSliceBoolV(rv.Interface().([]bool), fastpathCheckNilFalse, f.e) +func (_ fastpathT) EncAsMapSliceInt64V(v []int64, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + if len(v)%2 == 1 { + e.errorf("mapBySlice requires even slice length, but got %v", len(v)) + return + } + ee.EncodeMapStart(len(v) / 2) + for j, v2 := range v { + if cr != nil { + if j%2 == 0 { + cr.sendContainerState(containerMapKey) + } else { + cr.sendContainerState(containerMapValue) + } + } + ee.EncodeInt(int64(v2)) + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncSliceBoolR(rv reflect.Value) { + if f.ti.mbs { + fastpathTV.EncAsMapSliceBoolV(rv.Interface().([]bool), fastpathCheckNilFalse, f.e) + } else { + fastpathTV.EncSliceBoolV(rv.Interface().([]bool), fastpathCheckNilFalse, f.e) + } } func (_ fastpathT) EncSliceBoolV(v []bool, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeArrayStart(len(v)) - if e.be { - for _, v2 := range v { - ee.EncodeBool(v2) + for _, v2 := range v { + if cr != nil { + cr.sendContainerState(containerArrayElem) } - } else { - for j, v2 := range v { - if j > 0 { - ee.EncodeArrayEntrySeparator() - } - ee.EncodeBool(v2) - } - ee.EncodeArrayEnd() + ee.EncodeBool(v2) + } + if cr != nil { + cr.sendContainerState(containerArrayEnd) } } -func (f encFnInfo) fastpathEncMapIntfIntfR(rv reflect.Value) { +func (_ fastpathT) EncAsMapSliceBoolV(v []bool, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + if len(v)%2 == 1 { + e.errorf("mapBySlice requires even slice length, but got %v", len(v)) + return + } + ee.EncodeMapStart(len(v) / 2) + for j, v2 := range v { + if cr != nil { + if j%2 == 0 { + cr.sendContainerState(containerMapKey) + } else { + cr.sendContainerState(containerMapValue) + } + } + ee.EncodeBool(v2) + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapIntfIntfR(rv reflect.Value) { fastpathTV.EncMapIntfIntfV(rv.Interface().(map[interface{}]interface{}), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntfIntfV(v map[interface{}]interface{}, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - e.encode(k2) - e.encode(v2) + if e.h.Canonical { + 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 int + var vp *bytesI + for k2, _ := range v { + l = len(mksv) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 + i++ + } + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.asis(v2[j].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[v2[j].i]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } e.encode(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } e.encode(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntfStringR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntfStringR(rv reflect.Value) { fastpathTV.EncMapIntfStringV(rv.Interface().(map[interface{}]string), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntfStringV(v map[interface{}]string, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - e.encode(k2) - ee.EncodeString(c_UTF8, v2) + if e.h.Canonical { + 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 int + var vp *bytesI + for k2, _ := range v { + l = len(mksv) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 + i++ + } + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.asis(v2[j].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[v2[j].i]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } e.encode(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeString(c_UTF8, v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntfUintR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntfUintR(rv reflect.Value) { fastpathTV.EncMapIntfUintV(rv.Interface().(map[interface{}]uint), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntfUintV(v map[interface{}]uint, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - e.encode(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + 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 int + var vp *bytesI + for k2, _ := range v { + l = len(mksv) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 + i++ + } + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.asis(v2[j].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[v2[j].i]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } e.encode(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntfUint8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntfUint8R(rv reflect.Value) { fastpathTV.EncMapIntfUint8V(rv.Interface().(map[interface{}]uint8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntfUint8V(v map[interface{}]uint8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - e.encode(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + 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 int + var vp *bytesI + for k2, _ := range v { + l = len(mksv) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 + i++ + } + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.asis(v2[j].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[v2[j].i]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } e.encode(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntfUint16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntfUint16R(rv reflect.Value) { fastpathTV.EncMapIntfUint16V(rv.Interface().(map[interface{}]uint16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntfUint16V(v map[interface{}]uint16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - e.encode(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + 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 int + var vp *bytesI + for k2, _ := range v { + l = len(mksv) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 + i++ + } + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.asis(v2[j].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[v2[j].i]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } e.encode(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntfUint32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntfUint32R(rv reflect.Value) { fastpathTV.EncMapIntfUint32V(rv.Interface().(map[interface{}]uint32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntfUint32V(v map[interface{}]uint32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - e.encode(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + 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 int + var vp *bytesI + for k2, _ := range v { + l = len(mksv) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 + i++ + } + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.asis(v2[j].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[v2[j].i]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } e.encode(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntfUint64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntfUint64R(rv reflect.Value) { fastpathTV.EncMapIntfUint64V(rv.Interface().(map[interface{}]uint64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntfUint64V(v map[interface{}]uint64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - e.encode(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + 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 int + var vp *bytesI + for k2, _ := range v { + l = len(mksv) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 + i++ + } + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.asis(v2[j].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[v2[j].i]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } e.encode(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntfIntR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntfUintptrR(rv reflect.Value) { + fastpathTV.EncMapIntfUintptrV(rv.Interface().(map[interface{}]uintptr), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapIntfUintptrV(v map[interface{}]uintptr, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + 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 int + var vp *bytesI + for k2, _ := range v { + l = len(mksv) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 + i++ + } + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.asis(v2[j].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[v2[j].i]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapIntfIntR(rv reflect.Value) { fastpathTV.EncMapIntfIntV(rv.Interface().(map[interface{}]int), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntfIntV(v map[interface{}]int, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - e.encode(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + 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 int + var vp *bytesI + for k2, _ := range v { + l = len(mksv) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 + i++ + } + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.asis(v2[j].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[v2[j].i]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } e.encode(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntfInt8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntfInt8R(rv reflect.Value) { fastpathTV.EncMapIntfInt8V(rv.Interface().(map[interface{}]int8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntfInt8V(v map[interface{}]int8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - e.encode(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + 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 int + var vp *bytesI + for k2, _ := range v { + l = len(mksv) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 + i++ + } + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.asis(v2[j].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[v2[j].i]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } e.encode(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntfInt16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntfInt16R(rv reflect.Value) { fastpathTV.EncMapIntfInt16V(rv.Interface().(map[interface{}]int16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntfInt16V(v map[interface{}]int16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - e.encode(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + 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 int + var vp *bytesI + for k2, _ := range v { + l = len(mksv) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 + i++ + } + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.asis(v2[j].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[v2[j].i]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } e.encode(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntfInt32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntfInt32R(rv reflect.Value) { fastpathTV.EncMapIntfInt32V(rv.Interface().(map[interface{}]int32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntfInt32V(v map[interface{}]int32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - e.encode(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + 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 int + var vp *bytesI + for k2, _ := range v { + l = len(mksv) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 + i++ + } + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.asis(v2[j].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[v2[j].i]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } e.encode(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntfInt64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntfInt64R(rv reflect.Value) { fastpathTV.EncMapIntfInt64V(rv.Interface().(map[interface{}]int64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntfInt64V(v map[interface{}]int64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - e.encode(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + 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 int + var vp *bytesI + for k2, _ := range v { + l = len(mksv) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 + i++ + } + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.asis(v2[j].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[v2[j].i]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } e.encode(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntfFloat32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntfFloat32R(rv reflect.Value) { fastpathTV.EncMapIntfFloat32V(rv.Interface().(map[interface{}]float32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntfFloat32V(v map[interface{}]float32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - e.encode(k2) - ee.EncodeFloat32(v2) + if e.h.Canonical { + 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 int + var vp *bytesI + for k2, _ := range v { + l = len(mksv) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 + i++ + } + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.asis(v2[j].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[v2[j].i]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } e.encode(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat32(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntfFloat64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntfFloat64R(rv reflect.Value) { fastpathTV.EncMapIntfFloat64V(rv.Interface().(map[interface{}]float64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntfFloat64V(v map[interface{}]float64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - e.encode(k2) - ee.EncodeFloat64(v2) + if e.h.Canonical { + 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 int + var vp *bytesI + for k2, _ := range v { + l = len(mksv) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 + i++ + } + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.asis(v2[j].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[v2[j].i]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } e.encode(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat64(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntfBoolR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntfBoolR(rv reflect.Value) { fastpathTV.EncMapIntfBoolV(rv.Interface().(map[interface{}]bool), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntfBoolV(v map[interface{}]bool, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - e.encode(k2) - ee.EncodeBool(v2) + if e.h.Canonical { + 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 int + var vp *bytesI + for k2, _ := range v { + l = len(mksv) + e2.MustEncode(k2) + vp = &v2[i] + vp.v = mksv[l:] + vp.i = k2 + i++ + } + sort.Sort(bytesISlice(v2)) + for j := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.asis(v2[j].v) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[v2[j].i]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } e.encode(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeBool(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapStringIntfR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapStringIntfR(rv reflect.Value) { fastpathTV.EncMapStringIntfV(rv.Interface().(map[string]interface{}), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapStringIntfV(v map[string]interface{}, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 - if e.be { - for k2, v2 := range v { + if e.h.Canonical { + v2 := make([]string, len(v)) + var i int + for k, _ := range v { + v2[i] = string(k) + i++ + } + sort.Sort(stringSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - e.encode(v2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[string(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } e.encode(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapStringStringR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapStringStringR(rv reflect.Value) { fastpathTV.EncMapStringStringV(rv.Interface().(map[string]string), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapStringStringV(v map[string]string, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 - if e.be { - for k2, v2 := range v { + if e.h.Canonical { + v2 := make([]string, len(v)) + var i int + for k, _ := range v { + v2[i] = string(k) + i++ + } + sort.Sort(stringSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeString(c_UTF8, v2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeString(c_UTF8, v[string(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeString(c_UTF8, v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapStringUintR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapStringUintR(rv reflect.Value) { fastpathTV.EncMapStringUintV(rv.Interface().(map[string]uint), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapStringUintV(v map[string]uint, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 - if e.be { - for k2, v2 := range v { + if e.h.Canonical { + v2 := make([]string, len(v)) + var i int + for k, _ := range v { + v2[i] = string(k) + i++ + } + sort.Sort(stringSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeUint(uint64(v2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[string(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapStringUint8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapStringUint8R(rv reflect.Value) { fastpathTV.EncMapStringUint8V(rv.Interface().(map[string]uint8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapStringUint8V(v map[string]uint8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 - if e.be { - for k2, v2 := range v { + if e.h.Canonical { + v2 := make([]string, len(v)) + var i int + for k, _ := range v { + v2[i] = string(k) + i++ + } + sort.Sort(stringSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeUint(uint64(v2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[string(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapStringUint16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapStringUint16R(rv reflect.Value) { fastpathTV.EncMapStringUint16V(rv.Interface().(map[string]uint16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapStringUint16V(v map[string]uint16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 - if e.be { - for k2, v2 := range v { + if e.h.Canonical { + v2 := make([]string, len(v)) + var i int + for k, _ := range v { + v2[i] = string(k) + i++ + } + sort.Sort(stringSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeUint(uint64(v2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[string(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapStringUint32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapStringUint32R(rv reflect.Value) { fastpathTV.EncMapStringUint32V(rv.Interface().(map[string]uint32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapStringUint32V(v map[string]uint32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 - if e.be { - for k2, v2 := range v { + if e.h.Canonical { + v2 := make([]string, len(v)) + var i int + for k, _ := range v { + v2[i] = string(k) + i++ + } + sort.Sort(stringSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeUint(uint64(v2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[string(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapStringUint64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapStringUint64R(rv reflect.Value) { fastpathTV.EncMapStringUint64V(rv.Interface().(map[string]uint64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapStringUint64V(v map[string]uint64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 - if e.be { - for k2, v2 := range v { + if e.h.Canonical { + v2 := make([]string, len(v)) + var i int + for k, _ := range v { + v2[i] = string(k) + i++ + } + sort.Sort(stringSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeUint(uint64(v2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[string(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapStringIntR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapStringUintptrR(rv reflect.Value) { + fastpathTV.EncMapStringUintptrV(rv.Interface().(map[string]uintptr), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapStringUintptrV(v map[string]uintptr, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 + if e.h.Canonical { + v2 := make([]string, len(v)) + var i int + for k, _ := range v { + v2[i] = string(k) + i++ + } + sort.Sort(stringSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + if asSymbols { + ee.EncodeSymbol(k2) + } else { + ee.EncodeString(c_UTF8, k2) + } + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[string(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + if asSymbols { + ee.EncodeSymbol(k2) + } else { + ee.EncodeString(c_UTF8, k2) + } + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapStringIntR(rv reflect.Value) { fastpathTV.EncMapStringIntV(rv.Interface().(map[string]int), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapStringIntV(v map[string]int, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 - if e.be { - for k2, v2 := range v { + if e.h.Canonical { + v2 := make([]string, len(v)) + var i int + for k, _ := range v { + v2[i] = string(k) + i++ + } + sort.Sort(stringSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeInt(int64(v2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[string(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapStringInt8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapStringInt8R(rv reflect.Value) { fastpathTV.EncMapStringInt8V(rv.Interface().(map[string]int8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapStringInt8V(v map[string]int8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 - if e.be { - for k2, v2 := range v { + if e.h.Canonical { + v2 := make([]string, len(v)) + var i int + for k, _ := range v { + v2[i] = string(k) + i++ + } + sort.Sort(stringSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeInt(int64(v2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[string(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapStringInt16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapStringInt16R(rv reflect.Value) { fastpathTV.EncMapStringInt16V(rv.Interface().(map[string]int16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapStringInt16V(v map[string]int16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 - if e.be { - for k2, v2 := range v { + if e.h.Canonical { + v2 := make([]string, len(v)) + var i int + for k, _ := range v { + v2[i] = string(k) + i++ + } + sort.Sort(stringSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeInt(int64(v2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[string(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapStringInt32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapStringInt32R(rv reflect.Value) { fastpathTV.EncMapStringInt32V(rv.Interface().(map[string]int32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapStringInt32V(v map[string]int32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 - if e.be { - for k2, v2 := range v { + if e.h.Canonical { + v2 := make([]string, len(v)) + var i int + for k, _ := range v { + v2[i] = string(k) + i++ + } + sort.Sort(stringSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeInt(int64(v2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[string(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapStringInt64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapStringInt64R(rv reflect.Value) { fastpathTV.EncMapStringInt64V(rv.Interface().(map[string]int64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapStringInt64V(v map[string]int64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 - if e.be { - for k2, v2 := range v { + if e.h.Canonical { + v2 := make([]string, len(v)) + var i int + for k, _ := range v { + v2[i] = string(k) + i++ + } + sort.Sort(stringSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeInt(int64(v2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[string(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapStringFloat32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapStringFloat32R(rv reflect.Value) { fastpathTV.EncMapStringFloat32V(rv.Interface().(map[string]float32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapStringFloat32V(v map[string]float32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 - if e.be { - for k2, v2 := range v { + if e.h.Canonical { + v2 := make([]string, len(v)) + var i int + for k, _ := range v { + v2[i] = string(k) + i++ + } + sort.Sort(stringSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeFloat32(v2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat32(v[string(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat32(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapStringFloat64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapStringFloat64R(rv reflect.Value) { fastpathTV.EncMapStringFloat64V(rv.Interface().(map[string]float64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapStringFloat64V(v map[string]float64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 - if e.be { - for k2, v2 := range v { + if e.h.Canonical { + v2 := make([]string, len(v)) + var i int + for k, _ := range v { + v2[i] = string(k) + i++ + } + sort.Sort(stringSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeFloat64(v2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat64(v[string(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat64(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapStringBoolR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapStringBoolR(rv reflect.Value) { fastpathTV.EncMapStringBoolV(rv.Interface().(map[string]bool), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapStringBoolV(v map[string]bool, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 - if e.be { - for k2, v2 := range v { + if e.h.Canonical { + v2 := make([]string, len(v)) + var i int + for k, _ := range v { + v2[i] = string(k) + i++ + } + sort.Sort(stringSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeBool(v2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeBool(v[string(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) } - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeBool(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat32IntfR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat32IntfR(rv reflect.Value) { fastpathTV.EncMapFloat32IntfV(rv.Interface().(map[float32]interface{}), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat32IntfV(v map[float32]interface{}, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat32(k2) - e.encode(v2) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat32(float32(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[float32(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat32(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } e.encode(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat32StringR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat32StringR(rv reflect.Value) { fastpathTV.EncMapFloat32StringV(rv.Interface().(map[float32]string), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat32StringV(v map[float32]string, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat32(k2) - ee.EncodeString(c_UTF8, v2) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat32(float32(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeString(c_UTF8, v[float32(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat32(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeString(c_UTF8, v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat32UintR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat32UintR(rv reflect.Value) { fastpathTV.EncMapFloat32UintV(rv.Interface().(map[float32]uint), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat32UintV(v map[float32]uint, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat32(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat32(float32(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[float32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat32(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat32Uint8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat32Uint8R(rv reflect.Value) { fastpathTV.EncMapFloat32Uint8V(rv.Interface().(map[float32]uint8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat32Uint8V(v map[float32]uint8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat32(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat32(float32(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[float32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat32(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat32Uint16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat32Uint16R(rv reflect.Value) { fastpathTV.EncMapFloat32Uint16V(rv.Interface().(map[float32]uint16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat32Uint16V(v map[float32]uint16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat32(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat32(float32(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[float32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat32(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat32Uint32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat32Uint32R(rv reflect.Value) { fastpathTV.EncMapFloat32Uint32V(rv.Interface().(map[float32]uint32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat32Uint32V(v map[float32]uint32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat32(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat32(float32(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[float32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat32(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat32Uint64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat32Uint64R(rv reflect.Value) { fastpathTV.EncMapFloat32Uint64V(rv.Interface().(map[float32]uint64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat32Uint64V(v map[float32]uint64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat32(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat32(float32(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[float32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat32(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat32IntR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat32UintptrR(rv reflect.Value) { + fastpathTV.EncMapFloat32UintptrV(rv.Interface().(map[float32]uintptr), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapFloat32UintptrV(v map[float32]uintptr, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat32(float32(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[float32(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat32(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapFloat32IntR(rv reflect.Value) { fastpathTV.EncMapFloat32IntV(rv.Interface().(map[float32]int), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat32IntV(v map[float32]int, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat32(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat32(float32(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[float32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat32(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat32Int8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat32Int8R(rv reflect.Value) { fastpathTV.EncMapFloat32Int8V(rv.Interface().(map[float32]int8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat32Int8V(v map[float32]int8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat32(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat32(float32(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[float32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat32(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat32Int16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat32Int16R(rv reflect.Value) { fastpathTV.EncMapFloat32Int16V(rv.Interface().(map[float32]int16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat32Int16V(v map[float32]int16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat32(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat32(float32(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[float32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat32(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat32Int32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat32Int32R(rv reflect.Value) { fastpathTV.EncMapFloat32Int32V(rv.Interface().(map[float32]int32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat32Int32V(v map[float32]int32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat32(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat32(float32(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[float32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat32(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat32Int64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat32Int64R(rv reflect.Value) { fastpathTV.EncMapFloat32Int64V(rv.Interface().(map[float32]int64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat32Int64V(v map[float32]int64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat32(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat32(float32(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[float32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat32(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat32Float32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat32Float32R(rv reflect.Value) { fastpathTV.EncMapFloat32Float32V(rv.Interface().(map[float32]float32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat32Float32V(v map[float32]float32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat32(k2) - ee.EncodeFloat32(v2) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat32(float32(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat32(v[float32(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat32(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat32(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat32Float64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat32Float64R(rv reflect.Value) { fastpathTV.EncMapFloat32Float64V(rv.Interface().(map[float32]float64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat32Float64V(v map[float32]float64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat32(k2) - ee.EncodeFloat64(v2) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat32(float32(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat64(v[float32(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat32(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat64(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat32BoolR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat32BoolR(rv reflect.Value) { fastpathTV.EncMapFloat32BoolV(rv.Interface().(map[float32]bool), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat32BoolV(v map[float32]bool, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat32(k2) - ee.EncodeBool(v2) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat32(float32(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeBool(v[float32(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat32(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeBool(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat64IntfR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat64IntfR(rv reflect.Value) { fastpathTV.EncMapFloat64IntfV(rv.Interface().(map[float64]interface{}), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat64IntfV(v map[float64]interface{}, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat64(k2) - e.encode(v2) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat64(float64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[float64(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat64(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } e.encode(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat64StringR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat64StringR(rv reflect.Value) { fastpathTV.EncMapFloat64StringV(rv.Interface().(map[float64]string), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat64StringV(v map[float64]string, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat64(k2) - ee.EncodeString(c_UTF8, v2) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat64(float64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeString(c_UTF8, v[float64(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat64(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeString(c_UTF8, v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat64UintR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat64UintR(rv reflect.Value) { fastpathTV.EncMapFloat64UintV(rv.Interface().(map[float64]uint), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat64UintV(v map[float64]uint, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat64(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat64(float64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[float64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat64(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat64Uint8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat64Uint8R(rv reflect.Value) { fastpathTV.EncMapFloat64Uint8V(rv.Interface().(map[float64]uint8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat64Uint8V(v map[float64]uint8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat64(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat64(float64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[float64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat64(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat64Uint16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat64Uint16R(rv reflect.Value) { fastpathTV.EncMapFloat64Uint16V(rv.Interface().(map[float64]uint16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat64Uint16V(v map[float64]uint16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat64(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat64(float64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[float64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat64(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat64Uint32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat64Uint32R(rv reflect.Value) { fastpathTV.EncMapFloat64Uint32V(rv.Interface().(map[float64]uint32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat64Uint32V(v map[float64]uint32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat64(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat64(float64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[float64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat64(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat64Uint64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat64Uint64R(rv reflect.Value) { fastpathTV.EncMapFloat64Uint64V(rv.Interface().(map[float64]uint64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat64Uint64V(v map[float64]uint64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat64(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat64(float64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[float64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat64(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat64IntR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat64UintptrR(rv reflect.Value) { + fastpathTV.EncMapFloat64UintptrV(rv.Interface().(map[float64]uintptr), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapFloat64UintptrV(v map[float64]uintptr, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat64(float64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[float64(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat64(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapFloat64IntR(rv reflect.Value) { fastpathTV.EncMapFloat64IntV(rv.Interface().(map[float64]int), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat64IntV(v map[float64]int, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat64(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat64(float64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[float64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat64(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat64Int8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat64Int8R(rv reflect.Value) { fastpathTV.EncMapFloat64Int8V(rv.Interface().(map[float64]int8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat64Int8V(v map[float64]int8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat64(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat64(float64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[float64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat64(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat64Int16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat64Int16R(rv reflect.Value) { fastpathTV.EncMapFloat64Int16V(rv.Interface().(map[float64]int16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat64Int16V(v map[float64]int16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat64(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat64(float64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[float64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat64(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat64Int32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat64Int32R(rv reflect.Value) { fastpathTV.EncMapFloat64Int32V(rv.Interface().(map[float64]int32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat64Int32V(v map[float64]int32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat64(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat64(float64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[float64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat64(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat64Int64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat64Int64R(rv reflect.Value) { fastpathTV.EncMapFloat64Int64V(rv.Interface().(map[float64]int64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat64Int64V(v map[float64]int64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat64(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat64(float64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[float64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat64(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat64Float32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat64Float32R(rv reflect.Value) { fastpathTV.EncMapFloat64Float32V(rv.Interface().(map[float64]float32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat64Float32V(v map[float64]float32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat64(k2) - ee.EncodeFloat32(v2) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat64(float64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat32(v[float64(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat64(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat32(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat64Float64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat64Float64R(rv reflect.Value) { fastpathTV.EncMapFloat64Float64V(rv.Interface().(map[float64]float64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat64Float64V(v map[float64]float64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat64(k2) - ee.EncodeFloat64(v2) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat64(float64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat64(v[float64(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat64(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat64(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapFloat64BoolR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapFloat64BoolR(rv reflect.Value) { fastpathTV.EncMapFloat64BoolV(rv.Interface().(map[float64]bool), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapFloat64BoolV(v map[float64]bool, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeFloat64(k2) - ee.EncodeBool(v2) + if e.h.Canonical { + v2 := make([]float64, len(v)) + var i int + for k, _ := range v { + v2[i] = float64(k) + i++ + } + sort.Sort(floatSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeFloat64(float64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeBool(v[float64(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeFloat64(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeBool(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUintIntfR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUintIntfR(rv reflect.Value) { fastpathTV.EncMapUintIntfV(rv.Interface().(map[uint]interface{}), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUintIntfV(v map[uint]interface{}, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - e.encode(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[uint(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } e.encode(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUintStringR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUintStringR(rv reflect.Value) { fastpathTV.EncMapUintStringV(rv.Interface().(map[uint]string), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUintStringV(v map[uint]string, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeString(c_UTF8, v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeString(c_UTF8, v[uint(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeString(c_UTF8, v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUintUintR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUintUintR(rv reflect.Value) { fastpathTV.EncMapUintUintV(rv.Interface().(map[uint]uint), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUintUintV(v map[uint]uint, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUintUint8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUintUint8R(rv reflect.Value) { fastpathTV.EncMapUintUint8V(rv.Interface().(map[uint]uint8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUintUint8V(v map[uint]uint8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUintUint16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUintUint16R(rv reflect.Value) { fastpathTV.EncMapUintUint16V(rv.Interface().(map[uint]uint16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUintUint16V(v map[uint]uint16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUintUint32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUintUint32R(rv reflect.Value) { fastpathTV.EncMapUintUint32V(rv.Interface().(map[uint]uint32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUintUint32V(v map[uint]uint32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUintUint64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUintUint64R(rv reflect.Value) { fastpathTV.EncMapUintUint64V(rv.Interface().(map[uint]uint64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUintUint64V(v map[uint]uint64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUintIntR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUintUintptrR(rv reflect.Value) { + fastpathTV.EncMapUintUintptrV(rv.Interface().(map[uint]uintptr), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUintUintptrV(v map[uint]uintptr, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[uint(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUintIntR(rv reflect.Value) { fastpathTV.EncMapUintIntV(rv.Interface().(map[uint]int), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUintIntV(v map[uint]int, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUintInt8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUintInt8R(rv reflect.Value) { fastpathTV.EncMapUintInt8V(rv.Interface().(map[uint]int8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUintInt8V(v map[uint]int8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUintInt16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUintInt16R(rv reflect.Value) { fastpathTV.EncMapUintInt16V(rv.Interface().(map[uint]int16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUintInt16V(v map[uint]int16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUintInt32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUintInt32R(rv reflect.Value) { fastpathTV.EncMapUintInt32V(rv.Interface().(map[uint]int32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUintInt32V(v map[uint]int32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUintInt64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUintInt64R(rv reflect.Value) { fastpathTV.EncMapUintInt64V(rv.Interface().(map[uint]int64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUintInt64V(v map[uint]int64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUintFloat32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUintFloat32R(rv reflect.Value) { fastpathTV.EncMapUintFloat32V(rv.Interface().(map[uint]float32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUintFloat32V(v map[uint]float32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeFloat32(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat32(v[uint(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat32(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUintFloat64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUintFloat64R(rv reflect.Value) { fastpathTV.EncMapUintFloat64V(rv.Interface().(map[uint]float64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUintFloat64V(v map[uint]float64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeFloat64(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat64(v[uint(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat64(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUintBoolR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUintBoolR(rv reflect.Value) { fastpathTV.EncMapUintBoolV(rv.Interface().(map[uint]bool), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUintBoolV(v map[uint]bool, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeBool(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeBool(v[uint(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeBool(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint8IntfR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint8IntfR(rv reflect.Value) { fastpathTV.EncMapUint8IntfV(rv.Interface().(map[uint8]interface{}), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint8IntfV(v map[uint8]interface{}, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - e.encode(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[uint8(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } e.encode(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint8StringR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint8StringR(rv reflect.Value) { fastpathTV.EncMapUint8StringV(rv.Interface().(map[uint8]string), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint8StringV(v map[uint8]string, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeString(c_UTF8, v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeString(c_UTF8, v[uint8(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeString(c_UTF8, v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint8UintR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint8UintR(rv reflect.Value) { fastpathTV.EncMapUint8UintV(rv.Interface().(map[uint8]uint), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint8UintV(v map[uint8]uint, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint8Uint8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint8Uint8R(rv reflect.Value) { fastpathTV.EncMapUint8Uint8V(rv.Interface().(map[uint8]uint8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint8Uint8V(v map[uint8]uint8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint8Uint16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint8Uint16R(rv reflect.Value) { fastpathTV.EncMapUint8Uint16V(rv.Interface().(map[uint8]uint16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint8Uint16V(v map[uint8]uint16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint8Uint32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint8Uint32R(rv reflect.Value) { fastpathTV.EncMapUint8Uint32V(rv.Interface().(map[uint8]uint32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint8Uint32V(v map[uint8]uint32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint8Uint64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint8Uint64R(rv reflect.Value) { fastpathTV.EncMapUint8Uint64V(rv.Interface().(map[uint8]uint64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint8Uint64V(v map[uint8]uint64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint8IntR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint8UintptrR(rv reflect.Value) { + fastpathTV.EncMapUint8UintptrV(rv.Interface().(map[uint8]uintptr), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUint8UintptrV(v map[uint8]uintptr, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[uint8(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUint8IntR(rv reflect.Value) { fastpathTV.EncMapUint8IntV(rv.Interface().(map[uint8]int), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint8IntV(v map[uint8]int, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint8Int8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint8Int8R(rv reflect.Value) { fastpathTV.EncMapUint8Int8V(rv.Interface().(map[uint8]int8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint8Int8V(v map[uint8]int8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint8Int16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint8Int16R(rv reflect.Value) { fastpathTV.EncMapUint8Int16V(rv.Interface().(map[uint8]int16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint8Int16V(v map[uint8]int16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint8Int32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint8Int32R(rv reflect.Value) { fastpathTV.EncMapUint8Int32V(rv.Interface().(map[uint8]int32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint8Int32V(v map[uint8]int32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint8Int64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint8Int64R(rv reflect.Value) { fastpathTV.EncMapUint8Int64V(rv.Interface().(map[uint8]int64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint8Int64V(v map[uint8]int64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint8Float32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint8Float32R(rv reflect.Value) { fastpathTV.EncMapUint8Float32V(rv.Interface().(map[uint8]float32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint8Float32V(v map[uint8]float32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeFloat32(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat32(v[uint8(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat32(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint8Float64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint8Float64R(rv reflect.Value) { fastpathTV.EncMapUint8Float64V(rv.Interface().(map[uint8]float64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint8Float64V(v map[uint8]float64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeFloat64(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat64(v[uint8(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat64(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint8BoolR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint8BoolR(rv reflect.Value) { fastpathTV.EncMapUint8BoolV(rv.Interface().(map[uint8]bool), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint8BoolV(v map[uint8]bool, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeBool(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeBool(v[uint8(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeBool(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint16IntfR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint16IntfR(rv reflect.Value) { fastpathTV.EncMapUint16IntfV(rv.Interface().(map[uint16]interface{}), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint16IntfV(v map[uint16]interface{}, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - e.encode(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[uint16(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } e.encode(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint16StringR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint16StringR(rv reflect.Value) { fastpathTV.EncMapUint16StringV(rv.Interface().(map[uint16]string), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint16StringV(v map[uint16]string, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeString(c_UTF8, v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeString(c_UTF8, v[uint16(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeString(c_UTF8, v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint16UintR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint16UintR(rv reflect.Value) { fastpathTV.EncMapUint16UintV(rv.Interface().(map[uint16]uint), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint16UintV(v map[uint16]uint, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint16Uint8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint16Uint8R(rv reflect.Value) { fastpathTV.EncMapUint16Uint8V(rv.Interface().(map[uint16]uint8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint16Uint8V(v map[uint16]uint8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint16Uint16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint16Uint16R(rv reflect.Value) { fastpathTV.EncMapUint16Uint16V(rv.Interface().(map[uint16]uint16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint16Uint16V(v map[uint16]uint16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint16Uint32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint16Uint32R(rv reflect.Value) { fastpathTV.EncMapUint16Uint32V(rv.Interface().(map[uint16]uint32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint16Uint32V(v map[uint16]uint32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint16Uint64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint16Uint64R(rv reflect.Value) { fastpathTV.EncMapUint16Uint64V(rv.Interface().(map[uint16]uint64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint16Uint64V(v map[uint16]uint64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint16IntR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint16UintptrR(rv reflect.Value) { + fastpathTV.EncMapUint16UintptrV(rv.Interface().(map[uint16]uintptr), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUint16UintptrV(v map[uint16]uintptr, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[uint16(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUint16IntR(rv reflect.Value) { fastpathTV.EncMapUint16IntV(rv.Interface().(map[uint16]int), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint16IntV(v map[uint16]int, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint16Int8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint16Int8R(rv reflect.Value) { fastpathTV.EncMapUint16Int8V(rv.Interface().(map[uint16]int8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint16Int8V(v map[uint16]int8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint16Int16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint16Int16R(rv reflect.Value) { fastpathTV.EncMapUint16Int16V(rv.Interface().(map[uint16]int16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint16Int16V(v map[uint16]int16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint16Int32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint16Int32R(rv reflect.Value) { fastpathTV.EncMapUint16Int32V(rv.Interface().(map[uint16]int32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint16Int32V(v map[uint16]int32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint16Int64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint16Int64R(rv reflect.Value) { fastpathTV.EncMapUint16Int64V(rv.Interface().(map[uint16]int64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint16Int64V(v map[uint16]int64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint16Float32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint16Float32R(rv reflect.Value) { fastpathTV.EncMapUint16Float32V(rv.Interface().(map[uint16]float32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint16Float32V(v map[uint16]float32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeFloat32(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat32(v[uint16(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat32(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint16Float64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint16Float64R(rv reflect.Value) { fastpathTV.EncMapUint16Float64V(rv.Interface().(map[uint16]float64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint16Float64V(v map[uint16]float64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeFloat64(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat64(v[uint16(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat64(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint16BoolR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint16BoolR(rv reflect.Value) { fastpathTV.EncMapUint16BoolV(rv.Interface().(map[uint16]bool), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint16BoolV(v map[uint16]bool, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeBool(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeBool(v[uint16(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeBool(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint32IntfR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint32IntfR(rv reflect.Value) { fastpathTV.EncMapUint32IntfV(rv.Interface().(map[uint32]interface{}), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint32IntfV(v map[uint32]interface{}, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - e.encode(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[uint32(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } e.encode(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint32StringR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint32StringR(rv reflect.Value) { fastpathTV.EncMapUint32StringV(rv.Interface().(map[uint32]string), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint32StringV(v map[uint32]string, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeString(c_UTF8, v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeString(c_UTF8, v[uint32(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeString(c_UTF8, v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint32UintR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint32UintR(rv reflect.Value) { fastpathTV.EncMapUint32UintV(rv.Interface().(map[uint32]uint), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint32UintV(v map[uint32]uint, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint32Uint8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint32Uint8R(rv reflect.Value) { fastpathTV.EncMapUint32Uint8V(rv.Interface().(map[uint32]uint8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint32Uint8V(v map[uint32]uint8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint32Uint16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint32Uint16R(rv reflect.Value) { fastpathTV.EncMapUint32Uint16V(rv.Interface().(map[uint32]uint16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint32Uint16V(v map[uint32]uint16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint32Uint32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint32Uint32R(rv reflect.Value) { fastpathTV.EncMapUint32Uint32V(rv.Interface().(map[uint32]uint32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint32Uint32V(v map[uint32]uint32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint32Uint64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint32Uint64R(rv reflect.Value) { fastpathTV.EncMapUint32Uint64V(rv.Interface().(map[uint32]uint64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint32Uint64V(v map[uint32]uint64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint32IntR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint32UintptrR(rv reflect.Value) { + fastpathTV.EncMapUint32UintptrV(rv.Interface().(map[uint32]uintptr), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUint32UintptrV(v map[uint32]uintptr, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[uint32(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUint32IntR(rv reflect.Value) { fastpathTV.EncMapUint32IntV(rv.Interface().(map[uint32]int), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint32IntV(v map[uint32]int, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint32Int8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint32Int8R(rv reflect.Value) { fastpathTV.EncMapUint32Int8V(rv.Interface().(map[uint32]int8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint32Int8V(v map[uint32]int8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint32Int16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint32Int16R(rv reflect.Value) { fastpathTV.EncMapUint32Int16V(rv.Interface().(map[uint32]int16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint32Int16V(v map[uint32]int16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint32Int32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint32Int32R(rv reflect.Value) { fastpathTV.EncMapUint32Int32V(rv.Interface().(map[uint32]int32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint32Int32V(v map[uint32]int32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint32Int64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint32Int64R(rv reflect.Value) { fastpathTV.EncMapUint32Int64V(rv.Interface().(map[uint32]int64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint32Int64V(v map[uint32]int64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint32Float32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint32Float32R(rv reflect.Value) { fastpathTV.EncMapUint32Float32V(rv.Interface().(map[uint32]float32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint32Float32V(v map[uint32]float32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeFloat32(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat32(v[uint32(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat32(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint32Float64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint32Float64R(rv reflect.Value) { fastpathTV.EncMapUint32Float64V(rv.Interface().(map[uint32]float64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint32Float64V(v map[uint32]float64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeFloat64(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat64(v[uint32(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat64(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint32BoolR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint32BoolR(rv reflect.Value) { fastpathTV.EncMapUint32BoolV(rv.Interface().(map[uint32]bool), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint32BoolV(v map[uint32]bool, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeBool(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeBool(v[uint32(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeBool(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint64IntfR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint64IntfR(rv reflect.Value) { fastpathTV.EncMapUint64IntfV(rv.Interface().(map[uint64]interface{}), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint64IntfV(v map[uint64]interface{}, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - e.encode(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[uint64(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } e.encode(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint64StringR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint64StringR(rv reflect.Value) { fastpathTV.EncMapUint64StringV(rv.Interface().(map[uint64]string), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint64StringV(v map[uint64]string, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeString(c_UTF8, v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeString(c_UTF8, v[uint64(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeString(c_UTF8, v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint64UintR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint64UintR(rv reflect.Value) { fastpathTV.EncMapUint64UintV(rv.Interface().(map[uint64]uint), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint64UintV(v map[uint64]uint, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint64Uint8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint64Uint8R(rv reflect.Value) { fastpathTV.EncMapUint64Uint8V(rv.Interface().(map[uint64]uint8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint64Uint8V(v map[uint64]uint8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint64Uint16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint64Uint16R(rv reflect.Value) { fastpathTV.EncMapUint64Uint16V(rv.Interface().(map[uint64]uint16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint64Uint16V(v map[uint64]uint16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint64Uint32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint64Uint32R(rv reflect.Value) { fastpathTV.EncMapUint64Uint32V(rv.Interface().(map[uint64]uint32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint64Uint32V(v map[uint64]uint32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint64Uint64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint64Uint64R(rv reflect.Value) { fastpathTV.EncMapUint64Uint64V(rv.Interface().(map[uint64]uint64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint64Uint64V(v map[uint64]uint64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uint64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint64IntR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint64UintptrR(rv reflect.Value) { + fastpathTV.EncMapUint64UintptrV(rv.Interface().(map[uint64]uintptr), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUint64UintptrV(v map[uint64]uintptr, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[uint64(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUint64IntR(rv reflect.Value) { fastpathTV.EncMapUint64IntV(rv.Interface().(map[uint64]int), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint64IntV(v map[uint64]int, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint64Int8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint64Int8R(rv reflect.Value) { fastpathTV.EncMapUint64Int8V(rv.Interface().(map[uint64]int8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint64Int8V(v map[uint64]int8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint64Int16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint64Int16R(rv reflect.Value) { fastpathTV.EncMapUint64Int16V(rv.Interface().(map[uint64]int16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint64Int16V(v map[uint64]int16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint64Int32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint64Int32R(rv reflect.Value) { fastpathTV.EncMapUint64Int32V(rv.Interface().(map[uint64]int32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint64Int32V(v map[uint64]int32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint64Int64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint64Int64R(rv reflect.Value) { fastpathTV.EncMapUint64Int64V(rv.Interface().(map[uint64]int64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint64Int64V(v map[uint64]int64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uint64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint64Float32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint64Float32R(rv reflect.Value) { fastpathTV.EncMapUint64Float32V(rv.Interface().(map[uint64]float32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint64Float32V(v map[uint64]float32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeFloat32(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat32(v[uint64(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat32(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint64Float64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint64Float64R(rv reflect.Value) { fastpathTV.EncMapUint64Float64V(rv.Interface().(map[uint64]float64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint64Float64V(v map[uint64]float64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeFloat64(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat64(v[uint64(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat64(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapUint64BoolR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUint64BoolR(rv reflect.Value) { fastpathTV.EncMapUint64BoolV(rv.Interface().(map[uint64]bool), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapUint64BoolV(v map[uint64]bool, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeUint(uint64(k2)) - ee.EncodeBool(v2) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeUint(uint64(uint64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeBool(v[uint64(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeUint(uint64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeBool(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntIntfR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapUintptrIntfR(rv reflect.Value) { + fastpathTV.EncMapUintptrIntfV(rv.Interface().(map[uintptr]interface{}), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUintptrIntfV(v map[uintptr]interface{}, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(uintptr(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[uintptr(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUintptrStringR(rv reflect.Value) { + fastpathTV.EncMapUintptrStringV(rv.Interface().(map[uintptr]string), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUintptrStringV(v map[uintptr]string, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(uintptr(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeString(c_UTF8, v[uintptr(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeString(c_UTF8, v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUintptrUintR(rv reflect.Value) { + fastpathTV.EncMapUintptrUintV(rv.Interface().(map[uintptr]uint), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUintptrUintV(v map[uintptr]uint, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(uintptr(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v2)) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUintptrUint8R(rv reflect.Value) { + fastpathTV.EncMapUintptrUint8V(rv.Interface().(map[uintptr]uint8), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUintptrUint8V(v map[uintptr]uint8, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(uintptr(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v2)) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUintptrUint16R(rv reflect.Value) { + fastpathTV.EncMapUintptrUint16V(rv.Interface().(map[uintptr]uint16), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUintptrUint16V(v map[uintptr]uint16, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(uintptr(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v2)) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUintptrUint32R(rv reflect.Value) { + fastpathTV.EncMapUintptrUint32V(rv.Interface().(map[uintptr]uint32), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUintptrUint32V(v map[uintptr]uint32, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(uintptr(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v2)) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUintptrUint64R(rv reflect.Value) { + fastpathTV.EncMapUintptrUint64V(rv.Interface().(map[uintptr]uint64), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUintptrUint64V(v map[uintptr]uint64, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(uintptr(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v2)) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUintptrUintptrR(rv reflect.Value) { + fastpathTV.EncMapUintptrUintptrV(rv.Interface().(map[uintptr]uintptr), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUintptrUintptrV(v map[uintptr]uintptr, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(uintptr(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[uintptr(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUintptrIntR(rv reflect.Value) { + fastpathTV.EncMapUintptrIntV(rv.Interface().(map[uintptr]int), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUintptrIntV(v map[uintptr]int, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(uintptr(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v2)) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUintptrInt8R(rv reflect.Value) { + fastpathTV.EncMapUintptrInt8V(rv.Interface().(map[uintptr]int8), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUintptrInt8V(v map[uintptr]int8, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(uintptr(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v2)) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUintptrInt16R(rv reflect.Value) { + fastpathTV.EncMapUintptrInt16V(rv.Interface().(map[uintptr]int16), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUintptrInt16V(v map[uintptr]int16, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(uintptr(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v2)) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUintptrInt32R(rv reflect.Value) { + fastpathTV.EncMapUintptrInt32V(rv.Interface().(map[uintptr]int32), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUintptrInt32V(v map[uintptr]int32, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(uintptr(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v2)) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUintptrInt64R(rv reflect.Value) { + fastpathTV.EncMapUintptrInt64V(rv.Interface().(map[uintptr]int64), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUintptrInt64V(v map[uintptr]int64, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(uintptr(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[uintptr(k2)])) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v2)) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUintptrFloat32R(rv reflect.Value) { + fastpathTV.EncMapUintptrFloat32V(rv.Interface().(map[uintptr]float32), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUintptrFloat32V(v map[uintptr]float32, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(uintptr(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat32(v[uintptr(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat32(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUintptrFloat64R(rv reflect.Value) { + fastpathTV.EncMapUintptrFloat64V(rv.Interface().(map[uintptr]float64), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUintptrFloat64V(v map[uintptr]float64, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(uintptr(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat64(v[uintptr(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat64(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapUintptrBoolR(rv reflect.Value) { + fastpathTV.EncMapUintptrBoolV(rv.Interface().(map[uintptr]bool), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapUintptrBoolV(v map[uintptr]bool, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]uint64, len(v)) + var i int + for k, _ := range v { + v2[i] = uint64(k) + i++ + } + sort.Sort(uintSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(uintptr(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeBool(v[uintptr(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + e.encode(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeBool(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapIntIntfR(rv reflect.Value) { fastpathTV.EncMapIntIntfV(rv.Interface().(map[int]interface{}), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntIntfV(v map[int]interface{}, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - e.encode(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[int(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } e.encode(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntStringR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntStringR(rv reflect.Value) { fastpathTV.EncMapIntStringV(rv.Interface().(map[int]string), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntStringV(v map[int]string, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeString(c_UTF8, v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeString(c_UTF8, v[int(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeString(c_UTF8, v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntUintR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntUintR(rv reflect.Value) { fastpathTV.EncMapIntUintV(rv.Interface().(map[int]uint), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntUintV(v map[int]uint, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntUint8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntUint8R(rv reflect.Value) { fastpathTV.EncMapIntUint8V(rv.Interface().(map[int]uint8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntUint8V(v map[int]uint8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntUint16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntUint16R(rv reflect.Value) { fastpathTV.EncMapIntUint16V(rv.Interface().(map[int]uint16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntUint16V(v map[int]uint16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntUint32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntUint32R(rv reflect.Value) { fastpathTV.EncMapIntUint32V(rv.Interface().(map[int]uint32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntUint32V(v map[int]uint32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntUint64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntUint64R(rv reflect.Value) { fastpathTV.EncMapIntUint64V(rv.Interface().(map[int]uint64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntUint64V(v map[int]uint64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntIntR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntUintptrR(rv reflect.Value) { + fastpathTV.EncMapIntUintptrV(rv.Interface().(map[int]uintptr), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapIntUintptrV(v map[int]uintptr, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[int(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapIntIntR(rv reflect.Value) { fastpathTV.EncMapIntIntV(rv.Interface().(map[int]int), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntIntV(v map[int]int, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntInt8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntInt8R(rv reflect.Value) { fastpathTV.EncMapIntInt8V(rv.Interface().(map[int]int8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntInt8V(v map[int]int8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntInt16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntInt16R(rv reflect.Value) { fastpathTV.EncMapIntInt16V(rv.Interface().(map[int]int16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntInt16V(v map[int]int16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntInt32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntInt32R(rv reflect.Value) { fastpathTV.EncMapIntInt32V(rv.Interface().(map[int]int32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntInt32V(v map[int]int32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntInt64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntInt64R(rv reflect.Value) { fastpathTV.EncMapIntInt64V(rv.Interface().(map[int]int64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntInt64V(v map[int]int64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntFloat32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntFloat32R(rv reflect.Value) { fastpathTV.EncMapIntFloat32V(rv.Interface().(map[int]float32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntFloat32V(v map[int]float32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeFloat32(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat32(v[int(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat32(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntFloat64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntFloat64R(rv reflect.Value) { fastpathTV.EncMapIntFloat64V(rv.Interface().(map[int]float64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntFloat64V(v map[int]float64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeFloat64(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat64(v[int(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat64(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapIntBoolR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapIntBoolR(rv reflect.Value) { fastpathTV.EncMapIntBoolV(rv.Interface().(map[int]bool), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapIntBoolV(v map[int]bool, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeBool(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeBool(v[int(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeBool(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt8IntfR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt8IntfR(rv reflect.Value) { fastpathTV.EncMapInt8IntfV(rv.Interface().(map[int8]interface{}), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt8IntfV(v map[int8]interface{}, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - e.encode(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[int8(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } e.encode(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt8StringR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt8StringR(rv reflect.Value) { fastpathTV.EncMapInt8StringV(rv.Interface().(map[int8]string), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt8StringV(v map[int8]string, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeString(c_UTF8, v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeString(c_UTF8, v[int8(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeString(c_UTF8, v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt8UintR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt8UintR(rv reflect.Value) { fastpathTV.EncMapInt8UintV(rv.Interface().(map[int8]uint), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt8UintV(v map[int8]uint, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt8Uint8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt8Uint8R(rv reflect.Value) { fastpathTV.EncMapInt8Uint8V(rv.Interface().(map[int8]uint8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt8Uint8V(v map[int8]uint8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt8Uint16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt8Uint16R(rv reflect.Value) { fastpathTV.EncMapInt8Uint16V(rv.Interface().(map[int8]uint16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt8Uint16V(v map[int8]uint16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt8Uint32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt8Uint32R(rv reflect.Value) { fastpathTV.EncMapInt8Uint32V(rv.Interface().(map[int8]uint32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt8Uint32V(v map[int8]uint32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt8Uint64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt8Uint64R(rv reflect.Value) { fastpathTV.EncMapInt8Uint64V(rv.Interface().(map[int8]uint64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt8Uint64V(v map[int8]uint64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt8IntR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt8UintptrR(rv reflect.Value) { + fastpathTV.EncMapInt8UintptrV(rv.Interface().(map[int8]uintptr), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapInt8UintptrV(v map[int8]uintptr, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[int8(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapInt8IntR(rv reflect.Value) { fastpathTV.EncMapInt8IntV(rv.Interface().(map[int8]int), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt8IntV(v map[int8]int, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt8Int8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt8Int8R(rv reflect.Value) { fastpathTV.EncMapInt8Int8V(rv.Interface().(map[int8]int8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt8Int8V(v map[int8]int8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt8Int16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt8Int16R(rv reflect.Value) { fastpathTV.EncMapInt8Int16V(rv.Interface().(map[int8]int16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt8Int16V(v map[int8]int16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt8Int32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt8Int32R(rv reflect.Value) { fastpathTV.EncMapInt8Int32V(rv.Interface().(map[int8]int32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt8Int32V(v map[int8]int32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt8Int64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt8Int64R(rv reflect.Value) { fastpathTV.EncMapInt8Int64V(rv.Interface().(map[int8]int64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt8Int64V(v map[int8]int64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int8(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt8Float32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt8Float32R(rv reflect.Value) { fastpathTV.EncMapInt8Float32V(rv.Interface().(map[int8]float32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt8Float32V(v map[int8]float32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeFloat32(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat32(v[int8(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat32(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt8Float64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt8Float64R(rv reflect.Value) { fastpathTV.EncMapInt8Float64V(rv.Interface().(map[int8]float64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt8Float64V(v map[int8]float64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeFloat64(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat64(v[int8(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat64(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt8BoolR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt8BoolR(rv reflect.Value) { fastpathTV.EncMapInt8BoolV(rv.Interface().(map[int8]bool), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt8BoolV(v map[int8]bool, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeBool(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int8(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeBool(v[int8(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeBool(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt16IntfR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt16IntfR(rv reflect.Value) { fastpathTV.EncMapInt16IntfV(rv.Interface().(map[int16]interface{}), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt16IntfV(v map[int16]interface{}, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - e.encode(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[int16(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } e.encode(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt16StringR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt16StringR(rv reflect.Value) { fastpathTV.EncMapInt16StringV(rv.Interface().(map[int16]string), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt16StringV(v map[int16]string, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeString(c_UTF8, v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeString(c_UTF8, v[int16(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeString(c_UTF8, v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt16UintR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt16UintR(rv reflect.Value) { fastpathTV.EncMapInt16UintV(rv.Interface().(map[int16]uint), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt16UintV(v map[int16]uint, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt16Uint8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt16Uint8R(rv reflect.Value) { fastpathTV.EncMapInt16Uint8V(rv.Interface().(map[int16]uint8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt16Uint8V(v map[int16]uint8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt16Uint16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt16Uint16R(rv reflect.Value) { fastpathTV.EncMapInt16Uint16V(rv.Interface().(map[int16]uint16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt16Uint16V(v map[int16]uint16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt16Uint32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt16Uint32R(rv reflect.Value) { fastpathTV.EncMapInt16Uint32V(rv.Interface().(map[int16]uint32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt16Uint32V(v map[int16]uint32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt16Uint64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt16Uint64R(rv reflect.Value) { fastpathTV.EncMapInt16Uint64V(rv.Interface().(map[int16]uint64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt16Uint64V(v map[int16]uint64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt16IntR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt16UintptrR(rv reflect.Value) { + fastpathTV.EncMapInt16UintptrV(rv.Interface().(map[int16]uintptr), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapInt16UintptrV(v map[int16]uintptr, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[int16(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapInt16IntR(rv reflect.Value) { fastpathTV.EncMapInt16IntV(rv.Interface().(map[int16]int), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt16IntV(v map[int16]int, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt16Int8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt16Int8R(rv reflect.Value) { fastpathTV.EncMapInt16Int8V(rv.Interface().(map[int16]int8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt16Int8V(v map[int16]int8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt16Int16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt16Int16R(rv reflect.Value) { fastpathTV.EncMapInt16Int16V(rv.Interface().(map[int16]int16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt16Int16V(v map[int16]int16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt16Int32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt16Int32R(rv reflect.Value) { fastpathTV.EncMapInt16Int32V(rv.Interface().(map[int16]int32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt16Int32V(v map[int16]int32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt16Int64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt16Int64R(rv reflect.Value) { fastpathTV.EncMapInt16Int64V(rv.Interface().(map[int16]int64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt16Int64V(v map[int16]int64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int16(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt16Float32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt16Float32R(rv reflect.Value) { fastpathTV.EncMapInt16Float32V(rv.Interface().(map[int16]float32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt16Float32V(v map[int16]float32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeFloat32(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat32(v[int16(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat32(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt16Float64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt16Float64R(rv reflect.Value) { fastpathTV.EncMapInt16Float64V(rv.Interface().(map[int16]float64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt16Float64V(v map[int16]float64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeFloat64(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat64(v[int16(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat64(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt16BoolR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt16BoolR(rv reflect.Value) { fastpathTV.EncMapInt16BoolV(rv.Interface().(map[int16]bool), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt16BoolV(v map[int16]bool, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeBool(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int16(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeBool(v[int16(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeBool(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt32IntfR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt32IntfR(rv reflect.Value) { fastpathTV.EncMapInt32IntfV(rv.Interface().(map[int32]interface{}), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt32IntfV(v map[int32]interface{}, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - e.encode(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[int32(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } e.encode(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt32StringR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt32StringR(rv reflect.Value) { fastpathTV.EncMapInt32StringV(rv.Interface().(map[int32]string), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt32StringV(v map[int32]string, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeString(c_UTF8, v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeString(c_UTF8, v[int32(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeString(c_UTF8, v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt32UintR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt32UintR(rv reflect.Value) { fastpathTV.EncMapInt32UintV(rv.Interface().(map[int32]uint), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt32UintV(v map[int32]uint, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt32Uint8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt32Uint8R(rv reflect.Value) { fastpathTV.EncMapInt32Uint8V(rv.Interface().(map[int32]uint8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt32Uint8V(v map[int32]uint8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt32Uint16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt32Uint16R(rv reflect.Value) { fastpathTV.EncMapInt32Uint16V(rv.Interface().(map[int32]uint16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt32Uint16V(v map[int32]uint16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt32Uint32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt32Uint32R(rv reflect.Value) { fastpathTV.EncMapInt32Uint32V(rv.Interface().(map[int32]uint32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt32Uint32V(v map[int32]uint32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt32Uint64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt32Uint64R(rv reflect.Value) { fastpathTV.EncMapInt32Uint64V(rv.Interface().(map[int32]uint64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt32Uint64V(v map[int32]uint64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt32IntR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt32UintptrR(rv reflect.Value) { + fastpathTV.EncMapInt32UintptrV(rv.Interface().(map[int32]uintptr), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapInt32UintptrV(v map[int32]uintptr, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[int32(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapInt32IntR(rv reflect.Value) { fastpathTV.EncMapInt32IntV(rv.Interface().(map[int32]int), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt32IntV(v map[int32]int, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt32Int8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt32Int8R(rv reflect.Value) { fastpathTV.EncMapInt32Int8V(rv.Interface().(map[int32]int8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt32Int8V(v map[int32]int8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt32Int16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt32Int16R(rv reflect.Value) { fastpathTV.EncMapInt32Int16V(rv.Interface().(map[int32]int16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt32Int16V(v map[int32]int16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt32Int32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt32Int32R(rv reflect.Value) { fastpathTV.EncMapInt32Int32V(rv.Interface().(map[int32]int32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt32Int32V(v map[int32]int32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt32Int64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt32Int64R(rv reflect.Value) { fastpathTV.EncMapInt32Int64V(rv.Interface().(map[int32]int64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt32Int64V(v map[int32]int64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int32(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt32Float32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt32Float32R(rv reflect.Value) { fastpathTV.EncMapInt32Float32V(rv.Interface().(map[int32]float32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt32Float32V(v map[int32]float32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeFloat32(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat32(v[int32(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat32(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt32Float64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt32Float64R(rv reflect.Value) { fastpathTV.EncMapInt32Float64V(rv.Interface().(map[int32]float64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt32Float64V(v map[int32]float64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeFloat64(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat64(v[int32(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat64(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt32BoolR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt32BoolR(rv reflect.Value) { fastpathTV.EncMapInt32BoolV(rv.Interface().(map[int32]bool), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt32BoolV(v map[int32]bool, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeBool(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int32(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeBool(v[int32(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeBool(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt64IntfR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt64IntfR(rv reflect.Value) { fastpathTV.EncMapInt64IntfV(rv.Interface().(map[int64]interface{}), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt64IntfV(v map[int64]interface{}, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - e.encode(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[int64(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } e.encode(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt64StringR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt64StringR(rv reflect.Value) { fastpathTV.EncMapInt64StringV(rv.Interface().(map[int64]string), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt64StringV(v map[int64]string, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeString(c_UTF8, v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeString(c_UTF8, v[int64(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeString(c_UTF8, v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt64UintR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt64UintR(rv reflect.Value) { fastpathTV.EncMapInt64UintV(rv.Interface().(map[int64]uint), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt64UintV(v map[int64]uint, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt64Uint8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt64Uint8R(rv reflect.Value) { fastpathTV.EncMapInt64Uint8V(rv.Interface().(map[int64]uint8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt64Uint8V(v map[int64]uint8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt64Uint16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt64Uint16R(rv reflect.Value) { fastpathTV.EncMapInt64Uint16V(rv.Interface().(map[int64]uint16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt64Uint16V(v map[int64]uint16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt64Uint32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt64Uint32R(rv reflect.Value) { fastpathTV.EncMapInt64Uint32V(rv.Interface().(map[int64]uint32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt64Uint32V(v map[int64]uint32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt64Uint64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt64Uint64R(rv reflect.Value) { fastpathTV.EncMapInt64Uint64V(rv.Interface().(map[int64]uint64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt64Uint64V(v map[int64]uint64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[int64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt64IntR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt64UintptrR(rv reflect.Value) { + fastpathTV.EncMapInt64UintptrV(rv.Interface().(map[int64]uintptr), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapInt64UintptrV(v map[int64]uintptr, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[int64(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapInt64IntR(rv reflect.Value) { fastpathTV.EncMapInt64IntV(rv.Interface().(map[int64]int), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt64IntV(v map[int64]int, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt64Int8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt64Int8R(rv reflect.Value) { fastpathTV.EncMapInt64Int8V(rv.Interface().(map[int64]int8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt64Int8V(v map[int64]int8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt64Int16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt64Int16R(rv reflect.Value) { fastpathTV.EncMapInt64Int16V(rv.Interface().(map[int64]int16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt64Int16V(v map[int64]int16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt64Int32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt64Int32R(rv reflect.Value) { fastpathTV.EncMapInt64Int32V(rv.Interface().(map[int64]int32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt64Int32V(v map[int64]int32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt64Int64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt64Int64R(rv reflect.Value) { fastpathTV.EncMapInt64Int64V(rv.Interface().(map[int64]int64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt64Int64V(v map[int64]int64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[int64(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt64Float32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt64Float32R(rv reflect.Value) { fastpathTV.EncMapInt64Float32V(rv.Interface().(map[int64]float32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt64Float32V(v map[int64]float32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeFloat32(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat32(v[int64(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat32(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt64Float64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt64Float64R(rv reflect.Value) { fastpathTV.EncMapInt64Float64V(rv.Interface().(map[int64]float64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt64Float64V(v map[int64]float64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeFloat64(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat64(v[int64(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat64(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapInt64BoolR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapInt64BoolR(rv reflect.Value) { fastpathTV.EncMapInt64BoolV(rv.Interface().(map[int64]bool), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapInt64BoolV(v map[int64]bool, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeInt(int64(k2)) - ee.EncodeBool(v2) + if e.h.Canonical { + v2 := make([]int64, len(v)) + var i int + for k, _ := range v { + v2[i] = int64(k) + i++ + } + sort.Sort(intSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeInt(int64(int64(k2))) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeBool(v[int64(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeInt(int64(k2)) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeBool(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapBoolIntfR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapBoolIntfR(rv reflect.Value) { fastpathTV.EncMapBoolIntfV(rv.Interface().(map[bool]interface{}), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapBoolIntfV(v map[bool]interface{}, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeBool(k2) - e.encode(v2) + if e.h.Canonical { + v2 := make([]bool, len(v)) + var i int + for k, _ := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeBool(bool(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[bool(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeBool(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } e.encode(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapBoolStringR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapBoolStringR(rv reflect.Value) { fastpathTV.EncMapBoolStringV(rv.Interface().(map[bool]string), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapBoolStringV(v map[bool]string, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeBool(k2) - ee.EncodeString(c_UTF8, v2) + if e.h.Canonical { + v2 := make([]bool, len(v)) + var i int + for k, _ := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeBool(bool(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeString(c_UTF8, v[bool(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeBool(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeString(c_UTF8, v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapBoolUintR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapBoolUintR(rv reflect.Value) { fastpathTV.EncMapBoolUintV(rv.Interface().(map[bool]uint), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapBoolUintV(v map[bool]uint, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeBool(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]bool, len(v)) + var i int + for k, _ := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeBool(bool(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[bool(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeBool(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapBoolUint8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapBoolUint8R(rv reflect.Value) { fastpathTV.EncMapBoolUint8V(rv.Interface().(map[bool]uint8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapBoolUint8V(v map[bool]uint8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeBool(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]bool, len(v)) + var i int + for k, _ := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeBool(bool(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[bool(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeBool(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapBoolUint16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapBoolUint16R(rv reflect.Value) { fastpathTV.EncMapBoolUint16V(rv.Interface().(map[bool]uint16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapBoolUint16V(v map[bool]uint16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeBool(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]bool, len(v)) + var i int + for k, _ := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeBool(bool(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[bool(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeBool(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapBoolUint32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapBoolUint32R(rv reflect.Value) { fastpathTV.EncMapBoolUint32V(rv.Interface().(map[bool]uint32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapBoolUint32V(v map[bool]uint32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeBool(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]bool, len(v)) + var i int + for k, _ := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeBool(bool(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[bool(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeBool(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapBoolUint64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapBoolUint64R(rv reflect.Value) { fastpathTV.EncMapBoolUint64V(rv.Interface().(map[bool]uint64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapBoolUint64V(v map[bool]uint64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeBool(k2) - ee.EncodeUint(uint64(v2)) + if e.h.Canonical { + v2 := make([]bool, len(v)) + var i int + for k, _ := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeBool(bool(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeUint(uint64(v[bool(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeBool(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeUint(uint64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapBoolIntR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapBoolUintptrR(rv reflect.Value) { + fastpathTV.EncMapBoolUintptrV(rv.Interface().(map[bool]uintptr), fastpathCheckNilFalse, f.e) +} +func (_ fastpathT) EncMapBoolUintptrV(v map[bool]uintptr, checkNil bool, e *Encoder) { + ee := e.e + cr := e.cr + if checkNil && v == nil { + ee.EncodeNil() + return + } + ee.EncodeMapStart(len(v)) + if e.h.Canonical { + v2 := make([]bool, len(v)) + var i int + for k, _ := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeBool(bool(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v[bool(k2)]) + } + } else { + for k2, v2 := range v { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeBool(k2) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + e.encode(v2) + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } +} + +func (f *encFnInfo) fastpathEncMapBoolIntR(rv reflect.Value) { fastpathTV.EncMapBoolIntV(rv.Interface().(map[bool]int), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapBoolIntV(v map[bool]int, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeBool(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]bool, len(v)) + var i int + for k, _ := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeBool(bool(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[bool(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeBool(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapBoolInt8R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapBoolInt8R(rv reflect.Value) { fastpathTV.EncMapBoolInt8V(rv.Interface().(map[bool]int8), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapBoolInt8V(v map[bool]int8, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeBool(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]bool, len(v)) + var i int + for k, _ := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeBool(bool(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[bool(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeBool(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapBoolInt16R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapBoolInt16R(rv reflect.Value) { fastpathTV.EncMapBoolInt16V(rv.Interface().(map[bool]int16), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapBoolInt16V(v map[bool]int16, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeBool(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]bool, len(v)) + var i int + for k, _ := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeBool(bool(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[bool(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeBool(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapBoolInt32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapBoolInt32R(rv reflect.Value) { fastpathTV.EncMapBoolInt32V(rv.Interface().(map[bool]int32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapBoolInt32V(v map[bool]int32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeBool(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]bool, len(v)) + var i int + for k, _ := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeBool(bool(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[bool(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeBool(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapBoolInt64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapBoolInt64R(rv reflect.Value) { fastpathTV.EncMapBoolInt64V(rv.Interface().(map[bool]int64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapBoolInt64V(v map[bool]int64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeBool(k2) - ee.EncodeInt(int64(v2)) + if e.h.Canonical { + v2 := make([]bool, len(v)) + var i int + for k, _ := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeBool(bool(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeInt(int64(v[bool(k2)])) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeBool(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeInt(int64(v2)) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapBoolFloat32R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapBoolFloat32R(rv reflect.Value) { fastpathTV.EncMapBoolFloat32V(rv.Interface().(map[bool]float32), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapBoolFloat32V(v map[bool]float32, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeBool(k2) - ee.EncodeFloat32(v2) + if e.h.Canonical { + v2 := make([]bool, len(v)) + var i int + for k, _ := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeBool(bool(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat32(v[bool(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeBool(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat32(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapBoolFloat64R(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapBoolFloat64R(rv reflect.Value) { fastpathTV.EncMapBoolFloat64V(rv.Interface().(map[bool]float64), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapBoolFloat64V(v map[bool]float64, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeBool(k2) - ee.EncodeFloat64(v2) + if e.h.Canonical { + v2 := make([]bool, len(v)) + var i int + for k, _ := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeBool(bool(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeFloat64(v[bool(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeBool(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeFloat64(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -func (f encFnInfo) fastpathEncMapBoolBoolR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncMapBoolBoolR(rv reflect.Value) { fastpathTV.EncMapBoolBoolV(rv.Interface().(map[bool]bool), fastpathCheckNilFalse, f.e) } func (_ fastpathT) EncMapBoolBoolV(v map[bool]bool, checkNil bool, e *Encoder) { ee := e.e + cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) - - if e.be { - for k2, v2 := range v { - ee.EncodeBool(k2) - ee.EncodeBool(v2) + if e.h.Canonical { + v2 := make([]bool, len(v)) + var i int + for k, _ := range v { + v2[i] = bool(k) + i++ + } + sort.Sort(boolSlice(v2)) + for _, k2 := range v2 { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + ee.EncodeBool(bool(k2)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + ee.EncodeBool(v[bool(k2)]) } } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } ee.EncodeBool(k2) - ee.EncodeMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } ee.EncodeBool(v2) - j++ } - ee.EncodeMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } @@ -10274,6 +16010,14 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { *v = v2 } + case map[interface{}]uintptr: + fastpathTV.DecMapIntfUintptrV(v, fastpathCheckNilFalse, false, d) + case *map[interface{}]uintptr: + v2, changed2 := fastpathTV.DecMapIntfUintptrV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + case map[interface{}]int: fastpathTV.DecMapIntfIntV(v, fastpathCheckNilFalse, false, d) case *map[interface{}]int: @@ -10402,6 +16146,14 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { *v = v2 } + case map[string]uintptr: + fastpathTV.DecMapStringUintptrV(v, fastpathCheckNilFalse, false, d) + case *map[string]uintptr: + v2, changed2 := fastpathTV.DecMapStringUintptrV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + case map[string]int: fastpathTV.DecMapStringIntV(v, fastpathCheckNilFalse, false, d) case *map[string]int: @@ -10530,6 +16282,14 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { *v = v2 } + case map[float32]uintptr: + fastpathTV.DecMapFloat32UintptrV(v, fastpathCheckNilFalse, false, d) + case *map[float32]uintptr: + v2, changed2 := fastpathTV.DecMapFloat32UintptrV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + case map[float32]int: fastpathTV.DecMapFloat32IntV(v, fastpathCheckNilFalse, false, d) case *map[float32]int: @@ -10658,6 +16418,14 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { *v = v2 } + case map[float64]uintptr: + fastpathTV.DecMapFloat64UintptrV(v, fastpathCheckNilFalse, false, d) + case *map[float64]uintptr: + v2, changed2 := fastpathTV.DecMapFloat64UintptrV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + case map[float64]int: fastpathTV.DecMapFloat64IntV(v, fastpathCheckNilFalse, false, d) case *map[float64]int: @@ -10786,6 +16554,14 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { *v = v2 } + case map[uint]uintptr: + fastpathTV.DecMapUintUintptrV(v, fastpathCheckNilFalse, false, d) + case *map[uint]uintptr: + v2, changed2 := fastpathTV.DecMapUintUintptrV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + case map[uint]int: fastpathTV.DecMapUintIntV(v, fastpathCheckNilFalse, false, d) case *map[uint]int: @@ -10906,6 +16682,14 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { *v = v2 } + case map[uint8]uintptr: + fastpathTV.DecMapUint8UintptrV(v, fastpathCheckNilFalse, false, d) + case *map[uint8]uintptr: + v2, changed2 := fastpathTV.DecMapUint8UintptrV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + case map[uint8]int: fastpathTV.DecMapUint8IntV(v, fastpathCheckNilFalse, false, d) case *map[uint8]int: @@ -11034,6 +16818,14 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { *v = v2 } + case map[uint16]uintptr: + fastpathTV.DecMapUint16UintptrV(v, fastpathCheckNilFalse, false, d) + case *map[uint16]uintptr: + v2, changed2 := fastpathTV.DecMapUint16UintptrV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + case map[uint16]int: fastpathTV.DecMapUint16IntV(v, fastpathCheckNilFalse, false, d) case *map[uint16]int: @@ -11162,6 +16954,14 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { *v = v2 } + case map[uint32]uintptr: + fastpathTV.DecMapUint32UintptrV(v, fastpathCheckNilFalse, false, d) + case *map[uint32]uintptr: + v2, changed2 := fastpathTV.DecMapUint32UintptrV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + case map[uint32]int: fastpathTV.DecMapUint32IntV(v, fastpathCheckNilFalse, false, d) case *map[uint32]int: @@ -11290,6 +17090,14 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { *v = v2 } + case map[uint64]uintptr: + fastpathTV.DecMapUint64UintptrV(v, fastpathCheckNilFalse, false, d) + case *map[uint64]uintptr: + v2, changed2 := fastpathTV.DecMapUint64UintptrV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + case map[uint64]int: fastpathTV.DecMapUint64IntV(v, fastpathCheckNilFalse, false, d) case *map[uint64]int: @@ -11354,6 +17162,142 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { *v = v2 } + case []uintptr: + fastpathTV.DecSliceUintptrV(v, fastpathCheckNilFalse, false, d) + case *[]uintptr: + v2, changed2 := fastpathTV.DecSliceUintptrV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + + case map[uintptr]interface{}: + fastpathTV.DecMapUintptrIntfV(v, fastpathCheckNilFalse, false, d) + case *map[uintptr]interface{}: + v2, changed2 := fastpathTV.DecMapUintptrIntfV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + + case map[uintptr]string: + fastpathTV.DecMapUintptrStringV(v, fastpathCheckNilFalse, false, d) + case *map[uintptr]string: + v2, changed2 := fastpathTV.DecMapUintptrStringV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + + case map[uintptr]uint: + fastpathTV.DecMapUintptrUintV(v, fastpathCheckNilFalse, false, d) + case *map[uintptr]uint: + v2, changed2 := fastpathTV.DecMapUintptrUintV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + + case map[uintptr]uint8: + fastpathTV.DecMapUintptrUint8V(v, fastpathCheckNilFalse, false, d) + case *map[uintptr]uint8: + v2, changed2 := fastpathTV.DecMapUintptrUint8V(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + + case map[uintptr]uint16: + fastpathTV.DecMapUintptrUint16V(v, fastpathCheckNilFalse, false, d) + case *map[uintptr]uint16: + v2, changed2 := fastpathTV.DecMapUintptrUint16V(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + + case map[uintptr]uint32: + fastpathTV.DecMapUintptrUint32V(v, fastpathCheckNilFalse, false, d) + case *map[uintptr]uint32: + v2, changed2 := fastpathTV.DecMapUintptrUint32V(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + + case map[uintptr]uint64: + fastpathTV.DecMapUintptrUint64V(v, fastpathCheckNilFalse, false, d) + case *map[uintptr]uint64: + v2, changed2 := fastpathTV.DecMapUintptrUint64V(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + + case map[uintptr]uintptr: + fastpathTV.DecMapUintptrUintptrV(v, fastpathCheckNilFalse, false, d) + case *map[uintptr]uintptr: + v2, changed2 := fastpathTV.DecMapUintptrUintptrV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + + case map[uintptr]int: + fastpathTV.DecMapUintptrIntV(v, fastpathCheckNilFalse, false, d) + case *map[uintptr]int: + v2, changed2 := fastpathTV.DecMapUintptrIntV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + + case map[uintptr]int8: + fastpathTV.DecMapUintptrInt8V(v, fastpathCheckNilFalse, false, d) + case *map[uintptr]int8: + v2, changed2 := fastpathTV.DecMapUintptrInt8V(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + + case map[uintptr]int16: + fastpathTV.DecMapUintptrInt16V(v, fastpathCheckNilFalse, false, d) + case *map[uintptr]int16: + v2, changed2 := fastpathTV.DecMapUintptrInt16V(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + + case map[uintptr]int32: + fastpathTV.DecMapUintptrInt32V(v, fastpathCheckNilFalse, false, d) + case *map[uintptr]int32: + v2, changed2 := fastpathTV.DecMapUintptrInt32V(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + + case map[uintptr]int64: + fastpathTV.DecMapUintptrInt64V(v, fastpathCheckNilFalse, false, d) + case *map[uintptr]int64: + v2, changed2 := fastpathTV.DecMapUintptrInt64V(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + + case map[uintptr]float32: + fastpathTV.DecMapUintptrFloat32V(v, fastpathCheckNilFalse, false, d) + case *map[uintptr]float32: + v2, changed2 := fastpathTV.DecMapUintptrFloat32V(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + + case map[uintptr]float64: + fastpathTV.DecMapUintptrFloat64V(v, fastpathCheckNilFalse, false, d) + case *map[uintptr]float64: + v2, changed2 := fastpathTV.DecMapUintptrFloat64V(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + + case map[uintptr]bool: + fastpathTV.DecMapUintptrBoolV(v, fastpathCheckNilFalse, false, d) + case *map[uintptr]bool: + v2, changed2 := fastpathTV.DecMapUintptrBoolV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + case []int: fastpathTV.DecSliceIntV(v, fastpathCheckNilFalse, false, d) case *[]int: @@ -11418,6 +17362,14 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { *v = v2 } + case map[int]uintptr: + fastpathTV.DecMapIntUintptrV(v, fastpathCheckNilFalse, false, d) + case *map[int]uintptr: + v2, changed2 := fastpathTV.DecMapIntUintptrV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + case map[int]int: fastpathTV.DecMapIntIntV(v, fastpathCheckNilFalse, false, d) case *map[int]int: @@ -11546,6 +17498,14 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { *v = v2 } + case map[int8]uintptr: + fastpathTV.DecMapInt8UintptrV(v, fastpathCheckNilFalse, false, d) + case *map[int8]uintptr: + v2, changed2 := fastpathTV.DecMapInt8UintptrV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + case map[int8]int: fastpathTV.DecMapInt8IntV(v, fastpathCheckNilFalse, false, d) case *map[int8]int: @@ -11674,6 +17634,14 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { *v = v2 } + case map[int16]uintptr: + fastpathTV.DecMapInt16UintptrV(v, fastpathCheckNilFalse, false, d) + case *map[int16]uintptr: + v2, changed2 := fastpathTV.DecMapInt16UintptrV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + case map[int16]int: fastpathTV.DecMapInt16IntV(v, fastpathCheckNilFalse, false, d) case *map[int16]int: @@ -11802,6 +17770,14 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { *v = v2 } + case map[int32]uintptr: + fastpathTV.DecMapInt32UintptrV(v, fastpathCheckNilFalse, false, d) + case *map[int32]uintptr: + v2, changed2 := fastpathTV.DecMapInt32UintptrV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + case map[int32]int: fastpathTV.DecMapInt32IntV(v, fastpathCheckNilFalse, false, d) case *map[int32]int: @@ -11930,6 +17906,14 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { *v = v2 } + case map[int64]uintptr: + fastpathTV.DecMapInt64UintptrV(v, fastpathCheckNilFalse, false, d) + case *map[int64]uintptr: + v2, changed2 := fastpathTV.DecMapInt64UintptrV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + case map[int64]int: fastpathTV.DecMapInt64IntV(v, fastpathCheckNilFalse, false, d) case *map[int64]int: @@ -12058,6 +18042,14 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { *v = v2 } + case map[bool]uintptr: + fastpathTV.DecMapBoolUintptrV(v, fastpathCheckNilFalse, false, d) + case *map[bool]uintptr: + v2, changed2 := fastpathTV.DecMapBoolUintptrV(*v, fastpathCheckNilFalse, true, d) + if changed2 { + *v = v2 + } + case map[bool]int: fastpathTV.DecMapBoolIntV(v, fastpathCheckNilFalse, false, d) case *map[bool]int: @@ -12123,6 +18115,7 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { } default: + _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) return false } return true @@ -12130,9 +18123,9 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { // -- -- fast path functions -func (f decFnInfo) fastpathDecSliceIntfR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecSliceIntfR(rv reflect.Value) { array := f.seq == seqTypeArray - if !array && rv.CanAddr() { // CanSet => CanAddr + Exported + if !array && rv.CanAddr() { vp := rv.Addr().Interface().(*[]interface{}) v, changed := fastpathTV.DecSliceIntfV(*vp, fastpathCheckNilFalse, !array, f.d) if changed { @@ -12150,10 +18143,9 @@ func (f fastpathT) DecSliceIntfX(vp *[]interface{}, checkNil bool, d *Decoder) { *vp = v } } -func (_ fastpathT) DecSliceIntfV(v []interface{}, checkNil bool, canChange bool, - d *Decoder) (_ []interface{}, changed bool) { +func (_ fastpathT) DecSliceIntfV(v []interface{}, checkNil bool, canChange bool, d *Decoder) (_ []interface{}, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -12162,52 +18154,83 @@ func (_ fastpathT) DecSliceIntfV(v []interface{}, checkNil bool, canChange bool, } slh, containerLenS := d.decSliceHelperStart() - if canChange && v == nil { - if containerLenS <= 0 { - v = []interface{}{} - } else { - v = make([]interface{}, containerLenS, containerLenS) - } - changed = true - } if containerLenS == 0 { - if canChange && len(v) != 0 { - v = v[:0] + if canChange { + if v == nil { + v = []interface{}{} + } else if len(v) != 0 { + v = v[:0] + } changed = true } + slh.End() return v, changed } - // for j := 0; j < containerLenS; j++ { if containerLenS > 0 { - decLen := containerLenS + x2read := containerLenS + var xtrunc bool if containerLenS > cap(v) { if canChange { - s := make([]interface{}, containerLenS, containerLenS) - // copy(s, v[:cap(v)]) - v = s + var xlen int + xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 16) + if xtrunc { + if xlen <= cap(v) { + v = v[:xlen] + } else { + v = make([]interface{}, xlen) + } + } else { + v = make([]interface{}, xlen) + } changed = true } else { d.arrayCannotExpand(len(v), containerLenS) - decLen = len(v) } + x2read = len(v) } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + if canChange { + v = v[:containerLenS] + changed = true + } } - // all checks done. cannot go past len. j := 0 - for ; j < decLen; j++ { + for ; j < x2read; j++ { + slh.ElemContainerState(j) d.decode(&v[j]) } - if !canChange { + if xtrunc { for ; j < containerLenS; j++ { + v = append(v, nil) + slh.ElemContainerState(j) + d.decode(&v[j]) + } + } else if !canChange { + for ; j < containerLenS; j++ { + slh.ElemContainerState(j) d.swallow() } } } else { + breakFound := dd.CheckBreak() + if breakFound { + if canChange { + if v == nil { + v = []interface{}{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + if cap(v) == 0 { + v = make([]interface{}, 1, 4) + changed = true + } j := 0 - for ; !dd.CheckBreak(); j++ { + for ; !breakFound; j++ { if j >= len(v) { if canChange { v = append(v, nil) @@ -12216,24 +18239,27 @@ func (_ fastpathT) DecSliceIntfV(v []interface{}, checkNil bool, canChange bool, d.arrayCannotExpand(len(v), j+1) } } - if j > 0 { - slh.Sep(j) - } - if j < len(v) { // all checks done. cannot go past len. + slh.ElemContainerState(j) + if j < len(v) { d.decode(&v[j]) } else { d.swallow() } + breakFound = dd.CheckBreak() + } + if canChange && j < len(v) { + v = v[:j] + changed = true } - slh.End() } + slh.End() return v, changed } -func (f decFnInfo) fastpathDecSliceStringR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecSliceStringR(rv reflect.Value) { array := f.seq == seqTypeArray - if !array && rv.CanAddr() { // CanSet => CanAddr + Exported + if !array && rv.CanAddr() { vp := rv.Addr().Interface().(*[]string) v, changed := fastpathTV.DecSliceStringV(*vp, fastpathCheckNilFalse, !array, f.d) if changed { @@ -12251,10 +18277,9 @@ func (f fastpathT) DecSliceStringX(vp *[]string, checkNil bool, d *Decoder) { *vp = v } } -func (_ fastpathT) DecSliceStringV(v []string, checkNil bool, canChange bool, - d *Decoder) (_ []string, changed bool) { +func (_ fastpathT) DecSliceStringV(v []string, checkNil bool, canChange bool, d *Decoder) (_ []string, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -12263,52 +18288,83 @@ func (_ fastpathT) DecSliceStringV(v []string, checkNil bool, canChange bool, } slh, containerLenS := d.decSliceHelperStart() - if canChange && v == nil { - if containerLenS <= 0 { - v = []string{} - } else { - v = make([]string, containerLenS, containerLenS) - } - changed = true - } if containerLenS == 0 { - if canChange && len(v) != 0 { - v = v[:0] + if canChange { + if v == nil { + v = []string{} + } else if len(v) != 0 { + v = v[:0] + } changed = true } + slh.End() return v, changed } - // for j := 0; j < containerLenS; j++ { if containerLenS > 0 { - decLen := containerLenS + x2read := containerLenS + var xtrunc bool if containerLenS > cap(v) { if canChange { - s := make([]string, containerLenS, containerLenS) - // copy(s, v[:cap(v)]) - v = s + var xlen int + xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 16) + if xtrunc { + if xlen <= cap(v) { + v = v[:xlen] + } else { + v = make([]string, xlen) + } + } else { + v = make([]string, xlen) + } changed = true } else { d.arrayCannotExpand(len(v), containerLenS) - decLen = len(v) } + x2read = len(v) } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + if canChange { + v = v[:containerLenS] + changed = true + } } - // all checks done. cannot go past len. j := 0 - for ; j < decLen; j++ { + for ; j < x2read; j++ { + slh.ElemContainerState(j) v[j] = dd.DecodeString() } - if !canChange { + if xtrunc { for ; j < containerLenS; j++ { + v = append(v, "") + slh.ElemContainerState(j) + v[j] = dd.DecodeString() + } + } else if !canChange { + for ; j < containerLenS; j++ { + slh.ElemContainerState(j) d.swallow() } } } else { + breakFound := dd.CheckBreak() + if breakFound { + if canChange { + if v == nil { + v = []string{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + if cap(v) == 0 { + v = make([]string, 1, 4) + changed = true + } j := 0 - for ; !dd.CheckBreak(); j++ { + for ; !breakFound; j++ { if j >= len(v) { if canChange { v = append(v, "") @@ -12317,23 +18373,26 @@ func (_ fastpathT) DecSliceStringV(v []string, checkNil bool, canChange bool, d.arrayCannotExpand(len(v), j+1) } } - if j > 0 { - slh.Sep(j) - } - if j < len(v) { // all checks done. cannot go past len. + slh.ElemContainerState(j) + if j < len(v) { v[j] = dd.DecodeString() } else { d.swallow() } + breakFound = dd.CheckBreak() + } + if canChange && j < len(v) { + v = v[:j] + changed = true } - slh.End() } + slh.End() return v, changed } -func (f decFnInfo) fastpathDecSliceFloat32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecSliceFloat32R(rv reflect.Value) { array := f.seq == seqTypeArray - if !array && rv.CanAddr() { // CanSet => CanAddr + Exported + if !array && rv.CanAddr() { vp := rv.Addr().Interface().(*[]float32) v, changed := fastpathTV.DecSliceFloat32V(*vp, fastpathCheckNilFalse, !array, f.d) if changed { @@ -12351,10 +18410,9 @@ func (f fastpathT) DecSliceFloat32X(vp *[]float32, checkNil bool, d *Decoder) { *vp = v } } -func (_ fastpathT) DecSliceFloat32V(v []float32, checkNil bool, canChange bool, - d *Decoder) (_ []float32, changed bool) { +func (_ fastpathT) DecSliceFloat32V(v []float32, checkNil bool, canChange bool, d *Decoder) (_ []float32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -12363,52 +18421,83 @@ func (_ fastpathT) DecSliceFloat32V(v []float32, checkNil bool, canChange bool, } slh, containerLenS := d.decSliceHelperStart() - if canChange && v == nil { - if containerLenS <= 0 { - v = []float32{} - } else { - v = make([]float32, containerLenS, containerLenS) - } - changed = true - } if containerLenS == 0 { - if canChange && len(v) != 0 { - v = v[:0] + if canChange { + if v == nil { + v = []float32{} + } else if len(v) != 0 { + v = v[:0] + } changed = true } + slh.End() return v, changed } - // for j := 0; j < containerLenS; j++ { if containerLenS > 0 { - decLen := containerLenS + x2read := containerLenS + var xtrunc bool if containerLenS > cap(v) { if canChange { - s := make([]float32, containerLenS, containerLenS) - // copy(s, v[:cap(v)]) - v = s + var xlen int + xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 4) + if xtrunc { + if xlen <= cap(v) { + v = v[:xlen] + } else { + v = make([]float32, xlen) + } + } else { + v = make([]float32, xlen) + } changed = true } else { d.arrayCannotExpand(len(v), containerLenS) - decLen = len(v) } + x2read = len(v) } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + if canChange { + v = v[:containerLenS] + changed = true + } } - // all checks done. cannot go past len. j := 0 - for ; j < decLen; j++ { + for ; j < x2read; j++ { + slh.ElemContainerState(j) v[j] = float32(dd.DecodeFloat(true)) } - if !canChange { + if xtrunc { for ; j < containerLenS; j++ { + v = append(v, 0) + slh.ElemContainerState(j) + v[j] = float32(dd.DecodeFloat(true)) + } + } else if !canChange { + for ; j < containerLenS; j++ { + slh.ElemContainerState(j) d.swallow() } } } else { + breakFound := dd.CheckBreak() + if breakFound { + if canChange { + if v == nil { + v = []float32{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + if cap(v) == 0 { + v = make([]float32, 1, 4) + changed = true + } j := 0 - for ; !dd.CheckBreak(); j++ { + for ; !breakFound; j++ { if j >= len(v) { if canChange { v = append(v, 0) @@ -12417,23 +18506,26 @@ func (_ fastpathT) DecSliceFloat32V(v []float32, checkNil bool, canChange bool, d.arrayCannotExpand(len(v), j+1) } } - if j > 0 { - slh.Sep(j) - } - if j < len(v) { // all checks done. cannot go past len. + slh.ElemContainerState(j) + if j < len(v) { v[j] = float32(dd.DecodeFloat(true)) } else { d.swallow() } + breakFound = dd.CheckBreak() + } + if canChange && j < len(v) { + v = v[:j] + changed = true } - slh.End() } + slh.End() return v, changed } -func (f decFnInfo) fastpathDecSliceFloat64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecSliceFloat64R(rv reflect.Value) { array := f.seq == seqTypeArray - if !array && rv.CanAddr() { // CanSet => CanAddr + Exported + if !array && rv.CanAddr() { vp := rv.Addr().Interface().(*[]float64) v, changed := fastpathTV.DecSliceFloat64V(*vp, fastpathCheckNilFalse, !array, f.d) if changed { @@ -12451,10 +18543,9 @@ func (f fastpathT) DecSliceFloat64X(vp *[]float64, checkNil bool, d *Decoder) { *vp = v } } -func (_ fastpathT) DecSliceFloat64V(v []float64, checkNil bool, canChange bool, - d *Decoder) (_ []float64, changed bool) { +func (_ fastpathT) DecSliceFloat64V(v []float64, checkNil bool, canChange bool, d *Decoder) (_ []float64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -12463,52 +18554,83 @@ func (_ fastpathT) DecSliceFloat64V(v []float64, checkNil bool, canChange bool, } slh, containerLenS := d.decSliceHelperStart() - if canChange && v == nil { - if containerLenS <= 0 { - v = []float64{} - } else { - v = make([]float64, containerLenS, containerLenS) - } - changed = true - } if containerLenS == 0 { - if canChange && len(v) != 0 { - v = v[:0] + if canChange { + if v == nil { + v = []float64{} + } else if len(v) != 0 { + v = v[:0] + } changed = true } + slh.End() return v, changed } - // for j := 0; j < containerLenS; j++ { if containerLenS > 0 { - decLen := containerLenS + x2read := containerLenS + var xtrunc bool if containerLenS > cap(v) { if canChange { - s := make([]float64, containerLenS, containerLenS) - // copy(s, v[:cap(v)]) - v = s + var xlen int + xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 8) + if xtrunc { + if xlen <= cap(v) { + v = v[:xlen] + } else { + v = make([]float64, xlen) + } + } else { + v = make([]float64, xlen) + } changed = true } else { d.arrayCannotExpand(len(v), containerLenS) - decLen = len(v) } + x2read = len(v) } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + if canChange { + v = v[:containerLenS] + changed = true + } } - // all checks done. cannot go past len. j := 0 - for ; j < decLen; j++ { + for ; j < x2read; j++ { + slh.ElemContainerState(j) v[j] = dd.DecodeFloat(false) } - if !canChange { + if xtrunc { for ; j < containerLenS; j++ { + v = append(v, 0) + slh.ElemContainerState(j) + v[j] = dd.DecodeFloat(false) + } + } else if !canChange { + for ; j < containerLenS; j++ { + slh.ElemContainerState(j) d.swallow() } } } else { + breakFound := dd.CheckBreak() + if breakFound { + if canChange { + if v == nil { + v = []float64{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + if cap(v) == 0 { + v = make([]float64, 1, 4) + changed = true + } j := 0 - for ; !dd.CheckBreak(); j++ { + for ; !breakFound; j++ { if j >= len(v) { if canChange { v = append(v, 0) @@ -12517,23 +18639,26 @@ func (_ fastpathT) DecSliceFloat64V(v []float64, checkNil bool, canChange bool, d.arrayCannotExpand(len(v), j+1) } } - if j > 0 { - slh.Sep(j) - } - if j < len(v) { // all checks done. cannot go past len. + slh.ElemContainerState(j) + if j < len(v) { v[j] = dd.DecodeFloat(false) } else { d.swallow() } + breakFound = dd.CheckBreak() + } + if canChange && j < len(v) { + v = v[:j] + changed = true } - slh.End() } + slh.End() return v, changed } -func (f decFnInfo) fastpathDecSliceUintR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecSliceUintR(rv reflect.Value) { array := f.seq == seqTypeArray - if !array && rv.CanAddr() { // CanSet => CanAddr + Exported + if !array && rv.CanAddr() { vp := rv.Addr().Interface().(*[]uint) v, changed := fastpathTV.DecSliceUintV(*vp, fastpathCheckNilFalse, !array, f.d) if changed { @@ -12551,10 +18676,9 @@ func (f fastpathT) DecSliceUintX(vp *[]uint, checkNil bool, d *Decoder) { *vp = v } } -func (_ fastpathT) DecSliceUintV(v []uint, checkNil bool, canChange bool, - d *Decoder) (_ []uint, changed bool) { +func (_ fastpathT) DecSliceUintV(v []uint, checkNil bool, canChange bool, d *Decoder) (_ []uint, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -12563,52 +18687,83 @@ func (_ fastpathT) DecSliceUintV(v []uint, checkNil bool, canChange bool, } slh, containerLenS := d.decSliceHelperStart() - if canChange && v == nil { - if containerLenS <= 0 { - v = []uint{} - } else { - v = make([]uint, containerLenS, containerLenS) - } - changed = true - } if containerLenS == 0 { - if canChange && len(v) != 0 { - v = v[:0] + if canChange { + if v == nil { + v = []uint{} + } else if len(v) != 0 { + v = v[:0] + } changed = true } + slh.End() return v, changed } - // for j := 0; j < containerLenS; j++ { if containerLenS > 0 { - decLen := containerLenS + x2read := containerLenS + var xtrunc bool if containerLenS > cap(v) { if canChange { - s := make([]uint, containerLenS, containerLenS) - // copy(s, v[:cap(v)]) - v = s + var xlen int + xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 8) + if xtrunc { + if xlen <= cap(v) { + v = v[:xlen] + } else { + v = make([]uint, xlen) + } + } else { + v = make([]uint, xlen) + } changed = true } else { d.arrayCannotExpand(len(v), containerLenS) - decLen = len(v) } + x2read = len(v) } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + if canChange { + v = v[:containerLenS] + changed = true + } } - // all checks done. cannot go past len. j := 0 - for ; j < decLen; j++ { + for ; j < x2read; j++ { + slh.ElemContainerState(j) v[j] = uint(dd.DecodeUint(uintBitsize)) } - if !canChange { + if xtrunc { for ; j < containerLenS; j++ { + v = append(v, 0) + slh.ElemContainerState(j) + v[j] = uint(dd.DecodeUint(uintBitsize)) + } + } else if !canChange { + for ; j < containerLenS; j++ { + slh.ElemContainerState(j) d.swallow() } } } else { + breakFound := dd.CheckBreak() + if breakFound { + if canChange { + if v == nil { + v = []uint{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + if cap(v) == 0 { + v = make([]uint, 1, 4) + changed = true + } j := 0 - for ; !dd.CheckBreak(); j++ { + for ; !breakFound; j++ { if j >= len(v) { if canChange { v = append(v, 0) @@ -12617,23 +18772,26 @@ func (_ fastpathT) DecSliceUintV(v []uint, checkNil bool, canChange bool, d.arrayCannotExpand(len(v), j+1) } } - if j > 0 { - slh.Sep(j) - } - if j < len(v) { // all checks done. cannot go past len. + slh.ElemContainerState(j) + if j < len(v) { v[j] = uint(dd.DecodeUint(uintBitsize)) } else { d.swallow() } + breakFound = dd.CheckBreak() + } + if canChange && j < len(v) { + v = v[:j] + changed = true } - slh.End() } + slh.End() return v, changed } -func (f decFnInfo) fastpathDecSliceUint16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecSliceUint16R(rv reflect.Value) { array := f.seq == seqTypeArray - if !array && rv.CanAddr() { // CanSet => CanAddr + Exported + if !array && rv.CanAddr() { vp := rv.Addr().Interface().(*[]uint16) v, changed := fastpathTV.DecSliceUint16V(*vp, fastpathCheckNilFalse, !array, f.d) if changed { @@ -12651,10 +18809,9 @@ func (f fastpathT) DecSliceUint16X(vp *[]uint16, checkNil bool, d *Decoder) { *vp = v } } -func (_ fastpathT) DecSliceUint16V(v []uint16, checkNil bool, canChange bool, - d *Decoder) (_ []uint16, changed bool) { +func (_ fastpathT) DecSliceUint16V(v []uint16, checkNil bool, canChange bool, d *Decoder) (_ []uint16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -12663,52 +18820,83 @@ func (_ fastpathT) DecSliceUint16V(v []uint16, checkNil bool, canChange bool, } slh, containerLenS := d.decSliceHelperStart() - if canChange && v == nil { - if containerLenS <= 0 { - v = []uint16{} - } else { - v = make([]uint16, containerLenS, containerLenS) - } - changed = true - } if containerLenS == 0 { - if canChange && len(v) != 0 { - v = v[:0] + if canChange { + if v == nil { + v = []uint16{} + } else if len(v) != 0 { + v = v[:0] + } changed = true } + slh.End() return v, changed } - // for j := 0; j < containerLenS; j++ { if containerLenS > 0 { - decLen := containerLenS + x2read := containerLenS + var xtrunc bool if containerLenS > cap(v) { if canChange { - s := make([]uint16, containerLenS, containerLenS) - // copy(s, v[:cap(v)]) - v = s + var xlen int + xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 2) + if xtrunc { + if xlen <= cap(v) { + v = v[:xlen] + } else { + v = make([]uint16, xlen) + } + } else { + v = make([]uint16, xlen) + } changed = true } else { d.arrayCannotExpand(len(v), containerLenS) - decLen = len(v) } + x2read = len(v) } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + if canChange { + v = v[:containerLenS] + changed = true + } } - // all checks done. cannot go past len. j := 0 - for ; j < decLen; j++ { + for ; j < x2read; j++ { + slh.ElemContainerState(j) v[j] = uint16(dd.DecodeUint(16)) } - if !canChange { + if xtrunc { for ; j < containerLenS; j++ { + v = append(v, 0) + slh.ElemContainerState(j) + v[j] = uint16(dd.DecodeUint(16)) + } + } else if !canChange { + for ; j < containerLenS; j++ { + slh.ElemContainerState(j) d.swallow() } } } else { + breakFound := dd.CheckBreak() + if breakFound { + if canChange { + if v == nil { + v = []uint16{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + if cap(v) == 0 { + v = make([]uint16, 1, 4) + changed = true + } j := 0 - for ; !dd.CheckBreak(); j++ { + for ; !breakFound; j++ { if j >= len(v) { if canChange { v = append(v, 0) @@ -12717,23 +18905,26 @@ func (_ fastpathT) DecSliceUint16V(v []uint16, checkNil bool, canChange bool, d.arrayCannotExpand(len(v), j+1) } } - if j > 0 { - slh.Sep(j) - } - if j < len(v) { // all checks done. cannot go past len. + slh.ElemContainerState(j) + if j < len(v) { v[j] = uint16(dd.DecodeUint(16)) } else { d.swallow() } + breakFound = dd.CheckBreak() + } + if canChange && j < len(v) { + v = v[:j] + changed = true } - slh.End() } + slh.End() return v, changed } -func (f decFnInfo) fastpathDecSliceUint32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecSliceUint32R(rv reflect.Value) { array := f.seq == seqTypeArray - if !array && rv.CanAddr() { // CanSet => CanAddr + Exported + if !array && rv.CanAddr() { vp := rv.Addr().Interface().(*[]uint32) v, changed := fastpathTV.DecSliceUint32V(*vp, fastpathCheckNilFalse, !array, f.d) if changed { @@ -12751,10 +18942,9 @@ func (f fastpathT) DecSliceUint32X(vp *[]uint32, checkNil bool, d *Decoder) { *vp = v } } -func (_ fastpathT) DecSliceUint32V(v []uint32, checkNil bool, canChange bool, - d *Decoder) (_ []uint32, changed bool) { +func (_ fastpathT) DecSliceUint32V(v []uint32, checkNil bool, canChange bool, d *Decoder) (_ []uint32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -12763,52 +18953,83 @@ func (_ fastpathT) DecSliceUint32V(v []uint32, checkNil bool, canChange bool, } slh, containerLenS := d.decSliceHelperStart() - if canChange && v == nil { - if containerLenS <= 0 { - v = []uint32{} - } else { - v = make([]uint32, containerLenS, containerLenS) - } - changed = true - } if containerLenS == 0 { - if canChange && len(v) != 0 { - v = v[:0] + if canChange { + if v == nil { + v = []uint32{} + } else if len(v) != 0 { + v = v[:0] + } changed = true } + slh.End() return v, changed } - // for j := 0; j < containerLenS; j++ { if containerLenS > 0 { - decLen := containerLenS + x2read := containerLenS + var xtrunc bool if containerLenS > cap(v) { if canChange { - s := make([]uint32, containerLenS, containerLenS) - // copy(s, v[:cap(v)]) - v = s + var xlen int + xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 4) + if xtrunc { + if xlen <= cap(v) { + v = v[:xlen] + } else { + v = make([]uint32, xlen) + } + } else { + v = make([]uint32, xlen) + } changed = true } else { d.arrayCannotExpand(len(v), containerLenS) - decLen = len(v) } + x2read = len(v) } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + if canChange { + v = v[:containerLenS] + changed = true + } } - // all checks done. cannot go past len. j := 0 - for ; j < decLen; j++ { + for ; j < x2read; j++ { + slh.ElemContainerState(j) v[j] = uint32(dd.DecodeUint(32)) } - if !canChange { + if xtrunc { for ; j < containerLenS; j++ { + v = append(v, 0) + slh.ElemContainerState(j) + v[j] = uint32(dd.DecodeUint(32)) + } + } else if !canChange { + for ; j < containerLenS; j++ { + slh.ElemContainerState(j) d.swallow() } } } else { + breakFound := dd.CheckBreak() + if breakFound { + if canChange { + if v == nil { + v = []uint32{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + if cap(v) == 0 { + v = make([]uint32, 1, 4) + changed = true + } j := 0 - for ; !dd.CheckBreak(); j++ { + for ; !breakFound; j++ { if j >= len(v) { if canChange { v = append(v, 0) @@ -12817,23 +19038,26 @@ func (_ fastpathT) DecSliceUint32V(v []uint32, checkNil bool, canChange bool, d.arrayCannotExpand(len(v), j+1) } } - if j > 0 { - slh.Sep(j) - } - if j < len(v) { // all checks done. cannot go past len. + slh.ElemContainerState(j) + if j < len(v) { v[j] = uint32(dd.DecodeUint(32)) } else { d.swallow() } + breakFound = dd.CheckBreak() + } + if canChange && j < len(v) { + v = v[:j] + changed = true } - slh.End() } + slh.End() return v, changed } -func (f decFnInfo) fastpathDecSliceUint64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecSliceUint64R(rv reflect.Value) { array := f.seq == seqTypeArray - if !array && rv.CanAddr() { // CanSet => CanAddr + Exported + if !array && rv.CanAddr() { vp := rv.Addr().Interface().(*[]uint64) v, changed := fastpathTV.DecSliceUint64V(*vp, fastpathCheckNilFalse, !array, f.d) if changed { @@ -12851,10 +19075,9 @@ func (f fastpathT) DecSliceUint64X(vp *[]uint64, checkNil bool, d *Decoder) { *vp = v } } -func (_ fastpathT) DecSliceUint64V(v []uint64, checkNil bool, canChange bool, - d *Decoder) (_ []uint64, changed bool) { +func (_ fastpathT) DecSliceUint64V(v []uint64, checkNil bool, canChange bool, d *Decoder) (_ []uint64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -12863,52 +19086,83 @@ func (_ fastpathT) DecSliceUint64V(v []uint64, checkNil bool, canChange bool, } slh, containerLenS := d.decSliceHelperStart() - if canChange && v == nil { - if containerLenS <= 0 { - v = []uint64{} - } else { - v = make([]uint64, containerLenS, containerLenS) - } - changed = true - } if containerLenS == 0 { - if canChange && len(v) != 0 { - v = v[:0] + if canChange { + if v == nil { + v = []uint64{} + } else if len(v) != 0 { + v = v[:0] + } changed = true } + slh.End() return v, changed } - // for j := 0; j < containerLenS; j++ { if containerLenS > 0 { - decLen := containerLenS + x2read := containerLenS + var xtrunc bool if containerLenS > cap(v) { if canChange { - s := make([]uint64, containerLenS, containerLenS) - // copy(s, v[:cap(v)]) - v = s + var xlen int + xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 8) + if xtrunc { + if xlen <= cap(v) { + v = v[:xlen] + } else { + v = make([]uint64, xlen) + } + } else { + v = make([]uint64, xlen) + } changed = true } else { d.arrayCannotExpand(len(v), containerLenS) - decLen = len(v) } + x2read = len(v) } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + if canChange { + v = v[:containerLenS] + changed = true + } } - // all checks done. cannot go past len. j := 0 - for ; j < decLen; j++ { + for ; j < x2read; j++ { + slh.ElemContainerState(j) v[j] = dd.DecodeUint(64) } - if !canChange { + if xtrunc { for ; j < containerLenS; j++ { + v = append(v, 0) + slh.ElemContainerState(j) + v[j] = dd.DecodeUint(64) + } + } else if !canChange { + for ; j < containerLenS; j++ { + slh.ElemContainerState(j) d.swallow() } } } else { + breakFound := dd.CheckBreak() + if breakFound { + if canChange { + if v == nil { + v = []uint64{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + if cap(v) == 0 { + v = make([]uint64, 1, 4) + changed = true + } j := 0 - for ; !dd.CheckBreak(); j++ { + for ; !breakFound; j++ { if j >= len(v) { if canChange { v = append(v, 0) @@ -12917,23 +19171,159 @@ func (_ fastpathT) DecSliceUint64V(v []uint64, checkNil bool, canChange bool, d.arrayCannotExpand(len(v), j+1) } } - if j > 0 { - slh.Sep(j) - } - if j < len(v) { // all checks done. cannot go past len. + slh.ElemContainerState(j) + if j < len(v) { v[j] = dd.DecodeUint(64) } else { d.swallow() } + breakFound = dd.CheckBreak() + } + if canChange && j < len(v) { + v = v[:j] + changed = true } - slh.End() } + slh.End() return v, changed } -func (f decFnInfo) fastpathDecSliceIntR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecSliceUintptrR(rv reflect.Value) { array := f.seq == seqTypeArray - if !array && rv.CanAddr() { // CanSet => CanAddr + Exported + if !array && rv.CanAddr() { + vp := rv.Addr().Interface().(*[]uintptr) + v, changed := fastpathTV.DecSliceUintptrV(*vp, fastpathCheckNilFalse, !array, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().([]uintptr) + fastpathTV.DecSliceUintptrV(v, fastpathCheckNilFalse, false, f.d) + } +} + +func (f fastpathT) DecSliceUintptrX(vp *[]uintptr, checkNil bool, d *Decoder) { + v, changed := f.DecSliceUintptrV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecSliceUintptrV(v []uintptr, checkNil bool, canChange bool, d *Decoder) (_ []uintptr, changed bool) { + dd := d.d + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + 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 + } + + if containerLenS > 0 { + x2read := containerLenS + var xtrunc bool + if containerLenS > cap(v) { + if canChange { + var xlen int + xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 8) + if xtrunc { + if xlen <= cap(v) { + v = v[:xlen] + } else { + v = make([]uintptr, xlen) + } + } else { + v = make([]uintptr, xlen) + } + changed = true + } else { + d.arrayCannotExpand(len(v), containerLenS) + } + x2read = len(v) + } else if containerLenS != len(v) { + if canChange { + v = v[:containerLenS] + changed = true + } + } + j := 0 + for ; j < x2read; j++ { + slh.ElemContainerState(j) + v[j] = uintptr(dd.DecodeUint(uintBitsize)) + } + if xtrunc { + for ; j < containerLenS; j++ { + v = append(v, 0) + slh.ElemContainerState(j) + v[j] = uintptr(dd.DecodeUint(uintBitsize)) + } + } else if !canChange { + for ; j < containerLenS; j++ { + slh.ElemContainerState(j) + d.swallow() + } + } + } else { + breakFound := dd.CheckBreak() + if breakFound { + if canChange { + if v == nil { + v = []uintptr{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + if cap(v) == 0 { + v = make([]uintptr, 1, 4) + changed = true + } + j := 0 + for ; !breakFound; j++ { + if j >= len(v) { + if canChange { + v = append(v, 0) + changed = true + } else { + d.arrayCannotExpand(len(v), j+1) + } + } + slh.ElemContainerState(j) + if j < len(v) { + v[j] = uintptr(dd.DecodeUint(uintBitsize)) + } else { + d.swallow() + } + breakFound = dd.CheckBreak() + } + if canChange && j < len(v) { + v = v[:j] + changed = true + } + } + slh.End() + return v, changed +} + +func (f *decFnInfo) fastpathDecSliceIntR(rv reflect.Value) { + array := f.seq == seqTypeArray + if !array && rv.CanAddr() { vp := rv.Addr().Interface().(*[]int) v, changed := fastpathTV.DecSliceIntV(*vp, fastpathCheckNilFalse, !array, f.d) if changed { @@ -12951,10 +19341,9 @@ func (f fastpathT) DecSliceIntX(vp *[]int, checkNil bool, d *Decoder) { *vp = v } } -func (_ fastpathT) DecSliceIntV(v []int, checkNil bool, canChange bool, - d *Decoder) (_ []int, changed bool) { +func (_ fastpathT) DecSliceIntV(v []int, checkNil bool, canChange bool, d *Decoder) (_ []int, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -12963,52 +19352,83 @@ func (_ fastpathT) DecSliceIntV(v []int, checkNil bool, canChange bool, } slh, containerLenS := d.decSliceHelperStart() - if canChange && v == nil { - if containerLenS <= 0 { - v = []int{} - } else { - v = make([]int, containerLenS, containerLenS) - } - changed = true - } if containerLenS == 0 { - if canChange && len(v) != 0 { - v = v[:0] + if canChange { + if v == nil { + v = []int{} + } else if len(v) != 0 { + v = v[:0] + } changed = true } + slh.End() return v, changed } - // for j := 0; j < containerLenS; j++ { if containerLenS > 0 { - decLen := containerLenS + x2read := containerLenS + var xtrunc bool if containerLenS > cap(v) { if canChange { - s := make([]int, containerLenS, containerLenS) - // copy(s, v[:cap(v)]) - v = s + var xlen int + xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 8) + if xtrunc { + if xlen <= cap(v) { + v = v[:xlen] + } else { + v = make([]int, xlen) + } + } else { + v = make([]int, xlen) + } changed = true } else { d.arrayCannotExpand(len(v), containerLenS) - decLen = len(v) } + x2read = len(v) } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + if canChange { + v = v[:containerLenS] + changed = true + } } - // all checks done. cannot go past len. j := 0 - for ; j < decLen; j++ { + for ; j < x2read; j++ { + slh.ElemContainerState(j) v[j] = int(dd.DecodeInt(intBitsize)) } - if !canChange { + if xtrunc { for ; j < containerLenS; j++ { + v = append(v, 0) + slh.ElemContainerState(j) + v[j] = int(dd.DecodeInt(intBitsize)) + } + } else if !canChange { + for ; j < containerLenS; j++ { + slh.ElemContainerState(j) d.swallow() } } } else { + breakFound := dd.CheckBreak() + if breakFound { + if canChange { + if v == nil { + v = []int{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + if cap(v) == 0 { + v = make([]int, 1, 4) + changed = true + } j := 0 - for ; !dd.CheckBreak(); j++ { + for ; !breakFound; j++ { if j >= len(v) { if canChange { v = append(v, 0) @@ -13017,23 +19437,26 @@ func (_ fastpathT) DecSliceIntV(v []int, checkNil bool, canChange bool, d.arrayCannotExpand(len(v), j+1) } } - if j > 0 { - slh.Sep(j) - } - if j < len(v) { // all checks done. cannot go past len. + slh.ElemContainerState(j) + if j < len(v) { v[j] = int(dd.DecodeInt(intBitsize)) } else { d.swallow() } + breakFound = dd.CheckBreak() + } + if canChange && j < len(v) { + v = v[:j] + changed = true } - slh.End() } + slh.End() return v, changed } -func (f decFnInfo) fastpathDecSliceInt8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecSliceInt8R(rv reflect.Value) { array := f.seq == seqTypeArray - if !array && rv.CanAddr() { // CanSet => CanAddr + Exported + if !array && rv.CanAddr() { vp := rv.Addr().Interface().(*[]int8) v, changed := fastpathTV.DecSliceInt8V(*vp, fastpathCheckNilFalse, !array, f.d) if changed { @@ -13051,10 +19474,9 @@ func (f fastpathT) DecSliceInt8X(vp *[]int8, checkNil bool, d *Decoder) { *vp = v } } -func (_ fastpathT) DecSliceInt8V(v []int8, checkNil bool, canChange bool, - d *Decoder) (_ []int8, changed bool) { +func (_ fastpathT) DecSliceInt8V(v []int8, checkNil bool, canChange bool, d *Decoder) (_ []int8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -13063,52 +19485,83 @@ func (_ fastpathT) DecSliceInt8V(v []int8, checkNil bool, canChange bool, } slh, containerLenS := d.decSliceHelperStart() - if canChange && v == nil { - if containerLenS <= 0 { - v = []int8{} - } else { - v = make([]int8, containerLenS, containerLenS) - } - changed = true - } if containerLenS == 0 { - if canChange && len(v) != 0 { - v = v[:0] + if canChange { + if v == nil { + v = []int8{} + } else if len(v) != 0 { + v = v[:0] + } changed = true } + slh.End() return v, changed } - // for j := 0; j < containerLenS; j++ { if containerLenS > 0 { - decLen := containerLenS + x2read := containerLenS + var xtrunc bool if containerLenS > cap(v) { if canChange { - s := make([]int8, containerLenS, containerLenS) - // copy(s, v[:cap(v)]) - v = s + var xlen int + xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 1) + if xtrunc { + if xlen <= cap(v) { + v = v[:xlen] + } else { + v = make([]int8, xlen) + } + } else { + v = make([]int8, xlen) + } changed = true } else { d.arrayCannotExpand(len(v), containerLenS) - decLen = len(v) } + x2read = len(v) } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + if canChange { + v = v[:containerLenS] + changed = true + } } - // all checks done. cannot go past len. j := 0 - for ; j < decLen; j++ { + for ; j < x2read; j++ { + slh.ElemContainerState(j) v[j] = int8(dd.DecodeInt(8)) } - if !canChange { + if xtrunc { for ; j < containerLenS; j++ { + v = append(v, 0) + slh.ElemContainerState(j) + v[j] = int8(dd.DecodeInt(8)) + } + } else if !canChange { + for ; j < containerLenS; j++ { + slh.ElemContainerState(j) d.swallow() } } } else { + breakFound := dd.CheckBreak() + if breakFound { + if canChange { + if v == nil { + v = []int8{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + if cap(v) == 0 { + v = make([]int8, 1, 4) + changed = true + } j := 0 - for ; !dd.CheckBreak(); j++ { + for ; !breakFound; j++ { if j >= len(v) { if canChange { v = append(v, 0) @@ -13117,23 +19570,26 @@ func (_ fastpathT) DecSliceInt8V(v []int8, checkNil bool, canChange bool, d.arrayCannotExpand(len(v), j+1) } } - if j > 0 { - slh.Sep(j) - } - if j < len(v) { // all checks done. cannot go past len. + slh.ElemContainerState(j) + if j < len(v) { v[j] = int8(dd.DecodeInt(8)) } else { d.swallow() } + breakFound = dd.CheckBreak() + } + if canChange && j < len(v) { + v = v[:j] + changed = true } - slh.End() } + slh.End() return v, changed } -func (f decFnInfo) fastpathDecSliceInt16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecSliceInt16R(rv reflect.Value) { array := f.seq == seqTypeArray - if !array && rv.CanAddr() { // CanSet => CanAddr + Exported + if !array && rv.CanAddr() { vp := rv.Addr().Interface().(*[]int16) v, changed := fastpathTV.DecSliceInt16V(*vp, fastpathCheckNilFalse, !array, f.d) if changed { @@ -13151,10 +19607,9 @@ func (f fastpathT) DecSliceInt16X(vp *[]int16, checkNil bool, d *Decoder) { *vp = v } } -func (_ fastpathT) DecSliceInt16V(v []int16, checkNil bool, canChange bool, - d *Decoder) (_ []int16, changed bool) { +func (_ fastpathT) DecSliceInt16V(v []int16, checkNil bool, canChange bool, d *Decoder) (_ []int16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -13163,52 +19618,83 @@ func (_ fastpathT) DecSliceInt16V(v []int16, checkNil bool, canChange bool, } slh, containerLenS := d.decSliceHelperStart() - if canChange && v == nil { - if containerLenS <= 0 { - v = []int16{} - } else { - v = make([]int16, containerLenS, containerLenS) - } - changed = true - } if containerLenS == 0 { - if canChange && len(v) != 0 { - v = v[:0] + if canChange { + if v == nil { + v = []int16{} + } else if len(v) != 0 { + v = v[:0] + } changed = true } + slh.End() return v, changed } - // for j := 0; j < containerLenS; j++ { if containerLenS > 0 { - decLen := containerLenS + x2read := containerLenS + var xtrunc bool if containerLenS > cap(v) { if canChange { - s := make([]int16, containerLenS, containerLenS) - // copy(s, v[:cap(v)]) - v = s + var xlen int + xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 2) + if xtrunc { + if xlen <= cap(v) { + v = v[:xlen] + } else { + v = make([]int16, xlen) + } + } else { + v = make([]int16, xlen) + } changed = true } else { d.arrayCannotExpand(len(v), containerLenS) - decLen = len(v) } + x2read = len(v) } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + if canChange { + v = v[:containerLenS] + changed = true + } } - // all checks done. cannot go past len. j := 0 - for ; j < decLen; j++ { + for ; j < x2read; j++ { + slh.ElemContainerState(j) v[j] = int16(dd.DecodeInt(16)) } - if !canChange { + if xtrunc { for ; j < containerLenS; j++ { + v = append(v, 0) + slh.ElemContainerState(j) + v[j] = int16(dd.DecodeInt(16)) + } + } else if !canChange { + for ; j < containerLenS; j++ { + slh.ElemContainerState(j) d.swallow() } } } else { + breakFound := dd.CheckBreak() + if breakFound { + if canChange { + if v == nil { + v = []int16{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + if cap(v) == 0 { + v = make([]int16, 1, 4) + changed = true + } j := 0 - for ; !dd.CheckBreak(); j++ { + for ; !breakFound; j++ { if j >= len(v) { if canChange { v = append(v, 0) @@ -13217,23 +19703,26 @@ func (_ fastpathT) DecSliceInt16V(v []int16, checkNil bool, canChange bool, d.arrayCannotExpand(len(v), j+1) } } - if j > 0 { - slh.Sep(j) - } - if j < len(v) { // all checks done. cannot go past len. + slh.ElemContainerState(j) + if j < len(v) { v[j] = int16(dd.DecodeInt(16)) } else { d.swallow() } + breakFound = dd.CheckBreak() + } + if canChange && j < len(v) { + v = v[:j] + changed = true } - slh.End() } + slh.End() return v, changed } -func (f decFnInfo) fastpathDecSliceInt32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecSliceInt32R(rv reflect.Value) { array := f.seq == seqTypeArray - if !array && rv.CanAddr() { // CanSet => CanAddr + Exported + if !array && rv.CanAddr() { vp := rv.Addr().Interface().(*[]int32) v, changed := fastpathTV.DecSliceInt32V(*vp, fastpathCheckNilFalse, !array, f.d) if changed { @@ -13251,10 +19740,9 @@ func (f fastpathT) DecSliceInt32X(vp *[]int32, checkNil bool, d *Decoder) { *vp = v } } -func (_ fastpathT) DecSliceInt32V(v []int32, checkNil bool, canChange bool, - d *Decoder) (_ []int32, changed bool) { +func (_ fastpathT) DecSliceInt32V(v []int32, checkNil bool, canChange bool, d *Decoder) (_ []int32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -13263,52 +19751,83 @@ func (_ fastpathT) DecSliceInt32V(v []int32, checkNil bool, canChange bool, } slh, containerLenS := d.decSliceHelperStart() - if canChange && v == nil { - if containerLenS <= 0 { - v = []int32{} - } else { - v = make([]int32, containerLenS, containerLenS) - } - changed = true - } if containerLenS == 0 { - if canChange && len(v) != 0 { - v = v[:0] + if canChange { + if v == nil { + v = []int32{} + } else if len(v) != 0 { + v = v[:0] + } changed = true } + slh.End() return v, changed } - // for j := 0; j < containerLenS; j++ { if containerLenS > 0 { - decLen := containerLenS + x2read := containerLenS + var xtrunc bool if containerLenS > cap(v) { if canChange { - s := make([]int32, containerLenS, containerLenS) - // copy(s, v[:cap(v)]) - v = s + var xlen int + xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 4) + if xtrunc { + if xlen <= cap(v) { + v = v[:xlen] + } else { + v = make([]int32, xlen) + } + } else { + v = make([]int32, xlen) + } changed = true } else { d.arrayCannotExpand(len(v), containerLenS) - decLen = len(v) } + x2read = len(v) } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + if canChange { + v = v[:containerLenS] + changed = true + } } - // all checks done. cannot go past len. j := 0 - for ; j < decLen; j++ { + for ; j < x2read; j++ { + slh.ElemContainerState(j) v[j] = int32(dd.DecodeInt(32)) } - if !canChange { + if xtrunc { for ; j < containerLenS; j++ { + v = append(v, 0) + slh.ElemContainerState(j) + v[j] = int32(dd.DecodeInt(32)) + } + } else if !canChange { + for ; j < containerLenS; j++ { + slh.ElemContainerState(j) d.swallow() } } } else { + breakFound := dd.CheckBreak() + if breakFound { + if canChange { + if v == nil { + v = []int32{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + if cap(v) == 0 { + v = make([]int32, 1, 4) + changed = true + } j := 0 - for ; !dd.CheckBreak(); j++ { + for ; !breakFound; j++ { if j >= len(v) { if canChange { v = append(v, 0) @@ -13317,23 +19836,26 @@ func (_ fastpathT) DecSliceInt32V(v []int32, checkNil bool, canChange bool, d.arrayCannotExpand(len(v), j+1) } } - if j > 0 { - slh.Sep(j) - } - if j < len(v) { // all checks done. cannot go past len. + slh.ElemContainerState(j) + if j < len(v) { v[j] = int32(dd.DecodeInt(32)) } else { d.swallow() } + breakFound = dd.CheckBreak() + } + if canChange && j < len(v) { + v = v[:j] + changed = true } - slh.End() } + slh.End() return v, changed } -func (f decFnInfo) fastpathDecSliceInt64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecSliceInt64R(rv reflect.Value) { array := f.seq == seqTypeArray - if !array && rv.CanAddr() { // CanSet => CanAddr + Exported + if !array && rv.CanAddr() { vp := rv.Addr().Interface().(*[]int64) v, changed := fastpathTV.DecSliceInt64V(*vp, fastpathCheckNilFalse, !array, f.d) if changed { @@ -13351,10 +19873,9 @@ func (f fastpathT) DecSliceInt64X(vp *[]int64, checkNil bool, d *Decoder) { *vp = v } } -func (_ fastpathT) DecSliceInt64V(v []int64, checkNil bool, canChange bool, - d *Decoder) (_ []int64, changed bool) { +func (_ fastpathT) DecSliceInt64V(v []int64, checkNil bool, canChange bool, d *Decoder) (_ []int64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -13363,52 +19884,83 @@ func (_ fastpathT) DecSliceInt64V(v []int64, checkNil bool, canChange bool, } slh, containerLenS := d.decSliceHelperStart() - if canChange && v == nil { - if containerLenS <= 0 { - v = []int64{} - } else { - v = make([]int64, containerLenS, containerLenS) - } - changed = true - } if containerLenS == 0 { - if canChange && len(v) != 0 { - v = v[:0] + if canChange { + if v == nil { + v = []int64{} + } else if len(v) != 0 { + v = v[:0] + } changed = true } + slh.End() return v, changed } - // for j := 0; j < containerLenS; j++ { if containerLenS > 0 { - decLen := containerLenS + x2read := containerLenS + var xtrunc bool if containerLenS > cap(v) { if canChange { - s := make([]int64, containerLenS, containerLenS) - // copy(s, v[:cap(v)]) - v = s + var xlen int + xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 8) + if xtrunc { + if xlen <= cap(v) { + v = v[:xlen] + } else { + v = make([]int64, xlen) + } + } else { + v = make([]int64, xlen) + } changed = true } else { d.arrayCannotExpand(len(v), containerLenS) - decLen = len(v) } + x2read = len(v) } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + if canChange { + v = v[:containerLenS] + changed = true + } } - // all checks done. cannot go past len. j := 0 - for ; j < decLen; j++ { + for ; j < x2read; j++ { + slh.ElemContainerState(j) v[j] = dd.DecodeInt(64) } - if !canChange { + if xtrunc { for ; j < containerLenS; j++ { + v = append(v, 0) + slh.ElemContainerState(j) + v[j] = dd.DecodeInt(64) + } + } else if !canChange { + for ; j < containerLenS; j++ { + slh.ElemContainerState(j) d.swallow() } } } else { + breakFound := dd.CheckBreak() + if breakFound { + if canChange { + if v == nil { + v = []int64{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + if cap(v) == 0 { + v = make([]int64, 1, 4) + changed = true + } j := 0 - for ; !dd.CheckBreak(); j++ { + for ; !breakFound; j++ { if j >= len(v) { if canChange { v = append(v, 0) @@ -13417,23 +19969,26 @@ func (_ fastpathT) DecSliceInt64V(v []int64, checkNil bool, canChange bool, d.arrayCannotExpand(len(v), j+1) } } - if j > 0 { - slh.Sep(j) - } - if j < len(v) { // all checks done. cannot go past len. + slh.ElemContainerState(j) + if j < len(v) { v[j] = dd.DecodeInt(64) } else { d.swallow() } + breakFound = dd.CheckBreak() + } + if canChange && j < len(v) { + v = v[:j] + changed = true } - slh.End() } + slh.End() return v, changed } -func (f decFnInfo) fastpathDecSliceBoolR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecSliceBoolR(rv reflect.Value) { array := f.seq == seqTypeArray - if !array && rv.CanAddr() { // CanSet => CanAddr + Exported + if !array && rv.CanAddr() { vp := rv.Addr().Interface().(*[]bool) v, changed := fastpathTV.DecSliceBoolV(*vp, fastpathCheckNilFalse, !array, f.d) if changed { @@ -13451,10 +20006,9 @@ func (f fastpathT) DecSliceBoolX(vp *[]bool, checkNil bool, d *Decoder) { *vp = v } } -func (_ fastpathT) DecSliceBoolV(v []bool, checkNil bool, canChange bool, - d *Decoder) (_ []bool, changed bool) { +func (_ fastpathT) DecSliceBoolV(v []bool, checkNil bool, canChange bool, d *Decoder) (_ []bool, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -13463,52 +20017,83 @@ func (_ fastpathT) DecSliceBoolV(v []bool, checkNil bool, canChange bool, } slh, containerLenS := d.decSliceHelperStart() - if canChange && v == nil { - if containerLenS <= 0 { - v = []bool{} - } else { - v = make([]bool, containerLenS, containerLenS) - } - changed = true - } if containerLenS == 0 { - if canChange && len(v) != 0 { - v = v[:0] + if canChange { + if v == nil { + v = []bool{} + } else if len(v) != 0 { + v = v[:0] + } changed = true } + slh.End() return v, changed } - // for j := 0; j < containerLenS; j++ { if containerLenS > 0 { - decLen := containerLenS + x2read := containerLenS + var xtrunc bool if containerLenS > cap(v) { if canChange { - s := make([]bool, containerLenS, containerLenS) - // copy(s, v[:cap(v)]) - v = s + var xlen int + xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 1) + if xtrunc { + if xlen <= cap(v) { + v = v[:xlen] + } else { + v = make([]bool, xlen) + } + } else { + v = make([]bool, xlen) + } changed = true } else { d.arrayCannotExpand(len(v), containerLenS) - decLen = len(v) } + x2read = len(v) } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true + if canChange { + v = v[:containerLenS] + changed = true + } } - // all checks done. cannot go past len. j := 0 - for ; j < decLen; j++ { + for ; j < x2read; j++ { + slh.ElemContainerState(j) v[j] = dd.DecodeBool() } - if !canChange { + if xtrunc { for ; j < containerLenS; j++ { + v = append(v, false) + slh.ElemContainerState(j) + v[j] = dd.DecodeBool() + } + } else if !canChange { + for ; j < containerLenS; j++ { + slh.ElemContainerState(j) d.swallow() } } } else { + breakFound := dd.CheckBreak() + if breakFound { + if canChange { + if v == nil { + v = []bool{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return v, changed + } + if cap(v) == 0 { + v = make([]bool, 1, 4) + changed = true + } j := 0 - for ; !dd.CheckBreak(); j++ { + for ; !breakFound; j++ { if j >= len(v) { if canChange { v = append(v, false) @@ -13517,21 +20102,24 @@ func (_ fastpathT) DecSliceBoolV(v []bool, checkNil bool, canChange bool, d.arrayCannotExpand(len(v), j+1) } } - if j > 0 { - slh.Sep(j) - } - if j < len(v) { // all checks done. cannot go past len. + slh.ElemContainerState(j) + if j < len(v) { v[j] = dd.DecodeBool() } else { d.swallow() } + breakFound = dd.CheckBreak() + } + if canChange && j < len(v) { + v = v[:j] + changed = true } - slh.End() } + slh.End() return v, changed } -func (f decFnInfo) fastpathDecMapIntfIntfR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntfIntfR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[interface{}]interface{}) v, changed := fastpathTV.DecMapIntfIntfV(*vp, fastpathCheckNilFalse, true, f.d) @@ -13552,7 +20140,8 @@ func (f fastpathT) DecMapIntfIntfX(vp *map[interface{}]interface{}, checkNil boo func (_ fastpathT) DecMapIntfIntfV(v map[interface{}]interface{}, checkNil bool, canChange bool, d *Decoder) (_ map[interface{}]interface{}, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -13562,51 +20151,67 @@ func (_ fastpathT) DecMapIntfIntfV(v map[interface{}]interface{}, checkNil bool, containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[interface{}]interface{}, containerLen) - } else { - v = make(map[interface{}]interface{}) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 32) + v = make(map[interface{}]interface{}, xlen) changed = true } + mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + var mk interface{} + var mv interface{} if containerLen > 0 { for j := 0; j < containerLen; j++ { - var mk interface{} + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil } - mv := v[mk] d.decode(&mv) - if v != nil { v[mk] = mv } } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } - var mk interface{} + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil } - dd.ReadMapKVSeparator() - mv := v[mk] d.decode(&mv) - if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntfStringR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntfStringR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[interface{}]string) v, changed := fastpathTV.DecMapIntfStringV(*vp, fastpathCheckNilFalse, true, f.d) @@ -13627,7 +20232,8 @@ func (f fastpathT) DecMapIntfStringX(vp *map[interface{}]string, checkNil bool, func (_ fastpathT) DecMapIntfStringV(v map[interface{}]string, checkNil bool, canChange bool, d *Decoder) (_ map[interface{}]string, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -13637,21 +20243,26 @@ func (_ fastpathT) DecMapIntfStringV(v map[interface{}]string, checkNil bool, ca containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[interface{}]string, containerLen) - } else { - v = make(map[interface{}]string) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 32) + v = make(map[interface{}]string, xlen) changed = true } + + var mk interface{} + var mv string if containerLen > 0 { for j := 0; j < containerLen; j++ { - var mk interface{} + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - mv := v[mk] mv = dd.DecodeString() if v != nil { v[mk] = mv @@ -13659,27 +20270,30 @@ func (_ fastpathT) DecMapIntfStringV(v map[interface{}]string, checkNil bool, ca } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } - var mk interface{} + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeString() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntfUintR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntfUintR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[interface{}]uint) v, changed := fastpathTV.DecMapIntfUintV(*vp, fastpathCheckNilFalse, true, f.d) @@ -13700,7 +20314,8 @@ func (f fastpathT) DecMapIntfUintX(vp *map[interface{}]uint, checkNil bool, d *D func (_ fastpathT) DecMapIntfUintV(v map[interface{}]uint, checkNil bool, canChange bool, d *Decoder) (_ map[interface{}]uint, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -13710,21 +20325,26 @@ func (_ fastpathT) DecMapIntfUintV(v map[interface{}]uint, checkNil bool, canCha containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[interface{}]uint, containerLen) - } else { - v = make(map[interface{}]uint) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[interface{}]uint, xlen) changed = true } + + var mk interface{} + var mv uint if containerLen > 0 { for j := 0; j < containerLen; j++ { - var mk interface{} + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - mv := v[mk] mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv @@ -13732,27 +20352,30 @@ func (_ fastpathT) DecMapIntfUintV(v map[interface{}]uint, checkNil bool, canCha } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } - var mk interface{} + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntfUint8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntfUint8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[interface{}]uint8) v, changed := fastpathTV.DecMapIntfUint8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -13773,7 +20396,8 @@ func (f fastpathT) DecMapIntfUint8X(vp *map[interface{}]uint8, checkNil bool, d func (_ fastpathT) DecMapIntfUint8V(v map[interface{}]uint8, checkNil bool, canChange bool, d *Decoder) (_ map[interface{}]uint8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -13783,21 +20407,26 @@ func (_ fastpathT) DecMapIntfUint8V(v map[interface{}]uint8, checkNil bool, canC containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[interface{}]uint8, containerLen) - } else { - v = make(map[interface{}]uint8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17) + v = make(map[interface{}]uint8, xlen) changed = true } + + var mk interface{} + var mv uint8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - var mk interface{} + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - mv := v[mk] mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv @@ -13805,27 +20434,30 @@ func (_ fastpathT) DecMapIntfUint8V(v map[interface{}]uint8, checkNil bool, canC } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } - var mk interface{} + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntfUint16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntfUint16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[interface{}]uint16) v, changed := fastpathTV.DecMapIntfUint16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -13846,7 +20478,8 @@ func (f fastpathT) DecMapIntfUint16X(vp *map[interface{}]uint16, checkNil bool, func (_ fastpathT) DecMapIntfUint16V(v map[interface{}]uint16, checkNil bool, canChange bool, d *Decoder) (_ map[interface{}]uint16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -13856,21 +20489,26 @@ func (_ fastpathT) DecMapIntfUint16V(v map[interface{}]uint16, checkNil bool, ca containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[interface{}]uint16, containerLen) - } else { - v = make(map[interface{}]uint16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 18) + v = make(map[interface{}]uint16, xlen) changed = true } + + var mk interface{} + var mv uint16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - var mk interface{} + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - mv := v[mk] mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv @@ -13878,27 +20516,30 @@ func (_ fastpathT) DecMapIntfUint16V(v map[interface{}]uint16, checkNil bool, ca } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } - var mk interface{} + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntfUint32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntfUint32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[interface{}]uint32) v, changed := fastpathTV.DecMapIntfUint32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -13919,7 +20560,8 @@ func (f fastpathT) DecMapIntfUint32X(vp *map[interface{}]uint32, checkNil bool, func (_ fastpathT) DecMapIntfUint32V(v map[interface{}]uint32, checkNil bool, canChange bool, d *Decoder) (_ map[interface{}]uint32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -13929,21 +20571,26 @@ func (_ fastpathT) DecMapIntfUint32V(v map[interface{}]uint32, checkNil bool, ca containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[interface{}]uint32, containerLen) - } else { - v = make(map[interface{}]uint32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20) + v = make(map[interface{}]uint32, xlen) changed = true } + + var mk interface{} + var mv uint32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - var mk interface{} + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - mv := v[mk] mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv @@ -13951,27 +20598,30 @@ func (_ fastpathT) DecMapIntfUint32V(v map[interface{}]uint32, checkNil bool, ca } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } - var mk interface{} + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntfUint64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntfUint64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[interface{}]uint64) v, changed := fastpathTV.DecMapIntfUint64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -13992,7 +20642,8 @@ func (f fastpathT) DecMapIntfUint64X(vp *map[interface{}]uint64, checkNil bool, func (_ fastpathT) DecMapIntfUint64V(v map[interface{}]uint64, checkNil bool, canChange bool, d *Decoder) (_ map[interface{}]uint64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -14002,21 +20653,26 @@ func (_ fastpathT) DecMapIntfUint64V(v map[interface{}]uint64, checkNil bool, ca containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[interface{}]uint64, containerLen) - } else { - v = make(map[interface{}]uint64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[interface{}]uint64, xlen) changed = true } + + var mk interface{} + var mv uint64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - var mk interface{} + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - mv := v[mk] mv = dd.DecodeUint(64) if v != nil { v[mk] = mv @@ -14024,27 +20680,112 @@ func (_ fastpathT) DecMapIntfUint64V(v map[interface{}]uint64, checkNil bool, ca } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } - var mk interface{} + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeUint(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntfIntR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntfUintptrR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[interface{}]uintptr) + v, changed := fastpathTV.DecMapIntfUintptrV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[interface{}]uintptr) + fastpathTV.DecMapIntfUintptrV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapIntfUintptrX(vp *map[interface{}]uintptr, checkNil bool, d *Decoder) { + v, changed := f.DecMapIntfUintptrV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapIntfUintptrV(v map[interface{}]uintptr, checkNil bool, canChange bool, + d *Decoder) (_ map[interface{}]uintptr, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[interface{}]uintptr, xlen) + changed = true + } + + var mk interface{} + var mv uintptr + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = nil + d.decode(&mk) + if bv, bok := mk.([]byte); bok { + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = nil + d.decode(&mk) + if bv, bok := mk.([]byte); bok { + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapIntfIntR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[interface{}]int) v, changed := fastpathTV.DecMapIntfIntV(*vp, fastpathCheckNilFalse, true, f.d) @@ -14065,7 +20806,8 @@ func (f fastpathT) DecMapIntfIntX(vp *map[interface{}]int, checkNil bool, d *Dec func (_ fastpathT) DecMapIntfIntV(v map[interface{}]int, checkNil bool, canChange bool, d *Decoder) (_ map[interface{}]int, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -14075,21 +20817,26 @@ func (_ fastpathT) DecMapIntfIntV(v map[interface{}]int, checkNil bool, canChang containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[interface{}]int, containerLen) - } else { - v = make(map[interface{}]int) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[interface{}]int, xlen) changed = true } + + var mk interface{} + var mv int if containerLen > 0 { for j := 0; j < containerLen; j++ { - var mk interface{} + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - mv := v[mk] mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv @@ -14097,27 +20844,30 @@ func (_ fastpathT) DecMapIntfIntV(v map[interface{}]int, checkNil bool, canChang } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } - var mk interface{} + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - dd.ReadMapKVSeparator() - mv := v[mk] mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntfInt8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntfInt8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[interface{}]int8) v, changed := fastpathTV.DecMapIntfInt8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -14138,7 +20888,8 @@ func (f fastpathT) DecMapIntfInt8X(vp *map[interface{}]int8, checkNil bool, d *D func (_ fastpathT) DecMapIntfInt8V(v map[interface{}]int8, checkNil bool, canChange bool, d *Decoder) (_ map[interface{}]int8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -14148,21 +20899,26 @@ func (_ fastpathT) DecMapIntfInt8V(v map[interface{}]int8, checkNil bool, canCha containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[interface{}]int8, containerLen) - } else { - v = make(map[interface{}]int8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17) + v = make(map[interface{}]int8, xlen) changed = true } + + var mk interface{} + var mv int8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - var mk interface{} + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - mv := v[mk] mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv @@ -14170,27 +20926,30 @@ func (_ fastpathT) DecMapIntfInt8V(v map[interface{}]int8, checkNil bool, canCha } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } - var mk interface{} + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - dd.ReadMapKVSeparator() - mv := v[mk] mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntfInt16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntfInt16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[interface{}]int16) v, changed := fastpathTV.DecMapIntfInt16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -14211,7 +20970,8 @@ func (f fastpathT) DecMapIntfInt16X(vp *map[interface{}]int16, checkNil bool, d func (_ fastpathT) DecMapIntfInt16V(v map[interface{}]int16, checkNil bool, canChange bool, d *Decoder) (_ map[interface{}]int16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -14221,21 +20981,26 @@ func (_ fastpathT) DecMapIntfInt16V(v map[interface{}]int16, checkNil bool, canC containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[interface{}]int16, containerLen) - } else { - v = make(map[interface{}]int16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 18) + v = make(map[interface{}]int16, xlen) changed = true } + + var mk interface{} + var mv int16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - var mk interface{} + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - mv := v[mk] mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv @@ -14243,27 +21008,30 @@ func (_ fastpathT) DecMapIntfInt16V(v map[interface{}]int16, checkNil bool, canC } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } - var mk interface{} + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - dd.ReadMapKVSeparator() - mv := v[mk] mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntfInt32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntfInt32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[interface{}]int32) v, changed := fastpathTV.DecMapIntfInt32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -14284,7 +21052,8 @@ func (f fastpathT) DecMapIntfInt32X(vp *map[interface{}]int32, checkNil bool, d func (_ fastpathT) DecMapIntfInt32V(v map[interface{}]int32, checkNil bool, canChange bool, d *Decoder) (_ map[interface{}]int32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -14294,21 +21063,26 @@ func (_ fastpathT) DecMapIntfInt32V(v map[interface{}]int32, checkNil bool, canC containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[interface{}]int32, containerLen) - } else { - v = make(map[interface{}]int32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20) + v = make(map[interface{}]int32, xlen) changed = true } + + var mk interface{} + var mv int32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - var mk interface{} + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - mv := v[mk] mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv @@ -14316,27 +21090,30 @@ func (_ fastpathT) DecMapIntfInt32V(v map[interface{}]int32, checkNil bool, canC } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } - var mk interface{} + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - dd.ReadMapKVSeparator() - mv := v[mk] mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntfInt64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntfInt64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[interface{}]int64) v, changed := fastpathTV.DecMapIntfInt64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -14357,7 +21134,8 @@ func (f fastpathT) DecMapIntfInt64X(vp *map[interface{}]int64, checkNil bool, d func (_ fastpathT) DecMapIntfInt64V(v map[interface{}]int64, checkNil bool, canChange bool, d *Decoder) (_ map[interface{}]int64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -14367,21 +21145,26 @@ func (_ fastpathT) DecMapIntfInt64V(v map[interface{}]int64, checkNil bool, canC containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[interface{}]int64, containerLen) - } else { - v = make(map[interface{}]int64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[interface{}]int64, xlen) changed = true } + + var mk interface{} + var mv int64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - var mk interface{} + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - mv := v[mk] mv = dd.DecodeInt(64) if v != nil { v[mk] = mv @@ -14389,27 +21172,30 @@ func (_ fastpathT) DecMapIntfInt64V(v map[interface{}]int64, checkNil bool, canC } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } - var mk interface{} + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeInt(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntfFloat32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntfFloat32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[interface{}]float32) v, changed := fastpathTV.DecMapIntfFloat32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -14430,7 +21216,8 @@ func (f fastpathT) DecMapIntfFloat32X(vp *map[interface{}]float32, checkNil bool func (_ fastpathT) DecMapIntfFloat32V(v map[interface{}]float32, checkNil bool, canChange bool, d *Decoder) (_ map[interface{}]float32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -14440,21 +21227,26 @@ func (_ fastpathT) DecMapIntfFloat32V(v map[interface{}]float32, checkNil bool, containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[interface{}]float32, containerLen) - } else { - v = make(map[interface{}]float32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20) + v = make(map[interface{}]float32, xlen) changed = true } + + var mk interface{} + var mv float32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - var mk interface{} + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - mv := v[mk] mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv @@ -14462,27 +21254,30 @@ func (_ fastpathT) DecMapIntfFloat32V(v map[interface{}]float32, checkNil bool, } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } - var mk interface{} + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - dd.ReadMapKVSeparator() - mv := v[mk] mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntfFloat64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntfFloat64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[interface{}]float64) v, changed := fastpathTV.DecMapIntfFloat64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -14503,7 +21298,8 @@ func (f fastpathT) DecMapIntfFloat64X(vp *map[interface{}]float64, checkNil bool func (_ fastpathT) DecMapIntfFloat64V(v map[interface{}]float64, checkNil bool, canChange bool, d *Decoder) (_ map[interface{}]float64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -14513,21 +21309,26 @@ func (_ fastpathT) DecMapIntfFloat64V(v map[interface{}]float64, checkNil bool, containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[interface{}]float64, containerLen) - } else { - v = make(map[interface{}]float64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[interface{}]float64, xlen) changed = true } + + var mk interface{} + var mv float64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - var mk interface{} + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - mv := v[mk] mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv @@ -14535,27 +21336,30 @@ func (_ fastpathT) DecMapIntfFloat64V(v map[interface{}]float64, checkNil bool, } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } - var mk interface{} + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntfBoolR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntfBoolR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[interface{}]bool) v, changed := fastpathTV.DecMapIntfBoolV(*vp, fastpathCheckNilFalse, true, f.d) @@ -14576,7 +21380,8 @@ func (f fastpathT) DecMapIntfBoolX(vp *map[interface{}]bool, checkNil bool, d *D func (_ fastpathT) DecMapIntfBoolV(v map[interface{}]bool, checkNil bool, canChange bool, d *Decoder) (_ map[interface{}]bool, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -14586,21 +21391,26 @@ func (_ fastpathT) DecMapIntfBoolV(v map[interface{}]bool, checkNil bool, canCha containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[interface{}]bool, containerLen) - } else { - v = make(map[interface{}]bool) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17) + v = make(map[interface{}]bool, xlen) changed = true } + + var mk interface{} + var mv bool if containerLen > 0 { for j := 0; j < containerLen; j++ { - var mk interface{} + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - mv := v[mk] mv = dd.DecodeBool() if v != nil { v[mk] = mv @@ -14608,27 +21418,30 @@ func (_ fastpathT) DecMapIntfBoolV(v map[interface{}]bool, checkNil bool, canCha } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } - var mk interface{} + mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. + mk = d.string(bv) + } + if cr != nil { + cr.sendContainerState(containerMapValue) } - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeBool() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapStringIntfR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapStringIntfR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[string]interface{}) v, changed := fastpathTV.DecMapStringIntfV(*vp, fastpathCheckNilFalse, true, f.d) @@ -14649,7 +21462,8 @@ func (f fastpathT) DecMapStringIntfX(vp *map[string]interface{}, checkNil bool, func (_ fastpathT) DecMapStringIntfV(v map[string]interface{}, checkNil bool, canChange bool, d *Decoder) (_ map[string]interface{}, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -14659,43 +21473,59 @@ func (_ fastpathT) DecMapStringIntfV(v map[string]interface{}, checkNil bool, ca containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[string]interface{}, containerLen) - } else { - v = make(map[string]interface{}) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 32) + v = make(map[string]interface{}, xlen) changed = true } + mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + var mk string + var mv interface{} if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeString() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } d.decode(&mv) - if v != nil { v[mk] = mv } } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil } - mk := dd.DecodeString() - dd.ReadMapKVSeparator() - mv := v[mk] d.decode(&mv) - if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapStringStringR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapStringStringR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[string]string) v, changed := fastpathTV.DecMapStringStringV(*vp, fastpathCheckNilFalse, true, f.d) @@ -14716,7 +21546,8 @@ func (f fastpathT) DecMapStringStringX(vp *map[string]string, checkNil bool, d * func (_ fastpathT) DecMapStringStringV(v map[string]string, checkNil bool, canChange bool, d *Decoder) (_ map[string]string, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -14726,17 +21557,22 @@ func (_ fastpathT) DecMapStringStringV(v map[string]string, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[string]string, containerLen) - } else { - v = make(map[string]string) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 32) + v = make(map[string]string, xlen) changed = true } + + var mk string + var mv string if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeString() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeString() if v != nil { v[mk] = mv @@ -14744,23 +21580,26 @@ func (_ fastpathT) DecMapStringStringV(v map[string]string, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeString() - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeString() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapStringUintR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapStringUintR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[string]uint) v, changed := fastpathTV.DecMapStringUintV(*vp, fastpathCheckNilFalse, true, f.d) @@ -14781,7 +21620,8 @@ func (f fastpathT) DecMapStringUintX(vp *map[string]uint, checkNil bool, d *Deco func (_ fastpathT) DecMapStringUintV(v map[string]uint, checkNil bool, canChange bool, d *Decoder) (_ map[string]uint, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -14791,17 +21631,22 @@ func (_ fastpathT) DecMapStringUintV(v map[string]uint, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[string]uint, containerLen) - } else { - v = make(map[string]uint) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[string]uint, xlen) changed = true } + + var mk string + var mv uint if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeString() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv @@ -14809,23 +21654,26 @@ func (_ fastpathT) DecMapStringUintV(v map[string]uint, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeString() - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapStringUint8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapStringUint8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[string]uint8) v, changed := fastpathTV.DecMapStringUint8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -14846,7 +21694,8 @@ func (f fastpathT) DecMapStringUint8X(vp *map[string]uint8, checkNil bool, d *De func (_ fastpathT) DecMapStringUint8V(v map[string]uint8, checkNil bool, canChange bool, d *Decoder) (_ map[string]uint8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -14856,17 +21705,22 @@ func (_ fastpathT) DecMapStringUint8V(v map[string]uint8, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[string]uint8, containerLen) - } else { - v = make(map[string]uint8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17) + v = make(map[string]uint8, xlen) changed = true } + + var mk string + var mv uint8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeString() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv @@ -14874,23 +21728,26 @@ func (_ fastpathT) DecMapStringUint8V(v map[string]uint8, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeString() - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapStringUint16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapStringUint16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[string]uint16) v, changed := fastpathTV.DecMapStringUint16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -14911,7 +21768,8 @@ func (f fastpathT) DecMapStringUint16X(vp *map[string]uint16, checkNil bool, d * func (_ fastpathT) DecMapStringUint16V(v map[string]uint16, checkNil bool, canChange bool, d *Decoder) (_ map[string]uint16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -14921,17 +21779,22 @@ func (_ fastpathT) DecMapStringUint16V(v map[string]uint16, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[string]uint16, containerLen) - } else { - v = make(map[string]uint16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 18) + v = make(map[string]uint16, xlen) changed = true } + + var mk string + var mv uint16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeString() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv @@ -14939,23 +21802,26 @@ func (_ fastpathT) DecMapStringUint16V(v map[string]uint16, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeString() - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapStringUint32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapStringUint32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[string]uint32) v, changed := fastpathTV.DecMapStringUint32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -14976,7 +21842,8 @@ func (f fastpathT) DecMapStringUint32X(vp *map[string]uint32, checkNil bool, d * func (_ fastpathT) DecMapStringUint32V(v map[string]uint32, checkNil bool, canChange bool, d *Decoder) (_ map[string]uint32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -14986,17 +21853,22 @@ func (_ fastpathT) DecMapStringUint32V(v map[string]uint32, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[string]uint32, containerLen) - } else { - v = make(map[string]uint32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20) + v = make(map[string]uint32, xlen) changed = true } + + var mk string + var mv uint32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeString() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv @@ -15004,23 +21876,26 @@ func (_ fastpathT) DecMapStringUint32V(v map[string]uint32, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeString() - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapStringUint64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapStringUint64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[string]uint64) v, changed := fastpathTV.DecMapStringUint64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -15041,7 +21916,8 @@ func (f fastpathT) DecMapStringUint64X(vp *map[string]uint64, checkNil bool, d * func (_ fastpathT) DecMapStringUint64V(v map[string]uint64, checkNil bool, canChange bool, d *Decoder) (_ map[string]uint64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -15051,17 +21927,22 @@ func (_ fastpathT) DecMapStringUint64V(v map[string]uint64, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[string]uint64, containerLen) - } else { - v = make(map[string]uint64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[string]uint64, xlen) changed = true } + + var mk string + var mv uint64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeString() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeUint(64) if v != nil { v[mk] = mv @@ -15069,23 +21950,100 @@ func (_ fastpathT) DecMapStringUint64V(v map[string]uint64, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeString() - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeUint(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapStringIntR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapStringUintptrR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[string]uintptr) + v, changed := fastpathTV.DecMapStringUintptrV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[string]uintptr) + fastpathTV.DecMapStringUintptrV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapStringUintptrX(vp *map[string]uintptr, checkNil bool, d *Decoder) { + v, changed := f.DecMapStringUintptrV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapStringUintptrV(v map[string]uintptr, checkNil bool, canChange bool, + d *Decoder) (_ map[string]uintptr, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[string]uintptr, xlen) + changed = true + } + + var mk string + var mv uintptr + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapStringIntR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[string]int) v, changed := fastpathTV.DecMapStringIntV(*vp, fastpathCheckNilFalse, true, f.d) @@ -15106,7 +22064,8 @@ func (f fastpathT) DecMapStringIntX(vp *map[string]int, checkNil bool, d *Decode func (_ fastpathT) DecMapStringIntV(v map[string]int, checkNil bool, canChange bool, d *Decoder) (_ map[string]int, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -15116,17 +22075,22 @@ func (_ fastpathT) DecMapStringIntV(v map[string]int, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[string]int, containerLen) - } else { - v = make(map[string]int) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[string]int, xlen) changed = true } + + var mk string + var mv int if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeString() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv @@ -15134,23 +22098,26 @@ func (_ fastpathT) DecMapStringIntV(v map[string]int, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeString() - dd.ReadMapKVSeparator() - mv := v[mk] mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapStringInt8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapStringInt8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[string]int8) v, changed := fastpathTV.DecMapStringInt8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -15171,7 +22138,8 @@ func (f fastpathT) DecMapStringInt8X(vp *map[string]int8, checkNil bool, d *Deco func (_ fastpathT) DecMapStringInt8V(v map[string]int8, checkNil bool, canChange bool, d *Decoder) (_ map[string]int8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -15181,17 +22149,22 @@ func (_ fastpathT) DecMapStringInt8V(v map[string]int8, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[string]int8, containerLen) - } else { - v = make(map[string]int8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17) + v = make(map[string]int8, xlen) changed = true } + + var mk string + var mv int8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeString() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv @@ -15199,23 +22172,26 @@ func (_ fastpathT) DecMapStringInt8V(v map[string]int8, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeString() - dd.ReadMapKVSeparator() - mv := v[mk] mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapStringInt16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapStringInt16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[string]int16) v, changed := fastpathTV.DecMapStringInt16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -15236,7 +22212,8 @@ func (f fastpathT) DecMapStringInt16X(vp *map[string]int16, checkNil bool, d *De func (_ fastpathT) DecMapStringInt16V(v map[string]int16, checkNil bool, canChange bool, d *Decoder) (_ map[string]int16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -15246,17 +22223,22 @@ func (_ fastpathT) DecMapStringInt16V(v map[string]int16, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[string]int16, containerLen) - } else { - v = make(map[string]int16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 18) + v = make(map[string]int16, xlen) changed = true } + + var mk string + var mv int16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeString() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv @@ -15264,23 +22246,26 @@ func (_ fastpathT) DecMapStringInt16V(v map[string]int16, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeString() - dd.ReadMapKVSeparator() - mv := v[mk] mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapStringInt32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapStringInt32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[string]int32) v, changed := fastpathTV.DecMapStringInt32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -15301,7 +22286,8 @@ func (f fastpathT) DecMapStringInt32X(vp *map[string]int32, checkNil bool, d *De func (_ fastpathT) DecMapStringInt32V(v map[string]int32, checkNil bool, canChange bool, d *Decoder) (_ map[string]int32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -15311,17 +22297,22 @@ func (_ fastpathT) DecMapStringInt32V(v map[string]int32, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[string]int32, containerLen) - } else { - v = make(map[string]int32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20) + v = make(map[string]int32, xlen) changed = true } + + var mk string + var mv int32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeString() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv @@ -15329,23 +22320,26 @@ func (_ fastpathT) DecMapStringInt32V(v map[string]int32, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeString() - dd.ReadMapKVSeparator() - mv := v[mk] mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapStringInt64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapStringInt64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[string]int64) v, changed := fastpathTV.DecMapStringInt64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -15366,7 +22360,8 @@ func (f fastpathT) DecMapStringInt64X(vp *map[string]int64, checkNil bool, d *De func (_ fastpathT) DecMapStringInt64V(v map[string]int64, checkNil bool, canChange bool, d *Decoder) (_ map[string]int64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -15376,17 +22371,22 @@ func (_ fastpathT) DecMapStringInt64V(v map[string]int64, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[string]int64, containerLen) - } else { - v = make(map[string]int64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[string]int64, xlen) changed = true } + + var mk string + var mv int64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeString() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeInt(64) if v != nil { v[mk] = mv @@ -15394,23 +22394,26 @@ func (_ fastpathT) DecMapStringInt64V(v map[string]int64, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeString() - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeInt(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapStringFloat32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapStringFloat32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[string]float32) v, changed := fastpathTV.DecMapStringFloat32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -15431,7 +22434,8 @@ func (f fastpathT) DecMapStringFloat32X(vp *map[string]float32, checkNil bool, d func (_ fastpathT) DecMapStringFloat32V(v map[string]float32, checkNil bool, canChange bool, d *Decoder) (_ map[string]float32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -15441,17 +22445,22 @@ func (_ fastpathT) DecMapStringFloat32V(v map[string]float32, checkNil bool, can containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[string]float32, containerLen) - } else { - v = make(map[string]float32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20) + v = make(map[string]float32, xlen) changed = true } + + var mk string + var mv float32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeString() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv @@ -15459,23 +22468,26 @@ func (_ fastpathT) DecMapStringFloat32V(v map[string]float32, checkNil bool, can } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeString() - dd.ReadMapKVSeparator() - mv := v[mk] mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapStringFloat64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapStringFloat64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[string]float64) v, changed := fastpathTV.DecMapStringFloat64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -15496,7 +22508,8 @@ func (f fastpathT) DecMapStringFloat64X(vp *map[string]float64, checkNil bool, d func (_ fastpathT) DecMapStringFloat64V(v map[string]float64, checkNil bool, canChange bool, d *Decoder) (_ map[string]float64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -15506,17 +22519,22 @@ func (_ fastpathT) DecMapStringFloat64V(v map[string]float64, checkNil bool, can containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[string]float64, containerLen) - } else { - v = make(map[string]float64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[string]float64, xlen) changed = true } + + var mk string + var mv float64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeString() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv @@ -15524,23 +22542,26 @@ func (_ fastpathT) DecMapStringFloat64V(v map[string]float64, checkNil bool, can } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeString() - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapStringBoolR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapStringBoolR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[string]bool) v, changed := fastpathTV.DecMapStringBoolV(*vp, fastpathCheckNilFalse, true, f.d) @@ -15561,7 +22582,8 @@ func (f fastpathT) DecMapStringBoolX(vp *map[string]bool, checkNil bool, d *Deco func (_ fastpathT) DecMapStringBoolV(v map[string]bool, checkNil bool, canChange bool, d *Decoder) (_ map[string]bool, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -15571,17 +22593,22 @@ func (_ fastpathT) DecMapStringBoolV(v map[string]bool, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[string]bool, containerLen) - } else { - v = make(map[string]bool) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17) + v = make(map[string]bool, xlen) changed = true } + + var mk string + var mv bool if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeString() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeBool() if v != nil { v[mk] = mv @@ -15589,23 +22616,26 @@ func (_ fastpathT) DecMapStringBoolV(v map[string]bool, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeString() - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeBool() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat32IntfR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat32IntfR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float32]interface{}) v, changed := fastpathTV.DecMapFloat32IntfV(*vp, fastpathCheckNilFalse, true, f.d) @@ -15626,7 +22656,8 @@ func (f fastpathT) DecMapFloat32IntfX(vp *map[float32]interface{}, checkNil bool func (_ fastpathT) DecMapFloat32IntfV(v map[float32]interface{}, checkNil bool, canChange bool, d *Decoder) (_ map[float32]interface{}, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -15636,43 +22667,59 @@ func (_ fastpathT) DecMapFloat32IntfV(v map[float32]interface{}, checkNil bool, containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float32]interface{}, containerLen) - } else { - v = make(map[float32]interface{}) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20) + v = make(map[float32]interface{}, xlen) changed = true } + mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + var mk float32 + var mv interface{} if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := float32(dd.DecodeFloat(true)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } d.decode(&mv) - if v != nil { v[mk] = mv } } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil } - mk := float32(dd.DecodeFloat(true)) - dd.ReadMapKVSeparator() - mv := v[mk] d.decode(&mv) - if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat32StringR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat32StringR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float32]string) v, changed := fastpathTV.DecMapFloat32StringV(*vp, fastpathCheckNilFalse, true, f.d) @@ -15693,7 +22740,8 @@ func (f fastpathT) DecMapFloat32StringX(vp *map[float32]string, checkNil bool, d func (_ fastpathT) DecMapFloat32StringV(v map[float32]string, checkNil bool, canChange bool, d *Decoder) (_ map[float32]string, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -15703,17 +22751,22 @@ func (_ fastpathT) DecMapFloat32StringV(v map[float32]string, checkNil bool, can containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float32]string, containerLen) - } else { - v = make(map[float32]string) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20) + v = make(map[float32]string, xlen) changed = true } + + var mk float32 + var mv string if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := float32(dd.DecodeFloat(true)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeString() if v != nil { v[mk] = mv @@ -15721,23 +22774,26 @@ func (_ fastpathT) DecMapFloat32StringV(v map[float32]string, checkNil bool, can } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := float32(dd.DecodeFloat(true)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeString() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat32UintR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat32UintR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float32]uint) v, changed := fastpathTV.DecMapFloat32UintV(*vp, fastpathCheckNilFalse, true, f.d) @@ -15758,7 +22814,8 @@ func (f fastpathT) DecMapFloat32UintX(vp *map[float32]uint, checkNil bool, d *De func (_ fastpathT) DecMapFloat32UintV(v map[float32]uint, checkNil bool, canChange bool, d *Decoder) (_ map[float32]uint, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -15768,17 +22825,22 @@ func (_ fastpathT) DecMapFloat32UintV(v map[float32]uint, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float32]uint, containerLen) - } else { - v = make(map[float32]uint) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[float32]uint, xlen) changed = true } + + var mk float32 + var mv uint if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := float32(dd.DecodeFloat(true)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv @@ -15786,23 +22848,26 @@ func (_ fastpathT) DecMapFloat32UintV(v map[float32]uint, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := float32(dd.DecodeFloat(true)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat32Uint8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat32Uint8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float32]uint8) v, changed := fastpathTV.DecMapFloat32Uint8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -15823,7 +22888,8 @@ func (f fastpathT) DecMapFloat32Uint8X(vp *map[float32]uint8, checkNil bool, d * func (_ fastpathT) DecMapFloat32Uint8V(v map[float32]uint8, checkNil bool, canChange bool, d *Decoder) (_ map[float32]uint8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -15833,17 +22899,22 @@ func (_ fastpathT) DecMapFloat32Uint8V(v map[float32]uint8, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float32]uint8, containerLen) - } else { - v = make(map[float32]uint8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5) + v = make(map[float32]uint8, xlen) changed = true } + + var mk float32 + var mv uint8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := float32(dd.DecodeFloat(true)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv @@ -15851,23 +22922,26 @@ func (_ fastpathT) DecMapFloat32Uint8V(v map[float32]uint8, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := float32(dd.DecodeFloat(true)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat32Uint16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat32Uint16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float32]uint16) v, changed := fastpathTV.DecMapFloat32Uint16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -15888,7 +22962,8 @@ func (f fastpathT) DecMapFloat32Uint16X(vp *map[float32]uint16, checkNil bool, d func (_ fastpathT) DecMapFloat32Uint16V(v map[float32]uint16, checkNil bool, canChange bool, d *Decoder) (_ map[float32]uint16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -15898,17 +22973,22 @@ func (_ fastpathT) DecMapFloat32Uint16V(v map[float32]uint16, checkNil bool, can containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float32]uint16, containerLen) - } else { - v = make(map[float32]uint16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6) + v = make(map[float32]uint16, xlen) changed = true } + + var mk float32 + var mv uint16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := float32(dd.DecodeFloat(true)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv @@ -15916,23 +22996,26 @@ func (_ fastpathT) DecMapFloat32Uint16V(v map[float32]uint16, checkNil bool, can } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := float32(dd.DecodeFloat(true)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat32Uint32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat32Uint32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float32]uint32) v, changed := fastpathTV.DecMapFloat32Uint32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -15953,7 +23036,8 @@ func (f fastpathT) DecMapFloat32Uint32X(vp *map[float32]uint32, checkNil bool, d func (_ fastpathT) DecMapFloat32Uint32V(v map[float32]uint32, checkNil bool, canChange bool, d *Decoder) (_ map[float32]uint32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -15963,17 +23047,22 @@ func (_ fastpathT) DecMapFloat32Uint32V(v map[float32]uint32, checkNil bool, can containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float32]uint32, containerLen) - } else { - v = make(map[float32]uint32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 8) + v = make(map[float32]uint32, xlen) changed = true } + + var mk float32 + var mv uint32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := float32(dd.DecodeFloat(true)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv @@ -15981,23 +23070,26 @@ func (_ fastpathT) DecMapFloat32Uint32V(v map[float32]uint32, checkNil bool, can } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := float32(dd.DecodeFloat(true)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat32Uint64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat32Uint64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float32]uint64) v, changed := fastpathTV.DecMapFloat32Uint64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -16018,7 +23110,8 @@ func (f fastpathT) DecMapFloat32Uint64X(vp *map[float32]uint64, checkNil bool, d func (_ fastpathT) DecMapFloat32Uint64V(v map[float32]uint64, checkNil bool, canChange bool, d *Decoder) (_ map[float32]uint64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -16028,17 +23121,22 @@ func (_ fastpathT) DecMapFloat32Uint64V(v map[float32]uint64, checkNil bool, can containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float32]uint64, containerLen) - } else { - v = make(map[float32]uint64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[float32]uint64, xlen) changed = true } + + var mk float32 + var mv uint64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := float32(dd.DecodeFloat(true)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeUint(64) if v != nil { v[mk] = mv @@ -16046,23 +23144,100 @@ func (_ fastpathT) DecMapFloat32Uint64V(v map[float32]uint64, checkNil bool, can } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := float32(dd.DecodeFloat(true)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeUint(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat32IntR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat32UintptrR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[float32]uintptr) + v, changed := fastpathTV.DecMapFloat32UintptrV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[float32]uintptr) + fastpathTV.DecMapFloat32UintptrV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapFloat32UintptrX(vp *map[float32]uintptr, checkNil bool, d *Decoder) { + v, changed := f.DecMapFloat32UintptrV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapFloat32UintptrV(v map[float32]uintptr, checkNil bool, canChange bool, + d *Decoder) (_ map[float32]uintptr, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[float32]uintptr, xlen) + changed = true + } + + var mk float32 + var mv uintptr + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapFloat32IntR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float32]int) v, changed := fastpathTV.DecMapFloat32IntV(*vp, fastpathCheckNilFalse, true, f.d) @@ -16083,7 +23258,8 @@ func (f fastpathT) DecMapFloat32IntX(vp *map[float32]int, checkNil bool, d *Deco func (_ fastpathT) DecMapFloat32IntV(v map[float32]int, checkNil bool, canChange bool, d *Decoder) (_ map[float32]int, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -16093,17 +23269,22 @@ func (_ fastpathT) DecMapFloat32IntV(v map[float32]int, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float32]int, containerLen) - } else { - v = make(map[float32]int) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[float32]int, xlen) changed = true } + + var mk float32 + var mv int if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := float32(dd.DecodeFloat(true)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv @@ -16111,23 +23292,26 @@ func (_ fastpathT) DecMapFloat32IntV(v map[float32]int, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := float32(dd.DecodeFloat(true)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat32Int8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat32Int8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float32]int8) v, changed := fastpathTV.DecMapFloat32Int8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -16148,7 +23332,8 @@ func (f fastpathT) DecMapFloat32Int8X(vp *map[float32]int8, checkNil bool, d *De func (_ fastpathT) DecMapFloat32Int8V(v map[float32]int8, checkNil bool, canChange bool, d *Decoder) (_ map[float32]int8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -16158,17 +23343,22 @@ func (_ fastpathT) DecMapFloat32Int8V(v map[float32]int8, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float32]int8, containerLen) - } else { - v = make(map[float32]int8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5) + v = make(map[float32]int8, xlen) changed = true } + + var mk float32 + var mv int8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := float32(dd.DecodeFloat(true)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv @@ -16176,23 +23366,26 @@ func (_ fastpathT) DecMapFloat32Int8V(v map[float32]int8, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := float32(dd.DecodeFloat(true)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat32Int16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat32Int16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float32]int16) v, changed := fastpathTV.DecMapFloat32Int16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -16213,7 +23406,8 @@ func (f fastpathT) DecMapFloat32Int16X(vp *map[float32]int16, checkNil bool, d * func (_ fastpathT) DecMapFloat32Int16V(v map[float32]int16, checkNil bool, canChange bool, d *Decoder) (_ map[float32]int16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -16223,17 +23417,22 @@ func (_ fastpathT) DecMapFloat32Int16V(v map[float32]int16, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float32]int16, containerLen) - } else { - v = make(map[float32]int16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6) + v = make(map[float32]int16, xlen) changed = true } + + var mk float32 + var mv int16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := float32(dd.DecodeFloat(true)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv @@ -16241,23 +23440,26 @@ func (_ fastpathT) DecMapFloat32Int16V(v map[float32]int16, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := float32(dd.DecodeFloat(true)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat32Int32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat32Int32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float32]int32) v, changed := fastpathTV.DecMapFloat32Int32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -16278,7 +23480,8 @@ func (f fastpathT) DecMapFloat32Int32X(vp *map[float32]int32, checkNil bool, d * func (_ fastpathT) DecMapFloat32Int32V(v map[float32]int32, checkNil bool, canChange bool, d *Decoder) (_ map[float32]int32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -16288,17 +23491,22 @@ func (_ fastpathT) DecMapFloat32Int32V(v map[float32]int32, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float32]int32, containerLen) - } else { - v = make(map[float32]int32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 8) + v = make(map[float32]int32, xlen) changed = true } + + var mk float32 + var mv int32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := float32(dd.DecodeFloat(true)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv @@ -16306,23 +23514,26 @@ func (_ fastpathT) DecMapFloat32Int32V(v map[float32]int32, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := float32(dd.DecodeFloat(true)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat32Int64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat32Int64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float32]int64) v, changed := fastpathTV.DecMapFloat32Int64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -16343,7 +23554,8 @@ func (f fastpathT) DecMapFloat32Int64X(vp *map[float32]int64, checkNil bool, d * func (_ fastpathT) DecMapFloat32Int64V(v map[float32]int64, checkNil bool, canChange bool, d *Decoder) (_ map[float32]int64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -16353,17 +23565,22 @@ func (_ fastpathT) DecMapFloat32Int64V(v map[float32]int64, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float32]int64, containerLen) - } else { - v = make(map[float32]int64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[float32]int64, xlen) changed = true } + + var mk float32 + var mv int64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := float32(dd.DecodeFloat(true)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeInt(64) if v != nil { v[mk] = mv @@ -16371,23 +23588,26 @@ func (_ fastpathT) DecMapFloat32Int64V(v map[float32]int64, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := float32(dd.DecodeFloat(true)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeInt(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat32Float32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat32Float32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float32]float32) v, changed := fastpathTV.DecMapFloat32Float32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -16408,7 +23628,8 @@ func (f fastpathT) DecMapFloat32Float32X(vp *map[float32]float32, checkNil bool, func (_ fastpathT) DecMapFloat32Float32V(v map[float32]float32, checkNil bool, canChange bool, d *Decoder) (_ map[float32]float32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -16418,17 +23639,22 @@ func (_ fastpathT) DecMapFloat32Float32V(v map[float32]float32, checkNil bool, c containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float32]float32, containerLen) - } else { - v = make(map[float32]float32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 8) + v = make(map[float32]float32, xlen) changed = true } + + var mk float32 + var mv float32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := float32(dd.DecodeFloat(true)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv @@ -16436,23 +23662,26 @@ func (_ fastpathT) DecMapFloat32Float32V(v map[float32]float32, checkNil bool, c } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := float32(dd.DecodeFloat(true)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat32Float64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat32Float64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float32]float64) v, changed := fastpathTV.DecMapFloat32Float64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -16473,7 +23702,8 @@ func (f fastpathT) DecMapFloat32Float64X(vp *map[float32]float64, checkNil bool, func (_ fastpathT) DecMapFloat32Float64V(v map[float32]float64, checkNil bool, canChange bool, d *Decoder) (_ map[float32]float64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -16483,17 +23713,22 @@ func (_ fastpathT) DecMapFloat32Float64V(v map[float32]float64, checkNil bool, c containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float32]float64, containerLen) - } else { - v = make(map[float32]float64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[float32]float64, xlen) changed = true } + + var mk float32 + var mv float64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := float32(dd.DecodeFloat(true)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv @@ -16501,23 +23736,26 @@ func (_ fastpathT) DecMapFloat32Float64V(v map[float32]float64, checkNil bool, c } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := float32(dd.DecodeFloat(true)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat32BoolR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat32BoolR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float32]bool) v, changed := fastpathTV.DecMapFloat32BoolV(*vp, fastpathCheckNilFalse, true, f.d) @@ -16538,7 +23776,8 @@ func (f fastpathT) DecMapFloat32BoolX(vp *map[float32]bool, checkNil bool, d *De func (_ fastpathT) DecMapFloat32BoolV(v map[float32]bool, checkNil bool, canChange bool, d *Decoder) (_ map[float32]bool, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -16548,17 +23787,22 @@ func (_ fastpathT) DecMapFloat32BoolV(v map[float32]bool, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float32]bool, containerLen) - } else { - v = make(map[float32]bool) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5) + v = make(map[float32]bool, xlen) changed = true } + + var mk float32 + var mv bool if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := float32(dd.DecodeFloat(true)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeBool() if v != nil { v[mk] = mv @@ -16566,23 +23810,26 @@ func (_ fastpathT) DecMapFloat32BoolV(v map[float32]bool, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = float32(dd.DecodeFloat(true)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := float32(dd.DecodeFloat(true)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeBool() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat64IntfR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat64IntfR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float64]interface{}) v, changed := fastpathTV.DecMapFloat64IntfV(*vp, fastpathCheckNilFalse, true, f.d) @@ -16603,7 +23850,8 @@ func (f fastpathT) DecMapFloat64IntfX(vp *map[float64]interface{}, checkNil bool func (_ fastpathT) DecMapFloat64IntfV(v map[float64]interface{}, checkNil bool, canChange bool, d *Decoder) (_ map[float64]interface{}, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -16613,43 +23861,59 @@ func (_ fastpathT) DecMapFloat64IntfV(v map[float64]interface{}, checkNil bool, containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float64]interface{}, containerLen) - } else { - v = make(map[float64]interface{}) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[float64]interface{}, xlen) changed = true } + mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + var mk float64 + var mv interface{} if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeFloat(false) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } d.decode(&mv) - if v != nil { v[mk] = mv } } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil } - mk := dd.DecodeFloat(false) - dd.ReadMapKVSeparator() - mv := v[mk] d.decode(&mv) - if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat64StringR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat64StringR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float64]string) v, changed := fastpathTV.DecMapFloat64StringV(*vp, fastpathCheckNilFalse, true, f.d) @@ -16670,7 +23934,8 @@ func (f fastpathT) DecMapFloat64StringX(vp *map[float64]string, checkNil bool, d func (_ fastpathT) DecMapFloat64StringV(v map[float64]string, checkNil bool, canChange bool, d *Decoder) (_ map[float64]string, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -16680,17 +23945,22 @@ func (_ fastpathT) DecMapFloat64StringV(v map[float64]string, checkNil bool, can containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float64]string, containerLen) - } else { - v = make(map[float64]string) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[float64]string, xlen) changed = true } + + var mk float64 + var mv string if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeFloat(false) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeString() if v != nil { v[mk] = mv @@ -16698,23 +23968,26 @@ func (_ fastpathT) DecMapFloat64StringV(v map[float64]string, checkNil bool, can } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeFloat(false) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeString() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat64UintR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat64UintR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float64]uint) v, changed := fastpathTV.DecMapFloat64UintV(*vp, fastpathCheckNilFalse, true, f.d) @@ -16735,7 +24008,8 @@ func (f fastpathT) DecMapFloat64UintX(vp *map[float64]uint, checkNil bool, d *De func (_ fastpathT) DecMapFloat64UintV(v map[float64]uint, checkNil bool, canChange bool, d *Decoder) (_ map[float64]uint, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -16745,17 +24019,22 @@ func (_ fastpathT) DecMapFloat64UintV(v map[float64]uint, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float64]uint, containerLen) - } else { - v = make(map[float64]uint) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[float64]uint, xlen) changed = true } + + var mk float64 + var mv uint if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeFloat(false) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv @@ -16763,23 +24042,26 @@ func (_ fastpathT) DecMapFloat64UintV(v map[float64]uint, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeFloat(false) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat64Uint8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat64Uint8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float64]uint8) v, changed := fastpathTV.DecMapFloat64Uint8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -16800,7 +24082,8 @@ func (f fastpathT) DecMapFloat64Uint8X(vp *map[float64]uint8, checkNil bool, d * func (_ fastpathT) DecMapFloat64Uint8V(v map[float64]uint8, checkNil bool, canChange bool, d *Decoder) (_ map[float64]uint8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -16810,17 +24093,22 @@ func (_ fastpathT) DecMapFloat64Uint8V(v map[float64]uint8, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float64]uint8, containerLen) - } else { - v = make(map[float64]uint8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[float64]uint8, xlen) changed = true } + + var mk float64 + var mv uint8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeFloat(false) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv @@ -16828,23 +24116,26 @@ func (_ fastpathT) DecMapFloat64Uint8V(v map[float64]uint8, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeFloat(false) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat64Uint16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat64Uint16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float64]uint16) v, changed := fastpathTV.DecMapFloat64Uint16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -16865,7 +24156,8 @@ func (f fastpathT) DecMapFloat64Uint16X(vp *map[float64]uint16, checkNil bool, d func (_ fastpathT) DecMapFloat64Uint16V(v map[float64]uint16, checkNil bool, canChange bool, d *Decoder) (_ map[float64]uint16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -16875,17 +24167,22 @@ func (_ fastpathT) DecMapFloat64Uint16V(v map[float64]uint16, checkNil bool, can containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float64]uint16, containerLen) - } else { - v = make(map[float64]uint16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[float64]uint16, xlen) changed = true } + + var mk float64 + var mv uint16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeFloat(false) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv @@ -16893,23 +24190,26 @@ func (_ fastpathT) DecMapFloat64Uint16V(v map[float64]uint16, checkNil bool, can } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeFloat(false) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat64Uint32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat64Uint32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float64]uint32) v, changed := fastpathTV.DecMapFloat64Uint32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -16930,7 +24230,8 @@ func (f fastpathT) DecMapFloat64Uint32X(vp *map[float64]uint32, checkNil bool, d func (_ fastpathT) DecMapFloat64Uint32V(v map[float64]uint32, checkNil bool, canChange bool, d *Decoder) (_ map[float64]uint32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -16940,17 +24241,22 @@ func (_ fastpathT) DecMapFloat64Uint32V(v map[float64]uint32, checkNil bool, can containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float64]uint32, containerLen) - } else { - v = make(map[float64]uint32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[float64]uint32, xlen) changed = true } + + var mk float64 + var mv uint32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeFloat(false) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv @@ -16958,23 +24264,26 @@ func (_ fastpathT) DecMapFloat64Uint32V(v map[float64]uint32, checkNil bool, can } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeFloat(false) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat64Uint64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat64Uint64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float64]uint64) v, changed := fastpathTV.DecMapFloat64Uint64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -16995,7 +24304,8 @@ func (f fastpathT) DecMapFloat64Uint64X(vp *map[float64]uint64, checkNil bool, d func (_ fastpathT) DecMapFloat64Uint64V(v map[float64]uint64, checkNil bool, canChange bool, d *Decoder) (_ map[float64]uint64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -17005,17 +24315,22 @@ func (_ fastpathT) DecMapFloat64Uint64V(v map[float64]uint64, checkNil bool, can containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float64]uint64, containerLen) - } else { - v = make(map[float64]uint64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[float64]uint64, xlen) changed = true } + + var mk float64 + var mv uint64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeFloat(false) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeUint(64) if v != nil { v[mk] = mv @@ -17023,23 +24338,100 @@ func (_ fastpathT) DecMapFloat64Uint64V(v map[float64]uint64, checkNil bool, can } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeFloat(false) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeUint(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat64IntR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat64UintptrR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[float64]uintptr) + v, changed := fastpathTV.DecMapFloat64UintptrV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[float64]uintptr) + fastpathTV.DecMapFloat64UintptrV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapFloat64UintptrX(vp *map[float64]uintptr, checkNil bool, d *Decoder) { + v, changed := f.DecMapFloat64UintptrV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapFloat64UintptrV(v map[float64]uintptr, checkNil bool, canChange bool, + d *Decoder) (_ map[float64]uintptr, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[float64]uintptr, xlen) + changed = true + } + + var mk float64 + var mv uintptr + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapFloat64IntR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float64]int) v, changed := fastpathTV.DecMapFloat64IntV(*vp, fastpathCheckNilFalse, true, f.d) @@ -17060,7 +24452,8 @@ func (f fastpathT) DecMapFloat64IntX(vp *map[float64]int, checkNil bool, d *Deco func (_ fastpathT) DecMapFloat64IntV(v map[float64]int, checkNil bool, canChange bool, d *Decoder) (_ map[float64]int, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -17070,17 +24463,22 @@ func (_ fastpathT) DecMapFloat64IntV(v map[float64]int, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float64]int, containerLen) - } else { - v = make(map[float64]int) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[float64]int, xlen) changed = true } + + var mk float64 + var mv int if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeFloat(false) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv @@ -17088,23 +24486,26 @@ func (_ fastpathT) DecMapFloat64IntV(v map[float64]int, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeFloat(false) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat64Int8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat64Int8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float64]int8) v, changed := fastpathTV.DecMapFloat64Int8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -17125,7 +24526,8 @@ func (f fastpathT) DecMapFloat64Int8X(vp *map[float64]int8, checkNil bool, d *De func (_ fastpathT) DecMapFloat64Int8V(v map[float64]int8, checkNil bool, canChange bool, d *Decoder) (_ map[float64]int8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -17135,17 +24537,22 @@ func (_ fastpathT) DecMapFloat64Int8V(v map[float64]int8, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float64]int8, containerLen) - } else { - v = make(map[float64]int8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[float64]int8, xlen) changed = true } + + var mk float64 + var mv int8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeFloat(false) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv @@ -17153,23 +24560,26 @@ func (_ fastpathT) DecMapFloat64Int8V(v map[float64]int8, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeFloat(false) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat64Int16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat64Int16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float64]int16) v, changed := fastpathTV.DecMapFloat64Int16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -17190,7 +24600,8 @@ func (f fastpathT) DecMapFloat64Int16X(vp *map[float64]int16, checkNil bool, d * func (_ fastpathT) DecMapFloat64Int16V(v map[float64]int16, checkNil bool, canChange bool, d *Decoder) (_ map[float64]int16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -17200,17 +24611,22 @@ func (_ fastpathT) DecMapFloat64Int16V(v map[float64]int16, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float64]int16, containerLen) - } else { - v = make(map[float64]int16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[float64]int16, xlen) changed = true } + + var mk float64 + var mv int16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeFloat(false) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv @@ -17218,23 +24634,26 @@ func (_ fastpathT) DecMapFloat64Int16V(v map[float64]int16, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeFloat(false) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat64Int32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat64Int32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float64]int32) v, changed := fastpathTV.DecMapFloat64Int32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -17255,7 +24674,8 @@ func (f fastpathT) DecMapFloat64Int32X(vp *map[float64]int32, checkNil bool, d * func (_ fastpathT) DecMapFloat64Int32V(v map[float64]int32, checkNil bool, canChange bool, d *Decoder) (_ map[float64]int32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -17265,17 +24685,22 @@ func (_ fastpathT) DecMapFloat64Int32V(v map[float64]int32, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float64]int32, containerLen) - } else { - v = make(map[float64]int32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[float64]int32, xlen) changed = true } + + var mk float64 + var mv int32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeFloat(false) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv @@ -17283,23 +24708,26 @@ func (_ fastpathT) DecMapFloat64Int32V(v map[float64]int32, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeFloat(false) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat64Int64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat64Int64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float64]int64) v, changed := fastpathTV.DecMapFloat64Int64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -17320,7 +24748,8 @@ func (f fastpathT) DecMapFloat64Int64X(vp *map[float64]int64, checkNil bool, d * func (_ fastpathT) DecMapFloat64Int64V(v map[float64]int64, checkNil bool, canChange bool, d *Decoder) (_ map[float64]int64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -17330,17 +24759,22 @@ func (_ fastpathT) DecMapFloat64Int64V(v map[float64]int64, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float64]int64, containerLen) - } else { - v = make(map[float64]int64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[float64]int64, xlen) changed = true } + + var mk float64 + var mv int64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeFloat(false) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeInt(64) if v != nil { v[mk] = mv @@ -17348,23 +24782,26 @@ func (_ fastpathT) DecMapFloat64Int64V(v map[float64]int64, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeFloat(false) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeInt(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat64Float32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat64Float32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float64]float32) v, changed := fastpathTV.DecMapFloat64Float32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -17385,7 +24822,8 @@ func (f fastpathT) DecMapFloat64Float32X(vp *map[float64]float32, checkNil bool, func (_ fastpathT) DecMapFloat64Float32V(v map[float64]float32, checkNil bool, canChange bool, d *Decoder) (_ map[float64]float32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -17395,17 +24833,22 @@ func (_ fastpathT) DecMapFloat64Float32V(v map[float64]float32, checkNil bool, c containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float64]float32, containerLen) - } else { - v = make(map[float64]float32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[float64]float32, xlen) changed = true } + + var mk float64 + var mv float32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeFloat(false) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv @@ -17413,23 +24856,26 @@ func (_ fastpathT) DecMapFloat64Float32V(v map[float64]float32, checkNil bool, c } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeFloat(false) - dd.ReadMapKVSeparator() - mv := v[mk] mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat64Float64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat64Float64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float64]float64) v, changed := fastpathTV.DecMapFloat64Float64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -17450,7 +24896,8 @@ func (f fastpathT) DecMapFloat64Float64X(vp *map[float64]float64, checkNil bool, func (_ fastpathT) DecMapFloat64Float64V(v map[float64]float64, checkNil bool, canChange bool, d *Decoder) (_ map[float64]float64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -17460,17 +24907,22 @@ func (_ fastpathT) DecMapFloat64Float64V(v map[float64]float64, checkNil bool, c containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float64]float64, containerLen) - } else { - v = make(map[float64]float64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[float64]float64, xlen) changed = true } + + var mk float64 + var mv float64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeFloat(false) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv @@ -17478,23 +24930,26 @@ func (_ fastpathT) DecMapFloat64Float64V(v map[float64]float64, checkNil bool, c } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeFloat(false) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapFloat64BoolR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapFloat64BoolR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[float64]bool) v, changed := fastpathTV.DecMapFloat64BoolV(*vp, fastpathCheckNilFalse, true, f.d) @@ -17515,7 +24970,8 @@ func (f fastpathT) DecMapFloat64BoolX(vp *map[float64]bool, checkNil bool, d *De func (_ fastpathT) DecMapFloat64BoolV(v map[float64]bool, checkNil bool, canChange bool, d *Decoder) (_ map[float64]bool, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -17525,17 +24981,22 @@ func (_ fastpathT) DecMapFloat64BoolV(v map[float64]bool, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[float64]bool, containerLen) - } else { - v = make(map[float64]bool) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[float64]bool, xlen) changed = true } + + var mk float64 + var mv bool if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeFloat(false) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeBool() if v != nil { v[mk] = mv @@ -17543,23 +25004,26 @@ func (_ fastpathT) DecMapFloat64BoolV(v map[float64]bool, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeFloat(false) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeFloat(false) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeBool() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUintIntfR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUintIntfR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint]interface{}) v, changed := fastpathTV.DecMapUintIntfV(*vp, fastpathCheckNilFalse, true, f.d) @@ -17580,7 +25044,8 @@ func (f fastpathT) DecMapUintIntfX(vp *map[uint]interface{}, checkNil bool, d *D func (_ fastpathT) DecMapUintIntfV(v map[uint]interface{}, checkNil bool, canChange bool, d *Decoder) (_ map[uint]interface{}, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -17590,43 +25055,59 @@ func (_ fastpathT) DecMapUintIntfV(v map[uint]interface{}, checkNil bool, canCha containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint]interface{}, containerLen) - } else { - v = make(map[uint]interface{}) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[uint]interface{}, xlen) changed = true } + mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + var mk uint + var mv interface{} if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint(dd.DecodeUint(uintBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } d.decode(&mv) - if v != nil { v[mk] = mv } } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil } - mk := uint(dd.DecodeUint(uintBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] d.decode(&mv) - if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUintStringR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUintStringR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint]string) v, changed := fastpathTV.DecMapUintStringV(*vp, fastpathCheckNilFalse, true, f.d) @@ -17647,7 +25128,8 @@ func (f fastpathT) DecMapUintStringX(vp *map[uint]string, checkNil bool, d *Deco func (_ fastpathT) DecMapUintStringV(v map[uint]string, checkNil bool, canChange bool, d *Decoder) (_ map[uint]string, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -17657,17 +25139,22 @@ func (_ fastpathT) DecMapUintStringV(v map[uint]string, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint]string, containerLen) - } else { - v = make(map[uint]string) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[uint]string, xlen) changed = true } + + var mk uint + var mv string if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint(dd.DecodeUint(uintBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeString() if v != nil { v[mk] = mv @@ -17675,23 +25162,26 @@ func (_ fastpathT) DecMapUintStringV(v map[uint]string, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint(dd.DecodeUint(uintBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeString() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUintUintR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUintUintR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint]uint) v, changed := fastpathTV.DecMapUintUintV(*vp, fastpathCheckNilFalse, true, f.d) @@ -17712,7 +25202,8 @@ func (f fastpathT) DecMapUintUintX(vp *map[uint]uint, checkNil bool, d *Decoder) func (_ fastpathT) DecMapUintUintV(v map[uint]uint, checkNil bool, canChange bool, d *Decoder) (_ map[uint]uint, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -17722,17 +25213,22 @@ func (_ fastpathT) DecMapUintUintV(v map[uint]uint, checkNil bool, canChange boo containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint]uint, containerLen) - } else { - v = make(map[uint]uint) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[uint]uint, xlen) changed = true } + + var mk uint + var mv uint if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint(dd.DecodeUint(uintBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv @@ -17740,23 +25236,26 @@ func (_ fastpathT) DecMapUintUintV(v map[uint]uint, checkNil bool, canChange boo } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint(dd.DecodeUint(uintBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUintUint8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUintUint8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint]uint8) v, changed := fastpathTV.DecMapUintUint8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -17777,7 +25276,8 @@ func (f fastpathT) DecMapUintUint8X(vp *map[uint]uint8, checkNil bool, d *Decode func (_ fastpathT) DecMapUintUint8V(v map[uint]uint8, checkNil bool, canChange bool, d *Decoder) (_ map[uint]uint8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -17787,17 +25287,22 @@ func (_ fastpathT) DecMapUintUint8V(v map[uint]uint8, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint]uint8, containerLen) - } else { - v = make(map[uint]uint8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[uint]uint8, xlen) changed = true } + + var mk uint + var mv uint8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint(dd.DecodeUint(uintBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv @@ -17805,23 +25310,26 @@ func (_ fastpathT) DecMapUintUint8V(v map[uint]uint8, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint(dd.DecodeUint(uintBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUintUint16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUintUint16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint]uint16) v, changed := fastpathTV.DecMapUintUint16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -17842,7 +25350,8 @@ func (f fastpathT) DecMapUintUint16X(vp *map[uint]uint16, checkNil bool, d *Deco func (_ fastpathT) DecMapUintUint16V(v map[uint]uint16, checkNil bool, canChange bool, d *Decoder) (_ map[uint]uint16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -17852,17 +25361,22 @@ func (_ fastpathT) DecMapUintUint16V(v map[uint]uint16, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint]uint16, containerLen) - } else { - v = make(map[uint]uint16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[uint]uint16, xlen) changed = true } + + var mk uint + var mv uint16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint(dd.DecodeUint(uintBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv @@ -17870,23 +25384,26 @@ func (_ fastpathT) DecMapUintUint16V(v map[uint]uint16, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint(dd.DecodeUint(uintBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUintUint32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUintUint32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint]uint32) v, changed := fastpathTV.DecMapUintUint32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -17907,7 +25424,8 @@ func (f fastpathT) DecMapUintUint32X(vp *map[uint]uint32, checkNil bool, d *Deco func (_ fastpathT) DecMapUintUint32V(v map[uint]uint32, checkNil bool, canChange bool, d *Decoder) (_ map[uint]uint32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -17917,17 +25435,22 @@ func (_ fastpathT) DecMapUintUint32V(v map[uint]uint32, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint]uint32, containerLen) - } else { - v = make(map[uint]uint32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[uint]uint32, xlen) changed = true } + + var mk uint + var mv uint32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint(dd.DecodeUint(uintBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv @@ -17935,23 +25458,26 @@ func (_ fastpathT) DecMapUintUint32V(v map[uint]uint32, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint(dd.DecodeUint(uintBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUintUint64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUintUint64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint]uint64) v, changed := fastpathTV.DecMapUintUint64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -17972,7 +25498,8 @@ func (f fastpathT) DecMapUintUint64X(vp *map[uint]uint64, checkNil bool, d *Deco func (_ fastpathT) DecMapUintUint64V(v map[uint]uint64, checkNil bool, canChange bool, d *Decoder) (_ map[uint]uint64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -17982,17 +25509,22 @@ func (_ fastpathT) DecMapUintUint64V(v map[uint]uint64, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint]uint64, containerLen) - } else { - v = make(map[uint]uint64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[uint]uint64, xlen) changed = true } + + var mk uint + var mv uint64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint(dd.DecodeUint(uintBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeUint(64) if v != nil { v[mk] = mv @@ -18000,23 +25532,100 @@ func (_ fastpathT) DecMapUintUint64V(v map[uint]uint64, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint(dd.DecodeUint(uintBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeUint(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUintIntR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUintUintptrR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uint]uintptr) + v, changed := fastpathTV.DecMapUintUintptrV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uint]uintptr) + fastpathTV.DecMapUintUintptrV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUintUintptrX(vp *map[uint]uintptr, checkNil bool, d *Decoder) { + v, changed := f.DecMapUintUintptrV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUintUintptrV(v map[uint]uintptr, checkNil bool, canChange bool, + d *Decoder) (_ map[uint]uintptr, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[uint]uintptr, xlen) + changed = true + } + + var mk uint + var mv uintptr + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUintIntR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint]int) v, changed := fastpathTV.DecMapUintIntV(*vp, fastpathCheckNilFalse, true, f.d) @@ -18037,7 +25646,8 @@ func (f fastpathT) DecMapUintIntX(vp *map[uint]int, checkNil bool, d *Decoder) { func (_ fastpathT) DecMapUintIntV(v map[uint]int, checkNil bool, canChange bool, d *Decoder) (_ map[uint]int, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -18047,17 +25657,22 @@ func (_ fastpathT) DecMapUintIntV(v map[uint]int, checkNil bool, canChange bool, containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint]int, containerLen) - } else { - v = make(map[uint]int) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[uint]int, xlen) changed = true } + + var mk uint + var mv int if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint(dd.DecodeUint(uintBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv @@ -18065,23 +25680,26 @@ func (_ fastpathT) DecMapUintIntV(v map[uint]int, checkNil bool, canChange bool, } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint(dd.DecodeUint(uintBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUintInt8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUintInt8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint]int8) v, changed := fastpathTV.DecMapUintInt8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -18102,7 +25720,8 @@ func (f fastpathT) DecMapUintInt8X(vp *map[uint]int8, checkNil bool, d *Decoder) func (_ fastpathT) DecMapUintInt8V(v map[uint]int8, checkNil bool, canChange bool, d *Decoder) (_ map[uint]int8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -18112,17 +25731,22 @@ func (_ fastpathT) DecMapUintInt8V(v map[uint]int8, checkNil bool, canChange boo containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint]int8, containerLen) - } else { - v = make(map[uint]int8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[uint]int8, xlen) changed = true } + + var mk uint + var mv int8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint(dd.DecodeUint(uintBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv @@ -18130,23 +25754,26 @@ func (_ fastpathT) DecMapUintInt8V(v map[uint]int8, checkNil bool, canChange boo } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint(dd.DecodeUint(uintBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUintInt16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUintInt16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint]int16) v, changed := fastpathTV.DecMapUintInt16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -18167,7 +25794,8 @@ func (f fastpathT) DecMapUintInt16X(vp *map[uint]int16, checkNil bool, d *Decode func (_ fastpathT) DecMapUintInt16V(v map[uint]int16, checkNil bool, canChange bool, d *Decoder) (_ map[uint]int16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -18177,17 +25805,22 @@ func (_ fastpathT) DecMapUintInt16V(v map[uint]int16, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint]int16, containerLen) - } else { - v = make(map[uint]int16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[uint]int16, xlen) changed = true } + + var mk uint + var mv int16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint(dd.DecodeUint(uintBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv @@ -18195,23 +25828,26 @@ func (_ fastpathT) DecMapUintInt16V(v map[uint]int16, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint(dd.DecodeUint(uintBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUintInt32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUintInt32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint]int32) v, changed := fastpathTV.DecMapUintInt32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -18232,7 +25868,8 @@ func (f fastpathT) DecMapUintInt32X(vp *map[uint]int32, checkNil bool, d *Decode func (_ fastpathT) DecMapUintInt32V(v map[uint]int32, checkNil bool, canChange bool, d *Decoder) (_ map[uint]int32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -18242,17 +25879,22 @@ func (_ fastpathT) DecMapUintInt32V(v map[uint]int32, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint]int32, containerLen) - } else { - v = make(map[uint]int32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[uint]int32, xlen) changed = true } + + var mk uint + var mv int32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint(dd.DecodeUint(uintBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv @@ -18260,23 +25902,26 @@ func (_ fastpathT) DecMapUintInt32V(v map[uint]int32, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint(dd.DecodeUint(uintBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUintInt64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUintInt64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint]int64) v, changed := fastpathTV.DecMapUintInt64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -18297,7 +25942,8 @@ func (f fastpathT) DecMapUintInt64X(vp *map[uint]int64, checkNil bool, d *Decode func (_ fastpathT) DecMapUintInt64V(v map[uint]int64, checkNil bool, canChange bool, d *Decoder) (_ map[uint]int64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -18307,17 +25953,22 @@ func (_ fastpathT) DecMapUintInt64V(v map[uint]int64, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint]int64, containerLen) - } else { - v = make(map[uint]int64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[uint]int64, xlen) changed = true } + + var mk uint + var mv int64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint(dd.DecodeUint(uintBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeInt(64) if v != nil { v[mk] = mv @@ -18325,23 +25976,26 @@ func (_ fastpathT) DecMapUintInt64V(v map[uint]int64, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint(dd.DecodeUint(uintBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeInt(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUintFloat32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUintFloat32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint]float32) v, changed := fastpathTV.DecMapUintFloat32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -18362,7 +26016,8 @@ func (f fastpathT) DecMapUintFloat32X(vp *map[uint]float32, checkNil bool, d *De func (_ fastpathT) DecMapUintFloat32V(v map[uint]float32, checkNil bool, canChange bool, d *Decoder) (_ map[uint]float32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -18372,17 +26027,22 @@ func (_ fastpathT) DecMapUintFloat32V(v map[uint]float32, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint]float32, containerLen) - } else { - v = make(map[uint]float32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[uint]float32, xlen) changed = true } + + var mk uint + var mv float32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint(dd.DecodeUint(uintBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv @@ -18390,23 +26050,26 @@ func (_ fastpathT) DecMapUintFloat32V(v map[uint]float32, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint(dd.DecodeUint(uintBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUintFloat64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUintFloat64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint]float64) v, changed := fastpathTV.DecMapUintFloat64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -18427,7 +26090,8 @@ func (f fastpathT) DecMapUintFloat64X(vp *map[uint]float64, checkNil bool, d *De func (_ fastpathT) DecMapUintFloat64V(v map[uint]float64, checkNil bool, canChange bool, d *Decoder) (_ map[uint]float64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -18437,17 +26101,22 @@ func (_ fastpathT) DecMapUintFloat64V(v map[uint]float64, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint]float64, containerLen) - } else { - v = make(map[uint]float64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[uint]float64, xlen) changed = true } + + var mk uint + var mv float64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint(dd.DecodeUint(uintBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv @@ -18455,23 +26124,26 @@ func (_ fastpathT) DecMapUintFloat64V(v map[uint]float64, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint(dd.DecodeUint(uintBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUintBoolR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUintBoolR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint]bool) v, changed := fastpathTV.DecMapUintBoolV(*vp, fastpathCheckNilFalse, true, f.d) @@ -18492,7 +26164,8 @@ func (f fastpathT) DecMapUintBoolX(vp *map[uint]bool, checkNil bool, d *Decoder) func (_ fastpathT) DecMapUintBoolV(v map[uint]bool, checkNil bool, canChange bool, d *Decoder) (_ map[uint]bool, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -18502,17 +26175,22 @@ func (_ fastpathT) DecMapUintBoolV(v map[uint]bool, checkNil bool, canChange boo containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint]bool, containerLen) - } else { - v = make(map[uint]bool) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[uint]bool, xlen) changed = true } + + var mk uint + var mv bool if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint(dd.DecodeUint(uintBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeBool() if v != nil { v[mk] = mv @@ -18520,23 +26198,26 @@ func (_ fastpathT) DecMapUintBoolV(v map[uint]bool, checkNil bool, canChange boo } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint(dd.DecodeUint(uintBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeBool() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint8IntfR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint8IntfR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint8]interface{}) v, changed := fastpathTV.DecMapUint8IntfV(*vp, fastpathCheckNilFalse, true, f.d) @@ -18557,7 +26238,8 @@ func (f fastpathT) DecMapUint8IntfX(vp *map[uint8]interface{}, checkNil bool, d func (_ fastpathT) DecMapUint8IntfV(v map[uint8]interface{}, checkNil bool, canChange bool, d *Decoder) (_ map[uint8]interface{}, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -18567,43 +26249,59 @@ func (_ fastpathT) DecMapUint8IntfV(v map[uint8]interface{}, checkNil bool, canC containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint8]interface{}, containerLen) - } else { - v = make(map[uint8]interface{}) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17) + v = make(map[uint8]interface{}, xlen) changed = true } + mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + var mk uint8 + var mv interface{} if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint8(dd.DecodeUint(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } d.decode(&mv) - if v != nil { v[mk] = mv } } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil } - mk := uint8(dd.DecodeUint(8)) - dd.ReadMapKVSeparator() - mv := v[mk] d.decode(&mv) - if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint8StringR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint8StringR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint8]string) v, changed := fastpathTV.DecMapUint8StringV(*vp, fastpathCheckNilFalse, true, f.d) @@ -18624,7 +26322,8 @@ func (f fastpathT) DecMapUint8StringX(vp *map[uint8]string, checkNil bool, d *De func (_ fastpathT) DecMapUint8StringV(v map[uint8]string, checkNil bool, canChange bool, d *Decoder) (_ map[uint8]string, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -18634,17 +26333,22 @@ func (_ fastpathT) DecMapUint8StringV(v map[uint8]string, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint8]string, containerLen) - } else { - v = make(map[uint8]string) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17) + v = make(map[uint8]string, xlen) changed = true } + + var mk uint8 + var mv string if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint8(dd.DecodeUint(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeString() if v != nil { v[mk] = mv @@ -18652,23 +26356,26 @@ func (_ fastpathT) DecMapUint8StringV(v map[uint8]string, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint8(dd.DecodeUint(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeString() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint8UintR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint8UintR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint8]uint) v, changed := fastpathTV.DecMapUint8UintV(*vp, fastpathCheckNilFalse, true, f.d) @@ -18689,7 +26396,8 @@ func (f fastpathT) DecMapUint8UintX(vp *map[uint8]uint, checkNil bool, d *Decode func (_ fastpathT) DecMapUint8UintV(v map[uint8]uint, checkNil bool, canChange bool, d *Decoder) (_ map[uint8]uint, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -18699,17 +26407,22 @@ func (_ fastpathT) DecMapUint8UintV(v map[uint8]uint, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint8]uint, containerLen) - } else { - v = make(map[uint8]uint) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[uint8]uint, xlen) changed = true } + + var mk uint8 + var mv uint if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint8(dd.DecodeUint(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv @@ -18717,23 +26430,26 @@ func (_ fastpathT) DecMapUint8UintV(v map[uint8]uint, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint8(dd.DecodeUint(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint8Uint8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint8Uint8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint8]uint8) v, changed := fastpathTV.DecMapUint8Uint8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -18754,7 +26470,8 @@ func (f fastpathT) DecMapUint8Uint8X(vp *map[uint8]uint8, checkNil bool, d *Deco func (_ fastpathT) DecMapUint8Uint8V(v map[uint8]uint8, checkNil bool, canChange bool, d *Decoder) (_ map[uint8]uint8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -18764,17 +26481,22 @@ func (_ fastpathT) DecMapUint8Uint8V(v map[uint8]uint8, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint8]uint8, containerLen) - } else { - v = make(map[uint8]uint8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 2) + v = make(map[uint8]uint8, xlen) changed = true } + + var mk uint8 + var mv uint8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint8(dd.DecodeUint(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv @@ -18782,23 +26504,26 @@ func (_ fastpathT) DecMapUint8Uint8V(v map[uint8]uint8, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint8(dd.DecodeUint(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint8Uint16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint8Uint16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint8]uint16) v, changed := fastpathTV.DecMapUint8Uint16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -18819,7 +26544,8 @@ func (f fastpathT) DecMapUint8Uint16X(vp *map[uint8]uint16, checkNil bool, d *De func (_ fastpathT) DecMapUint8Uint16V(v map[uint8]uint16, checkNil bool, canChange bool, d *Decoder) (_ map[uint8]uint16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -18829,17 +26555,22 @@ func (_ fastpathT) DecMapUint8Uint16V(v map[uint8]uint16, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint8]uint16, containerLen) - } else { - v = make(map[uint8]uint16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3) + v = make(map[uint8]uint16, xlen) changed = true } + + var mk uint8 + var mv uint16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint8(dd.DecodeUint(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv @@ -18847,23 +26578,26 @@ func (_ fastpathT) DecMapUint8Uint16V(v map[uint8]uint16, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint8(dd.DecodeUint(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint8Uint32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint8Uint32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint8]uint32) v, changed := fastpathTV.DecMapUint8Uint32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -18884,7 +26618,8 @@ func (f fastpathT) DecMapUint8Uint32X(vp *map[uint8]uint32, checkNil bool, d *De func (_ fastpathT) DecMapUint8Uint32V(v map[uint8]uint32, checkNil bool, canChange bool, d *Decoder) (_ map[uint8]uint32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -18894,17 +26629,22 @@ func (_ fastpathT) DecMapUint8Uint32V(v map[uint8]uint32, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint8]uint32, containerLen) - } else { - v = make(map[uint8]uint32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5) + v = make(map[uint8]uint32, xlen) changed = true } + + var mk uint8 + var mv uint32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint8(dd.DecodeUint(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv @@ -18912,23 +26652,26 @@ func (_ fastpathT) DecMapUint8Uint32V(v map[uint8]uint32, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint8(dd.DecodeUint(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint8Uint64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint8Uint64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint8]uint64) v, changed := fastpathTV.DecMapUint8Uint64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -18949,7 +26692,8 @@ func (f fastpathT) DecMapUint8Uint64X(vp *map[uint8]uint64, checkNil bool, d *De func (_ fastpathT) DecMapUint8Uint64V(v map[uint8]uint64, checkNil bool, canChange bool, d *Decoder) (_ map[uint8]uint64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -18959,17 +26703,22 @@ func (_ fastpathT) DecMapUint8Uint64V(v map[uint8]uint64, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint8]uint64, containerLen) - } else { - v = make(map[uint8]uint64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[uint8]uint64, xlen) changed = true } + + var mk uint8 + var mv uint64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint8(dd.DecodeUint(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeUint(64) if v != nil { v[mk] = mv @@ -18977,23 +26726,100 @@ func (_ fastpathT) DecMapUint8Uint64V(v map[uint8]uint64, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint8(dd.DecodeUint(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeUint(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint8IntR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint8UintptrR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uint8]uintptr) + v, changed := fastpathTV.DecMapUint8UintptrV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uint8]uintptr) + fastpathTV.DecMapUint8UintptrV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUint8UintptrX(vp *map[uint8]uintptr, checkNil bool, d *Decoder) { + v, changed := f.DecMapUint8UintptrV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUint8UintptrV(v map[uint8]uintptr, checkNil bool, canChange bool, + d *Decoder) (_ map[uint8]uintptr, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[uint8]uintptr, xlen) + changed = true + } + + var mk uint8 + var mv uintptr + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUint8IntR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint8]int) v, changed := fastpathTV.DecMapUint8IntV(*vp, fastpathCheckNilFalse, true, f.d) @@ -19014,7 +26840,8 @@ func (f fastpathT) DecMapUint8IntX(vp *map[uint8]int, checkNil bool, d *Decoder) func (_ fastpathT) DecMapUint8IntV(v map[uint8]int, checkNil bool, canChange bool, d *Decoder) (_ map[uint8]int, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -19024,17 +26851,22 @@ func (_ fastpathT) DecMapUint8IntV(v map[uint8]int, checkNil bool, canChange boo containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint8]int, containerLen) - } else { - v = make(map[uint8]int) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[uint8]int, xlen) changed = true } + + var mk uint8 + var mv int if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint8(dd.DecodeUint(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv @@ -19042,23 +26874,26 @@ func (_ fastpathT) DecMapUint8IntV(v map[uint8]int, checkNil bool, canChange boo } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint8(dd.DecodeUint(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint8Int8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint8Int8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint8]int8) v, changed := fastpathTV.DecMapUint8Int8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -19079,7 +26914,8 @@ func (f fastpathT) DecMapUint8Int8X(vp *map[uint8]int8, checkNil bool, d *Decode func (_ fastpathT) DecMapUint8Int8V(v map[uint8]int8, checkNil bool, canChange bool, d *Decoder) (_ map[uint8]int8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -19089,17 +26925,22 @@ func (_ fastpathT) DecMapUint8Int8V(v map[uint8]int8, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint8]int8, containerLen) - } else { - v = make(map[uint8]int8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 2) + v = make(map[uint8]int8, xlen) changed = true } + + var mk uint8 + var mv int8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint8(dd.DecodeUint(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv @@ -19107,23 +26948,26 @@ func (_ fastpathT) DecMapUint8Int8V(v map[uint8]int8, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint8(dd.DecodeUint(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint8Int16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint8Int16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint8]int16) v, changed := fastpathTV.DecMapUint8Int16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -19144,7 +26988,8 @@ func (f fastpathT) DecMapUint8Int16X(vp *map[uint8]int16, checkNil bool, d *Deco func (_ fastpathT) DecMapUint8Int16V(v map[uint8]int16, checkNil bool, canChange bool, d *Decoder) (_ map[uint8]int16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -19154,17 +26999,22 @@ func (_ fastpathT) DecMapUint8Int16V(v map[uint8]int16, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint8]int16, containerLen) - } else { - v = make(map[uint8]int16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3) + v = make(map[uint8]int16, xlen) changed = true } + + var mk uint8 + var mv int16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint8(dd.DecodeUint(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv @@ -19172,23 +27022,26 @@ func (_ fastpathT) DecMapUint8Int16V(v map[uint8]int16, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint8(dd.DecodeUint(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint8Int32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint8Int32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint8]int32) v, changed := fastpathTV.DecMapUint8Int32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -19209,7 +27062,8 @@ func (f fastpathT) DecMapUint8Int32X(vp *map[uint8]int32, checkNil bool, d *Deco func (_ fastpathT) DecMapUint8Int32V(v map[uint8]int32, checkNil bool, canChange bool, d *Decoder) (_ map[uint8]int32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -19219,17 +27073,22 @@ func (_ fastpathT) DecMapUint8Int32V(v map[uint8]int32, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint8]int32, containerLen) - } else { - v = make(map[uint8]int32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5) + v = make(map[uint8]int32, xlen) changed = true } + + var mk uint8 + var mv int32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint8(dd.DecodeUint(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv @@ -19237,23 +27096,26 @@ func (_ fastpathT) DecMapUint8Int32V(v map[uint8]int32, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint8(dd.DecodeUint(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint8Int64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint8Int64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint8]int64) v, changed := fastpathTV.DecMapUint8Int64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -19274,7 +27136,8 @@ func (f fastpathT) DecMapUint8Int64X(vp *map[uint8]int64, checkNil bool, d *Deco func (_ fastpathT) DecMapUint8Int64V(v map[uint8]int64, checkNil bool, canChange bool, d *Decoder) (_ map[uint8]int64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -19284,17 +27147,22 @@ func (_ fastpathT) DecMapUint8Int64V(v map[uint8]int64, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint8]int64, containerLen) - } else { - v = make(map[uint8]int64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[uint8]int64, xlen) changed = true } + + var mk uint8 + var mv int64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint8(dd.DecodeUint(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeInt(64) if v != nil { v[mk] = mv @@ -19302,23 +27170,26 @@ func (_ fastpathT) DecMapUint8Int64V(v map[uint8]int64, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint8(dd.DecodeUint(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeInt(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint8Float32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint8Float32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint8]float32) v, changed := fastpathTV.DecMapUint8Float32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -19339,7 +27210,8 @@ func (f fastpathT) DecMapUint8Float32X(vp *map[uint8]float32, checkNil bool, d * func (_ fastpathT) DecMapUint8Float32V(v map[uint8]float32, checkNil bool, canChange bool, d *Decoder) (_ map[uint8]float32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -19349,17 +27221,22 @@ func (_ fastpathT) DecMapUint8Float32V(v map[uint8]float32, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint8]float32, containerLen) - } else { - v = make(map[uint8]float32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5) + v = make(map[uint8]float32, xlen) changed = true } + + var mk uint8 + var mv float32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint8(dd.DecodeUint(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv @@ -19367,23 +27244,26 @@ func (_ fastpathT) DecMapUint8Float32V(v map[uint8]float32, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint8(dd.DecodeUint(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint8Float64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint8Float64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint8]float64) v, changed := fastpathTV.DecMapUint8Float64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -19404,7 +27284,8 @@ func (f fastpathT) DecMapUint8Float64X(vp *map[uint8]float64, checkNil bool, d * func (_ fastpathT) DecMapUint8Float64V(v map[uint8]float64, checkNil bool, canChange bool, d *Decoder) (_ map[uint8]float64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -19414,17 +27295,22 @@ func (_ fastpathT) DecMapUint8Float64V(v map[uint8]float64, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint8]float64, containerLen) - } else { - v = make(map[uint8]float64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[uint8]float64, xlen) changed = true } + + var mk uint8 + var mv float64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint8(dd.DecodeUint(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv @@ -19432,23 +27318,26 @@ func (_ fastpathT) DecMapUint8Float64V(v map[uint8]float64, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint8(dd.DecodeUint(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint8BoolR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint8BoolR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint8]bool) v, changed := fastpathTV.DecMapUint8BoolV(*vp, fastpathCheckNilFalse, true, f.d) @@ -19469,7 +27358,8 @@ func (f fastpathT) DecMapUint8BoolX(vp *map[uint8]bool, checkNil bool, d *Decode func (_ fastpathT) DecMapUint8BoolV(v map[uint8]bool, checkNil bool, canChange bool, d *Decoder) (_ map[uint8]bool, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -19479,17 +27369,22 @@ func (_ fastpathT) DecMapUint8BoolV(v map[uint8]bool, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint8]bool, containerLen) - } else { - v = make(map[uint8]bool) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 2) + v = make(map[uint8]bool, xlen) changed = true } + + var mk uint8 + var mv bool if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint8(dd.DecodeUint(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeBool() if v != nil { v[mk] = mv @@ -19497,23 +27392,26 @@ func (_ fastpathT) DecMapUint8BoolV(v map[uint8]bool, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint8(dd.DecodeUint(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint8(dd.DecodeUint(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeBool() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint16IntfR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint16IntfR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint16]interface{}) v, changed := fastpathTV.DecMapUint16IntfV(*vp, fastpathCheckNilFalse, true, f.d) @@ -19534,7 +27432,8 @@ func (f fastpathT) DecMapUint16IntfX(vp *map[uint16]interface{}, checkNil bool, func (_ fastpathT) DecMapUint16IntfV(v map[uint16]interface{}, checkNil bool, canChange bool, d *Decoder) (_ map[uint16]interface{}, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -19544,43 +27443,59 @@ func (_ fastpathT) DecMapUint16IntfV(v map[uint16]interface{}, checkNil bool, ca containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint16]interface{}, containerLen) - } else { - v = make(map[uint16]interface{}) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 18) + v = make(map[uint16]interface{}, xlen) changed = true } + mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + var mk uint16 + var mv interface{} if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint16(dd.DecodeUint(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } d.decode(&mv) - if v != nil { v[mk] = mv } } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil } - mk := uint16(dd.DecodeUint(16)) - dd.ReadMapKVSeparator() - mv := v[mk] d.decode(&mv) - if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint16StringR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint16StringR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint16]string) v, changed := fastpathTV.DecMapUint16StringV(*vp, fastpathCheckNilFalse, true, f.d) @@ -19601,7 +27516,8 @@ func (f fastpathT) DecMapUint16StringX(vp *map[uint16]string, checkNil bool, d * func (_ fastpathT) DecMapUint16StringV(v map[uint16]string, checkNil bool, canChange bool, d *Decoder) (_ map[uint16]string, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -19611,17 +27527,22 @@ func (_ fastpathT) DecMapUint16StringV(v map[uint16]string, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint16]string, containerLen) - } else { - v = make(map[uint16]string) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 18) + v = make(map[uint16]string, xlen) changed = true } + + var mk uint16 + var mv string if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint16(dd.DecodeUint(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeString() if v != nil { v[mk] = mv @@ -19629,23 +27550,26 @@ func (_ fastpathT) DecMapUint16StringV(v map[uint16]string, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint16(dd.DecodeUint(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeString() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint16UintR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint16UintR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint16]uint) v, changed := fastpathTV.DecMapUint16UintV(*vp, fastpathCheckNilFalse, true, f.d) @@ -19666,7 +27590,8 @@ func (f fastpathT) DecMapUint16UintX(vp *map[uint16]uint, checkNil bool, d *Deco func (_ fastpathT) DecMapUint16UintV(v map[uint16]uint, checkNil bool, canChange bool, d *Decoder) (_ map[uint16]uint, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -19676,17 +27601,22 @@ func (_ fastpathT) DecMapUint16UintV(v map[uint16]uint, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint16]uint, containerLen) - } else { - v = make(map[uint16]uint) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[uint16]uint, xlen) changed = true } + + var mk uint16 + var mv uint if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint16(dd.DecodeUint(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv @@ -19694,23 +27624,26 @@ func (_ fastpathT) DecMapUint16UintV(v map[uint16]uint, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint16(dd.DecodeUint(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint16Uint8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint16Uint8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint16]uint8) v, changed := fastpathTV.DecMapUint16Uint8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -19731,7 +27664,8 @@ func (f fastpathT) DecMapUint16Uint8X(vp *map[uint16]uint8, checkNil bool, d *De func (_ fastpathT) DecMapUint16Uint8V(v map[uint16]uint8, checkNil bool, canChange bool, d *Decoder) (_ map[uint16]uint8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -19741,17 +27675,22 @@ func (_ fastpathT) DecMapUint16Uint8V(v map[uint16]uint8, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint16]uint8, containerLen) - } else { - v = make(map[uint16]uint8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3) + v = make(map[uint16]uint8, xlen) changed = true } + + var mk uint16 + var mv uint8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint16(dd.DecodeUint(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv @@ -19759,23 +27698,26 @@ func (_ fastpathT) DecMapUint16Uint8V(v map[uint16]uint8, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint16(dd.DecodeUint(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint16Uint16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint16Uint16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint16]uint16) v, changed := fastpathTV.DecMapUint16Uint16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -19796,7 +27738,8 @@ func (f fastpathT) DecMapUint16Uint16X(vp *map[uint16]uint16, checkNil bool, d * func (_ fastpathT) DecMapUint16Uint16V(v map[uint16]uint16, checkNil bool, canChange bool, d *Decoder) (_ map[uint16]uint16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -19806,17 +27749,22 @@ func (_ fastpathT) DecMapUint16Uint16V(v map[uint16]uint16, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint16]uint16, containerLen) - } else { - v = make(map[uint16]uint16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 4) + v = make(map[uint16]uint16, xlen) changed = true } + + var mk uint16 + var mv uint16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint16(dd.DecodeUint(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv @@ -19824,23 +27772,26 @@ func (_ fastpathT) DecMapUint16Uint16V(v map[uint16]uint16, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint16(dd.DecodeUint(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint16Uint32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint16Uint32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint16]uint32) v, changed := fastpathTV.DecMapUint16Uint32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -19861,7 +27812,8 @@ func (f fastpathT) DecMapUint16Uint32X(vp *map[uint16]uint32, checkNil bool, d * func (_ fastpathT) DecMapUint16Uint32V(v map[uint16]uint32, checkNil bool, canChange bool, d *Decoder) (_ map[uint16]uint32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -19871,17 +27823,22 @@ func (_ fastpathT) DecMapUint16Uint32V(v map[uint16]uint32, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint16]uint32, containerLen) - } else { - v = make(map[uint16]uint32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6) + v = make(map[uint16]uint32, xlen) changed = true } + + var mk uint16 + var mv uint32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint16(dd.DecodeUint(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv @@ -19889,23 +27846,26 @@ func (_ fastpathT) DecMapUint16Uint32V(v map[uint16]uint32, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint16(dd.DecodeUint(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint16Uint64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint16Uint64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint16]uint64) v, changed := fastpathTV.DecMapUint16Uint64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -19926,7 +27886,8 @@ func (f fastpathT) DecMapUint16Uint64X(vp *map[uint16]uint64, checkNil bool, d * func (_ fastpathT) DecMapUint16Uint64V(v map[uint16]uint64, checkNil bool, canChange bool, d *Decoder) (_ map[uint16]uint64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -19936,17 +27897,22 @@ func (_ fastpathT) DecMapUint16Uint64V(v map[uint16]uint64, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint16]uint64, containerLen) - } else { - v = make(map[uint16]uint64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[uint16]uint64, xlen) changed = true } + + var mk uint16 + var mv uint64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint16(dd.DecodeUint(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeUint(64) if v != nil { v[mk] = mv @@ -19954,23 +27920,100 @@ func (_ fastpathT) DecMapUint16Uint64V(v map[uint16]uint64, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint16(dd.DecodeUint(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeUint(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint16IntR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint16UintptrR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uint16]uintptr) + v, changed := fastpathTV.DecMapUint16UintptrV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uint16]uintptr) + fastpathTV.DecMapUint16UintptrV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUint16UintptrX(vp *map[uint16]uintptr, checkNil bool, d *Decoder) { + v, changed := f.DecMapUint16UintptrV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUint16UintptrV(v map[uint16]uintptr, checkNil bool, canChange bool, + d *Decoder) (_ map[uint16]uintptr, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[uint16]uintptr, xlen) + changed = true + } + + var mk uint16 + var mv uintptr + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUint16IntR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint16]int) v, changed := fastpathTV.DecMapUint16IntV(*vp, fastpathCheckNilFalse, true, f.d) @@ -19991,7 +28034,8 @@ func (f fastpathT) DecMapUint16IntX(vp *map[uint16]int, checkNil bool, d *Decode func (_ fastpathT) DecMapUint16IntV(v map[uint16]int, checkNil bool, canChange bool, d *Decoder) (_ map[uint16]int, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -20001,17 +28045,22 @@ func (_ fastpathT) DecMapUint16IntV(v map[uint16]int, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint16]int, containerLen) - } else { - v = make(map[uint16]int) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[uint16]int, xlen) changed = true } + + var mk uint16 + var mv int if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint16(dd.DecodeUint(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv @@ -20019,23 +28068,26 @@ func (_ fastpathT) DecMapUint16IntV(v map[uint16]int, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint16(dd.DecodeUint(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint16Int8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint16Int8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint16]int8) v, changed := fastpathTV.DecMapUint16Int8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -20056,7 +28108,8 @@ func (f fastpathT) DecMapUint16Int8X(vp *map[uint16]int8, checkNil bool, d *Deco func (_ fastpathT) DecMapUint16Int8V(v map[uint16]int8, checkNil bool, canChange bool, d *Decoder) (_ map[uint16]int8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -20066,17 +28119,22 @@ func (_ fastpathT) DecMapUint16Int8V(v map[uint16]int8, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint16]int8, containerLen) - } else { - v = make(map[uint16]int8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3) + v = make(map[uint16]int8, xlen) changed = true } + + var mk uint16 + var mv int8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint16(dd.DecodeUint(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv @@ -20084,23 +28142,26 @@ func (_ fastpathT) DecMapUint16Int8V(v map[uint16]int8, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint16(dd.DecodeUint(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint16Int16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint16Int16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint16]int16) v, changed := fastpathTV.DecMapUint16Int16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -20121,7 +28182,8 @@ func (f fastpathT) DecMapUint16Int16X(vp *map[uint16]int16, checkNil bool, d *De func (_ fastpathT) DecMapUint16Int16V(v map[uint16]int16, checkNil bool, canChange bool, d *Decoder) (_ map[uint16]int16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -20131,17 +28193,22 @@ func (_ fastpathT) DecMapUint16Int16V(v map[uint16]int16, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint16]int16, containerLen) - } else { - v = make(map[uint16]int16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 4) + v = make(map[uint16]int16, xlen) changed = true } + + var mk uint16 + var mv int16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint16(dd.DecodeUint(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv @@ -20149,23 +28216,26 @@ func (_ fastpathT) DecMapUint16Int16V(v map[uint16]int16, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint16(dd.DecodeUint(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint16Int32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint16Int32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint16]int32) v, changed := fastpathTV.DecMapUint16Int32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -20186,7 +28256,8 @@ func (f fastpathT) DecMapUint16Int32X(vp *map[uint16]int32, checkNil bool, d *De func (_ fastpathT) DecMapUint16Int32V(v map[uint16]int32, checkNil bool, canChange bool, d *Decoder) (_ map[uint16]int32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -20196,17 +28267,22 @@ func (_ fastpathT) DecMapUint16Int32V(v map[uint16]int32, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint16]int32, containerLen) - } else { - v = make(map[uint16]int32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6) + v = make(map[uint16]int32, xlen) changed = true } + + var mk uint16 + var mv int32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint16(dd.DecodeUint(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv @@ -20214,23 +28290,26 @@ func (_ fastpathT) DecMapUint16Int32V(v map[uint16]int32, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint16(dd.DecodeUint(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint16Int64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint16Int64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint16]int64) v, changed := fastpathTV.DecMapUint16Int64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -20251,7 +28330,8 @@ func (f fastpathT) DecMapUint16Int64X(vp *map[uint16]int64, checkNil bool, d *De func (_ fastpathT) DecMapUint16Int64V(v map[uint16]int64, checkNil bool, canChange bool, d *Decoder) (_ map[uint16]int64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -20261,17 +28341,22 @@ func (_ fastpathT) DecMapUint16Int64V(v map[uint16]int64, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint16]int64, containerLen) - } else { - v = make(map[uint16]int64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[uint16]int64, xlen) changed = true } + + var mk uint16 + var mv int64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint16(dd.DecodeUint(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeInt(64) if v != nil { v[mk] = mv @@ -20279,23 +28364,26 @@ func (_ fastpathT) DecMapUint16Int64V(v map[uint16]int64, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint16(dd.DecodeUint(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeInt(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint16Float32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint16Float32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint16]float32) v, changed := fastpathTV.DecMapUint16Float32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -20316,7 +28404,8 @@ func (f fastpathT) DecMapUint16Float32X(vp *map[uint16]float32, checkNil bool, d func (_ fastpathT) DecMapUint16Float32V(v map[uint16]float32, checkNil bool, canChange bool, d *Decoder) (_ map[uint16]float32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -20326,17 +28415,22 @@ func (_ fastpathT) DecMapUint16Float32V(v map[uint16]float32, checkNil bool, can containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint16]float32, containerLen) - } else { - v = make(map[uint16]float32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6) + v = make(map[uint16]float32, xlen) changed = true } + + var mk uint16 + var mv float32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint16(dd.DecodeUint(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv @@ -20344,23 +28438,26 @@ func (_ fastpathT) DecMapUint16Float32V(v map[uint16]float32, checkNil bool, can } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint16(dd.DecodeUint(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint16Float64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint16Float64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint16]float64) v, changed := fastpathTV.DecMapUint16Float64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -20381,7 +28478,8 @@ func (f fastpathT) DecMapUint16Float64X(vp *map[uint16]float64, checkNil bool, d func (_ fastpathT) DecMapUint16Float64V(v map[uint16]float64, checkNil bool, canChange bool, d *Decoder) (_ map[uint16]float64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -20391,17 +28489,22 @@ func (_ fastpathT) DecMapUint16Float64V(v map[uint16]float64, checkNil bool, can containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint16]float64, containerLen) - } else { - v = make(map[uint16]float64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[uint16]float64, xlen) changed = true } + + var mk uint16 + var mv float64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint16(dd.DecodeUint(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv @@ -20409,23 +28512,26 @@ func (_ fastpathT) DecMapUint16Float64V(v map[uint16]float64, checkNil bool, can } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint16(dd.DecodeUint(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint16BoolR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint16BoolR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint16]bool) v, changed := fastpathTV.DecMapUint16BoolV(*vp, fastpathCheckNilFalse, true, f.d) @@ -20446,7 +28552,8 @@ func (f fastpathT) DecMapUint16BoolX(vp *map[uint16]bool, checkNil bool, d *Deco func (_ fastpathT) DecMapUint16BoolV(v map[uint16]bool, checkNil bool, canChange bool, d *Decoder) (_ map[uint16]bool, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -20456,17 +28563,22 @@ func (_ fastpathT) DecMapUint16BoolV(v map[uint16]bool, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint16]bool, containerLen) - } else { - v = make(map[uint16]bool) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3) + v = make(map[uint16]bool, xlen) changed = true } + + var mk uint16 + var mv bool if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint16(dd.DecodeUint(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeBool() if v != nil { v[mk] = mv @@ -20474,23 +28586,26 @@ func (_ fastpathT) DecMapUint16BoolV(v map[uint16]bool, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint16(dd.DecodeUint(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint16(dd.DecodeUint(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeBool() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint32IntfR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint32IntfR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint32]interface{}) v, changed := fastpathTV.DecMapUint32IntfV(*vp, fastpathCheckNilFalse, true, f.d) @@ -20511,7 +28626,8 @@ func (f fastpathT) DecMapUint32IntfX(vp *map[uint32]interface{}, checkNil bool, func (_ fastpathT) DecMapUint32IntfV(v map[uint32]interface{}, checkNil bool, canChange bool, d *Decoder) (_ map[uint32]interface{}, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -20521,43 +28637,59 @@ func (_ fastpathT) DecMapUint32IntfV(v map[uint32]interface{}, checkNil bool, ca containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint32]interface{}, containerLen) - } else { - v = make(map[uint32]interface{}) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20) + v = make(map[uint32]interface{}, xlen) changed = true } + mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + var mk uint32 + var mv interface{} if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint32(dd.DecodeUint(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } d.decode(&mv) - if v != nil { v[mk] = mv } } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil } - mk := uint32(dd.DecodeUint(32)) - dd.ReadMapKVSeparator() - mv := v[mk] d.decode(&mv) - if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint32StringR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint32StringR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint32]string) v, changed := fastpathTV.DecMapUint32StringV(*vp, fastpathCheckNilFalse, true, f.d) @@ -20578,7 +28710,8 @@ func (f fastpathT) DecMapUint32StringX(vp *map[uint32]string, checkNil bool, d * func (_ fastpathT) DecMapUint32StringV(v map[uint32]string, checkNil bool, canChange bool, d *Decoder) (_ map[uint32]string, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -20588,17 +28721,22 @@ func (_ fastpathT) DecMapUint32StringV(v map[uint32]string, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint32]string, containerLen) - } else { - v = make(map[uint32]string) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20) + v = make(map[uint32]string, xlen) changed = true } + + var mk uint32 + var mv string if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint32(dd.DecodeUint(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeString() if v != nil { v[mk] = mv @@ -20606,23 +28744,26 @@ func (_ fastpathT) DecMapUint32StringV(v map[uint32]string, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint32(dd.DecodeUint(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeString() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint32UintR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint32UintR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint32]uint) v, changed := fastpathTV.DecMapUint32UintV(*vp, fastpathCheckNilFalse, true, f.d) @@ -20643,7 +28784,8 @@ func (f fastpathT) DecMapUint32UintX(vp *map[uint32]uint, checkNil bool, d *Deco func (_ fastpathT) DecMapUint32UintV(v map[uint32]uint, checkNil bool, canChange bool, d *Decoder) (_ map[uint32]uint, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -20653,17 +28795,22 @@ func (_ fastpathT) DecMapUint32UintV(v map[uint32]uint, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint32]uint, containerLen) - } else { - v = make(map[uint32]uint) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[uint32]uint, xlen) changed = true } + + var mk uint32 + var mv uint if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint32(dd.DecodeUint(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv @@ -20671,23 +28818,26 @@ func (_ fastpathT) DecMapUint32UintV(v map[uint32]uint, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint32(dd.DecodeUint(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint32Uint8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint32Uint8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint32]uint8) v, changed := fastpathTV.DecMapUint32Uint8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -20708,7 +28858,8 @@ func (f fastpathT) DecMapUint32Uint8X(vp *map[uint32]uint8, checkNil bool, d *De func (_ fastpathT) DecMapUint32Uint8V(v map[uint32]uint8, checkNil bool, canChange bool, d *Decoder) (_ map[uint32]uint8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -20718,17 +28869,22 @@ func (_ fastpathT) DecMapUint32Uint8V(v map[uint32]uint8, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint32]uint8, containerLen) - } else { - v = make(map[uint32]uint8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5) + v = make(map[uint32]uint8, xlen) changed = true } + + var mk uint32 + var mv uint8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint32(dd.DecodeUint(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv @@ -20736,23 +28892,26 @@ func (_ fastpathT) DecMapUint32Uint8V(v map[uint32]uint8, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint32(dd.DecodeUint(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint32Uint16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint32Uint16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint32]uint16) v, changed := fastpathTV.DecMapUint32Uint16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -20773,7 +28932,8 @@ func (f fastpathT) DecMapUint32Uint16X(vp *map[uint32]uint16, checkNil bool, d * func (_ fastpathT) DecMapUint32Uint16V(v map[uint32]uint16, checkNil bool, canChange bool, d *Decoder) (_ map[uint32]uint16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -20783,17 +28943,22 @@ func (_ fastpathT) DecMapUint32Uint16V(v map[uint32]uint16, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint32]uint16, containerLen) - } else { - v = make(map[uint32]uint16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6) + v = make(map[uint32]uint16, xlen) changed = true } + + var mk uint32 + var mv uint16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint32(dd.DecodeUint(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv @@ -20801,23 +28966,26 @@ func (_ fastpathT) DecMapUint32Uint16V(v map[uint32]uint16, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint32(dd.DecodeUint(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint32Uint32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint32Uint32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint32]uint32) v, changed := fastpathTV.DecMapUint32Uint32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -20838,7 +29006,8 @@ func (f fastpathT) DecMapUint32Uint32X(vp *map[uint32]uint32, checkNil bool, d * func (_ fastpathT) DecMapUint32Uint32V(v map[uint32]uint32, checkNil bool, canChange bool, d *Decoder) (_ map[uint32]uint32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -20848,17 +29017,22 @@ func (_ fastpathT) DecMapUint32Uint32V(v map[uint32]uint32, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint32]uint32, containerLen) - } else { - v = make(map[uint32]uint32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 8) + v = make(map[uint32]uint32, xlen) changed = true } + + var mk uint32 + var mv uint32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint32(dd.DecodeUint(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv @@ -20866,23 +29040,26 @@ func (_ fastpathT) DecMapUint32Uint32V(v map[uint32]uint32, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint32(dd.DecodeUint(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint32Uint64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint32Uint64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint32]uint64) v, changed := fastpathTV.DecMapUint32Uint64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -20903,7 +29080,8 @@ func (f fastpathT) DecMapUint32Uint64X(vp *map[uint32]uint64, checkNil bool, d * func (_ fastpathT) DecMapUint32Uint64V(v map[uint32]uint64, checkNil bool, canChange bool, d *Decoder) (_ map[uint32]uint64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -20913,17 +29091,22 @@ func (_ fastpathT) DecMapUint32Uint64V(v map[uint32]uint64, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint32]uint64, containerLen) - } else { - v = make(map[uint32]uint64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[uint32]uint64, xlen) changed = true } + + var mk uint32 + var mv uint64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint32(dd.DecodeUint(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeUint(64) if v != nil { v[mk] = mv @@ -20931,23 +29114,100 @@ func (_ fastpathT) DecMapUint32Uint64V(v map[uint32]uint64, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint32(dd.DecodeUint(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeUint(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint32IntR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint32UintptrR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uint32]uintptr) + v, changed := fastpathTV.DecMapUint32UintptrV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uint32]uintptr) + fastpathTV.DecMapUint32UintptrV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUint32UintptrX(vp *map[uint32]uintptr, checkNil bool, d *Decoder) { + v, changed := f.DecMapUint32UintptrV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUint32UintptrV(v map[uint32]uintptr, checkNil bool, canChange bool, + d *Decoder) (_ map[uint32]uintptr, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[uint32]uintptr, xlen) + changed = true + } + + var mk uint32 + var mv uintptr + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUint32IntR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint32]int) v, changed := fastpathTV.DecMapUint32IntV(*vp, fastpathCheckNilFalse, true, f.d) @@ -20968,7 +29228,8 @@ func (f fastpathT) DecMapUint32IntX(vp *map[uint32]int, checkNil bool, d *Decode func (_ fastpathT) DecMapUint32IntV(v map[uint32]int, checkNil bool, canChange bool, d *Decoder) (_ map[uint32]int, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -20978,17 +29239,22 @@ func (_ fastpathT) DecMapUint32IntV(v map[uint32]int, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint32]int, containerLen) - } else { - v = make(map[uint32]int) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[uint32]int, xlen) changed = true } + + var mk uint32 + var mv int if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint32(dd.DecodeUint(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv @@ -20996,23 +29262,26 @@ func (_ fastpathT) DecMapUint32IntV(v map[uint32]int, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint32(dd.DecodeUint(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint32Int8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint32Int8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint32]int8) v, changed := fastpathTV.DecMapUint32Int8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -21033,7 +29302,8 @@ func (f fastpathT) DecMapUint32Int8X(vp *map[uint32]int8, checkNil bool, d *Deco func (_ fastpathT) DecMapUint32Int8V(v map[uint32]int8, checkNil bool, canChange bool, d *Decoder) (_ map[uint32]int8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -21043,17 +29313,22 @@ func (_ fastpathT) DecMapUint32Int8V(v map[uint32]int8, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint32]int8, containerLen) - } else { - v = make(map[uint32]int8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5) + v = make(map[uint32]int8, xlen) changed = true } + + var mk uint32 + var mv int8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint32(dd.DecodeUint(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv @@ -21061,23 +29336,26 @@ func (_ fastpathT) DecMapUint32Int8V(v map[uint32]int8, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint32(dd.DecodeUint(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint32Int16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint32Int16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint32]int16) v, changed := fastpathTV.DecMapUint32Int16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -21098,7 +29376,8 @@ func (f fastpathT) DecMapUint32Int16X(vp *map[uint32]int16, checkNil bool, d *De func (_ fastpathT) DecMapUint32Int16V(v map[uint32]int16, checkNil bool, canChange bool, d *Decoder) (_ map[uint32]int16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -21108,17 +29387,22 @@ func (_ fastpathT) DecMapUint32Int16V(v map[uint32]int16, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint32]int16, containerLen) - } else { - v = make(map[uint32]int16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6) + v = make(map[uint32]int16, xlen) changed = true } + + var mk uint32 + var mv int16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint32(dd.DecodeUint(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv @@ -21126,23 +29410,26 @@ func (_ fastpathT) DecMapUint32Int16V(v map[uint32]int16, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint32(dd.DecodeUint(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint32Int32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint32Int32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint32]int32) v, changed := fastpathTV.DecMapUint32Int32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -21163,7 +29450,8 @@ func (f fastpathT) DecMapUint32Int32X(vp *map[uint32]int32, checkNil bool, d *De func (_ fastpathT) DecMapUint32Int32V(v map[uint32]int32, checkNil bool, canChange bool, d *Decoder) (_ map[uint32]int32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -21173,17 +29461,22 @@ func (_ fastpathT) DecMapUint32Int32V(v map[uint32]int32, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint32]int32, containerLen) - } else { - v = make(map[uint32]int32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 8) + v = make(map[uint32]int32, xlen) changed = true } + + var mk uint32 + var mv int32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint32(dd.DecodeUint(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv @@ -21191,23 +29484,26 @@ func (_ fastpathT) DecMapUint32Int32V(v map[uint32]int32, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint32(dd.DecodeUint(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint32Int64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint32Int64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint32]int64) v, changed := fastpathTV.DecMapUint32Int64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -21228,7 +29524,8 @@ func (f fastpathT) DecMapUint32Int64X(vp *map[uint32]int64, checkNil bool, d *De func (_ fastpathT) DecMapUint32Int64V(v map[uint32]int64, checkNil bool, canChange bool, d *Decoder) (_ map[uint32]int64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -21238,17 +29535,22 @@ func (_ fastpathT) DecMapUint32Int64V(v map[uint32]int64, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint32]int64, containerLen) - } else { - v = make(map[uint32]int64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[uint32]int64, xlen) changed = true } + + var mk uint32 + var mv int64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint32(dd.DecodeUint(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeInt(64) if v != nil { v[mk] = mv @@ -21256,23 +29558,26 @@ func (_ fastpathT) DecMapUint32Int64V(v map[uint32]int64, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint32(dd.DecodeUint(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeInt(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint32Float32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint32Float32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint32]float32) v, changed := fastpathTV.DecMapUint32Float32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -21293,7 +29598,8 @@ func (f fastpathT) DecMapUint32Float32X(vp *map[uint32]float32, checkNil bool, d func (_ fastpathT) DecMapUint32Float32V(v map[uint32]float32, checkNil bool, canChange bool, d *Decoder) (_ map[uint32]float32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -21303,17 +29609,22 @@ func (_ fastpathT) DecMapUint32Float32V(v map[uint32]float32, checkNil bool, can containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint32]float32, containerLen) - } else { - v = make(map[uint32]float32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 8) + v = make(map[uint32]float32, xlen) changed = true } + + var mk uint32 + var mv float32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint32(dd.DecodeUint(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv @@ -21321,23 +29632,26 @@ func (_ fastpathT) DecMapUint32Float32V(v map[uint32]float32, checkNil bool, can } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint32(dd.DecodeUint(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint32Float64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint32Float64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint32]float64) v, changed := fastpathTV.DecMapUint32Float64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -21358,7 +29672,8 @@ func (f fastpathT) DecMapUint32Float64X(vp *map[uint32]float64, checkNil bool, d func (_ fastpathT) DecMapUint32Float64V(v map[uint32]float64, checkNil bool, canChange bool, d *Decoder) (_ map[uint32]float64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -21368,17 +29683,22 @@ func (_ fastpathT) DecMapUint32Float64V(v map[uint32]float64, checkNil bool, can containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint32]float64, containerLen) - } else { - v = make(map[uint32]float64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[uint32]float64, xlen) changed = true } + + var mk uint32 + var mv float64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint32(dd.DecodeUint(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv @@ -21386,23 +29706,26 @@ func (_ fastpathT) DecMapUint32Float64V(v map[uint32]float64, checkNil bool, can } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint32(dd.DecodeUint(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint32BoolR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint32BoolR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint32]bool) v, changed := fastpathTV.DecMapUint32BoolV(*vp, fastpathCheckNilFalse, true, f.d) @@ -21423,7 +29746,8 @@ func (f fastpathT) DecMapUint32BoolX(vp *map[uint32]bool, checkNil bool, d *Deco func (_ fastpathT) DecMapUint32BoolV(v map[uint32]bool, checkNil bool, canChange bool, d *Decoder) (_ map[uint32]bool, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -21433,17 +29757,22 @@ func (_ fastpathT) DecMapUint32BoolV(v map[uint32]bool, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint32]bool, containerLen) - } else { - v = make(map[uint32]bool) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5) + v = make(map[uint32]bool, xlen) changed = true } + + var mk uint32 + var mv bool if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := uint32(dd.DecodeUint(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeBool() if v != nil { v[mk] = mv @@ -21451,23 +29780,26 @@ func (_ fastpathT) DecMapUint32BoolV(v map[uint32]bool, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uint32(dd.DecodeUint(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := uint32(dd.DecodeUint(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeBool() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint64IntfR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint64IntfR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint64]interface{}) v, changed := fastpathTV.DecMapUint64IntfV(*vp, fastpathCheckNilFalse, true, f.d) @@ -21488,7 +29820,8 @@ func (f fastpathT) DecMapUint64IntfX(vp *map[uint64]interface{}, checkNil bool, func (_ fastpathT) DecMapUint64IntfV(v map[uint64]interface{}, checkNil bool, canChange bool, d *Decoder) (_ map[uint64]interface{}, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -21498,43 +29831,59 @@ func (_ fastpathT) DecMapUint64IntfV(v map[uint64]interface{}, checkNil bool, ca containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint64]interface{}, containerLen) - } else { - v = make(map[uint64]interface{}) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[uint64]interface{}, xlen) changed = true } + mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + var mk uint64 + var mv interface{} if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeUint(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } d.decode(&mv) - if v != nil { v[mk] = mv } } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil } - mk := dd.DecodeUint(64) - dd.ReadMapKVSeparator() - mv := v[mk] d.decode(&mv) - if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint64StringR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint64StringR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint64]string) v, changed := fastpathTV.DecMapUint64StringV(*vp, fastpathCheckNilFalse, true, f.d) @@ -21555,7 +29904,8 @@ func (f fastpathT) DecMapUint64StringX(vp *map[uint64]string, checkNil bool, d * func (_ fastpathT) DecMapUint64StringV(v map[uint64]string, checkNil bool, canChange bool, d *Decoder) (_ map[uint64]string, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -21565,17 +29915,22 @@ func (_ fastpathT) DecMapUint64StringV(v map[uint64]string, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint64]string, containerLen) - } else { - v = make(map[uint64]string) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[uint64]string, xlen) changed = true } + + var mk uint64 + var mv string if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeUint(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeString() if v != nil { v[mk] = mv @@ -21583,23 +29938,26 @@ func (_ fastpathT) DecMapUint64StringV(v map[uint64]string, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeUint(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeString() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint64UintR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint64UintR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint64]uint) v, changed := fastpathTV.DecMapUint64UintV(*vp, fastpathCheckNilFalse, true, f.d) @@ -21620,7 +29978,8 @@ func (f fastpathT) DecMapUint64UintX(vp *map[uint64]uint, checkNil bool, d *Deco func (_ fastpathT) DecMapUint64UintV(v map[uint64]uint, checkNil bool, canChange bool, d *Decoder) (_ map[uint64]uint, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -21630,17 +29989,22 @@ func (_ fastpathT) DecMapUint64UintV(v map[uint64]uint, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint64]uint, containerLen) - } else { - v = make(map[uint64]uint) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[uint64]uint, xlen) changed = true } + + var mk uint64 + var mv uint if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeUint(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv @@ -21648,23 +30012,26 @@ func (_ fastpathT) DecMapUint64UintV(v map[uint64]uint, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeUint(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint64Uint8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint64Uint8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint64]uint8) v, changed := fastpathTV.DecMapUint64Uint8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -21685,7 +30052,8 @@ func (f fastpathT) DecMapUint64Uint8X(vp *map[uint64]uint8, checkNil bool, d *De func (_ fastpathT) DecMapUint64Uint8V(v map[uint64]uint8, checkNil bool, canChange bool, d *Decoder) (_ map[uint64]uint8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -21695,17 +30063,22 @@ func (_ fastpathT) DecMapUint64Uint8V(v map[uint64]uint8, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint64]uint8, containerLen) - } else { - v = make(map[uint64]uint8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[uint64]uint8, xlen) changed = true } + + var mk uint64 + var mv uint8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeUint(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv @@ -21713,23 +30086,26 @@ func (_ fastpathT) DecMapUint64Uint8V(v map[uint64]uint8, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeUint(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint64Uint16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint64Uint16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint64]uint16) v, changed := fastpathTV.DecMapUint64Uint16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -21750,7 +30126,8 @@ func (f fastpathT) DecMapUint64Uint16X(vp *map[uint64]uint16, checkNil bool, d * func (_ fastpathT) DecMapUint64Uint16V(v map[uint64]uint16, checkNil bool, canChange bool, d *Decoder) (_ map[uint64]uint16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -21760,17 +30137,22 @@ func (_ fastpathT) DecMapUint64Uint16V(v map[uint64]uint16, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint64]uint16, containerLen) - } else { - v = make(map[uint64]uint16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[uint64]uint16, xlen) changed = true } + + var mk uint64 + var mv uint16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeUint(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv @@ -21778,23 +30160,26 @@ func (_ fastpathT) DecMapUint64Uint16V(v map[uint64]uint16, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeUint(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint64Uint32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint64Uint32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint64]uint32) v, changed := fastpathTV.DecMapUint64Uint32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -21815,7 +30200,8 @@ func (f fastpathT) DecMapUint64Uint32X(vp *map[uint64]uint32, checkNil bool, d * func (_ fastpathT) DecMapUint64Uint32V(v map[uint64]uint32, checkNil bool, canChange bool, d *Decoder) (_ map[uint64]uint32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -21825,17 +30211,22 @@ func (_ fastpathT) DecMapUint64Uint32V(v map[uint64]uint32, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint64]uint32, containerLen) - } else { - v = make(map[uint64]uint32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[uint64]uint32, xlen) changed = true } + + var mk uint64 + var mv uint32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeUint(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv @@ -21843,23 +30234,26 @@ func (_ fastpathT) DecMapUint64Uint32V(v map[uint64]uint32, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeUint(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint64Uint64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint64Uint64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint64]uint64) v, changed := fastpathTV.DecMapUint64Uint64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -21880,7 +30274,8 @@ func (f fastpathT) DecMapUint64Uint64X(vp *map[uint64]uint64, checkNil bool, d * func (_ fastpathT) DecMapUint64Uint64V(v map[uint64]uint64, checkNil bool, canChange bool, d *Decoder) (_ map[uint64]uint64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -21890,17 +30285,22 @@ func (_ fastpathT) DecMapUint64Uint64V(v map[uint64]uint64, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint64]uint64, containerLen) - } else { - v = make(map[uint64]uint64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[uint64]uint64, xlen) changed = true } + + var mk uint64 + var mv uint64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeUint(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeUint(64) if v != nil { v[mk] = mv @@ -21908,23 +30308,100 @@ func (_ fastpathT) DecMapUint64Uint64V(v map[uint64]uint64, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeUint(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeUint(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint64IntR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint64UintptrR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uint64]uintptr) + v, changed := fastpathTV.DecMapUint64UintptrV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uint64]uintptr) + fastpathTV.DecMapUint64UintptrV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUint64UintptrX(vp *map[uint64]uintptr, checkNil bool, d *Decoder) { + v, changed := f.DecMapUint64UintptrV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUint64UintptrV(v map[uint64]uintptr, checkNil bool, canChange bool, + d *Decoder) (_ map[uint64]uintptr, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[uint64]uintptr, xlen) + changed = true + } + + var mk uint64 + var mv uintptr + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUint64IntR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint64]int) v, changed := fastpathTV.DecMapUint64IntV(*vp, fastpathCheckNilFalse, true, f.d) @@ -21945,7 +30422,8 @@ func (f fastpathT) DecMapUint64IntX(vp *map[uint64]int, checkNil bool, d *Decode func (_ fastpathT) DecMapUint64IntV(v map[uint64]int, checkNil bool, canChange bool, d *Decoder) (_ map[uint64]int, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -21955,17 +30433,22 @@ func (_ fastpathT) DecMapUint64IntV(v map[uint64]int, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint64]int, containerLen) - } else { - v = make(map[uint64]int) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[uint64]int, xlen) changed = true } + + var mk uint64 + var mv int if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeUint(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv @@ -21973,23 +30456,26 @@ func (_ fastpathT) DecMapUint64IntV(v map[uint64]int, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeUint(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint64Int8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint64Int8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint64]int8) v, changed := fastpathTV.DecMapUint64Int8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -22010,7 +30496,8 @@ func (f fastpathT) DecMapUint64Int8X(vp *map[uint64]int8, checkNil bool, d *Deco func (_ fastpathT) DecMapUint64Int8V(v map[uint64]int8, checkNil bool, canChange bool, d *Decoder) (_ map[uint64]int8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -22020,17 +30507,22 @@ func (_ fastpathT) DecMapUint64Int8V(v map[uint64]int8, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint64]int8, containerLen) - } else { - v = make(map[uint64]int8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[uint64]int8, xlen) changed = true } + + var mk uint64 + var mv int8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeUint(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv @@ -22038,23 +30530,26 @@ func (_ fastpathT) DecMapUint64Int8V(v map[uint64]int8, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeUint(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint64Int16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint64Int16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint64]int16) v, changed := fastpathTV.DecMapUint64Int16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -22075,7 +30570,8 @@ func (f fastpathT) DecMapUint64Int16X(vp *map[uint64]int16, checkNil bool, d *De func (_ fastpathT) DecMapUint64Int16V(v map[uint64]int16, checkNil bool, canChange bool, d *Decoder) (_ map[uint64]int16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -22085,17 +30581,22 @@ func (_ fastpathT) DecMapUint64Int16V(v map[uint64]int16, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint64]int16, containerLen) - } else { - v = make(map[uint64]int16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[uint64]int16, xlen) changed = true } + + var mk uint64 + var mv int16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeUint(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv @@ -22103,23 +30604,26 @@ func (_ fastpathT) DecMapUint64Int16V(v map[uint64]int16, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeUint(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint64Int32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint64Int32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint64]int32) v, changed := fastpathTV.DecMapUint64Int32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -22140,7 +30644,8 @@ func (f fastpathT) DecMapUint64Int32X(vp *map[uint64]int32, checkNil bool, d *De func (_ fastpathT) DecMapUint64Int32V(v map[uint64]int32, checkNil bool, canChange bool, d *Decoder) (_ map[uint64]int32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -22150,17 +30655,22 @@ func (_ fastpathT) DecMapUint64Int32V(v map[uint64]int32, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint64]int32, containerLen) - } else { - v = make(map[uint64]int32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[uint64]int32, xlen) changed = true } + + var mk uint64 + var mv int32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeUint(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv @@ -22168,23 +30678,26 @@ func (_ fastpathT) DecMapUint64Int32V(v map[uint64]int32, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeUint(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint64Int64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint64Int64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint64]int64) v, changed := fastpathTV.DecMapUint64Int64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -22205,7 +30718,8 @@ func (f fastpathT) DecMapUint64Int64X(vp *map[uint64]int64, checkNil bool, d *De func (_ fastpathT) DecMapUint64Int64V(v map[uint64]int64, checkNil bool, canChange bool, d *Decoder) (_ map[uint64]int64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -22215,17 +30729,22 @@ func (_ fastpathT) DecMapUint64Int64V(v map[uint64]int64, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint64]int64, containerLen) - } else { - v = make(map[uint64]int64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[uint64]int64, xlen) changed = true } + + var mk uint64 + var mv int64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeUint(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeInt(64) if v != nil { v[mk] = mv @@ -22233,23 +30752,26 @@ func (_ fastpathT) DecMapUint64Int64V(v map[uint64]int64, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeUint(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeInt(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint64Float32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint64Float32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint64]float32) v, changed := fastpathTV.DecMapUint64Float32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -22270,7 +30792,8 @@ func (f fastpathT) DecMapUint64Float32X(vp *map[uint64]float32, checkNil bool, d func (_ fastpathT) DecMapUint64Float32V(v map[uint64]float32, checkNil bool, canChange bool, d *Decoder) (_ map[uint64]float32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -22280,17 +30803,22 @@ func (_ fastpathT) DecMapUint64Float32V(v map[uint64]float32, checkNil bool, can containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint64]float32, containerLen) - } else { - v = make(map[uint64]float32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[uint64]float32, xlen) changed = true } + + var mk uint64 + var mv float32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeUint(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv @@ -22298,23 +30826,26 @@ func (_ fastpathT) DecMapUint64Float32V(v map[uint64]float32, checkNil bool, can } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeUint(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint64Float64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint64Float64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint64]float64) v, changed := fastpathTV.DecMapUint64Float64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -22335,7 +30866,8 @@ func (f fastpathT) DecMapUint64Float64X(vp *map[uint64]float64, checkNil bool, d func (_ fastpathT) DecMapUint64Float64V(v map[uint64]float64, checkNil bool, canChange bool, d *Decoder) (_ map[uint64]float64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -22345,17 +30877,22 @@ func (_ fastpathT) DecMapUint64Float64V(v map[uint64]float64, checkNil bool, can containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint64]float64, containerLen) - } else { - v = make(map[uint64]float64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[uint64]float64, xlen) changed = true } + + var mk uint64 + var mv float64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeUint(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv @@ -22363,23 +30900,26 @@ func (_ fastpathT) DecMapUint64Float64V(v map[uint64]float64, checkNil bool, can } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeUint(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapUint64BoolR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUint64BoolR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[uint64]bool) v, changed := fastpathTV.DecMapUint64BoolV(*vp, fastpathCheckNilFalse, true, f.d) @@ -22400,7 +30940,8 @@ func (f fastpathT) DecMapUint64BoolX(vp *map[uint64]bool, checkNil bool, d *Deco func (_ fastpathT) DecMapUint64BoolV(v map[uint64]bool, checkNil bool, canChange bool, d *Decoder) (_ map[uint64]bool, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -22410,17 +30951,22 @@ func (_ fastpathT) DecMapUint64BoolV(v map[uint64]bool, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[uint64]bool, containerLen) - } else { - v = make(map[uint64]bool) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[uint64]bool, xlen) changed = true } + + var mk uint64 + var mv bool if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeUint(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeBool() if v != nil { v[mk] = mv @@ -22428,23 +30974,1220 @@ func (_ fastpathT) DecMapUint64BoolV(v map[uint64]bool, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeUint(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeUint(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeBool() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntIntfR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapUintptrIntfR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uintptr]interface{}) + v, changed := fastpathTV.DecMapUintptrIntfV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uintptr]interface{}) + fastpathTV.DecMapUintptrIntfV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUintptrIntfX(vp *map[uintptr]interface{}, checkNil bool, d *Decoder) { + v, changed := f.DecMapUintptrIntfV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUintptrIntfV(v map[uintptr]interface{}, checkNil bool, canChange bool, + d *Decoder) (_ map[uintptr]interface{}, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[uintptr]interface{}, xlen) + changed = true + } + mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + var mk uintptr + var mv interface{} + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } + d.decode(&mv) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } + d.decode(&mv) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUintptrStringR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uintptr]string) + v, changed := fastpathTV.DecMapUintptrStringV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uintptr]string) + fastpathTV.DecMapUintptrStringV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUintptrStringX(vp *map[uintptr]string, checkNil bool, d *Decoder) { + v, changed := f.DecMapUintptrStringV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUintptrStringV(v map[uintptr]string, checkNil bool, canChange bool, + d *Decoder) (_ map[uintptr]string, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[uintptr]string, xlen) + changed = true + } + + var mk uintptr + var mv string + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = dd.DecodeString() + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = dd.DecodeString() + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUintptrUintR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uintptr]uint) + v, changed := fastpathTV.DecMapUintptrUintV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uintptr]uint) + fastpathTV.DecMapUintptrUintV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUintptrUintX(vp *map[uintptr]uint, checkNil bool, d *Decoder) { + v, changed := f.DecMapUintptrUintV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUintptrUintV(v map[uintptr]uint, checkNil bool, canChange bool, + d *Decoder) (_ map[uintptr]uint, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[uintptr]uint, xlen) + changed = true + } + + var mk uintptr + var mv uint + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uint(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uint(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUintptrUint8R(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uintptr]uint8) + v, changed := fastpathTV.DecMapUintptrUint8V(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uintptr]uint8) + fastpathTV.DecMapUintptrUint8V(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUintptrUint8X(vp *map[uintptr]uint8, checkNil bool, d *Decoder) { + v, changed := f.DecMapUintptrUint8V(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUintptrUint8V(v map[uintptr]uint8, checkNil bool, canChange bool, + d *Decoder) (_ map[uintptr]uint8, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[uintptr]uint8, xlen) + changed = true + } + + var mk uintptr + var mv uint8 + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uint8(dd.DecodeUint(8)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uint8(dd.DecodeUint(8)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUintptrUint16R(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uintptr]uint16) + v, changed := fastpathTV.DecMapUintptrUint16V(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uintptr]uint16) + fastpathTV.DecMapUintptrUint16V(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUintptrUint16X(vp *map[uintptr]uint16, checkNil bool, d *Decoder) { + v, changed := f.DecMapUintptrUint16V(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUintptrUint16V(v map[uintptr]uint16, checkNil bool, canChange bool, + d *Decoder) (_ map[uintptr]uint16, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[uintptr]uint16, xlen) + changed = true + } + + var mk uintptr + var mv uint16 + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uint16(dd.DecodeUint(16)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uint16(dd.DecodeUint(16)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUintptrUint32R(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uintptr]uint32) + v, changed := fastpathTV.DecMapUintptrUint32V(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uintptr]uint32) + fastpathTV.DecMapUintptrUint32V(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUintptrUint32X(vp *map[uintptr]uint32, checkNil bool, d *Decoder) { + v, changed := f.DecMapUintptrUint32V(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUintptrUint32V(v map[uintptr]uint32, checkNil bool, canChange bool, + d *Decoder) (_ map[uintptr]uint32, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[uintptr]uint32, xlen) + changed = true + } + + var mk uintptr + var mv uint32 + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uint32(dd.DecodeUint(32)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uint32(dd.DecodeUint(32)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUintptrUint64R(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uintptr]uint64) + v, changed := fastpathTV.DecMapUintptrUint64V(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uintptr]uint64) + fastpathTV.DecMapUintptrUint64V(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUintptrUint64X(vp *map[uintptr]uint64, checkNil bool, d *Decoder) { + v, changed := f.DecMapUintptrUint64V(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUintptrUint64V(v map[uintptr]uint64, checkNil bool, canChange bool, + d *Decoder) (_ map[uintptr]uint64, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[uintptr]uint64, xlen) + changed = true + } + + var mk uintptr + var mv uint64 + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = dd.DecodeUint(64) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = dd.DecodeUint(64) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUintptrUintptrR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uintptr]uintptr) + v, changed := fastpathTV.DecMapUintptrUintptrV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uintptr]uintptr) + fastpathTV.DecMapUintptrUintptrV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUintptrUintptrX(vp *map[uintptr]uintptr, checkNil bool, d *Decoder) { + v, changed := f.DecMapUintptrUintptrV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUintptrUintptrV(v map[uintptr]uintptr, checkNil bool, canChange bool, + d *Decoder) (_ map[uintptr]uintptr, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[uintptr]uintptr, xlen) + changed = true + } + + var mk uintptr + var mv uintptr + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUintptrIntR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uintptr]int) + v, changed := fastpathTV.DecMapUintptrIntV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uintptr]int) + fastpathTV.DecMapUintptrIntV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUintptrIntX(vp *map[uintptr]int, checkNil bool, d *Decoder) { + v, changed := f.DecMapUintptrIntV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUintptrIntV(v map[uintptr]int, checkNil bool, canChange bool, + d *Decoder) (_ map[uintptr]int, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[uintptr]int, xlen) + changed = true + } + + var mk uintptr + var mv int + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = int(dd.DecodeInt(intBitsize)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = int(dd.DecodeInt(intBitsize)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUintptrInt8R(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uintptr]int8) + v, changed := fastpathTV.DecMapUintptrInt8V(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uintptr]int8) + fastpathTV.DecMapUintptrInt8V(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUintptrInt8X(vp *map[uintptr]int8, checkNil bool, d *Decoder) { + v, changed := f.DecMapUintptrInt8V(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUintptrInt8V(v map[uintptr]int8, checkNil bool, canChange bool, + d *Decoder) (_ map[uintptr]int8, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[uintptr]int8, xlen) + changed = true + } + + var mk uintptr + var mv int8 + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = int8(dd.DecodeInt(8)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = int8(dd.DecodeInt(8)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUintptrInt16R(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uintptr]int16) + v, changed := fastpathTV.DecMapUintptrInt16V(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uintptr]int16) + fastpathTV.DecMapUintptrInt16V(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUintptrInt16X(vp *map[uintptr]int16, checkNil bool, d *Decoder) { + v, changed := f.DecMapUintptrInt16V(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUintptrInt16V(v map[uintptr]int16, checkNil bool, canChange bool, + d *Decoder) (_ map[uintptr]int16, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[uintptr]int16, xlen) + changed = true + } + + var mk uintptr + var mv int16 + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = int16(dd.DecodeInt(16)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = int16(dd.DecodeInt(16)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUintptrInt32R(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uintptr]int32) + v, changed := fastpathTV.DecMapUintptrInt32V(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uintptr]int32) + fastpathTV.DecMapUintptrInt32V(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUintptrInt32X(vp *map[uintptr]int32, checkNil bool, d *Decoder) { + v, changed := f.DecMapUintptrInt32V(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUintptrInt32V(v map[uintptr]int32, checkNil bool, canChange bool, + d *Decoder) (_ map[uintptr]int32, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[uintptr]int32, xlen) + changed = true + } + + var mk uintptr + var mv int32 + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = int32(dd.DecodeInt(32)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = int32(dd.DecodeInt(32)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUintptrInt64R(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uintptr]int64) + v, changed := fastpathTV.DecMapUintptrInt64V(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uintptr]int64) + fastpathTV.DecMapUintptrInt64V(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUintptrInt64X(vp *map[uintptr]int64, checkNil bool, d *Decoder) { + v, changed := f.DecMapUintptrInt64V(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUintptrInt64V(v map[uintptr]int64, checkNil bool, canChange bool, + d *Decoder) (_ map[uintptr]int64, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[uintptr]int64, xlen) + changed = true + } + + var mk uintptr + var mv int64 + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = dd.DecodeInt(64) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = dd.DecodeInt(64) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUintptrFloat32R(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uintptr]float32) + v, changed := fastpathTV.DecMapUintptrFloat32V(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uintptr]float32) + fastpathTV.DecMapUintptrFloat32V(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUintptrFloat32X(vp *map[uintptr]float32, checkNil bool, d *Decoder) { + v, changed := f.DecMapUintptrFloat32V(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUintptrFloat32V(v map[uintptr]float32, checkNil bool, canChange bool, + d *Decoder) (_ map[uintptr]float32, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[uintptr]float32, xlen) + changed = true + } + + var mk uintptr + var mv float32 + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = float32(dd.DecodeFloat(true)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = float32(dd.DecodeFloat(true)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUintptrFloat64R(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uintptr]float64) + v, changed := fastpathTV.DecMapUintptrFloat64V(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uintptr]float64) + fastpathTV.DecMapUintptrFloat64V(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUintptrFloat64X(vp *map[uintptr]float64, checkNil bool, d *Decoder) { + v, changed := f.DecMapUintptrFloat64V(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUintptrFloat64V(v map[uintptr]float64, checkNil bool, canChange bool, + d *Decoder) (_ map[uintptr]float64, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[uintptr]float64, xlen) + changed = true + } + + var mk uintptr + var mv float64 + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = dd.DecodeFloat(false) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = dd.DecodeFloat(false) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapUintptrBoolR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[uintptr]bool) + v, changed := fastpathTV.DecMapUintptrBoolV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[uintptr]bool) + fastpathTV.DecMapUintptrBoolV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapUintptrBoolX(vp *map[uintptr]bool, checkNil bool, d *Decoder) { + v, changed := f.DecMapUintptrBoolV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapUintptrBoolV(v map[uintptr]bool, checkNil bool, canChange bool, + d *Decoder) (_ map[uintptr]bool, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[uintptr]bool, xlen) + changed = true + } + + var mk uintptr + var mv bool + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = dd.DecodeBool() + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = uintptr(dd.DecodeUint(uintBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = dd.DecodeBool() + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapIntIntfR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int]interface{}) v, changed := fastpathTV.DecMapIntIntfV(*vp, fastpathCheckNilFalse, true, f.d) @@ -22465,7 +32208,8 @@ func (f fastpathT) DecMapIntIntfX(vp *map[int]interface{}, checkNil bool, d *Dec func (_ fastpathT) DecMapIntIntfV(v map[int]interface{}, checkNil bool, canChange bool, d *Decoder) (_ map[int]interface{}, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -22475,43 +32219,59 @@ func (_ fastpathT) DecMapIntIntfV(v map[int]interface{}, checkNil bool, canChang containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int]interface{}, containerLen) - } else { - v = make(map[int]interface{}) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[int]interface{}, xlen) changed = true } + mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + var mk int + var mv interface{} if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int(dd.DecodeInt(intBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } d.decode(&mv) - if v != nil { v[mk] = mv } } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil } - mk := int(dd.DecodeInt(intBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] d.decode(&mv) - if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntStringR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntStringR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int]string) v, changed := fastpathTV.DecMapIntStringV(*vp, fastpathCheckNilFalse, true, f.d) @@ -22532,7 +32292,8 @@ func (f fastpathT) DecMapIntStringX(vp *map[int]string, checkNil bool, d *Decode func (_ fastpathT) DecMapIntStringV(v map[int]string, checkNil bool, canChange bool, d *Decoder) (_ map[int]string, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -22542,17 +32303,22 @@ func (_ fastpathT) DecMapIntStringV(v map[int]string, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int]string, containerLen) - } else { - v = make(map[int]string) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[int]string, xlen) changed = true } + + var mk int + var mv string if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int(dd.DecodeInt(intBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeString() if v != nil { v[mk] = mv @@ -22560,23 +32326,26 @@ func (_ fastpathT) DecMapIntStringV(v map[int]string, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int(dd.DecodeInt(intBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeString() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntUintR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntUintR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int]uint) v, changed := fastpathTV.DecMapIntUintV(*vp, fastpathCheckNilFalse, true, f.d) @@ -22597,7 +32366,8 @@ func (f fastpathT) DecMapIntUintX(vp *map[int]uint, checkNil bool, d *Decoder) { func (_ fastpathT) DecMapIntUintV(v map[int]uint, checkNil bool, canChange bool, d *Decoder) (_ map[int]uint, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -22607,17 +32377,22 @@ func (_ fastpathT) DecMapIntUintV(v map[int]uint, checkNil bool, canChange bool, containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int]uint, containerLen) - } else { - v = make(map[int]uint) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[int]uint, xlen) changed = true } + + var mk int + var mv uint if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int(dd.DecodeInt(intBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv @@ -22625,23 +32400,26 @@ func (_ fastpathT) DecMapIntUintV(v map[int]uint, checkNil bool, canChange bool, } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int(dd.DecodeInt(intBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntUint8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntUint8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int]uint8) v, changed := fastpathTV.DecMapIntUint8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -22662,7 +32440,8 @@ func (f fastpathT) DecMapIntUint8X(vp *map[int]uint8, checkNil bool, d *Decoder) func (_ fastpathT) DecMapIntUint8V(v map[int]uint8, checkNil bool, canChange bool, d *Decoder) (_ map[int]uint8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -22672,17 +32451,22 @@ func (_ fastpathT) DecMapIntUint8V(v map[int]uint8, checkNil bool, canChange boo containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int]uint8, containerLen) - } else { - v = make(map[int]uint8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[int]uint8, xlen) changed = true } + + var mk int + var mv uint8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int(dd.DecodeInt(intBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv @@ -22690,23 +32474,26 @@ func (_ fastpathT) DecMapIntUint8V(v map[int]uint8, checkNil bool, canChange boo } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int(dd.DecodeInt(intBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntUint16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntUint16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int]uint16) v, changed := fastpathTV.DecMapIntUint16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -22727,7 +32514,8 @@ func (f fastpathT) DecMapIntUint16X(vp *map[int]uint16, checkNil bool, d *Decode func (_ fastpathT) DecMapIntUint16V(v map[int]uint16, checkNil bool, canChange bool, d *Decoder) (_ map[int]uint16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -22737,17 +32525,22 @@ func (_ fastpathT) DecMapIntUint16V(v map[int]uint16, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int]uint16, containerLen) - } else { - v = make(map[int]uint16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[int]uint16, xlen) changed = true } + + var mk int + var mv uint16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int(dd.DecodeInt(intBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv @@ -22755,23 +32548,26 @@ func (_ fastpathT) DecMapIntUint16V(v map[int]uint16, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int(dd.DecodeInt(intBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntUint32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntUint32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int]uint32) v, changed := fastpathTV.DecMapIntUint32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -22792,7 +32588,8 @@ func (f fastpathT) DecMapIntUint32X(vp *map[int]uint32, checkNil bool, d *Decode func (_ fastpathT) DecMapIntUint32V(v map[int]uint32, checkNil bool, canChange bool, d *Decoder) (_ map[int]uint32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -22802,17 +32599,22 @@ func (_ fastpathT) DecMapIntUint32V(v map[int]uint32, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int]uint32, containerLen) - } else { - v = make(map[int]uint32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[int]uint32, xlen) changed = true } + + var mk int + var mv uint32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int(dd.DecodeInt(intBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv @@ -22820,23 +32622,26 @@ func (_ fastpathT) DecMapIntUint32V(v map[int]uint32, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int(dd.DecodeInt(intBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntUint64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntUint64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int]uint64) v, changed := fastpathTV.DecMapIntUint64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -22857,7 +32662,8 @@ func (f fastpathT) DecMapIntUint64X(vp *map[int]uint64, checkNil bool, d *Decode func (_ fastpathT) DecMapIntUint64V(v map[int]uint64, checkNil bool, canChange bool, d *Decoder) (_ map[int]uint64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -22867,17 +32673,22 @@ func (_ fastpathT) DecMapIntUint64V(v map[int]uint64, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int]uint64, containerLen) - } else { - v = make(map[int]uint64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[int]uint64, xlen) changed = true } + + var mk int + var mv uint64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int(dd.DecodeInt(intBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeUint(64) if v != nil { v[mk] = mv @@ -22885,23 +32696,100 @@ func (_ fastpathT) DecMapIntUint64V(v map[int]uint64, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int(dd.DecodeInt(intBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeUint(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntIntR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntUintptrR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[int]uintptr) + v, changed := fastpathTV.DecMapIntUintptrV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[int]uintptr) + fastpathTV.DecMapIntUintptrV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapIntUintptrX(vp *map[int]uintptr, checkNil bool, d *Decoder) { + v, changed := f.DecMapIntUintptrV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapIntUintptrV(v map[int]uintptr, checkNil bool, canChange bool, + d *Decoder) (_ map[int]uintptr, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[int]uintptr, xlen) + changed = true + } + + var mk int + var mv uintptr + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapIntIntR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int]int) v, changed := fastpathTV.DecMapIntIntV(*vp, fastpathCheckNilFalse, true, f.d) @@ -22922,7 +32810,8 @@ func (f fastpathT) DecMapIntIntX(vp *map[int]int, checkNil bool, d *Decoder) { func (_ fastpathT) DecMapIntIntV(v map[int]int, checkNil bool, canChange bool, d *Decoder) (_ map[int]int, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -22932,17 +32821,22 @@ func (_ fastpathT) DecMapIntIntV(v map[int]int, checkNil bool, canChange bool, containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int]int, containerLen) - } else { - v = make(map[int]int) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[int]int, xlen) changed = true } + + var mk int + var mv int if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int(dd.DecodeInt(intBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv @@ -22950,23 +32844,26 @@ func (_ fastpathT) DecMapIntIntV(v map[int]int, checkNil bool, canChange bool, } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int(dd.DecodeInt(intBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntInt8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntInt8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int]int8) v, changed := fastpathTV.DecMapIntInt8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -22987,7 +32884,8 @@ func (f fastpathT) DecMapIntInt8X(vp *map[int]int8, checkNil bool, d *Decoder) { func (_ fastpathT) DecMapIntInt8V(v map[int]int8, checkNil bool, canChange bool, d *Decoder) (_ map[int]int8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -22997,17 +32895,22 @@ func (_ fastpathT) DecMapIntInt8V(v map[int]int8, checkNil bool, canChange bool, containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int]int8, containerLen) - } else { - v = make(map[int]int8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[int]int8, xlen) changed = true } + + var mk int + var mv int8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int(dd.DecodeInt(intBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv @@ -23015,23 +32918,26 @@ func (_ fastpathT) DecMapIntInt8V(v map[int]int8, checkNil bool, canChange bool, } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int(dd.DecodeInt(intBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntInt16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntInt16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int]int16) v, changed := fastpathTV.DecMapIntInt16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -23052,7 +32958,8 @@ func (f fastpathT) DecMapIntInt16X(vp *map[int]int16, checkNil bool, d *Decoder) func (_ fastpathT) DecMapIntInt16V(v map[int]int16, checkNil bool, canChange bool, d *Decoder) (_ map[int]int16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -23062,17 +32969,22 @@ func (_ fastpathT) DecMapIntInt16V(v map[int]int16, checkNil bool, canChange boo containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int]int16, containerLen) - } else { - v = make(map[int]int16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[int]int16, xlen) changed = true } + + var mk int + var mv int16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int(dd.DecodeInt(intBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv @@ -23080,23 +32992,26 @@ func (_ fastpathT) DecMapIntInt16V(v map[int]int16, checkNil bool, canChange boo } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int(dd.DecodeInt(intBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntInt32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntInt32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int]int32) v, changed := fastpathTV.DecMapIntInt32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -23117,7 +33032,8 @@ func (f fastpathT) DecMapIntInt32X(vp *map[int]int32, checkNil bool, d *Decoder) func (_ fastpathT) DecMapIntInt32V(v map[int]int32, checkNil bool, canChange bool, d *Decoder) (_ map[int]int32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -23127,17 +33043,22 @@ func (_ fastpathT) DecMapIntInt32V(v map[int]int32, checkNil bool, canChange boo containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int]int32, containerLen) - } else { - v = make(map[int]int32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[int]int32, xlen) changed = true } + + var mk int + var mv int32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int(dd.DecodeInt(intBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv @@ -23145,23 +33066,26 @@ func (_ fastpathT) DecMapIntInt32V(v map[int]int32, checkNil bool, canChange boo } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int(dd.DecodeInt(intBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntInt64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntInt64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int]int64) v, changed := fastpathTV.DecMapIntInt64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -23182,7 +33106,8 @@ func (f fastpathT) DecMapIntInt64X(vp *map[int]int64, checkNil bool, d *Decoder) func (_ fastpathT) DecMapIntInt64V(v map[int]int64, checkNil bool, canChange bool, d *Decoder) (_ map[int]int64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -23192,17 +33117,22 @@ func (_ fastpathT) DecMapIntInt64V(v map[int]int64, checkNil bool, canChange boo containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int]int64, containerLen) - } else { - v = make(map[int]int64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[int]int64, xlen) changed = true } + + var mk int + var mv int64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int(dd.DecodeInt(intBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeInt(64) if v != nil { v[mk] = mv @@ -23210,23 +33140,26 @@ func (_ fastpathT) DecMapIntInt64V(v map[int]int64, checkNil bool, canChange boo } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int(dd.DecodeInt(intBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeInt(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntFloat32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntFloat32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int]float32) v, changed := fastpathTV.DecMapIntFloat32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -23247,7 +33180,8 @@ func (f fastpathT) DecMapIntFloat32X(vp *map[int]float32, checkNil bool, d *Deco func (_ fastpathT) DecMapIntFloat32V(v map[int]float32, checkNil bool, canChange bool, d *Decoder) (_ map[int]float32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -23257,17 +33191,22 @@ func (_ fastpathT) DecMapIntFloat32V(v map[int]float32, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int]float32, containerLen) - } else { - v = make(map[int]float32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[int]float32, xlen) changed = true } + + var mk int + var mv float32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int(dd.DecodeInt(intBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv @@ -23275,23 +33214,26 @@ func (_ fastpathT) DecMapIntFloat32V(v map[int]float32, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int(dd.DecodeInt(intBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntFloat64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntFloat64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int]float64) v, changed := fastpathTV.DecMapIntFloat64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -23312,7 +33254,8 @@ func (f fastpathT) DecMapIntFloat64X(vp *map[int]float64, checkNil bool, d *Deco func (_ fastpathT) DecMapIntFloat64V(v map[int]float64, checkNil bool, canChange bool, d *Decoder) (_ map[int]float64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -23322,17 +33265,22 @@ func (_ fastpathT) DecMapIntFloat64V(v map[int]float64, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int]float64, containerLen) - } else { - v = make(map[int]float64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[int]float64, xlen) changed = true } + + var mk int + var mv float64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int(dd.DecodeInt(intBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv @@ -23340,23 +33288,26 @@ func (_ fastpathT) DecMapIntFloat64V(v map[int]float64, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int(dd.DecodeInt(intBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapIntBoolR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapIntBoolR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int]bool) v, changed := fastpathTV.DecMapIntBoolV(*vp, fastpathCheckNilFalse, true, f.d) @@ -23377,7 +33328,8 @@ func (f fastpathT) DecMapIntBoolX(vp *map[int]bool, checkNil bool, d *Decoder) { func (_ fastpathT) DecMapIntBoolV(v map[int]bool, checkNil bool, canChange bool, d *Decoder) (_ map[int]bool, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -23387,17 +33339,22 @@ func (_ fastpathT) DecMapIntBoolV(v map[int]bool, checkNil bool, canChange bool, containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int]bool, containerLen) - } else { - v = make(map[int]bool) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[int]bool, xlen) changed = true } + + var mk int + var mv bool if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int(dd.DecodeInt(intBitsize)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeBool() if v != nil { v[mk] = mv @@ -23405,23 +33362,26 @@ func (_ fastpathT) DecMapIntBoolV(v map[int]bool, checkNil bool, canChange bool, } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int(dd.DecodeInt(intBitsize)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int(dd.DecodeInt(intBitsize)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeBool() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt8IntfR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt8IntfR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int8]interface{}) v, changed := fastpathTV.DecMapInt8IntfV(*vp, fastpathCheckNilFalse, true, f.d) @@ -23442,7 +33402,8 @@ func (f fastpathT) DecMapInt8IntfX(vp *map[int8]interface{}, checkNil bool, d *D func (_ fastpathT) DecMapInt8IntfV(v map[int8]interface{}, checkNil bool, canChange bool, d *Decoder) (_ map[int8]interface{}, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -23452,43 +33413,59 @@ func (_ fastpathT) DecMapInt8IntfV(v map[int8]interface{}, checkNil bool, canCha containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int8]interface{}, containerLen) - } else { - v = make(map[int8]interface{}) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17) + v = make(map[int8]interface{}, xlen) changed = true } + mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + var mk int8 + var mv interface{} if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int8(dd.DecodeInt(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } d.decode(&mv) - if v != nil { v[mk] = mv } } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil } - mk := int8(dd.DecodeInt(8)) - dd.ReadMapKVSeparator() - mv := v[mk] d.decode(&mv) - if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt8StringR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt8StringR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int8]string) v, changed := fastpathTV.DecMapInt8StringV(*vp, fastpathCheckNilFalse, true, f.d) @@ -23509,7 +33486,8 @@ func (f fastpathT) DecMapInt8StringX(vp *map[int8]string, checkNil bool, d *Deco func (_ fastpathT) DecMapInt8StringV(v map[int8]string, checkNil bool, canChange bool, d *Decoder) (_ map[int8]string, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -23519,17 +33497,22 @@ func (_ fastpathT) DecMapInt8StringV(v map[int8]string, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int8]string, containerLen) - } else { - v = make(map[int8]string) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17) + v = make(map[int8]string, xlen) changed = true } + + var mk int8 + var mv string if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int8(dd.DecodeInt(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeString() if v != nil { v[mk] = mv @@ -23537,23 +33520,26 @@ func (_ fastpathT) DecMapInt8StringV(v map[int8]string, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int8(dd.DecodeInt(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeString() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt8UintR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt8UintR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int8]uint) v, changed := fastpathTV.DecMapInt8UintV(*vp, fastpathCheckNilFalse, true, f.d) @@ -23574,7 +33560,8 @@ func (f fastpathT) DecMapInt8UintX(vp *map[int8]uint, checkNil bool, d *Decoder) func (_ fastpathT) DecMapInt8UintV(v map[int8]uint, checkNil bool, canChange bool, d *Decoder) (_ map[int8]uint, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -23584,17 +33571,22 @@ func (_ fastpathT) DecMapInt8UintV(v map[int8]uint, checkNil bool, canChange boo containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int8]uint, containerLen) - } else { - v = make(map[int8]uint) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[int8]uint, xlen) changed = true } + + var mk int8 + var mv uint if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int8(dd.DecodeInt(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv @@ -23602,23 +33594,26 @@ func (_ fastpathT) DecMapInt8UintV(v map[int8]uint, checkNil bool, canChange boo } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int8(dd.DecodeInt(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt8Uint8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt8Uint8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int8]uint8) v, changed := fastpathTV.DecMapInt8Uint8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -23639,7 +33634,8 @@ func (f fastpathT) DecMapInt8Uint8X(vp *map[int8]uint8, checkNil bool, d *Decode func (_ fastpathT) DecMapInt8Uint8V(v map[int8]uint8, checkNil bool, canChange bool, d *Decoder) (_ map[int8]uint8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -23649,17 +33645,22 @@ func (_ fastpathT) DecMapInt8Uint8V(v map[int8]uint8, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int8]uint8, containerLen) - } else { - v = make(map[int8]uint8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 2) + v = make(map[int8]uint8, xlen) changed = true } + + var mk int8 + var mv uint8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int8(dd.DecodeInt(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv @@ -23667,23 +33668,26 @@ func (_ fastpathT) DecMapInt8Uint8V(v map[int8]uint8, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int8(dd.DecodeInt(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt8Uint16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt8Uint16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int8]uint16) v, changed := fastpathTV.DecMapInt8Uint16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -23704,7 +33708,8 @@ func (f fastpathT) DecMapInt8Uint16X(vp *map[int8]uint16, checkNil bool, d *Deco func (_ fastpathT) DecMapInt8Uint16V(v map[int8]uint16, checkNil bool, canChange bool, d *Decoder) (_ map[int8]uint16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -23714,17 +33719,22 @@ func (_ fastpathT) DecMapInt8Uint16V(v map[int8]uint16, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int8]uint16, containerLen) - } else { - v = make(map[int8]uint16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3) + v = make(map[int8]uint16, xlen) changed = true } + + var mk int8 + var mv uint16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int8(dd.DecodeInt(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv @@ -23732,23 +33742,26 @@ func (_ fastpathT) DecMapInt8Uint16V(v map[int8]uint16, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int8(dd.DecodeInt(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt8Uint32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt8Uint32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int8]uint32) v, changed := fastpathTV.DecMapInt8Uint32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -23769,7 +33782,8 @@ func (f fastpathT) DecMapInt8Uint32X(vp *map[int8]uint32, checkNil bool, d *Deco func (_ fastpathT) DecMapInt8Uint32V(v map[int8]uint32, checkNil bool, canChange bool, d *Decoder) (_ map[int8]uint32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -23779,17 +33793,22 @@ func (_ fastpathT) DecMapInt8Uint32V(v map[int8]uint32, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int8]uint32, containerLen) - } else { - v = make(map[int8]uint32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5) + v = make(map[int8]uint32, xlen) changed = true } + + var mk int8 + var mv uint32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int8(dd.DecodeInt(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv @@ -23797,23 +33816,26 @@ func (_ fastpathT) DecMapInt8Uint32V(v map[int8]uint32, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int8(dd.DecodeInt(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt8Uint64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt8Uint64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int8]uint64) v, changed := fastpathTV.DecMapInt8Uint64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -23834,7 +33856,8 @@ func (f fastpathT) DecMapInt8Uint64X(vp *map[int8]uint64, checkNil bool, d *Deco func (_ fastpathT) DecMapInt8Uint64V(v map[int8]uint64, checkNil bool, canChange bool, d *Decoder) (_ map[int8]uint64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -23844,17 +33867,22 @@ func (_ fastpathT) DecMapInt8Uint64V(v map[int8]uint64, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int8]uint64, containerLen) - } else { - v = make(map[int8]uint64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[int8]uint64, xlen) changed = true } + + var mk int8 + var mv uint64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int8(dd.DecodeInt(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeUint(64) if v != nil { v[mk] = mv @@ -23862,23 +33890,100 @@ func (_ fastpathT) DecMapInt8Uint64V(v map[int8]uint64, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int8(dd.DecodeInt(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeUint(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt8IntR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt8UintptrR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[int8]uintptr) + v, changed := fastpathTV.DecMapInt8UintptrV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[int8]uintptr) + fastpathTV.DecMapInt8UintptrV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapInt8UintptrX(vp *map[int8]uintptr, checkNil bool, d *Decoder) { + v, changed := f.DecMapInt8UintptrV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapInt8UintptrV(v map[int8]uintptr, checkNil bool, canChange bool, + d *Decoder) (_ map[int8]uintptr, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[int8]uintptr, xlen) + changed = true + } + + var mk int8 + var mv uintptr + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapInt8IntR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int8]int) v, changed := fastpathTV.DecMapInt8IntV(*vp, fastpathCheckNilFalse, true, f.d) @@ -23899,7 +34004,8 @@ func (f fastpathT) DecMapInt8IntX(vp *map[int8]int, checkNil bool, d *Decoder) { func (_ fastpathT) DecMapInt8IntV(v map[int8]int, checkNil bool, canChange bool, d *Decoder) (_ map[int8]int, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -23909,17 +34015,22 @@ func (_ fastpathT) DecMapInt8IntV(v map[int8]int, checkNil bool, canChange bool, containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int8]int, containerLen) - } else { - v = make(map[int8]int) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[int8]int, xlen) changed = true } + + var mk int8 + var mv int if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int8(dd.DecodeInt(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv @@ -23927,23 +34038,26 @@ func (_ fastpathT) DecMapInt8IntV(v map[int8]int, checkNil bool, canChange bool, } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int8(dd.DecodeInt(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt8Int8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt8Int8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int8]int8) v, changed := fastpathTV.DecMapInt8Int8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -23964,7 +34078,8 @@ func (f fastpathT) DecMapInt8Int8X(vp *map[int8]int8, checkNil bool, d *Decoder) func (_ fastpathT) DecMapInt8Int8V(v map[int8]int8, checkNil bool, canChange bool, d *Decoder) (_ map[int8]int8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -23974,17 +34089,22 @@ func (_ fastpathT) DecMapInt8Int8V(v map[int8]int8, checkNil bool, canChange boo containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int8]int8, containerLen) - } else { - v = make(map[int8]int8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 2) + v = make(map[int8]int8, xlen) changed = true } + + var mk int8 + var mv int8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int8(dd.DecodeInt(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv @@ -23992,23 +34112,26 @@ func (_ fastpathT) DecMapInt8Int8V(v map[int8]int8, checkNil bool, canChange boo } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int8(dd.DecodeInt(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt8Int16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt8Int16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int8]int16) v, changed := fastpathTV.DecMapInt8Int16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -24029,7 +34152,8 @@ func (f fastpathT) DecMapInt8Int16X(vp *map[int8]int16, checkNil bool, d *Decode func (_ fastpathT) DecMapInt8Int16V(v map[int8]int16, checkNil bool, canChange bool, d *Decoder) (_ map[int8]int16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -24039,17 +34163,22 @@ func (_ fastpathT) DecMapInt8Int16V(v map[int8]int16, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int8]int16, containerLen) - } else { - v = make(map[int8]int16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3) + v = make(map[int8]int16, xlen) changed = true } + + var mk int8 + var mv int16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int8(dd.DecodeInt(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv @@ -24057,23 +34186,26 @@ func (_ fastpathT) DecMapInt8Int16V(v map[int8]int16, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int8(dd.DecodeInt(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt8Int32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt8Int32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int8]int32) v, changed := fastpathTV.DecMapInt8Int32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -24094,7 +34226,8 @@ func (f fastpathT) DecMapInt8Int32X(vp *map[int8]int32, checkNil bool, d *Decode func (_ fastpathT) DecMapInt8Int32V(v map[int8]int32, checkNil bool, canChange bool, d *Decoder) (_ map[int8]int32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -24104,17 +34237,22 @@ func (_ fastpathT) DecMapInt8Int32V(v map[int8]int32, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int8]int32, containerLen) - } else { - v = make(map[int8]int32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5) + v = make(map[int8]int32, xlen) changed = true } + + var mk int8 + var mv int32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int8(dd.DecodeInt(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv @@ -24122,23 +34260,26 @@ func (_ fastpathT) DecMapInt8Int32V(v map[int8]int32, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int8(dd.DecodeInt(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt8Int64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt8Int64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int8]int64) v, changed := fastpathTV.DecMapInt8Int64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -24159,7 +34300,8 @@ func (f fastpathT) DecMapInt8Int64X(vp *map[int8]int64, checkNil bool, d *Decode func (_ fastpathT) DecMapInt8Int64V(v map[int8]int64, checkNil bool, canChange bool, d *Decoder) (_ map[int8]int64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -24169,17 +34311,22 @@ func (_ fastpathT) DecMapInt8Int64V(v map[int8]int64, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int8]int64, containerLen) - } else { - v = make(map[int8]int64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[int8]int64, xlen) changed = true } + + var mk int8 + var mv int64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int8(dd.DecodeInt(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeInt(64) if v != nil { v[mk] = mv @@ -24187,23 +34334,26 @@ func (_ fastpathT) DecMapInt8Int64V(v map[int8]int64, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int8(dd.DecodeInt(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeInt(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt8Float32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt8Float32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int8]float32) v, changed := fastpathTV.DecMapInt8Float32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -24224,7 +34374,8 @@ func (f fastpathT) DecMapInt8Float32X(vp *map[int8]float32, checkNil bool, d *De func (_ fastpathT) DecMapInt8Float32V(v map[int8]float32, checkNil bool, canChange bool, d *Decoder) (_ map[int8]float32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -24234,17 +34385,22 @@ func (_ fastpathT) DecMapInt8Float32V(v map[int8]float32, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int8]float32, containerLen) - } else { - v = make(map[int8]float32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5) + v = make(map[int8]float32, xlen) changed = true } + + var mk int8 + var mv float32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int8(dd.DecodeInt(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv @@ -24252,23 +34408,26 @@ func (_ fastpathT) DecMapInt8Float32V(v map[int8]float32, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int8(dd.DecodeInt(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt8Float64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt8Float64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int8]float64) v, changed := fastpathTV.DecMapInt8Float64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -24289,7 +34448,8 @@ func (f fastpathT) DecMapInt8Float64X(vp *map[int8]float64, checkNil bool, d *De func (_ fastpathT) DecMapInt8Float64V(v map[int8]float64, checkNil bool, canChange bool, d *Decoder) (_ map[int8]float64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -24299,17 +34459,22 @@ func (_ fastpathT) DecMapInt8Float64V(v map[int8]float64, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int8]float64, containerLen) - } else { - v = make(map[int8]float64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[int8]float64, xlen) changed = true } + + var mk int8 + var mv float64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int8(dd.DecodeInt(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv @@ -24317,23 +34482,26 @@ func (_ fastpathT) DecMapInt8Float64V(v map[int8]float64, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int8(dd.DecodeInt(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt8BoolR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt8BoolR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int8]bool) v, changed := fastpathTV.DecMapInt8BoolV(*vp, fastpathCheckNilFalse, true, f.d) @@ -24354,7 +34522,8 @@ func (f fastpathT) DecMapInt8BoolX(vp *map[int8]bool, checkNil bool, d *Decoder) func (_ fastpathT) DecMapInt8BoolV(v map[int8]bool, checkNil bool, canChange bool, d *Decoder) (_ map[int8]bool, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -24364,17 +34533,22 @@ func (_ fastpathT) DecMapInt8BoolV(v map[int8]bool, checkNil bool, canChange boo containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int8]bool, containerLen) - } else { - v = make(map[int8]bool) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 2) + v = make(map[int8]bool, xlen) changed = true } + + var mk int8 + var mv bool if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int8(dd.DecodeInt(8)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeBool() if v != nil { v[mk] = mv @@ -24382,23 +34556,26 @@ func (_ fastpathT) DecMapInt8BoolV(v map[int8]bool, checkNil bool, canChange boo } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int8(dd.DecodeInt(8)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int8(dd.DecodeInt(8)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeBool() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt16IntfR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt16IntfR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int16]interface{}) v, changed := fastpathTV.DecMapInt16IntfV(*vp, fastpathCheckNilFalse, true, f.d) @@ -24419,7 +34596,8 @@ func (f fastpathT) DecMapInt16IntfX(vp *map[int16]interface{}, checkNil bool, d func (_ fastpathT) DecMapInt16IntfV(v map[int16]interface{}, checkNil bool, canChange bool, d *Decoder) (_ map[int16]interface{}, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -24429,43 +34607,59 @@ func (_ fastpathT) DecMapInt16IntfV(v map[int16]interface{}, checkNil bool, canC containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int16]interface{}, containerLen) - } else { - v = make(map[int16]interface{}) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 18) + v = make(map[int16]interface{}, xlen) changed = true } + mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + var mk int16 + var mv interface{} if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int16(dd.DecodeInt(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } d.decode(&mv) - if v != nil { v[mk] = mv } } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil } - mk := int16(dd.DecodeInt(16)) - dd.ReadMapKVSeparator() - mv := v[mk] d.decode(&mv) - if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt16StringR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt16StringR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int16]string) v, changed := fastpathTV.DecMapInt16StringV(*vp, fastpathCheckNilFalse, true, f.d) @@ -24486,7 +34680,8 @@ func (f fastpathT) DecMapInt16StringX(vp *map[int16]string, checkNil bool, d *De func (_ fastpathT) DecMapInt16StringV(v map[int16]string, checkNil bool, canChange bool, d *Decoder) (_ map[int16]string, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -24496,17 +34691,22 @@ func (_ fastpathT) DecMapInt16StringV(v map[int16]string, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int16]string, containerLen) - } else { - v = make(map[int16]string) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 18) + v = make(map[int16]string, xlen) changed = true } + + var mk int16 + var mv string if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int16(dd.DecodeInt(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeString() if v != nil { v[mk] = mv @@ -24514,23 +34714,26 @@ func (_ fastpathT) DecMapInt16StringV(v map[int16]string, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int16(dd.DecodeInt(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeString() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt16UintR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt16UintR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int16]uint) v, changed := fastpathTV.DecMapInt16UintV(*vp, fastpathCheckNilFalse, true, f.d) @@ -24551,7 +34754,8 @@ func (f fastpathT) DecMapInt16UintX(vp *map[int16]uint, checkNil bool, d *Decode func (_ fastpathT) DecMapInt16UintV(v map[int16]uint, checkNil bool, canChange bool, d *Decoder) (_ map[int16]uint, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -24561,17 +34765,22 @@ func (_ fastpathT) DecMapInt16UintV(v map[int16]uint, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int16]uint, containerLen) - } else { - v = make(map[int16]uint) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[int16]uint, xlen) changed = true } + + var mk int16 + var mv uint if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int16(dd.DecodeInt(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv @@ -24579,23 +34788,26 @@ func (_ fastpathT) DecMapInt16UintV(v map[int16]uint, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int16(dd.DecodeInt(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt16Uint8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt16Uint8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int16]uint8) v, changed := fastpathTV.DecMapInt16Uint8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -24616,7 +34828,8 @@ func (f fastpathT) DecMapInt16Uint8X(vp *map[int16]uint8, checkNil bool, d *Deco func (_ fastpathT) DecMapInt16Uint8V(v map[int16]uint8, checkNil bool, canChange bool, d *Decoder) (_ map[int16]uint8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -24626,17 +34839,22 @@ func (_ fastpathT) DecMapInt16Uint8V(v map[int16]uint8, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int16]uint8, containerLen) - } else { - v = make(map[int16]uint8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3) + v = make(map[int16]uint8, xlen) changed = true } + + var mk int16 + var mv uint8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int16(dd.DecodeInt(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv @@ -24644,23 +34862,26 @@ func (_ fastpathT) DecMapInt16Uint8V(v map[int16]uint8, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int16(dd.DecodeInt(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt16Uint16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt16Uint16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int16]uint16) v, changed := fastpathTV.DecMapInt16Uint16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -24681,7 +34902,8 @@ func (f fastpathT) DecMapInt16Uint16X(vp *map[int16]uint16, checkNil bool, d *De func (_ fastpathT) DecMapInt16Uint16V(v map[int16]uint16, checkNil bool, canChange bool, d *Decoder) (_ map[int16]uint16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -24691,17 +34913,22 @@ func (_ fastpathT) DecMapInt16Uint16V(v map[int16]uint16, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int16]uint16, containerLen) - } else { - v = make(map[int16]uint16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 4) + v = make(map[int16]uint16, xlen) changed = true } + + var mk int16 + var mv uint16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int16(dd.DecodeInt(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv @@ -24709,23 +34936,26 @@ func (_ fastpathT) DecMapInt16Uint16V(v map[int16]uint16, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int16(dd.DecodeInt(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt16Uint32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt16Uint32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int16]uint32) v, changed := fastpathTV.DecMapInt16Uint32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -24746,7 +34976,8 @@ func (f fastpathT) DecMapInt16Uint32X(vp *map[int16]uint32, checkNil bool, d *De func (_ fastpathT) DecMapInt16Uint32V(v map[int16]uint32, checkNil bool, canChange bool, d *Decoder) (_ map[int16]uint32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -24756,17 +34987,22 @@ func (_ fastpathT) DecMapInt16Uint32V(v map[int16]uint32, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int16]uint32, containerLen) - } else { - v = make(map[int16]uint32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6) + v = make(map[int16]uint32, xlen) changed = true } + + var mk int16 + var mv uint32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int16(dd.DecodeInt(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv @@ -24774,23 +35010,26 @@ func (_ fastpathT) DecMapInt16Uint32V(v map[int16]uint32, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int16(dd.DecodeInt(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt16Uint64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt16Uint64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int16]uint64) v, changed := fastpathTV.DecMapInt16Uint64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -24811,7 +35050,8 @@ func (f fastpathT) DecMapInt16Uint64X(vp *map[int16]uint64, checkNil bool, d *De func (_ fastpathT) DecMapInt16Uint64V(v map[int16]uint64, checkNil bool, canChange bool, d *Decoder) (_ map[int16]uint64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -24821,17 +35061,22 @@ func (_ fastpathT) DecMapInt16Uint64V(v map[int16]uint64, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int16]uint64, containerLen) - } else { - v = make(map[int16]uint64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[int16]uint64, xlen) changed = true } + + var mk int16 + var mv uint64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int16(dd.DecodeInt(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeUint(64) if v != nil { v[mk] = mv @@ -24839,23 +35084,100 @@ func (_ fastpathT) DecMapInt16Uint64V(v map[int16]uint64, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int16(dd.DecodeInt(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeUint(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt16IntR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt16UintptrR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[int16]uintptr) + v, changed := fastpathTV.DecMapInt16UintptrV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[int16]uintptr) + fastpathTV.DecMapInt16UintptrV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapInt16UintptrX(vp *map[int16]uintptr, checkNil bool, d *Decoder) { + v, changed := f.DecMapInt16UintptrV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapInt16UintptrV(v map[int16]uintptr, checkNil bool, canChange bool, + d *Decoder) (_ map[int16]uintptr, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[int16]uintptr, xlen) + changed = true + } + + var mk int16 + var mv uintptr + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapInt16IntR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int16]int) v, changed := fastpathTV.DecMapInt16IntV(*vp, fastpathCheckNilFalse, true, f.d) @@ -24876,7 +35198,8 @@ func (f fastpathT) DecMapInt16IntX(vp *map[int16]int, checkNil bool, d *Decoder) func (_ fastpathT) DecMapInt16IntV(v map[int16]int, checkNil bool, canChange bool, d *Decoder) (_ map[int16]int, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -24886,17 +35209,22 @@ func (_ fastpathT) DecMapInt16IntV(v map[int16]int, checkNil bool, canChange boo containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int16]int, containerLen) - } else { - v = make(map[int16]int) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[int16]int, xlen) changed = true } + + var mk int16 + var mv int if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int16(dd.DecodeInt(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv @@ -24904,23 +35232,26 @@ func (_ fastpathT) DecMapInt16IntV(v map[int16]int, checkNil bool, canChange boo } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int16(dd.DecodeInt(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt16Int8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt16Int8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int16]int8) v, changed := fastpathTV.DecMapInt16Int8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -24941,7 +35272,8 @@ func (f fastpathT) DecMapInt16Int8X(vp *map[int16]int8, checkNil bool, d *Decode func (_ fastpathT) DecMapInt16Int8V(v map[int16]int8, checkNil bool, canChange bool, d *Decoder) (_ map[int16]int8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -24951,17 +35283,22 @@ func (_ fastpathT) DecMapInt16Int8V(v map[int16]int8, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int16]int8, containerLen) - } else { - v = make(map[int16]int8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3) + v = make(map[int16]int8, xlen) changed = true } + + var mk int16 + var mv int8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int16(dd.DecodeInt(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv @@ -24969,23 +35306,26 @@ func (_ fastpathT) DecMapInt16Int8V(v map[int16]int8, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int16(dd.DecodeInt(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt16Int16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt16Int16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int16]int16) v, changed := fastpathTV.DecMapInt16Int16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -25006,7 +35346,8 @@ func (f fastpathT) DecMapInt16Int16X(vp *map[int16]int16, checkNil bool, d *Deco func (_ fastpathT) DecMapInt16Int16V(v map[int16]int16, checkNil bool, canChange bool, d *Decoder) (_ map[int16]int16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -25016,17 +35357,22 @@ func (_ fastpathT) DecMapInt16Int16V(v map[int16]int16, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int16]int16, containerLen) - } else { - v = make(map[int16]int16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 4) + v = make(map[int16]int16, xlen) changed = true } + + var mk int16 + var mv int16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int16(dd.DecodeInt(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv @@ -25034,23 +35380,26 @@ func (_ fastpathT) DecMapInt16Int16V(v map[int16]int16, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int16(dd.DecodeInt(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt16Int32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt16Int32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int16]int32) v, changed := fastpathTV.DecMapInt16Int32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -25071,7 +35420,8 @@ func (f fastpathT) DecMapInt16Int32X(vp *map[int16]int32, checkNil bool, d *Deco func (_ fastpathT) DecMapInt16Int32V(v map[int16]int32, checkNil bool, canChange bool, d *Decoder) (_ map[int16]int32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -25081,17 +35431,22 @@ func (_ fastpathT) DecMapInt16Int32V(v map[int16]int32, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int16]int32, containerLen) - } else { - v = make(map[int16]int32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6) + v = make(map[int16]int32, xlen) changed = true } + + var mk int16 + var mv int32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int16(dd.DecodeInt(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv @@ -25099,23 +35454,26 @@ func (_ fastpathT) DecMapInt16Int32V(v map[int16]int32, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int16(dd.DecodeInt(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt16Int64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt16Int64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int16]int64) v, changed := fastpathTV.DecMapInt16Int64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -25136,7 +35494,8 @@ func (f fastpathT) DecMapInt16Int64X(vp *map[int16]int64, checkNil bool, d *Deco func (_ fastpathT) DecMapInt16Int64V(v map[int16]int64, checkNil bool, canChange bool, d *Decoder) (_ map[int16]int64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -25146,17 +35505,22 @@ func (_ fastpathT) DecMapInt16Int64V(v map[int16]int64, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int16]int64, containerLen) - } else { - v = make(map[int16]int64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[int16]int64, xlen) changed = true } + + var mk int16 + var mv int64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int16(dd.DecodeInt(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeInt(64) if v != nil { v[mk] = mv @@ -25164,23 +35528,26 @@ func (_ fastpathT) DecMapInt16Int64V(v map[int16]int64, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int16(dd.DecodeInt(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeInt(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt16Float32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt16Float32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int16]float32) v, changed := fastpathTV.DecMapInt16Float32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -25201,7 +35568,8 @@ func (f fastpathT) DecMapInt16Float32X(vp *map[int16]float32, checkNil bool, d * func (_ fastpathT) DecMapInt16Float32V(v map[int16]float32, checkNil bool, canChange bool, d *Decoder) (_ map[int16]float32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -25211,17 +35579,22 @@ func (_ fastpathT) DecMapInt16Float32V(v map[int16]float32, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int16]float32, containerLen) - } else { - v = make(map[int16]float32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6) + v = make(map[int16]float32, xlen) changed = true } + + var mk int16 + var mv float32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int16(dd.DecodeInt(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv @@ -25229,23 +35602,26 @@ func (_ fastpathT) DecMapInt16Float32V(v map[int16]float32, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int16(dd.DecodeInt(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt16Float64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt16Float64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int16]float64) v, changed := fastpathTV.DecMapInt16Float64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -25266,7 +35642,8 @@ func (f fastpathT) DecMapInt16Float64X(vp *map[int16]float64, checkNil bool, d * func (_ fastpathT) DecMapInt16Float64V(v map[int16]float64, checkNil bool, canChange bool, d *Decoder) (_ map[int16]float64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -25276,17 +35653,22 @@ func (_ fastpathT) DecMapInt16Float64V(v map[int16]float64, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int16]float64, containerLen) - } else { - v = make(map[int16]float64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[int16]float64, xlen) changed = true } + + var mk int16 + var mv float64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int16(dd.DecodeInt(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv @@ -25294,23 +35676,26 @@ func (_ fastpathT) DecMapInt16Float64V(v map[int16]float64, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int16(dd.DecodeInt(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt16BoolR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt16BoolR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int16]bool) v, changed := fastpathTV.DecMapInt16BoolV(*vp, fastpathCheckNilFalse, true, f.d) @@ -25331,7 +35716,8 @@ func (f fastpathT) DecMapInt16BoolX(vp *map[int16]bool, checkNil bool, d *Decode func (_ fastpathT) DecMapInt16BoolV(v map[int16]bool, checkNil bool, canChange bool, d *Decoder) (_ map[int16]bool, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -25341,17 +35727,22 @@ func (_ fastpathT) DecMapInt16BoolV(v map[int16]bool, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int16]bool, containerLen) - } else { - v = make(map[int16]bool) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3) + v = make(map[int16]bool, xlen) changed = true } + + var mk int16 + var mv bool if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int16(dd.DecodeInt(16)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeBool() if v != nil { v[mk] = mv @@ -25359,23 +35750,26 @@ func (_ fastpathT) DecMapInt16BoolV(v map[int16]bool, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int16(dd.DecodeInt(16)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int16(dd.DecodeInt(16)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeBool() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt32IntfR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt32IntfR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int32]interface{}) v, changed := fastpathTV.DecMapInt32IntfV(*vp, fastpathCheckNilFalse, true, f.d) @@ -25396,7 +35790,8 @@ func (f fastpathT) DecMapInt32IntfX(vp *map[int32]interface{}, checkNil bool, d func (_ fastpathT) DecMapInt32IntfV(v map[int32]interface{}, checkNil bool, canChange bool, d *Decoder) (_ map[int32]interface{}, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -25406,43 +35801,59 @@ func (_ fastpathT) DecMapInt32IntfV(v map[int32]interface{}, checkNil bool, canC containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int32]interface{}, containerLen) - } else { - v = make(map[int32]interface{}) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20) + v = make(map[int32]interface{}, xlen) changed = true } + mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + var mk int32 + var mv interface{} if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int32(dd.DecodeInt(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } d.decode(&mv) - if v != nil { v[mk] = mv } } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil } - mk := int32(dd.DecodeInt(32)) - dd.ReadMapKVSeparator() - mv := v[mk] d.decode(&mv) - if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt32StringR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt32StringR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int32]string) v, changed := fastpathTV.DecMapInt32StringV(*vp, fastpathCheckNilFalse, true, f.d) @@ -25463,7 +35874,8 @@ func (f fastpathT) DecMapInt32StringX(vp *map[int32]string, checkNil bool, d *De func (_ fastpathT) DecMapInt32StringV(v map[int32]string, checkNil bool, canChange bool, d *Decoder) (_ map[int32]string, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -25473,17 +35885,22 @@ func (_ fastpathT) DecMapInt32StringV(v map[int32]string, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int32]string, containerLen) - } else { - v = make(map[int32]string) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20) + v = make(map[int32]string, xlen) changed = true } + + var mk int32 + var mv string if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int32(dd.DecodeInt(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeString() if v != nil { v[mk] = mv @@ -25491,23 +35908,26 @@ func (_ fastpathT) DecMapInt32StringV(v map[int32]string, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int32(dd.DecodeInt(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeString() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt32UintR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt32UintR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int32]uint) v, changed := fastpathTV.DecMapInt32UintV(*vp, fastpathCheckNilFalse, true, f.d) @@ -25528,7 +35948,8 @@ func (f fastpathT) DecMapInt32UintX(vp *map[int32]uint, checkNil bool, d *Decode func (_ fastpathT) DecMapInt32UintV(v map[int32]uint, checkNil bool, canChange bool, d *Decoder) (_ map[int32]uint, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -25538,17 +35959,22 @@ func (_ fastpathT) DecMapInt32UintV(v map[int32]uint, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int32]uint, containerLen) - } else { - v = make(map[int32]uint) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[int32]uint, xlen) changed = true } + + var mk int32 + var mv uint if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int32(dd.DecodeInt(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv @@ -25556,23 +35982,26 @@ func (_ fastpathT) DecMapInt32UintV(v map[int32]uint, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int32(dd.DecodeInt(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt32Uint8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt32Uint8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int32]uint8) v, changed := fastpathTV.DecMapInt32Uint8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -25593,7 +36022,8 @@ func (f fastpathT) DecMapInt32Uint8X(vp *map[int32]uint8, checkNil bool, d *Deco func (_ fastpathT) DecMapInt32Uint8V(v map[int32]uint8, checkNil bool, canChange bool, d *Decoder) (_ map[int32]uint8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -25603,17 +36033,22 @@ func (_ fastpathT) DecMapInt32Uint8V(v map[int32]uint8, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int32]uint8, containerLen) - } else { - v = make(map[int32]uint8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5) + v = make(map[int32]uint8, xlen) changed = true } + + var mk int32 + var mv uint8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int32(dd.DecodeInt(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv @@ -25621,23 +36056,26 @@ func (_ fastpathT) DecMapInt32Uint8V(v map[int32]uint8, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int32(dd.DecodeInt(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt32Uint16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt32Uint16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int32]uint16) v, changed := fastpathTV.DecMapInt32Uint16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -25658,7 +36096,8 @@ func (f fastpathT) DecMapInt32Uint16X(vp *map[int32]uint16, checkNil bool, d *De func (_ fastpathT) DecMapInt32Uint16V(v map[int32]uint16, checkNil bool, canChange bool, d *Decoder) (_ map[int32]uint16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -25668,17 +36107,22 @@ func (_ fastpathT) DecMapInt32Uint16V(v map[int32]uint16, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int32]uint16, containerLen) - } else { - v = make(map[int32]uint16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6) + v = make(map[int32]uint16, xlen) changed = true } + + var mk int32 + var mv uint16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int32(dd.DecodeInt(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv @@ -25686,23 +36130,26 @@ func (_ fastpathT) DecMapInt32Uint16V(v map[int32]uint16, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int32(dd.DecodeInt(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt32Uint32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt32Uint32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int32]uint32) v, changed := fastpathTV.DecMapInt32Uint32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -25723,7 +36170,8 @@ func (f fastpathT) DecMapInt32Uint32X(vp *map[int32]uint32, checkNil bool, d *De func (_ fastpathT) DecMapInt32Uint32V(v map[int32]uint32, checkNil bool, canChange bool, d *Decoder) (_ map[int32]uint32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -25733,17 +36181,22 @@ func (_ fastpathT) DecMapInt32Uint32V(v map[int32]uint32, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int32]uint32, containerLen) - } else { - v = make(map[int32]uint32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 8) + v = make(map[int32]uint32, xlen) changed = true } + + var mk int32 + var mv uint32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int32(dd.DecodeInt(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv @@ -25751,23 +36204,26 @@ func (_ fastpathT) DecMapInt32Uint32V(v map[int32]uint32, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int32(dd.DecodeInt(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt32Uint64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt32Uint64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int32]uint64) v, changed := fastpathTV.DecMapInt32Uint64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -25788,7 +36244,8 @@ func (f fastpathT) DecMapInt32Uint64X(vp *map[int32]uint64, checkNil bool, d *De func (_ fastpathT) DecMapInt32Uint64V(v map[int32]uint64, checkNil bool, canChange bool, d *Decoder) (_ map[int32]uint64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -25798,17 +36255,22 @@ func (_ fastpathT) DecMapInt32Uint64V(v map[int32]uint64, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int32]uint64, containerLen) - } else { - v = make(map[int32]uint64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[int32]uint64, xlen) changed = true } + + var mk int32 + var mv uint64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int32(dd.DecodeInt(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeUint(64) if v != nil { v[mk] = mv @@ -25816,23 +36278,100 @@ func (_ fastpathT) DecMapInt32Uint64V(v map[int32]uint64, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int32(dd.DecodeInt(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeUint(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt32IntR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt32UintptrR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[int32]uintptr) + v, changed := fastpathTV.DecMapInt32UintptrV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[int32]uintptr) + fastpathTV.DecMapInt32UintptrV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapInt32UintptrX(vp *map[int32]uintptr, checkNil bool, d *Decoder) { + v, changed := f.DecMapInt32UintptrV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapInt32UintptrV(v map[int32]uintptr, checkNil bool, canChange bool, + d *Decoder) (_ map[int32]uintptr, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[int32]uintptr, xlen) + changed = true + } + + var mk int32 + var mv uintptr + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapInt32IntR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int32]int) v, changed := fastpathTV.DecMapInt32IntV(*vp, fastpathCheckNilFalse, true, f.d) @@ -25853,7 +36392,8 @@ func (f fastpathT) DecMapInt32IntX(vp *map[int32]int, checkNil bool, d *Decoder) func (_ fastpathT) DecMapInt32IntV(v map[int32]int, checkNil bool, canChange bool, d *Decoder) (_ map[int32]int, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -25863,17 +36403,22 @@ func (_ fastpathT) DecMapInt32IntV(v map[int32]int, checkNil bool, canChange boo containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int32]int, containerLen) - } else { - v = make(map[int32]int) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[int32]int, xlen) changed = true } + + var mk int32 + var mv int if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int32(dd.DecodeInt(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv @@ -25881,23 +36426,26 @@ func (_ fastpathT) DecMapInt32IntV(v map[int32]int, checkNil bool, canChange boo } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int32(dd.DecodeInt(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt32Int8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt32Int8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int32]int8) v, changed := fastpathTV.DecMapInt32Int8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -25918,7 +36466,8 @@ func (f fastpathT) DecMapInt32Int8X(vp *map[int32]int8, checkNil bool, d *Decode func (_ fastpathT) DecMapInt32Int8V(v map[int32]int8, checkNil bool, canChange bool, d *Decoder) (_ map[int32]int8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -25928,17 +36477,22 @@ func (_ fastpathT) DecMapInt32Int8V(v map[int32]int8, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int32]int8, containerLen) - } else { - v = make(map[int32]int8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5) + v = make(map[int32]int8, xlen) changed = true } + + var mk int32 + var mv int8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int32(dd.DecodeInt(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv @@ -25946,23 +36500,26 @@ func (_ fastpathT) DecMapInt32Int8V(v map[int32]int8, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int32(dd.DecodeInt(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt32Int16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt32Int16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int32]int16) v, changed := fastpathTV.DecMapInt32Int16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -25983,7 +36540,8 @@ func (f fastpathT) DecMapInt32Int16X(vp *map[int32]int16, checkNil bool, d *Deco func (_ fastpathT) DecMapInt32Int16V(v map[int32]int16, checkNil bool, canChange bool, d *Decoder) (_ map[int32]int16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -25993,17 +36551,22 @@ func (_ fastpathT) DecMapInt32Int16V(v map[int32]int16, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int32]int16, containerLen) - } else { - v = make(map[int32]int16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6) + v = make(map[int32]int16, xlen) changed = true } + + var mk int32 + var mv int16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int32(dd.DecodeInt(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv @@ -26011,23 +36574,26 @@ func (_ fastpathT) DecMapInt32Int16V(v map[int32]int16, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int32(dd.DecodeInt(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt32Int32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt32Int32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int32]int32) v, changed := fastpathTV.DecMapInt32Int32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -26048,7 +36614,8 @@ func (f fastpathT) DecMapInt32Int32X(vp *map[int32]int32, checkNil bool, d *Deco func (_ fastpathT) DecMapInt32Int32V(v map[int32]int32, checkNil bool, canChange bool, d *Decoder) (_ map[int32]int32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -26058,17 +36625,22 @@ func (_ fastpathT) DecMapInt32Int32V(v map[int32]int32, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int32]int32, containerLen) - } else { - v = make(map[int32]int32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 8) + v = make(map[int32]int32, xlen) changed = true } + + var mk int32 + var mv int32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int32(dd.DecodeInt(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv @@ -26076,23 +36648,26 @@ func (_ fastpathT) DecMapInt32Int32V(v map[int32]int32, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int32(dd.DecodeInt(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt32Int64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt32Int64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int32]int64) v, changed := fastpathTV.DecMapInt32Int64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -26113,7 +36688,8 @@ func (f fastpathT) DecMapInt32Int64X(vp *map[int32]int64, checkNil bool, d *Deco func (_ fastpathT) DecMapInt32Int64V(v map[int32]int64, checkNil bool, canChange bool, d *Decoder) (_ map[int32]int64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -26123,17 +36699,22 @@ func (_ fastpathT) DecMapInt32Int64V(v map[int32]int64, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int32]int64, containerLen) - } else { - v = make(map[int32]int64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[int32]int64, xlen) changed = true } + + var mk int32 + var mv int64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int32(dd.DecodeInt(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeInt(64) if v != nil { v[mk] = mv @@ -26141,23 +36722,26 @@ func (_ fastpathT) DecMapInt32Int64V(v map[int32]int64, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int32(dd.DecodeInt(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeInt(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt32Float32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt32Float32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int32]float32) v, changed := fastpathTV.DecMapInt32Float32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -26178,7 +36762,8 @@ func (f fastpathT) DecMapInt32Float32X(vp *map[int32]float32, checkNil bool, d * func (_ fastpathT) DecMapInt32Float32V(v map[int32]float32, checkNil bool, canChange bool, d *Decoder) (_ map[int32]float32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -26188,17 +36773,22 @@ func (_ fastpathT) DecMapInt32Float32V(v map[int32]float32, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int32]float32, containerLen) - } else { - v = make(map[int32]float32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 8) + v = make(map[int32]float32, xlen) changed = true } + + var mk int32 + var mv float32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int32(dd.DecodeInt(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv @@ -26206,23 +36796,26 @@ func (_ fastpathT) DecMapInt32Float32V(v map[int32]float32, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int32(dd.DecodeInt(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt32Float64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt32Float64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int32]float64) v, changed := fastpathTV.DecMapInt32Float64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -26243,7 +36836,8 @@ func (f fastpathT) DecMapInt32Float64X(vp *map[int32]float64, checkNil bool, d * func (_ fastpathT) DecMapInt32Float64V(v map[int32]float64, checkNil bool, canChange bool, d *Decoder) (_ map[int32]float64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -26253,17 +36847,22 @@ func (_ fastpathT) DecMapInt32Float64V(v map[int32]float64, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int32]float64, containerLen) - } else { - v = make(map[int32]float64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[int32]float64, xlen) changed = true } + + var mk int32 + var mv float64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int32(dd.DecodeInt(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv @@ -26271,23 +36870,26 @@ func (_ fastpathT) DecMapInt32Float64V(v map[int32]float64, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int32(dd.DecodeInt(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt32BoolR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt32BoolR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int32]bool) v, changed := fastpathTV.DecMapInt32BoolV(*vp, fastpathCheckNilFalse, true, f.d) @@ -26308,7 +36910,8 @@ func (f fastpathT) DecMapInt32BoolX(vp *map[int32]bool, checkNil bool, d *Decode func (_ fastpathT) DecMapInt32BoolV(v map[int32]bool, checkNil bool, canChange bool, d *Decoder) (_ map[int32]bool, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -26318,17 +36921,22 @@ func (_ fastpathT) DecMapInt32BoolV(v map[int32]bool, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int32]bool, containerLen) - } else { - v = make(map[int32]bool) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5) + v = make(map[int32]bool, xlen) changed = true } + + var mk int32 + var mv bool if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := int32(dd.DecodeInt(32)) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeBool() if v != nil { v[mk] = mv @@ -26336,23 +36944,26 @@ func (_ fastpathT) DecMapInt32BoolV(v map[int32]bool, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = int32(dd.DecodeInt(32)) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := int32(dd.DecodeInt(32)) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeBool() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt64IntfR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt64IntfR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int64]interface{}) v, changed := fastpathTV.DecMapInt64IntfV(*vp, fastpathCheckNilFalse, true, f.d) @@ -26373,7 +36984,8 @@ func (f fastpathT) DecMapInt64IntfX(vp *map[int64]interface{}, checkNil bool, d func (_ fastpathT) DecMapInt64IntfV(v map[int64]interface{}, checkNil bool, canChange bool, d *Decoder) (_ map[int64]interface{}, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -26383,43 +36995,59 @@ func (_ fastpathT) DecMapInt64IntfV(v map[int64]interface{}, checkNil bool, canC containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int64]interface{}, containerLen) - } else { - v = make(map[int64]interface{}) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[int64]interface{}, xlen) changed = true } + mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + var mk int64 + var mv interface{} if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeInt(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } d.decode(&mv) - if v != nil { v[mk] = mv } } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil } - mk := dd.DecodeInt(64) - dd.ReadMapKVSeparator() - mv := v[mk] d.decode(&mv) - if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt64StringR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt64StringR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int64]string) v, changed := fastpathTV.DecMapInt64StringV(*vp, fastpathCheckNilFalse, true, f.d) @@ -26440,7 +37068,8 @@ func (f fastpathT) DecMapInt64StringX(vp *map[int64]string, checkNil bool, d *De func (_ fastpathT) DecMapInt64StringV(v map[int64]string, checkNil bool, canChange bool, d *Decoder) (_ map[int64]string, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -26450,17 +37079,22 @@ func (_ fastpathT) DecMapInt64StringV(v map[int64]string, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int64]string, containerLen) - } else { - v = make(map[int64]string) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24) + v = make(map[int64]string, xlen) changed = true } + + var mk int64 + var mv string if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeInt(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeString() if v != nil { v[mk] = mv @@ -26468,23 +37102,26 @@ func (_ fastpathT) DecMapInt64StringV(v map[int64]string, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeInt(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeString() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt64UintR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt64UintR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int64]uint) v, changed := fastpathTV.DecMapInt64UintV(*vp, fastpathCheckNilFalse, true, f.d) @@ -26505,7 +37142,8 @@ func (f fastpathT) DecMapInt64UintX(vp *map[int64]uint, checkNil bool, d *Decode func (_ fastpathT) DecMapInt64UintV(v map[int64]uint, checkNil bool, canChange bool, d *Decoder) (_ map[int64]uint, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -26515,17 +37153,22 @@ func (_ fastpathT) DecMapInt64UintV(v map[int64]uint, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int64]uint, containerLen) - } else { - v = make(map[int64]uint) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[int64]uint, xlen) changed = true } + + var mk int64 + var mv uint if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeInt(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv @@ -26533,23 +37176,26 @@ func (_ fastpathT) DecMapInt64UintV(v map[int64]uint, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeInt(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt64Uint8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt64Uint8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int64]uint8) v, changed := fastpathTV.DecMapInt64Uint8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -26570,7 +37216,8 @@ func (f fastpathT) DecMapInt64Uint8X(vp *map[int64]uint8, checkNil bool, d *Deco func (_ fastpathT) DecMapInt64Uint8V(v map[int64]uint8, checkNil bool, canChange bool, d *Decoder) (_ map[int64]uint8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -26580,17 +37227,22 @@ func (_ fastpathT) DecMapInt64Uint8V(v map[int64]uint8, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int64]uint8, containerLen) - } else { - v = make(map[int64]uint8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[int64]uint8, xlen) changed = true } + + var mk int64 + var mv uint8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeInt(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv @@ -26598,23 +37250,26 @@ func (_ fastpathT) DecMapInt64Uint8V(v map[int64]uint8, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeInt(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt64Uint16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt64Uint16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int64]uint16) v, changed := fastpathTV.DecMapInt64Uint16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -26635,7 +37290,8 @@ func (f fastpathT) DecMapInt64Uint16X(vp *map[int64]uint16, checkNil bool, d *De func (_ fastpathT) DecMapInt64Uint16V(v map[int64]uint16, checkNil bool, canChange bool, d *Decoder) (_ map[int64]uint16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -26645,17 +37301,22 @@ func (_ fastpathT) DecMapInt64Uint16V(v map[int64]uint16, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int64]uint16, containerLen) - } else { - v = make(map[int64]uint16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[int64]uint16, xlen) changed = true } + + var mk int64 + var mv uint16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeInt(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv @@ -26663,23 +37324,26 @@ func (_ fastpathT) DecMapInt64Uint16V(v map[int64]uint16, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeInt(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt64Uint32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt64Uint32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int64]uint32) v, changed := fastpathTV.DecMapInt64Uint32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -26700,7 +37364,8 @@ func (f fastpathT) DecMapInt64Uint32X(vp *map[int64]uint32, checkNil bool, d *De func (_ fastpathT) DecMapInt64Uint32V(v map[int64]uint32, checkNil bool, canChange bool, d *Decoder) (_ map[int64]uint32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -26710,17 +37375,22 @@ func (_ fastpathT) DecMapInt64Uint32V(v map[int64]uint32, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int64]uint32, containerLen) - } else { - v = make(map[int64]uint32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[int64]uint32, xlen) changed = true } + + var mk int64 + var mv uint32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeInt(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv @@ -26728,23 +37398,26 @@ func (_ fastpathT) DecMapInt64Uint32V(v map[int64]uint32, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeInt(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt64Uint64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt64Uint64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int64]uint64) v, changed := fastpathTV.DecMapInt64Uint64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -26765,7 +37438,8 @@ func (f fastpathT) DecMapInt64Uint64X(vp *map[int64]uint64, checkNil bool, d *De func (_ fastpathT) DecMapInt64Uint64V(v map[int64]uint64, checkNil bool, canChange bool, d *Decoder) (_ map[int64]uint64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -26775,17 +37449,22 @@ func (_ fastpathT) DecMapInt64Uint64V(v map[int64]uint64, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int64]uint64, containerLen) - } else { - v = make(map[int64]uint64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[int64]uint64, xlen) changed = true } + + var mk int64 + var mv uint64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeInt(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeUint(64) if v != nil { v[mk] = mv @@ -26793,23 +37472,100 @@ func (_ fastpathT) DecMapInt64Uint64V(v map[int64]uint64, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeInt(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeUint(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt64IntR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt64UintptrR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[int64]uintptr) + v, changed := fastpathTV.DecMapInt64UintptrV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[int64]uintptr) + fastpathTV.DecMapInt64UintptrV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapInt64UintptrX(vp *map[int64]uintptr, checkNil bool, d *Decoder) { + v, changed := f.DecMapInt64UintptrV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapInt64UintptrV(v map[int64]uintptr, checkNil bool, canChange bool, + d *Decoder) (_ map[int64]uintptr, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[int64]uintptr, xlen) + changed = true + } + + var mk int64 + var mv uintptr + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapInt64IntR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int64]int) v, changed := fastpathTV.DecMapInt64IntV(*vp, fastpathCheckNilFalse, true, f.d) @@ -26830,7 +37586,8 @@ func (f fastpathT) DecMapInt64IntX(vp *map[int64]int, checkNil bool, d *Decoder) func (_ fastpathT) DecMapInt64IntV(v map[int64]int, checkNil bool, canChange bool, d *Decoder) (_ map[int64]int, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -26840,17 +37597,22 @@ func (_ fastpathT) DecMapInt64IntV(v map[int64]int, checkNil bool, canChange boo containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int64]int, containerLen) - } else { - v = make(map[int64]int) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[int64]int, xlen) changed = true } + + var mk int64 + var mv int if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeInt(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv @@ -26858,23 +37620,26 @@ func (_ fastpathT) DecMapInt64IntV(v map[int64]int, checkNil bool, canChange boo } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeInt(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt64Int8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt64Int8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int64]int8) v, changed := fastpathTV.DecMapInt64Int8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -26895,7 +37660,8 @@ func (f fastpathT) DecMapInt64Int8X(vp *map[int64]int8, checkNil bool, d *Decode func (_ fastpathT) DecMapInt64Int8V(v map[int64]int8, checkNil bool, canChange bool, d *Decoder) (_ map[int64]int8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -26905,17 +37671,22 @@ func (_ fastpathT) DecMapInt64Int8V(v map[int64]int8, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int64]int8, containerLen) - } else { - v = make(map[int64]int8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[int64]int8, xlen) changed = true } + + var mk int64 + var mv int8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeInt(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv @@ -26923,23 +37694,26 @@ func (_ fastpathT) DecMapInt64Int8V(v map[int64]int8, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeInt(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt64Int16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt64Int16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int64]int16) v, changed := fastpathTV.DecMapInt64Int16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -26960,7 +37734,8 @@ func (f fastpathT) DecMapInt64Int16X(vp *map[int64]int16, checkNil bool, d *Deco func (_ fastpathT) DecMapInt64Int16V(v map[int64]int16, checkNil bool, canChange bool, d *Decoder) (_ map[int64]int16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -26970,17 +37745,22 @@ func (_ fastpathT) DecMapInt64Int16V(v map[int64]int16, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int64]int16, containerLen) - } else { - v = make(map[int64]int16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10) + v = make(map[int64]int16, xlen) changed = true } + + var mk int64 + var mv int16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeInt(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv @@ -26988,23 +37768,26 @@ func (_ fastpathT) DecMapInt64Int16V(v map[int64]int16, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeInt(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt64Int32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt64Int32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int64]int32) v, changed := fastpathTV.DecMapInt64Int32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -27025,7 +37808,8 @@ func (f fastpathT) DecMapInt64Int32X(vp *map[int64]int32, checkNil bool, d *Deco func (_ fastpathT) DecMapInt64Int32V(v map[int64]int32, checkNil bool, canChange bool, d *Decoder) (_ map[int64]int32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -27035,17 +37819,22 @@ func (_ fastpathT) DecMapInt64Int32V(v map[int64]int32, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int64]int32, containerLen) - } else { - v = make(map[int64]int32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[int64]int32, xlen) changed = true } + + var mk int64 + var mv int32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeInt(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv @@ -27053,23 +37842,26 @@ func (_ fastpathT) DecMapInt64Int32V(v map[int64]int32, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeInt(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt64Int64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt64Int64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int64]int64) v, changed := fastpathTV.DecMapInt64Int64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -27090,7 +37882,8 @@ func (f fastpathT) DecMapInt64Int64X(vp *map[int64]int64, checkNil bool, d *Deco func (_ fastpathT) DecMapInt64Int64V(v map[int64]int64, checkNil bool, canChange bool, d *Decoder) (_ map[int64]int64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -27100,17 +37893,22 @@ func (_ fastpathT) DecMapInt64Int64V(v map[int64]int64, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int64]int64, containerLen) - } else { - v = make(map[int64]int64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[int64]int64, xlen) changed = true } + + var mk int64 + var mv int64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeInt(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeInt(64) if v != nil { v[mk] = mv @@ -27118,23 +37916,26 @@ func (_ fastpathT) DecMapInt64Int64V(v map[int64]int64, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeInt(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeInt(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt64Float32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt64Float32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int64]float32) v, changed := fastpathTV.DecMapInt64Float32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -27155,7 +37956,8 @@ func (f fastpathT) DecMapInt64Float32X(vp *map[int64]float32, checkNil bool, d * func (_ fastpathT) DecMapInt64Float32V(v map[int64]float32, checkNil bool, canChange bool, d *Decoder) (_ map[int64]float32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -27165,17 +37967,22 @@ func (_ fastpathT) DecMapInt64Float32V(v map[int64]float32, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int64]float32, containerLen) - } else { - v = make(map[int64]float32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12) + v = make(map[int64]float32, xlen) changed = true } + + var mk int64 + var mv float32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeInt(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv @@ -27183,23 +37990,26 @@ func (_ fastpathT) DecMapInt64Float32V(v map[int64]float32, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeInt(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt64Float64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt64Float64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int64]float64) v, changed := fastpathTV.DecMapInt64Float64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -27220,7 +38030,8 @@ func (f fastpathT) DecMapInt64Float64X(vp *map[int64]float64, checkNil bool, d * func (_ fastpathT) DecMapInt64Float64V(v map[int64]float64, checkNil bool, canChange bool, d *Decoder) (_ map[int64]float64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -27230,17 +38041,22 @@ func (_ fastpathT) DecMapInt64Float64V(v map[int64]float64, checkNil bool, canCh containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int64]float64, containerLen) - } else { - v = make(map[int64]float64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16) + v = make(map[int64]float64, xlen) changed = true } + + var mk int64 + var mv float64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeInt(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv @@ -27248,23 +38064,26 @@ func (_ fastpathT) DecMapInt64Float64V(v map[int64]float64, checkNil bool, canCh } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeInt(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapInt64BoolR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapInt64BoolR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[int64]bool) v, changed := fastpathTV.DecMapInt64BoolV(*vp, fastpathCheckNilFalse, true, f.d) @@ -27285,7 +38104,8 @@ func (f fastpathT) DecMapInt64BoolX(vp *map[int64]bool, checkNil bool, d *Decode func (_ fastpathT) DecMapInt64BoolV(v map[int64]bool, checkNil bool, canChange bool, d *Decoder) (_ map[int64]bool, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -27295,17 +38115,22 @@ func (_ fastpathT) DecMapInt64BoolV(v map[int64]bool, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[int64]bool, containerLen) - } else { - v = make(map[int64]bool) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[int64]bool, xlen) changed = true } + + var mk int64 + var mv bool if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeInt(64) - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeBool() if v != nil { v[mk] = mv @@ -27313,23 +38138,26 @@ func (_ fastpathT) DecMapInt64BoolV(v map[int64]bool, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeInt(64) + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeInt(64) - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeBool() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapBoolIntfR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapBoolIntfR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[bool]interface{}) v, changed := fastpathTV.DecMapBoolIntfV(*vp, fastpathCheckNilFalse, true, f.d) @@ -27350,7 +38178,8 @@ func (f fastpathT) DecMapBoolIntfX(vp *map[bool]interface{}, checkNil bool, d *D func (_ fastpathT) DecMapBoolIntfV(v map[bool]interface{}, checkNil bool, canChange bool, d *Decoder) (_ map[bool]interface{}, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -27360,43 +38189,59 @@ func (_ fastpathT) DecMapBoolIntfV(v map[bool]interface{}, checkNil bool, canCha containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[bool]interface{}, containerLen) - } else { - v = make(map[bool]interface{}) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17) + v = make(map[bool]interface{}, xlen) changed = true } + mapGet := !d.h.MapValueReset && !d.h.InterfaceReset + var mk bool + var mv interface{} if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeBool() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil + } d.decode(&mv) - if v != nil { v[mk] = mv } } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) + } + if mapGet { + mv = v[mk] + } else { + mv = nil } - mk := dd.DecodeBool() - dd.ReadMapKVSeparator() - mv := v[mk] d.decode(&mv) - if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapBoolStringR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapBoolStringR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[bool]string) v, changed := fastpathTV.DecMapBoolStringV(*vp, fastpathCheckNilFalse, true, f.d) @@ -27417,7 +38262,8 @@ func (f fastpathT) DecMapBoolStringX(vp *map[bool]string, checkNil bool, d *Deco func (_ fastpathT) DecMapBoolStringV(v map[bool]string, checkNil bool, canChange bool, d *Decoder) (_ map[bool]string, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -27427,17 +38273,22 @@ func (_ fastpathT) DecMapBoolStringV(v map[bool]string, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[bool]string, containerLen) - } else { - v = make(map[bool]string) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17) + v = make(map[bool]string, xlen) changed = true } + + var mk bool + var mv string if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeBool() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeString() if v != nil { v[mk] = mv @@ -27445,23 +38296,26 @@ func (_ fastpathT) DecMapBoolStringV(v map[bool]string, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeBool() - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeString() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapBoolUintR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapBoolUintR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[bool]uint) v, changed := fastpathTV.DecMapBoolUintV(*vp, fastpathCheckNilFalse, true, f.d) @@ -27482,7 +38336,8 @@ func (f fastpathT) DecMapBoolUintX(vp *map[bool]uint, checkNil bool, d *Decoder) func (_ fastpathT) DecMapBoolUintV(v map[bool]uint, checkNil bool, canChange bool, d *Decoder) (_ map[bool]uint, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -27492,17 +38347,22 @@ func (_ fastpathT) DecMapBoolUintV(v map[bool]uint, checkNil bool, canChange boo containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[bool]uint, containerLen) - } else { - v = make(map[bool]uint) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[bool]uint, xlen) changed = true } + + var mk bool + var mv uint if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeBool() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv @@ -27510,23 +38370,26 @@ func (_ fastpathT) DecMapBoolUintV(v map[bool]uint, checkNil bool, canChange boo } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeBool() - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint(dd.DecodeUint(uintBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapBoolUint8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapBoolUint8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[bool]uint8) v, changed := fastpathTV.DecMapBoolUint8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -27547,7 +38410,8 @@ func (f fastpathT) DecMapBoolUint8X(vp *map[bool]uint8, checkNil bool, d *Decode func (_ fastpathT) DecMapBoolUint8V(v map[bool]uint8, checkNil bool, canChange bool, d *Decoder) (_ map[bool]uint8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -27557,17 +38421,22 @@ func (_ fastpathT) DecMapBoolUint8V(v map[bool]uint8, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[bool]uint8, containerLen) - } else { - v = make(map[bool]uint8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 2) + v = make(map[bool]uint8, xlen) changed = true } + + var mk bool + var mv uint8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeBool() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv @@ -27575,23 +38444,26 @@ func (_ fastpathT) DecMapBoolUint8V(v map[bool]uint8, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeBool() - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint8(dd.DecodeUint(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapBoolUint16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapBoolUint16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[bool]uint16) v, changed := fastpathTV.DecMapBoolUint16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -27612,7 +38484,8 @@ func (f fastpathT) DecMapBoolUint16X(vp *map[bool]uint16, checkNil bool, d *Deco func (_ fastpathT) DecMapBoolUint16V(v map[bool]uint16, checkNil bool, canChange bool, d *Decoder) (_ map[bool]uint16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -27622,17 +38495,22 @@ func (_ fastpathT) DecMapBoolUint16V(v map[bool]uint16, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[bool]uint16, containerLen) - } else { - v = make(map[bool]uint16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3) + v = make(map[bool]uint16, xlen) changed = true } + + var mk bool + var mv uint16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeBool() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv @@ -27640,23 +38518,26 @@ func (_ fastpathT) DecMapBoolUint16V(v map[bool]uint16, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeBool() - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint16(dd.DecodeUint(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapBoolUint32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapBoolUint32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[bool]uint32) v, changed := fastpathTV.DecMapBoolUint32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -27677,7 +38558,8 @@ func (f fastpathT) DecMapBoolUint32X(vp *map[bool]uint32, checkNil bool, d *Deco func (_ fastpathT) DecMapBoolUint32V(v map[bool]uint32, checkNil bool, canChange bool, d *Decoder) (_ map[bool]uint32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -27687,17 +38569,22 @@ func (_ fastpathT) DecMapBoolUint32V(v map[bool]uint32, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[bool]uint32, containerLen) - } else { - v = make(map[bool]uint32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5) + v = make(map[bool]uint32, xlen) changed = true } + + var mk bool + var mv uint32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeBool() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv @@ -27705,23 +38592,26 @@ func (_ fastpathT) DecMapBoolUint32V(v map[bool]uint32, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeBool() - dd.ReadMapKVSeparator() - mv := v[mk] mv = uint32(dd.DecodeUint(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapBoolUint64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapBoolUint64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[bool]uint64) v, changed := fastpathTV.DecMapBoolUint64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -27742,7 +38632,8 @@ func (f fastpathT) DecMapBoolUint64X(vp *map[bool]uint64, checkNil bool, d *Deco func (_ fastpathT) DecMapBoolUint64V(v map[bool]uint64, checkNil bool, canChange bool, d *Decoder) (_ map[bool]uint64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -27752,17 +38643,22 @@ func (_ fastpathT) DecMapBoolUint64V(v map[bool]uint64, checkNil bool, canChange containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[bool]uint64, containerLen) - } else { - v = make(map[bool]uint64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[bool]uint64, xlen) changed = true } + + var mk bool + var mv uint64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeBool() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeUint(64) if v != nil { v[mk] = mv @@ -27770,23 +38666,100 @@ func (_ fastpathT) DecMapBoolUint64V(v map[bool]uint64, checkNil bool, canChange } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeBool() - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeUint(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapBoolIntR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapBoolUintptrR(rv reflect.Value) { + if rv.CanAddr() { + vp := rv.Addr().Interface().(*map[bool]uintptr) + v, changed := fastpathTV.DecMapBoolUintptrV(*vp, fastpathCheckNilFalse, true, f.d) + if changed { + *vp = v + } + } else { + v := rv.Interface().(map[bool]uintptr) + fastpathTV.DecMapBoolUintptrV(v, fastpathCheckNilFalse, false, f.d) + } +} +func (f fastpathT) DecMapBoolUintptrX(vp *map[bool]uintptr, checkNil bool, d *Decoder) { + v, changed := f.DecMapBoolUintptrV(*vp, checkNil, true, d) + if changed { + *vp = v + } +} +func (_ fastpathT) DecMapBoolUintptrV(v map[bool]uintptr, checkNil bool, canChange bool, + d *Decoder) (_ map[bool]uintptr, changed bool) { + dd := d.d + cr := d.cr + + if checkNil && dd.TryDecodeAsNil() { + if v != nil { + changed = true + } + return nil, changed + } + + containerLen := dd.ReadMapStart() + if canChange && v == nil { + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[bool]uintptr, xlen) + changed = true + } + + var mk bool + var mv uintptr + if containerLen > 0 { + for j := 0; j < containerLen; j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } else if containerLen < 0 { + for j := 0; !dd.CheckBreak(); j++ { + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) + } + mv = uintptr(dd.DecodeUint(uintBitsize)) + if v != nil { + v[mk] = mv + } + } + } + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + return v, changed +} + +func (f *decFnInfo) fastpathDecMapBoolIntR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[bool]int) v, changed := fastpathTV.DecMapBoolIntV(*vp, fastpathCheckNilFalse, true, f.d) @@ -27807,7 +38780,8 @@ func (f fastpathT) DecMapBoolIntX(vp *map[bool]int, checkNil bool, d *Decoder) { func (_ fastpathT) DecMapBoolIntV(v map[bool]int, checkNil bool, canChange bool, d *Decoder) (_ map[bool]int, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -27817,17 +38791,22 @@ func (_ fastpathT) DecMapBoolIntV(v map[bool]int, checkNil bool, canChange bool, containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[bool]int, containerLen) - } else { - v = make(map[bool]int) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[bool]int, xlen) changed = true } + + var mk bool + var mv int if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeBool() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv @@ -27835,23 +38814,26 @@ func (_ fastpathT) DecMapBoolIntV(v map[bool]int, checkNil bool, canChange bool, } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeBool() - dd.ReadMapKVSeparator() - mv := v[mk] mv = int(dd.DecodeInt(intBitsize)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapBoolInt8R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapBoolInt8R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[bool]int8) v, changed := fastpathTV.DecMapBoolInt8V(*vp, fastpathCheckNilFalse, true, f.d) @@ -27872,7 +38854,8 @@ func (f fastpathT) DecMapBoolInt8X(vp *map[bool]int8, checkNil bool, d *Decoder) func (_ fastpathT) DecMapBoolInt8V(v map[bool]int8, checkNil bool, canChange bool, d *Decoder) (_ map[bool]int8, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -27882,17 +38865,22 @@ func (_ fastpathT) DecMapBoolInt8V(v map[bool]int8, checkNil bool, canChange boo containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[bool]int8, containerLen) - } else { - v = make(map[bool]int8) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 2) + v = make(map[bool]int8, xlen) changed = true } + + var mk bool + var mv int8 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeBool() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv @@ -27900,23 +38888,26 @@ func (_ fastpathT) DecMapBoolInt8V(v map[bool]int8, checkNil bool, canChange boo } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeBool() - dd.ReadMapKVSeparator() - mv := v[mk] mv = int8(dd.DecodeInt(8)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapBoolInt16R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapBoolInt16R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[bool]int16) v, changed := fastpathTV.DecMapBoolInt16V(*vp, fastpathCheckNilFalse, true, f.d) @@ -27937,7 +38928,8 @@ func (f fastpathT) DecMapBoolInt16X(vp *map[bool]int16, checkNil bool, d *Decode func (_ fastpathT) DecMapBoolInt16V(v map[bool]int16, checkNil bool, canChange bool, d *Decoder) (_ map[bool]int16, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -27947,17 +38939,22 @@ func (_ fastpathT) DecMapBoolInt16V(v map[bool]int16, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[bool]int16, containerLen) - } else { - v = make(map[bool]int16) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3) + v = make(map[bool]int16, xlen) changed = true } + + var mk bool + var mv int16 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeBool() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv @@ -27965,23 +38962,26 @@ func (_ fastpathT) DecMapBoolInt16V(v map[bool]int16, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeBool() - dd.ReadMapKVSeparator() - mv := v[mk] mv = int16(dd.DecodeInt(16)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapBoolInt32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapBoolInt32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[bool]int32) v, changed := fastpathTV.DecMapBoolInt32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -28002,7 +39002,8 @@ func (f fastpathT) DecMapBoolInt32X(vp *map[bool]int32, checkNil bool, d *Decode func (_ fastpathT) DecMapBoolInt32V(v map[bool]int32, checkNil bool, canChange bool, d *Decoder) (_ map[bool]int32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -28012,17 +39013,22 @@ func (_ fastpathT) DecMapBoolInt32V(v map[bool]int32, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[bool]int32, containerLen) - } else { - v = make(map[bool]int32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5) + v = make(map[bool]int32, xlen) changed = true } + + var mk bool + var mv int32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeBool() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv @@ -28030,23 +39036,26 @@ func (_ fastpathT) DecMapBoolInt32V(v map[bool]int32, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeBool() - dd.ReadMapKVSeparator() - mv := v[mk] mv = int32(dd.DecodeInt(32)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapBoolInt64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapBoolInt64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[bool]int64) v, changed := fastpathTV.DecMapBoolInt64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -28067,7 +39076,8 @@ func (f fastpathT) DecMapBoolInt64X(vp *map[bool]int64, checkNil bool, d *Decode func (_ fastpathT) DecMapBoolInt64V(v map[bool]int64, checkNil bool, canChange bool, d *Decoder) (_ map[bool]int64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -28077,17 +39087,22 @@ func (_ fastpathT) DecMapBoolInt64V(v map[bool]int64, checkNil bool, canChange b containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[bool]int64, containerLen) - } else { - v = make(map[bool]int64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[bool]int64, xlen) changed = true } + + var mk bool + var mv int64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeBool() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeInt(64) if v != nil { v[mk] = mv @@ -28095,23 +39110,26 @@ func (_ fastpathT) DecMapBoolInt64V(v map[bool]int64, checkNil bool, canChange b } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeBool() - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeInt(64) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapBoolFloat32R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapBoolFloat32R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[bool]float32) v, changed := fastpathTV.DecMapBoolFloat32V(*vp, fastpathCheckNilFalse, true, f.d) @@ -28132,7 +39150,8 @@ func (f fastpathT) DecMapBoolFloat32X(vp *map[bool]float32, checkNil bool, d *De func (_ fastpathT) DecMapBoolFloat32V(v map[bool]float32, checkNil bool, canChange bool, d *Decoder) (_ map[bool]float32, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -28142,17 +39161,22 @@ func (_ fastpathT) DecMapBoolFloat32V(v map[bool]float32, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[bool]float32, containerLen) - } else { - v = make(map[bool]float32) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5) + v = make(map[bool]float32, xlen) changed = true } + + var mk bool + var mv float32 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeBool() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv @@ -28160,23 +39184,26 @@ func (_ fastpathT) DecMapBoolFloat32V(v map[bool]float32, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeBool() - dd.ReadMapKVSeparator() - mv := v[mk] mv = float32(dd.DecodeFloat(true)) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapBoolFloat64R(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapBoolFloat64R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[bool]float64) v, changed := fastpathTV.DecMapBoolFloat64V(*vp, fastpathCheckNilFalse, true, f.d) @@ -28197,7 +39224,8 @@ func (f fastpathT) DecMapBoolFloat64X(vp *map[bool]float64, checkNil bool, d *De func (_ fastpathT) DecMapBoolFloat64V(v map[bool]float64, checkNil bool, canChange bool, d *Decoder) (_ map[bool]float64, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -28207,17 +39235,22 @@ func (_ fastpathT) DecMapBoolFloat64V(v map[bool]float64, checkNil bool, canChan containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[bool]float64, containerLen) - } else { - v = make(map[bool]float64) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9) + v = make(map[bool]float64, xlen) changed = true } + + var mk bool + var mv float64 if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeBool() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv @@ -28225,23 +39258,26 @@ func (_ fastpathT) DecMapBoolFloat64V(v map[bool]float64, checkNil bool, canChan } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeBool() - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeFloat(false) if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } -func (f decFnInfo) fastpathDecMapBoolBoolR(rv reflect.Value) { +func (f *decFnInfo) fastpathDecMapBoolBoolR(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[bool]bool) v, changed := fastpathTV.DecMapBoolBoolV(*vp, fastpathCheckNilFalse, true, f.d) @@ -28262,7 +39298,8 @@ func (f fastpathT) DecMapBoolBoolX(vp *map[bool]bool, checkNil bool, d *Decoder) func (_ fastpathT) DecMapBoolBoolV(v map[bool]bool, checkNil bool, canChange bool, d *Decoder) (_ map[bool]bool, changed bool) { dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() + cr := d.cr + if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -28272,17 +39309,22 @@ func (_ fastpathT) DecMapBoolBoolV(v map[bool]bool, checkNil bool, canChange boo containerLen := dd.ReadMapStart() if canChange && v == nil { - if containerLen > 0 { - v = make(map[bool]bool, containerLen) - } else { - v = make(map[bool]bool) // supports indefinite-length, etc - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 2) + v = make(map[bool]bool, xlen) changed = true } + + var mk bool + var mv bool if containerLen > 0 { for j := 0; j < containerLen; j++ { - mk := dd.DecodeBool() - mv := v[mk] + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) + } mv = dd.DecodeBool() if v != nil { v[mk] = mv @@ -28290,18 +39332,21 @@ func (_ fastpathT) DecMapBoolBoolV(v map[bool]bool, checkNil bool, canChange boo } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) + } + mk = dd.DecodeBool() + if cr != nil { + cr.sendContainerState(containerMapValue) } - mk := dd.DecodeBool() - dd.ReadMapKVSeparator() - mv := v[mk] mv = dd.DecodeBool() if v != nil { v[mk] = mv } } - dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } return v, changed } diff --git a/_vendor/vendor/github.com/ugorji/go/codec/fast-path.not.go b/_vendor/vendor/github.com/ugorji/go/codec/fast-path.not.go new file mode 100644 index 0000000..63e5911 --- /dev/null +++ b/_vendor/vendor/github.com/ugorji/go/codec/fast-path.not.go @@ -0,0 +1,34 @@ +// +build notfastpath + +package codec + +import "reflect" + +const fastpathEnabled = false + +// The generated fast-path code is very large, and adds a few seconds to the build time. +// This causes test execution, execution of small tools which use codec, etc +// to take a long time. +// +// To mitigate, we now support the notfastpath tag. +// This tag disables fastpath during build, allowing for faster build, test execution, +// short-program runs, etc. + +func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { return false } +func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { return false } +func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { return false } +func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { return false } + +type fastpathT struct{} +type fastpathE struct { + rtid uintptr + rt reflect.Type + encfn func(*encFnInfo, reflect.Value) + decfn func(*decFnInfo, reflect.Value) +} +type fastpathA [0]fastpathE + +func (x fastpathA) index(rtid uintptr) int { return -1 } + +var fastpathAV fastpathA +var fastpathTV fastpathT diff --git a/cmd/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl b/_vendor/vendor/github.com/ugorji/go/codec/gen-helper.generated.go similarity index 50% rename from cmd/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl rename to _vendor/vendor/github.com/ugorji/go/codec/gen-helper.generated.go index 89d7518..22bce77 100644 --- a/cmd/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl +++ b/_vendor/vendor/github.com/ugorji/go/codec/gen-helper.generated.go @@ -10,241 +10,224 @@ package codec -// 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 +import ( + "encoding" + "reflect" +) + +// 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 continously and without notice. -// +// // To help enforce this, we create an unexported type with exported members. // The only way to get the type is via the one exported type that we control (somewhat). -// +// // When static codecs are created for types, they will use this value // to perform encoding or decoding of primitives or known slice or map types. // GenHelperEncoder is exported so that it can be used externally by codecgen. // Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE. func GenHelperEncoder(e *Encoder) (genHelperEncoder, encDriver) { - return genHelperEncoder{e:e}, e.e + return genHelperEncoder{e: e}, e.e } // GenHelperDecoder is exported so that it can be used externally by codecgen. // Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE. func GenHelperDecoder(d *Decoder) (genHelperDecoder, decDriver) { - return genHelperDecoder{d:d}, d.d + return genHelperDecoder{d: d}, d.d } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* type genHelperEncoder struct { e *Encoder - F fastpathT + F fastpathT } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* type genHelperDecoder struct { d *Decoder - F fastpathT + F fastpathT } // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) EncBasicHandle() *BasicHandle { return f.e.h } + // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) EncBinary() bool { return f.e.be // f.e.hh.isBinaryEncoding() } + // 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) } +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperEncoder) EncTextMarshal(iv encoding.TextMarshaler) { + bs, fnerr := iv.MarshalText() + f.e.marshal(bs, fnerr, false, c_UTF8) +} + +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperEncoder) EncJSONMarshal(iv jsonMarshaler) { + bs, fnerr := iv.MarshalJSON() + f.e.marshal(bs, fnerr, true, c_UTF8) +} + +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) { + bs, fnerr := iv.MarshalBinary() + f.e.marshal(bs, fnerr, false, c_RAW) +} + +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperEncoder) TimeRtidIfBinc() uintptr { + if _, ok := f.e.hh.(*BincHandle); ok { + return timeTypId + } + return 0 +} + +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperEncoder) IsJSONHandle() bool { + return f.e.js +} + +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperEncoder) 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) EncExt(v interface{}) (r bool) { + rt := reflect.TypeOf(v) + if rt.Kind() == reflect.Ptr { + rt = rt.Elem() + } + rtid := reflect.ValueOf(rt).Pointer() + if xfFn := f.e.h.getExt(rtid); xfFn != nil { + f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext, f.e) + return true + } + return false +} + +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperEncoder) EncSendContainerState(c containerState) { + if f.e.cr != nil { + f.e.cr.sendContainerState(c) + } +} + +// ---------------- DECODER FOLLOWS ----------------- + // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecBasicHandle() *BasicHandle { return f.d.h } + // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecBinary() bool { - return f.d.be // f.d.hh.isBinaryEncoding() + return f.d.be // f.d.hh.isBinaryEncoding() } + // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecSwallow() { f.d.swallow() } + // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecScratchBuffer() []byte { return f.d.b[:] } + // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecFallback(iv interface{}, chkPtr bool) { // println(">>>>>>>>> DecFallback") f.d.decodeI(iv, chkPtr, false, false, false) } + // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecSliceHelperStart() (decSliceHelper, int) { return f.d.decSliceHelperStart() } + // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecStructFieldNotFound(index int, name string) { f.d.structFieldNotFound(index, name) } + // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperDecoder) DecArrayCannotExpand(sliceLen, streamLen int) { f.d.arrayCannotExpand(sliceLen, streamLen) } - -{{/* - // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncDriver() encDriver { - return f.e.e -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecDriver() decDriver { - return f.d.d -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncNil() { - f.e.e.EncodeNil() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncBytes(v []byte) { - f.e.e.EncodeStringBytes(c_RAW, v) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncArrayStart(length int) { - f.e.e.EncodeArrayStart(length) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncArrayEnd() { - f.e.e.EncodeArrayEnd() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncArrayEntrySeparator() { - f.e.e.EncodeArrayEntrySeparator() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncMapStart(length int) { - f.e.e.EncodeMapStart(length) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncMapEnd() { - f.e.e.EncodeMapEnd() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncMapEntrySeparator() { - f.e.e.EncodeMapEntrySeparator() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncMapKVSeparator() { - f.e.e.EncodeMapKVSeparator() -} - -// --------- - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecBytes(v *[]byte) { - *v = f.d.d.DecodeBytes(*v) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecTryNil() bool { - return f.d.d.TryDecodeAsNil() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecContainerIsNil() (b bool) { - return f.d.d.IsContainerType(valueTypeNil) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecContainerIsMap() (b bool) { - return f.d.d.IsContainerType(valueTypeMap) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecContainerIsArray() (b bool) { - return f.d.d.IsContainerType(valueTypeArray) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecCheckBreak() bool { - return f.d.d.CheckBreak() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecMapStart() int { - return f.d.d.ReadMapStart() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecArrayStart() int { - return f.d.d.ReadArrayStart() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecMapEnd() { - f.d.d.ReadMapEnd() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecArrayEnd() { - f.d.d.ReadArrayEnd() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecArrayEntrySeparator() { - f.d.d.ReadArrayEntrySeparator() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecMapEntrySeparator() { - f.d.d.ReadMapEntrySeparator() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecMapKVSeparator() { - f.d.d.ReadMapKVSeparator() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) ReadStringAsBytes(bs []byte) []byte { - return f.d.d.DecodeStringAsBytes(bs) -} - - -// -- encode calls (primitives) -{{range .Values}}{{if .Primitive }}{{if ne .Primitive "interface{}" }} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) {{ .MethodNamePfx "Enc" true }}(v {{ .Primitive }}) { - ee := f.e.e - {{ encmd .Primitive "v" }} -} -{{ end }}{{ end }}{{ end }} - -// -- decode calls (primitives) -{{range .Values}}{{if .Primitive }}{{if ne .Primitive "interface{}" }} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) {{ .MethodNamePfx "Dec" true }}(vp *{{ .Primitive }}) { - dd := f.d.d - *vp = {{ decmd .Primitive }} -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) {{ .MethodNamePfx "Read" true }}() (v {{ .Primitive }}) { - dd := f.d.d - v = {{ decmd .Primitive }} - return -} -{{ end }}{{ end }}{{ end }} - - -// -- encode calls (slices/maps) -{{range .Values}}{{if not .Primitive }}{{if .Slice }} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) {{ .MethodNamePfx "Enc" false }}(v []{{ .Elem }}) { {{ else }} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) {{ .MethodNamePfx "Enc" false }}(v map[{{ .MapKey }}]{{ .Elem }}) { {{end}} - f.F.{{ .MethodNamePfx "Enc" false }}V(v, false, f.e) -} -{{ end }}{{ end }} - -// -- decode calls (slices/maps) -{{range .Values}}{{if not .Primitive }} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -{{if .Slice }}func (f genHelperDecoder) {{ .MethodNamePfx "Dec" false }}(vp *[]{{ .Elem }}) { -{{else}}func (f genHelperDecoder) {{ .MethodNamePfx "Dec" false }}(vp *map[{{ .MapKey }}]{{ .Elem }}) { {{end}} - v, changed := f.F.{{ .MethodNamePfx "Dec" false }}V(*vp, false, true, f.d) - if changed { - *vp = v +func (f genHelperDecoder) DecTextUnmarshal(tm encoding.TextUnmarshaler) { + fnerr := tm.UnmarshalText(f.d.d.DecodeBytes(f.d.b[:], true, true)) + if fnerr != nil { + panic(fnerr) + } +} + +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperDecoder) DecJSONUnmarshal(tm jsonUnmarshaler) { + // bs := f.dd.DecodeBytes(f.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(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) { + fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, false, true)) + if fnerr != nil { + panic(fnerr) + } +} + +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperDecoder) TimeRtidIfBinc() uintptr { + if _, ok := f.d.hh.(*BincHandle); ok { + return timeTypId + } + return 0 +} + +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperDecoder) IsJSONHandle() bool { + return f.d.js +} + +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperDecoder) 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) DecExt(v interface{}) (r bool) { + rt := reflect.TypeOf(v).Elem() + rtid := reflect.ValueOf(rt).Pointer() + if xfFn := f.d.h.getExt(rtid); 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, truncated bool) { + return decInferLen(clen, maxlen, unit) +} + +// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* +func (f genHelperDecoder) DecSendContainerState(c containerState) { + if f.d.cr != nil { + f.d.cr.sendContainerState(c) } } -{{ end }}{{ end }} -*/}} diff --git a/_vendor/vendor/github.com/ugorji/go/codec/gen.generated.go b/_vendor/vendor/github.com/ugorji/go/codec/gen.generated.go new file mode 100644 index 0000000..2ace97b --- /dev/null +++ b/_vendor/vendor/github.com/ugorji/go/codec/gen.generated.go @@ -0,0 +1,175 @@ +// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Use of this source code is governed by a MIT license found in the LICENSE file. + +package codec + +// DO NOT EDIT. THIS FILE IS AUTO-GENERATED FROM gen-dec-(map|array).go.tmpl + +const genDecMapTmpl = ` +{{var "v"}} := *{{ .Varname }} +{{var "l"}} := r.ReadMapStart() +{{var "bh"}} := z.DecBasicHandle() +if {{var "v"}} == nil { + {{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"}} {{if decElemKindPtr}}, {{var "ms"}}, {{var "mok"}}{{end}} bool +if {{var "bh"}}.MapValueReset { + {{if decElemKindPtr}}{{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 { +for {{var "j"}} := 0; {{var "j"}} < {{var "l"}}; {{var "j"}}++ { + 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}} + if {{var "mg"}} { + {{if decElemKindPtr}}{{var "mv"}}, {{var "mok"}} = {{var "v"}}[{{var "mk"}}] + if {{var "mok"}} { + {{var "ms"}} = false + } {{else}}{{var "mv"}} = {{var "v"}}[{{var "mk"}}] {{end}} + } {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}} + z.DecSendContainerState(codecSelfer_containerMapValue{{ .Sfx }}) + {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ decLineVar $x }} + if {{if decElemKindPtr}} {{var "ms"}} && {{end}} {{var "v"}} != nil { + {{var "v"}}[{{var "mk"}}] = {{var "mv"}} + } +} +} else if {{var "l"}} < 0 { +for {{var "j"}} := 0; !r.CheckBreak(); {{var "j"}}++ { + 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 }} + if {{var "mg"}} { + {{if decElemKindPtr}}{{var "mv"}}, {{var "mok"}} = {{var "v"}}[{{var "mk"}}] + if {{var "mok"}} { + {{var "ms"}} = false + } {{else}}{{var "mv"}} = {{var "v"}}[{{var "mk"}}] {{end}} + } {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}} + z.DecSendContainerState(codecSelfer_containerMapValue{{ .Sfx }}) + {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ decLineVar $x }} + 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.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 {{var "c"}} bool {{/* // changed */}} +_ = {{var "c"}}{{end}} +if {{var "l"}} == 0 { + {{if isSlice }}if {{var "v"}} == nil { + {{var "v"}} = []{{ .Typ }}{} + {{var "c"}} = true + } else if len({{var "v"}}) != 0 { + {{var "v"}} = {{var "v"}}[:0] + {{var "c"}} = true + } {{end}} {{if isChan }}if {{var "v"}} == nil { + {{var "v"}} = make({{ .CTyp }}, 0) + {{var "c"}} = true + } {{end}} +} else if {{var "l"}} > 0 { + {{if isChan }}if {{var "v"}} == nil { + {{var "rl"}}, _ = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }}) + {{var "v"}} = make({{ .CTyp }}, {{var "rl"}}) + {{var "c"}} = true + } + for {{var "r"}} := 0; {{var "r"}} < {{var "l"}}; {{var "r"}}++ { + {{var "h"}}.ElemContainerState({{var "r"}}) + var {{var "t"}} {{ .Typ }} + {{ $x := printf "%st%s" .TempVar .Rand }}{{ decLineVar $x }} + {{var "v"}} <- {{var "t"}} + } + {{ else }} var {{var "rr"}}, {{var "rl"}} int {{/* // num2read, length of slice/array/chan */}} + var {{var "rt"}} bool {{/* truncated */}} + _, _ = {{var "rl"}}, {{var "rt"}} + {{var "rr"}} = {{var "l"}} // len({{var "v"}}) + if {{var "l"}} > cap({{var "v"}}) { + {{if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "l"}}) + {{ else }}{{if not .Immutable }} + {{var "rg"}} := len({{var "v"}}) > 0 + {{var "v2"}} := {{var "v"}} {{end}} + {{var "rl"}}, {{var "rt"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }}) + if {{var "rt"}} { + if {{var "rl"}} <= cap({{var "v"}}) { + {{var "v"}} = {{var "v"}}[:{{var "rl"}}] + } else { + {{var "v"}} = make([]{{ .Typ }}, {{var "rl"}}) + } + } else { + {{var "v"}} = make([]{{ .Typ }}, {{var "rl"}}) + } + {{var "c"}} = true + {{var "rr"}} = len({{var "v"}}) {{if not .Immutable }} + if {{var "rg"}} { copy({{var "v"}}, {{var "v2"}}) } {{end}} {{end}}{{/* end not Immutable, isArray */}} + } {{if isSlice }} else if {{var "l"}} != len({{var "v"}}) { + {{var "v"}} = {{var "v"}}[:{{var "l"}}] + {{var "c"}} = true + } {{end}} {{/* end isSlice:47 */}} + {{var "j"}} := 0 + for ; {{var "j"}} < {{var "rr"}} ; {{var "j"}}++ { + {{var "h"}}.ElemContainerState({{var "j"}}) + {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }} + } + {{if isArray }}for ; {{var "j"}} < {{var "l"}} ; {{var "j"}}++ { + {{var "h"}}.ElemContainerState({{var "j"}}) + z.DecSwallow() + } + {{ else }}if {{var "rt"}} { + for ; {{var "j"}} < {{var "l"}} ; {{var "j"}}++ { + {{var "v"}} = append({{var "v"}}, {{ zero}}) + {{var "h"}}.ElemContainerState({{var "j"}}) + {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }} + } + } {{end}} {{/* end isArray:56 */}} + {{end}} {{/* end isChan:16 */}} +} else { {{/* len < 0 */}} + {{var "j"}} := 0 + for ; !r.CheckBreak(); {{var "j"}}++ { + {{if isChan }} + {{var "h"}}.ElemContainerState({{var "j"}}) + var {{var "t"}} {{ .Typ }} + {{ $x := printf "%st%s" .TempVar .Rand }}{{ decLineVar $x }} + {{var "v"}} <- {{var "t"}} + {{ else }} + if {{var "j"}} >= len({{var "v"}}) { + {{if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "j"}}+1) + {{ else }}{{var "v"}} = append({{var "v"}}, {{zero}})// var {{var "z"}} {{ .Typ }} + {{var "c"}} = true {{end}} + } + {{var "h"}}.ElemContainerState({{var "j"}}) + if {{var "j"}} < len({{var "v"}}) { + {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }} + } else { + z.DecSwallow() + } + {{end}} + } + {{if isSlice }}if {{var "j"}} < len({{var "v"}}) { + {{var "v"}} = {{var "v"}}[:{{var "j"}}] + {{var "c"}} = true + } else if {{var "j"}} == 0 && {{var "v"}} == nil { + {{var "v"}} = []{{ .Typ }}{} + {{var "c"}} = true + }{{end}} +} +{{var "h"}}.End() +{{if not isArray }}if {{var "c"}} { + *{{ .Varname }} = {{var "v"}} +}{{end}} +` + diff --git a/cmd/vendor/github.com/ugorji/go/codec/gen.go b/_vendor/vendor/github.com/ugorji/go/codec/gen.go similarity index 65% rename from cmd/vendor/github.com/ugorji/go/codec/gen.go rename to _vendor/vendor/github.com/ugorji/go/codec/gen.go index b1eee33..ac8cc6d 100644 --- a/cmd/vendor/github.com/ugorji/go/codec/gen.go +++ b/_vendor/vendor/github.com/ugorji/go/codec/gen.go @@ -14,22 +14,36 @@ import ( "math/rand" "reflect" "regexp" + "sort" "strconv" "strings" "sync" "text/template" "time" + "unicode" + "unicode/utf8" ) // --------------------------------------------------- -// codecgen only works in the following: -// - extensions are not supported. Do not make a type a Selfer and an extension. -// - Selfer takes precedence. -// Any type that implements it knows how to encode/decode itself statically. -// Extensions are only known at runtime. -// codecgen only looks at the Kind of the type. +// codecgen supports the full cycle of reflection-based codec: +// - RawExt +// - Builtins +// - Extensions +// - (Binary|Text|JSON)(Unm|M)arshal +// - generic by-kind // -// - the following types are supported: +// This means that, for dynamic things, we MUST use reflection to at least get the reflect.Type. +// In those areas, we try to only do reflection or interface-conversion when NECESSARY: +// - Extensions, only if Extensions are configured. +// +// However, codecgen doesn't support the following: +// - Canonical option. (codecgen IGNORES it currently) +// This is just because it has not been implemented. +// +// During encode/decode, Selfer takes precedence. +// A type implementing Selfer will know how to encode/decode itself statically. +// +// The following field types are supported: // array: [n]T // slice: []T // map: map[K]V @@ -66,11 +80,25 @@ import ( // It was a concious decision to have gen.go always explicitly call EncodeNil or TryDecodeAsNil. // This way, there isn't a function call overhead just to see that we should not enter a block of code. -const GenVersion = 2 // increment this value each time codecgen changes fundamentally. +// GenVersion is the current version of codecgen. +// +// NOTE: Increment this value each time codecgen changes fundamentally. +// Fundamental changes are: +// - helper methods change (signature change, new ones added, some removed, etc) +// - codecgen command line changes +// +// v1: Initial Version +// v2: +// v3: Changes for Kubernetes: +// changes in signature of some unpublished helper methods and codecgen cmdline arguments. +// v4: Removed separator support from (en|de)cDriver, and refactored codec(gen) +// v5: changes to support faster json decoding. Let encoder/decoder maintain state of collections. +const GenVersion = 5 const ( - genCodecPkg = "codec1978" - genTempVarPfx = "yy" + genCodecPkg = "codec1978" + genTempVarPfx = "yy" + genTopLevelVarName = "x" // ignore canBeNil parameter, and always set to true. // This is because nil can appear anywhere, so we should always check. @@ -84,40 +112,68 @@ const ( genUseOneFunctionForDecStructMap = true ) +type genStructMapStyle uint8 + +const ( + genStructMapStyleConsolidated genStructMapStyle = iota + genStructMapStyleLenPrefix + genStructMapStyleCheckBreak +) + var ( genAllTypesSamePkgErr = errors.New("All types must be in the same package") genExpectArrayOrMapErr = errors.New("unexpected type. Expecting array/map/slice") genBase64enc = base64.NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789__") genQNameRegex = regexp.MustCompile(`[A-Za-z_.]+`) + genCheckVendor bool ) // genRunner holds some state used during a Gen run. type genRunner struct { w io.Writer // output - c uint64 // ctr used for generating varsfx + c uint64 // counter used for generating varsfx 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 - cp string // codec import path - im map[string]reflect.Type // imports to add + 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 + cp string // codec import path + + im map[string]reflect.Type // imports to add + imn map[string]string // package names of imports to add + imc uint64 // counter for import numbers + is map[reflect.Type]struct{} // types seen during import search bp string // base PkgPath, for which we are generating for cpfx string // codec package prefix unsafe bool // is unsafe to be used in generated code? - ts map[reflect.Type]struct{} // types for which enc/dec must be generated - xs string // top level variable/constant suffix - hn string // fn helper type name + tm map[reflect.Type]struct{} // types for which enc/dec must be generated + ts []reflect.Type // types for which enc/dec must be generated - rr *rand.Rand // random generator for file-specific types + xs string // top level variable/constant suffix + hn string // fn helper type name + + ti *TypeInfos + // rr *rand.Rand // random generator for file-specific types } // Gen will write a complete go file containing Selfer implementations for each // type passed. All the types must be in the same package. -func Gen(w io.Writer, buildTags, pkgName string, useUnsafe bool, typ ...reflect.Type) { +// +// Library users: *DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE.* +func Gen(w io.Writer, buildTags, pkgName, uid string, useUnsafe bool, ti *TypeInfos, typ ...reflect.Type) { + // trim out all types which already implement Selfer + typ2 := make([]reflect.Type, 0, len(typ)) + for _, t := range typ { + if reflect.PtrTo(t).Implements(selferTyp) || t.Implements(selferTyp) { + continue + } + typ2 = append(typ2, t) + } + typ = typ2 + if len(typ) == 0 { return } @@ -128,17 +184,28 @@ func Gen(w io.Writer, buildTags, pkgName string, useUnsafe bool, typ ...reflect. te: make(map[uintptr]bool), td: make(map[uintptr]bool), im: make(map[string]reflect.Type), + imn: make(map[string]string), is: make(map[reflect.Type]struct{}), - ts: make(map[reflect.Type]struct{}), - bp: typ[0].PkgPath(), - rr: rand.New(rand.NewSource(time.Now().UnixNano())), + tm: make(map[reflect.Type]struct{}), + ts: []reflect.Type{}, + bp: genImportPath(typ[0]), + xs: uid, + ti: ti, + } + if x.ti == nil { + x.ti = defTypeInfos + } + if x.xs == "" { + rr := rand.New(rand.NewSource(time.Now().UnixNano())) + x.xs = strconv.FormatInt(rr.Int63n(9999), 10) } // gather imports first: - x.cp = reflect.TypeOf(x).PkgPath() + x.cp = genImportPath(reflect.TypeOf(x)) + x.imn[x.cp] = genCodecPkg for _, t := range typ { - // fmt.Printf("###########: PkgPath: '%v', Name: '%s'\n", t.PkgPath(), t.Name()) - if t.PkgPath() != x.bp { + // fmt.Printf("###########: PkgPath: '%v', Name: '%s'\n", genImportPath(t), t.Name()) + if genImportPath(t) != x.bp { panic(genAllTypesSamePkgErr) } x.genRefPkgs(t) @@ -162,8 +229,14 @@ func Gen(w io.Writer, buildTags, pkgName string, useUnsafe bool, typ ...reflect. x.cpfx = genCodecPkg + "." x.linef("%s \"%s\"", genCodecPkg, x.cp) } + // use a sorted set of im keys, so that we can get consistent output + imKeys := make([]string, 0, len(x.im)) for k, _ := range x.im { - x.line("\"" + k + "\"") + imKeys = append(imKeys, k) + } + sort.Strings(imKeys) + for _, k := range imKeys { // for k, _ := range x.im { + x.linef("%s \"%s\"", x.imn[k], k) } // add required packages for _, k := range [...]string{"reflect", "unsafe", "runtime", "fmt", "errors"} { @@ -177,13 +250,19 @@ func Gen(w io.Writer, buildTags, pkgName string, useUnsafe bool, typ ...reflect. x.line(")") x.line("") - x.xs = strconv.FormatInt(x.rr.Int63n(9999), 10) - x.line("const (") + x.linef("// ----- content types ----") x.linef("codecSelferC_UTF8%s = %v", x.xs, int64(c_UTF8)) x.linef("codecSelferC_RAW%s = %v", x.xs, int64(c_RAW)) - x.linef("codecSelverValueTypeArray%s = %v", x.xs, int64(valueTypeArray)) - x.linef("codecSelverValueTypeMap%s = %v", x.xs, int64(valueTypeMap)) + x.linef("// ----- value types used ----") + x.linef("codecSelferValueTypeArray%s = %v", x.xs, int64(valueTypeArray)) + x.linef("codecSelferValueTypeMap%s = %v", x.xs, int64(valueTypeMap)) + x.linef("// ----- containerStateValues ----") + x.linef("codecSelfer_containerMapKey%s = %v", x.xs, int64(containerMapKey)) + x.linef("codecSelfer_containerMapValue%s = %v", x.xs, int64(containerMapValue)) + x.linef("codecSelfer_containerMapEnd%s = %v", x.xs, int64(containerMapEnd)) + x.linef("codecSelfer_containerArrayElem%s = %v", x.xs, int64(containerArrayElem)) + x.linef("codecSelfer_containerArrayEnd%s = %v", x.xs, int64(containerArrayEnd)) x.line(")") x.line("var (") x.line("codecSelferBitsize" + x.xs + " = uint8(reflect.TypeOf(uint(0)).Bits())") @@ -199,19 +278,20 @@ func Gen(w io.Writer, buildTags, pkgName string, useUnsafe bool, typ ...reflect. x.line("type " + x.hn + " struct{}") x.line("") + x.varsfxreset() x.line("func init() {") x.linef("if %sGenVersion != %v {", x.cpfx, GenVersion) x.line("_, file, _, _ := runtime.Caller(0)") x.line(`err := fmt.Errorf("codecgen version mismatch: current: %v, need %v. Re-generate file: %v", `) x.linef(`%v, %sGenVersion, file)`, GenVersion, x.cpfx) x.line("panic(err)") - // x.linef(`panic(fmt.Errorf("Re-run codecgen due to version mismatch: `+ - // `current: %%v, need %%v, file: %%v", %v, %sGenVersion, file))`, GenVersion, x.cpfx) x.linef("}") x.line("if false { // reference the types, but skip this branch at build/run time") var n int - for _, t := range x.im { - x.linef("var v%v %s", n, t.String()) + // 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 x.unsafe { @@ -239,9 +319,10 @@ func Gen(w io.Writer, buildTags, pkgName string, useUnsafe bool, typ ...reflect. x.selfer(false) } - for t, _ := range x.ts { + for _, t := range x.ts { rtid := reflect.ValueOf(t).Pointer() // generate enc functions for all these slice/map types. + x.varsfxreset() x.linef("func (x %s) enc%s(v %s%s, e *%sEncoder) {", x.hn, x.genMethodNameT(t), x.arr2str(t, "*"), x.genTypeName(t), x.cpfx) x.genRequiredMethodVars(true) switch t.Kind() { @@ -256,6 +337,7 @@ func Gen(w io.Writer, buildTags, pkgName string, useUnsafe bool, typ ...reflect. x.line("") // generate dec functions for all these slice/map types. + x.varsfxreset() x.linef("func (x %s) dec%s(v *%s, d *%sDecoder) {", x.hn, x.genMethodNameT(t), x.genTypeName(t), x.cpfx) x.genRequiredMethodVars(false) switch t.Kind() { @@ -273,6 +355,12 @@ func Gen(w io.Writer, buildTags, pkgName string, useUnsafe bool, typ ...reflect. x.line("") } +func (x *genRunner) checkForSelfer(t reflect.Type, varname string) bool { + // return varname != genTopLevelVarName && t != x.tc + // the only time we checkForSelfer is if we are not at the TOP of the generated code. + return varname != genTopLevelVarName +} + func (x *genRunner) arr2str(t reflect.Type, s string) string { if t.Kind() == reflect.Array { return s @@ -294,11 +382,19 @@ func (x *genRunner) genRefPkgs(t reflect.Type) { if _, ok := x.is[t]; ok { return } - // fmt.Printf(">>>>>>: PkgPath: '%v', Name: '%s'\n", t.PkgPath(), t.Name()) + // fmt.Printf(">>>>>>: PkgPath: '%v', Name: '%s'\n", genImportPath(t), t.Name()) x.is[t] = struct{}{} - tpkg, tname := t.PkgPath(), t.Name() + tpkg, tname := genImportPath(t), t.Name() if tpkg != "" && tpkg != x.bp && tpkg != x.cp && tname != "" && tname[0] >= 'A' && tname[0] <= 'Z' { - x.im[tpkg] = t + if _, ok := x.im[tpkg]; !ok { + x.im[tpkg] = t + if idx := strings.LastIndex(tpkg, "/"); idx < 0 { + x.imn[tpkg] = tpkg + } else { + x.imc++ + x.imn[tpkg] = "pkg" + strconv.FormatUint(x.imc, 10) + "_" + genGoIdentifier(tpkg[idx+1:], false) + } + } } switch t.Kind() { case reflect.Array, reflect.Slice, reflect.Ptr, reflect.Chan: @@ -327,6 +423,10 @@ func (x *genRunner) varsfx() string { return strconv.FormatUint(x.c, 10) } +func (x *genRunner) varsfxreset() { + x.c = 0 +} + func (x *genRunner) out(s string) { if _, err := io.WriteString(x.w, s); err != nil { panic(err) @@ -342,7 +442,65 @@ func (x *genRunner) outf(s string, params ...interface{}) { } func (x *genRunner) genTypeName(t reflect.Type) (n string) { - return genTypeName(t, x.tc) + // 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. + // We cannot depend on t.String() because it includes current package, + // or t.PkgPath because it includes full import path, + // + var ptrPfx string + for t.Kind() == reflect.Ptr { + ptrPfx += "*" + t = t.Elem() + } + if tn := t.Name(); tn != "" { + return ptrPfx + x.genTypeNamePrim(t) + } + switch t.Kind() { + case reflect.Map: + return ptrPfx + "map[" + x.genTypeName(t.Key()) + "]" + x.genTypeName(t.Elem()) + case reflect.Slice: + return ptrPfx + "[]" + x.genTypeName(t.Elem()) + case reflect.Array: + return ptrPfx + "[" + strconv.FormatInt(int64(t.Len()), 10) + "]" + x.genTypeName(t.Elem()) + case reflect.Chan: + return ptrPfx + t.ChanDir().String() + " " + x.genTypeName(t.Elem()) + default: + if t == intfTyp { + return ptrPfx + "interface{}" + } else { + return ptrPfx + x.genTypeNamePrim(t) + } + } +} + +func (x *genRunner) genTypeNamePrim(t reflect.Type) (n string) { + if t.Name() == "" { + return t.String() + } else if genImportPath(t) == "" || genImportPath(t) == genImportPath(x.tc) { + return t.Name() + } else { + return x.imn[genImportPath(t)] + "." + t.Name() + // return t.String() // best way to get the package name inclusive + } +} + +func (x *genRunner) genZeroValueR(t reflect.Type) string { + // if t is a named type, w + switch t.Kind() { + case reflect.Ptr, reflect.Interface, reflect.Chan, reflect.Func, + reflect.Slice, reflect.Map, reflect.Invalid: + return "nil" + case reflect.Bool: + return "false" + case reflect.String: + return `""` + case reflect.Struct, reflect.Array: + return x.genTypeName(t) + "{}" + default: // all numbers + return "0" + } } func (x *genRunner) genMethodNameT(t reflect.Type) (s string) { @@ -355,6 +513,7 @@ func (x *genRunner) selfer(encode bool) { // always make decode use a pointer receiver, // and structs always use a ptr receiver (encode|decode) isptr := !encode || t.Kind() == reflect.Struct + x.varsfxreset() fnSigPfx := "func (x " if isptr { fnSigPfx += "*" @@ -368,16 +527,16 @@ func (x *genRunner) selfer(encode bool) { if encode { x.line(") CodecEncodeSelf(e *" + x.cpfx + "Encoder) {") x.genRequiredMethodVars(true) - // x.enc("x", t) - x.encVar("x", t) + // x.enc(genTopLevelVarName, t) + x.encVar(genTopLevelVarName, t) } else { x.line(") CodecDecodeSelf(d *" + x.cpfx + "Decoder) {") x.genRequiredMethodVars(false) // do not use decVar, as there is no need to check TryDecodeAsNil // or way to elegantly handle that, and also setting it to a // non-nil value doesn't affect the pointer passed. - // x.decVar("x", t, false) - x.dec("x", t0) + // x.decVar(genTopLevelVarName, t, false) + x.dec(genTopLevelVarName, t0) } x.line("}") x.line("") @@ -391,21 +550,21 @@ func (x *genRunner) selfer(encode bool) { x.out(fnSigPfx) x.line(") codecDecodeSelfFromMap(l int, d *" + x.cpfx + "Decoder) {") x.genRequiredMethodVars(false) - x.decStructMap("x", "l", reflect.ValueOf(t0).Pointer(), t0, 0) + x.decStructMap(genTopLevelVarName, "l", reflect.ValueOf(t0).Pointer(), t0, genStructMapStyleConsolidated) x.line("}") x.line("") } else { x.out(fnSigPfx) x.line(") codecDecodeSelfFromMapLenPrefix(l int, d *" + x.cpfx + "Decoder) {") x.genRequiredMethodVars(false) - x.decStructMap("x", "l", reflect.ValueOf(t0).Pointer(), t0, 1) + x.decStructMap(genTopLevelVarName, "l", reflect.ValueOf(t0).Pointer(), t0, genStructMapStyleLenPrefix) x.line("}") x.line("") x.out(fnSigPfx) x.line(") codecDecodeSelfFromMapCheckBreak(l int, d *" + x.cpfx + "Decoder) {") x.genRequiredMethodVars(false) - x.decStructMap("x", "l", reflect.ValueOf(t0).Pointer(), t0, 2) + x.decStructMap(genTopLevelVarName, "l", reflect.ValueOf(t0).Pointer(), t0, genStructMapStyleCheckBreak) x.line("}") x.line("") } @@ -414,7 +573,7 @@ func (x *genRunner) selfer(encode bool) { x.out(fnSigPfx) x.line(") codecDecodeSelfFromArray(l int, d *" + x.cpfx + "Decoder) {") x.genRequiredMethodVars(false) - x.decStructArray("x", "l", "return", reflect.ValueOf(t0).Pointer(), t0) + x.decStructArray(genTopLevelVarName, "l", "return", reflect.ValueOf(t0).Pointer(), t0) x.line("}") x.line("") @@ -424,17 +583,38 @@ func (x *genRunner) selfer(encode bool) { func (x *genRunner) xtraSM(varname string, encode bool, t reflect.Type) { if encode { x.linef("h.enc%s((%s%s)(%s), e)", x.genMethodNameT(t), x.arr2str(t, "*"), x.genTypeName(t), varname) - // x.line("h.enc" + x.genMethodNameT(t) + "(" + x.genTypeName(t) + "(" + varname + "), e)") } else { x.linef("h.dec%s((*%s)(%s), d)", x.genMethodNameT(t), x.genTypeName(t), varname) - // x.line("h.dec" + x.genMethodNameT(t) + "((*" + x.genTypeName(t) + ")(" + varname + "), d)") } - x.ts[t] = struct{}{} + x.registerXtraT(t) +} + +func (x *genRunner) registerXtraT(t reflect.Type) { + // recursively register the types + if _, ok := x.tm[t]; ok { + return + } + var tkey reflect.Type + switch t.Kind() { + case reflect.Chan, reflect.Slice, reflect.Array: + case reflect.Map: + tkey = t.Key() + default: + return + } + x.tm[t] = struct{}{} + x.ts = append(x.ts, t) + // check if this refers to any xtra types eg. a slice of array: add the array + x.registerXtraT(t.Elem()) + if tkey != nil { + x.registerXtraT(tkey) + } } // 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 switch t.Kind() { case reflect.Ptr, reflect.Interface, reflect.Slice, reflect.Map, reflect.Chan: @@ -467,49 +647,115 @@ func (x *genRunner) encVar(varname string, t reflect.Type) { } -// enc will encode a variable (varname) of type T, -// except t is of kind reflect.Struct or reflect.Array, wherein varname is of type *T (to prevent copying) +// enc will encode a variable (varname) of type t, +// except t is of kind reflect.Struct or reflect.Array, wherein varname is of type ptrTo(T) (to prevent copying) func (x *genRunner) enc(varname string, t reflect.Type) { - // varName here must be to a pointer to a struct, or to a value directly. rtid := reflect.ValueOf(t).Pointer() // We call CodecEncodeSelf if one of the following are honored: // - the type already implements Selfer, call that // - the type has a Selfer implementation just created, use that // - the type is in the list of the ones we will generate for, but it is not currently being generated - if t.Implements(selferTyp) { - x.line(varname + ".CodecEncodeSelf(e)") - return - } - if t.Kind() == reflect.Struct && reflect.PtrTo(t).Implements(selferTyp) { - x.line(varname + ".CodecEncodeSelf(e)") - return - } - if _, ok := x.te[rtid]; ok { - x.line(varname + ".CodecEncodeSelf(e)") - return + + mi := x.varsfx() + tptr := reflect.PtrTo(t) + tk := t.Kind() + if x.checkForSelfer(t, varname) { + if tk == reflect.Array || tk == reflect.Struct { // varname is of type *T + if tptr.Implements(selferTyp) || t.Implements(selferTyp) { + x.line(varname + ".CodecEncodeSelf(e)") + return + } + } else { // varname is of type T + if t.Implements(selferTyp) { + x.line(varname + ".CodecEncodeSelf(e)") + return + } else if tptr.Implements(selferTyp) { + x.linef("%ssf%s := &%s", genTempVarPfx, mi, varname) + x.linef("%ssf%s.CodecEncodeSelf(e)", genTempVarPfx, mi) + return + } + } + + if _, ok := x.te[rtid]; ok { + x.line(varname + ".CodecEncodeSelf(e)") + return + } } inlist := false for _, t0 := range x.t { if t == t0 { inlist = true - if t != x.tc { + if x.checkForSelfer(t, varname) { x.line(varname + ".CodecEncodeSelf(e)") return } break } } + var rtidAdded bool if t == x.tc { x.te[rtid] = true rtidAdded = true } + // check if + // - type is RawExt + // - the type implements (Text|JSON|Binary)(Unm|M)arshal + x.linef("%sm%s := z.EncBinary()", genTempVarPfx, mi) + x.linef("_ = %sm%s", genTempVarPfx, mi) + x.line("if false {") //start if block + defer func() { x.line("}") }() //end if block + + if t == rawExtTyp { + x.linef("} else { r.EncodeRawExt(%v, e)", varname) + return + } + // HACK: Support for Builtins. + // Currently, only Binc supports builtins, and the only builtin type is time.Time. + // Have a method that returns the rtid for time.Time if Handle is Binc. + if t == timeTyp { + vrtid := genTempVarPfx + "m" + x.varsfx() + x.linef("} else if %s := z.TimeRtidIfBinc(); %s != 0 { ", vrtid, vrtid) + x.linef("r.EncodeBuiltin(%s, %s)", vrtid, varname) + } + // only check for extensions if the type is named, and has a packagePath. + if genImportPath(t) != "" && t.Name() != "" { + // first check if extensions are configued, before doing the interface conversion + x.linef("} else if z.HasExtensions() && z.EncExt(%s) {", varname) + } + if tk == reflect.Array || tk == reflect.Struct { // varname is of type *T + if t.Implements(binaryMarshalerTyp) || tptr.Implements(binaryMarshalerTyp) { + x.linef("} else if %sm%s { z.EncBinaryMarshal(%v) ", genTempVarPfx, mi, varname) + } + if t.Implements(jsonMarshalerTyp) || tptr.Implements(jsonMarshalerTyp) { + x.linef("} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", genTempVarPfx, mi, varname) + } else if t.Implements(textMarshalerTyp) || tptr.Implements(textMarshalerTyp) { + x.linef("} else if !%sm%s { z.EncTextMarshal(%v) ", genTempVarPfx, mi, varname) + } + } else { // varname is of type T + if t.Implements(binaryMarshalerTyp) { + x.linef("} else if %sm%s { z.EncBinaryMarshal(%v) ", genTempVarPfx, mi, varname) + } else if tptr.Implements(binaryMarshalerTyp) { + x.linef("} else if %sm%s { z.EncBinaryMarshal(&%v) ", genTempVarPfx, mi, varname) + } + if t.Implements(jsonMarshalerTyp) { + x.linef("} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", genTempVarPfx, mi, varname) + } else if tptr.Implements(jsonMarshalerTyp) { + x.linef("} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(&%v) ", genTempVarPfx, mi, varname) + } else if t.Implements(textMarshalerTyp) { + x.linef("} else if !%sm%s { z.EncTextMarshal(%v) ", genTempVarPfx, mi, varname) + } else if tptr.Implements(textMarshalerTyp) { + x.linef("} else if !%sm%s { z.EncTextMarshal(&%v) ", genTempVarPfx, mi, varname) + } + } + x.line("} else {") + switch t.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: x.line("r.EncodeInt(int64(" + varname + "))") - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: x.line("r.EncodeUint(uint64(" + varname + "))") case reflect.Float32: x.line("r.EncodeFloat32(float32(" + varname + "))") @@ -534,7 +780,7 @@ func (x *genRunner) enc(varname string, t reflect.Type) { if rtid == uint8SliceTypId { x.line("r.EncodeStringBytes(codecSelferC_RAW" + x.xs + ", []byte(" + varname + "))") } else if fastpathAV.index(rtid) != -1 { - g := genV{Slice: true, Elem: x.genTypeName(t.Elem())} + g := x.newGenV(t) x.line("z.F." + g.MethodNamePfx("Enc", false) + "V(" + varname + ", false, e)") } else { x.xtraSM(varname, true, t) @@ -548,9 +794,7 @@ func (x *genRunner) enc(varname string, t reflect.Type) { // - else call Encoder.encode(XXX) on it. // x.line("if " + varname + " == nil { \nr.EncodeNil()\n } else { ") if fastpathAV.index(rtid) != -1 { - g := genV{Slice: false, - Elem: x.genTypeName(t.Elem()), - MapKey: x.genTypeName(t.Key())} + g := x.newGenV(t) x.line("z.F." + g.MethodNamePfx("Enc", false) + "V(" + varname + ", false, e)") } else { x.xtraSM(varname, true, t) @@ -575,7 +819,7 @@ func (x *genRunner) encZero(t reflect.Type) { switch t.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: x.line("r.EncodeInt(0)") - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: x.line("r.EncodeUint(0)") case reflect.Float32: x.line("r.EncodeFloat32(0)") @@ -595,24 +839,22 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) { // replicate code in kStruct i.e. for each field, deref type to non-pointer, and call x.enc on it // if t === type currently running selfer on, do for all - ti := getTypeInfo(rtid, t) + ti := x.ti.get(rtid, t) i := x.varsfx() sepVarname := genTempVarPfx + "sep" + i - firstVarname := genTempVarPfx + "first" + i numfieldsvar := genTempVarPfx + "q" + i ti2arrayvar := genTempVarPfx + "r" + i struct2arrvar := genTempVarPfx + "2arr" + i x.line(sepVarname + " := !z.EncBinary()") x.linef("%s := z.EncBasicHandle().StructToArray", struct2arrvar) - x.line("var " + firstVarname + " bool") tisfi := ti.sfip // always use sequence from file. decStruct expects same thing. // due to omitEmpty, we need to calculate the // number of non-empty things we write out first. // This is required as we need to pre-determine the size of the container, // to support length-prefixing. x.linef("var %s [%v]bool", numfieldsvar, len(tisfi)) - x.linef("_, _, _, _ = %s, %s, %s, %s", sepVarname, firstVarname, numfieldsvar, struct2arrvar) + x.linef("_, _, _ = %s, %s, %s", sepVarname, numfieldsvar, struct2arrvar) x.linef("const %s bool = %v", ti2arrayvar, ti.toArray) nn := 0 for j, si := range tisfi { @@ -647,16 +889,18 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) { case reflect.Map, reflect.Slice, reflect.Array, reflect.Chan: omitline += "len(" + varname + "." + t2.Name + ") != 0" default: - omitline += varname + "." + t2.Name + " != " + genZeroValueR(t2.Type, x.tc) + omitline += varname + "." + t2.Name + " != " + x.genZeroValueR(t2.Type) } x.linef("%s[%v] = %s", numfieldsvar, j, omitline) } + x.linef("var %snn%s int", genTempVarPfx, i) x.linef("if %s || %s {", ti2arrayvar, struct2arrvar) // if ti.toArray { x.line("r.EncodeArrayStart(" + strconv.FormatInt(int64(len(tisfi)), 10) + ")") x.linef("} else {") // if not ti.toArray - x.linef("var %snn%s int = %v", genTempVarPfx, i, nn) + x.linef("%snn%s = %v", genTempVarPfx, i, nn) x.linef("for _, b := range %s { if b { %snn%s++ } }", numfieldsvar, genTempVarPfx, i) x.linef("r.EncodeMapStart(%snn%s)", genTempVarPfx, i) + x.linef("%snn%s = %v", genTempVarPfx, i, 0) // x.line("r.EncodeMapStart(" + strconv.FormatInt(int64(len(tisfi)), 10) + ")") x.line("}") // close if not StructToArray @@ -697,19 +941,12 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) { // if the type of the field is a Selfer, or one of the ones x.linef("if %s || %s {", ti2arrayvar, struct2arrvar) // if ti.toArray - if j > 0 { - x.line("if " + sepVarname + " {") - x.line("r.EncodeArrayEntrySeparator()") - x.line("}") - } if labelUsed { x.line("if " + isNilVarName + " { r.EncodeNil() } else { ") } + x.linef("z.EncSendContainerState(codecSelfer_containerArrayElem%s)", x.xs) if si.omitEmpty { x.linef("if %s[%v] {", numfieldsvar, j) - // omitEmptyVarNameX := genTempVarPfx + "ov" + i - // x.line("var " + omitEmptyVarNameX + " " + x.genTypeName(t2.Type)) - // x.encVar(omitEmptyVarNameX, t2.Type) } x.encVar(varname+"."+t2.Name, t2.Type) if si.omitEmpty { @@ -720,30 +957,15 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) { if labelUsed { x.line("}") } + x.linef("} else {") // if not ti.toArray - // omitEmptyVar := genTempVarPfx + "x" + i + t2.Name - // x.line("const " + omitEmptyVar + " bool = " + strconv.FormatBool(si.omitEmpty)) - // doOmitEmpty := si.omitEmpty && t2.Type.Kind() != reflect.Struct + if si.omitEmpty { x.linef("if %s[%v] {", numfieldsvar, j) - // x.linef(`println("Encoding field: %v")`, j) - // x.out("if ") - // if labelUsed { - // x.out("!" + isNilVarName + " && ") - // } - // x.line(varname + "." + t2.Name + " != " + genZeroValueR(t2.Type, x.tc) + " {") } - if j == 0 { - x.linef("%s = true", firstVarname) - } else { - x.linef("if %s { r.EncodeMapEntrySeparator() } else { %s = true }", firstVarname, firstVarname) - } - - // x.line("r.EncodeString(codecSelferC_UTF8" + x.xs + ", string(\"" + t2.Name + "\"))") + x.linef("z.EncSendContainerState(codecSelfer_containerMapKey%s)", x.xs) x.line("r.EncodeString(codecSelferC_UTF8" + x.xs + ", string(\"" + si.encName + "\"))") - x.line("if " + sepVarname + " {") - x.line("r.EncodeMapKVSeparator()") - x.line("}") + x.linef("z.EncSendContainerState(codecSelfer_containerMapValue%s)", x.xs) if labelUsed { x.line("if " + isNilVarName + " { r.EncodeNil() } else { ") x.encVar(varname+"."+t2.Name, t2.Type) @@ -756,69 +978,44 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) { } x.linef("} ") // end if/else ti.toArray } - x.line("if " + sepVarname + " {") x.linef("if %s || %s {", ti2arrayvar, struct2arrvar) // if ti.toArray { - x.line("r.EncodeArrayEnd()") - x.linef("} else {") // if not ti.toArray - x.line("r.EncodeMapEnd()") - x.linef("} ") // end if/else ti.toArray + x.linef("z.EncSendContainerState(codecSelfer_containerArrayEnd%s)", x.xs) + x.line("} else {") + x.linef("z.EncSendContainerState(codecSelfer_containerMapEnd%s)", x.xs) x.line("}") + } func (x *genRunner) encListFallback(varname string, t reflect.Type) { i := x.varsfx() g := genTempVarPfx x.line("r.EncodeArrayStart(len(" + varname + "))") - x.line(genTempVarPfx + "s" + i + " := !z.EncBinary()") - x.line("if " + genTempVarPfx + "s" + i + " {") if t.Kind() == reflect.Chan { x.linef("for %si%s, %si2%s := 0, len(%s); %si%s < %si2%s; %si%s++ {", g, i, g, i, varname, g, i, g, i, g, i) + x.linef("z.EncSendContainerState(codecSelfer_containerArrayElem%s)", x.xs) x.linef("%sv%s := <-%s", g, i, varname) } else { - x.linef("for %si%s, %sv%s := range %s {", genTempVarPfx, i, genTempVarPfx, i, varname) - } - x.linef("if %si%s > 0 { r.EncodeArrayEntrySeparator() }", genTempVarPfx, i) - x.encVar(genTempVarPfx+"v"+i, t.Elem()) - x.line("}") - x.line("r.EncodeArrayEnd()") - x.line("} else {") - if t.Kind() == reflect.Chan { - x.linef("for %si%s, %si2%s := 0, len(%s); %si%s < %si2%s; %si%s++ {", g, i, g, i, varname, g, i, g, i, g, i) - x.linef("%sv%s := <-%s", g, i, varname) - } else { - x.line("for _, " + genTempVarPfx + "v" + i + " := range " + varname + " {") + // x.linef("for %si%s, %sv%s := range %s {", genTempVarPfx, i, genTempVarPfx, i, varname) + x.linef("for _, %sv%s := range %s {", genTempVarPfx, i, varname) + x.linef("z.EncSendContainerState(codecSelfer_containerArrayElem%s)", x.xs) } x.encVar(genTempVarPfx+"v"+i, t.Elem()) x.line("}") - x.line("}") + x.linef("z.EncSendContainerState(codecSelfer_containerArrayEnd%s)", x.xs) } func (x *genRunner) encMapFallback(varname string, t reflect.Type) { + // TODO: expand this to handle canonical. i := x.varsfx() x.line("r.EncodeMapStart(len(" + varname + "))") - x.line(genTempVarPfx + "s" + i + " := !z.EncBinary()") - - x.line(genTempVarPfx + "j" + i + " := 0") - - x.line("if " + genTempVarPfx + "s" + i + " {") - - x.line("for " + genTempVarPfx + "k" + i + ", " + - genTempVarPfx + "v" + i + " := range " + varname + " {") - x.line("if " + genTempVarPfx + "j" + i + " > 0 { r.EncodeMapEntrySeparator() }") - x.encVar(genTempVarPfx+"k"+i, t.Key()) - x.line("r.EncodeMapKVSeparator()") - x.encVar(genTempVarPfx+"v"+i, t.Elem()) - x.line(genTempVarPfx + "j" + i + "++") - x.line("}") - x.line("r.EncodeMapEnd()") - - x.line("} else {") x.linef("for %sk%s, %sv%s := range %s {", genTempVarPfx, i, genTempVarPfx, i, varname) + // x.line("for " + genTempVarPfx + "k" + i + ", " + genTempVarPfx + "v" + i + " := range " + varname + " {") + x.linef("z.EncSendContainerState(codecSelfer_containerMapKey%s)", x.xs) x.encVar(genTempVarPfx+"k"+i, t.Key()) + x.linef("z.EncSendContainerState(codecSelfer_containerMapValue%s)", x.xs) x.encVar(genTempVarPfx+"v"+i, t.Elem()) x.line("}") - - x.line("}") + x.linef("z.EncSendContainerState(codecSelfer_containerMapEnd%s)", x.xs) } func (x *genRunner) decVar(varname string, t reflect.Type, canBeNil bool) { @@ -836,23 +1033,17 @@ func (x *genRunner) decVar(varname string, t reflect.Type, canBeNil bool) { x.line("if r.TryDecodeAsNil() {") if t.Kind() == reflect.Ptr { x.line("if " + varname + " != nil { ") - // x.line("var " + genTempVarPfx + i + " " + x.genTypeName(t.Elem())) - // x.line("*" + varname + " = " + genTempVarPfx + i) // if varname is a field of a struct (has a dot in it), // then just set it to nil if strings.IndexByte(varname, '.') != -1 { x.line(varname + " = nil") } else { - x.line("*" + varname + " = " + genZeroValueR(t.Elem(), x.tc)) + x.line("*" + varname + " = " + x.genZeroValueR(t.Elem())) } - // x.line("*" + varname + " = nil") x.line("}") - } else { - // x.line("var " + genTempVarPfx + i + " " + x.genTypeName(t)) - // x.line(varname + " = " + genTempVarPfx + i) - x.line(varname + " = " + genZeroValueR(t, x.tc)) + x.line(varname + " = " + x.genZeroValueR(t)) } x.line("} else {") } else { @@ -894,38 +1085,82 @@ func (x *genRunner) decVar(varname string, t reflect.Type, canBeNil bool) { } } +// dec will decode a variable (varname) of type ptrTo(t). +// t is always a basetype (i.e. not of kind reflect.Ptr). func (x *genRunner) dec(varname string, t reflect.Type) { // assumptions: // - the varname is to a pointer already. No need to take address of it - + // - t is always a baseType T (not a *T, etc). rtid := reflect.ValueOf(t).Pointer() - if t.Implements(selferTyp) || (t.Kind() == reflect.Struct && - reflect.PtrTo(t).Implements(selferTyp)) { - x.line(varname + ".CodecDecodeSelf(d)") - return - } - if _, ok := x.td[rtid]; ok { - x.line(varname + ".CodecDecodeSelf(d)") - return + tptr := reflect.PtrTo(t) + if x.checkForSelfer(t, varname) { + if t.Implements(selferTyp) || tptr.Implements(selferTyp) { + x.line(varname + ".CodecDecodeSelf(d)") + return + } + if _, ok := x.td[rtid]; ok { + x.line(varname + ".CodecDecodeSelf(d)") + return + } } inlist := false for _, t0 := range x.t { if t == t0 { inlist = true - if t != x.tc { + if x.checkForSelfer(t, varname) { x.line(varname + ".CodecDecodeSelf(d)") return } break } } + var rtidAdded bool if t == x.tc { x.td[rtid] = true rtidAdded = true } + // check if + // - type is RawExt + // - the type implements (Text|JSON|Binary)(Unm|M)arshal + mi := x.varsfx() + x.linef("%sm%s := z.DecBinary()", genTempVarPfx, mi) + x.linef("_ = %sm%s", genTempVarPfx, mi) + x.line("if false {") //start if block + defer func() { x.line("}") }() //end if block + + if t == rawExtTyp { + x.linef("} else { r.DecodeExt(%v, 0, nil)", varname) + return + } + + // HACK: Support for Builtins. + // Currently, only Binc supports builtins, and the only builtin type is time.Time. + // Have a method that returns the rtid for time.Time if Handle is Binc. + if t == timeTyp { + vrtid := genTempVarPfx + "m" + x.varsfx() + x.linef("} else if %s := z.TimeRtidIfBinc(); %s != 0 { ", vrtid, vrtid) + x.linef("r.DecodeBuiltin(%s, %s)", vrtid, varname) + } + // only check for extensions if the type is named, and has a packagePath. + if 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) + } + + if t.Implements(binaryUnmarshalerTyp) || tptr.Implements(binaryUnmarshalerTyp) { + x.linef("} else if %sm%s { z.DecBinaryUnmarshal(%v) ", genTempVarPfx, mi, varname) + } + if t.Implements(jsonUnmarshalerTyp) || tptr.Implements(jsonUnmarshalerTyp) { + x.linef("} else if !%sm%s && z.IsJSONHandle() { z.DecJSONUnmarshal(%v)", genTempVarPfx, mi, varname) + } else if t.Implements(textUnmarshalerTyp) || tptr.Implements(textUnmarshalerTyp) { + x.linef("} else if !%sm%s { z.DecTextUnmarshal(%v)", genTempVarPfx, mi, varname) + } + + x.line("} else {") + // Since these are pointers, we cannot share, and have to use them one by one switch t.Kind() { case reflect.Int: @@ -959,6 +1194,8 @@ func (x *genRunner) dec(varname string, t reflect.Type) { case reflect.Uint64: x.line("*((*uint64)(" + varname + ")) = uint64(r.DecodeUint(64))") //x.line("z.DecUint64((*uint64)(" + varname + "))") + case reflect.Uintptr: + x.line("*((*uintptr)(" + varname + ")) = uintptr(r.DecodeUint(codecSelferBitsize" + x.xs + "))") case reflect.Float32: x.line("*((*float32)(" + varname + ")) = float32(r.DecodeFloat(true))") @@ -985,10 +1222,8 @@ func (x *genRunner) dec(varname string, t reflect.Type) { if rtid == uint8SliceTypId { x.line("*" + varname + " = r.DecodeBytes(*(*[]byte)(" + varname + "), false, false)") } else if fastpathAV.index(rtid) != -1 { - g := genV{Slice: true, Elem: x.genTypeName(t.Elem())} + g := x.newGenV(t) x.line("z.F." + g.MethodNamePfx("Dec", false) + "X(" + varname + ", false, d)") - // x.line("z." + g.MethodNamePfx("Dec", false) + "(" + varname + ")") - // x.line(g.FastpathName(false) + "(" + varname + ", d)") } else { x.xtraSM(varname, false, t) // x.decListFallback(varname, rtid, false, t) @@ -999,10 +1234,8 @@ func (x *genRunner) dec(varname string, t reflect.Type) { // - if elements are primitives or Selfers, call dedicated function on each member. // - else call Encoder.encode(XXX) on it. if fastpathAV.index(rtid) != -1 { - g := genV{Slice: false, Elem: x.genTypeName(t.Elem()), MapKey: x.genTypeName(t.Key())} + g := x.newGenV(t) x.line("z.F." + g.MethodNamePfx("Dec", false) + "X(" + varname + ", false, d)") - // x.line("z." + g.MethodNamePfx("Dec", false) + "(" + varname + ")") - // x.line(g.FastpathName(false) + "(" + varname + ", d)") } else { x.xtraSM(varname, false, t) // x.decMapFallback(varname, rtid, t) @@ -1023,57 +1256,49 @@ func (x *genRunner) dec(varname string, t reflect.Type) { } func (x *genRunner) decTryAssignPrimitive(varname string, t reflect.Type) (tryAsPtr bool) { - // We have to use the actual type name when doing a direct assignment. - // We don't have the luxury of casting the pointer to the underlying type. - // - // Consequently, in the situation of a - // type Message int32 - // var x Message - // var i int32 = 32 - // x = i // this will bomb - // x = Message(i) // this will work - // *((*int32)(&x)) = i // this will work - // - // Consequently, we replace: - // case reflect.Uint32: x.line(varname + " = uint32(r.DecodeUint(32))") - // with: - // case reflect.Uint32: x.line(varname + " = " + genTypeNamePrimitiveKind(t, x.tc) + "(r.DecodeUint(32))") + // This should only be used for exact primitives (ie un-named types). + // Named types may be implementations of Selfer, Unmarshaler, etc. + // They should be handled by dec(...) - xfn := func(t reflect.Type) string { - return genTypeNamePrimitiveKind(t, x.tc) + if t.Name() != "" { + tryAsPtr = true + return } + switch t.Kind() { case reflect.Int: - x.linef("%s = %s(r.DecodeInt(codecSelferBitsize%s))", varname, xfn(t), x.xs) + x.linef("%s = r.DecodeInt(codecSelferBitsize%s)", varname, x.xs) case reflect.Int8: - x.linef("%s = %s(r.DecodeInt(8))", varname, xfn(t)) + x.linef("%s = r.DecodeInt(8)", varname) case reflect.Int16: - x.linef("%s = %s(r.DecodeInt(16))", varname, xfn(t)) + x.linef("%s = r.DecodeInt(16)", varname) case reflect.Int32: - x.linef("%s = %s(r.DecodeInt(32))", varname, xfn(t)) + x.linef("%s = r.DecodeInt(32)", varname) case reflect.Int64: - x.linef("%s = %s(r.DecodeInt(64))", varname, xfn(t)) + x.linef("%s = r.DecodeInt(64)", varname) case reflect.Uint: - x.linef("%s = %s(r.DecodeUint(codecSelferBitsize%s))", varname, xfn(t), x.xs) + x.linef("%s = r.DecodeUint(codecSelferBitsize%s)", varname, x.xs) case reflect.Uint8: - x.linef("%s = %s(r.DecodeUint(8))", varname, xfn(t)) + x.linef("%s = r.DecodeUint(8)", varname) case reflect.Uint16: - x.linef("%s = %s(r.DecodeUint(16))", varname, xfn(t)) + x.linef("%s = r.DecodeUint(16)", varname) case reflect.Uint32: - x.linef("%s = %s(r.DecodeUint(32))", varname, xfn(t)) + x.linef("%s = r.DecodeUint(32)", varname) case reflect.Uint64: - x.linef("%s = %s(r.DecodeUint(64))", varname, xfn(t)) + x.linef("%s = r.DecodeUint(64)", varname) + case reflect.Uintptr: + x.linef("%s = r.DecodeUint(codecSelferBitsize%s)", varname, x.xs) case reflect.Float32: - x.linef("%s = %s(r.DecodeFloat(true))", varname, xfn(t)) + x.linef("%s = r.DecodeFloat(true)", varname) case reflect.Float64: - x.linef("%s = %s(r.DecodeFloat(false))", varname, xfn(t)) + x.linef("%s = r.DecodeFloat(false)", varname) case reflect.Bool: - x.linef("%s = %s(r.DecodeBool())", varname, xfn(t)) + x.linef("%s = r.DecodeBool()", varname) case reflect.String: - x.linef("%s = %s(r.DecodeString())", varname, xfn(t)) + x.linef("%s = r.DecodeString()", varname) default: tryAsPtr = true } @@ -1088,11 +1313,13 @@ func (x *genRunner) decListFallback(varname string, rtid uintptr, t reflect.Type CTyp string Typ string Immutable bool + Size int } telem := t.Elem() - ts := tstruc{genTempVarPfx, x.varsfx(), varname, x.genTypeName(t), x.genTypeName(telem), genIsImmutable(telem)} + ts := tstruc{genTempVarPfx, x.varsfx(), varname, x.genTypeName(t), x.genTypeName(telem), genIsImmutable(telem), int(telem.Size())} funcs := make(template.FuncMap) + funcs["decLineVar"] = func(varname string) string { x.decVar(varname, telem, false) return "" @@ -1105,7 +1332,7 @@ func (x *genRunner) decListFallback(varname string, rtid uintptr, t reflect.Type return ts.TempVar + s + ts.Rand } funcs["zero"] = func() string { - return genZeroValueR(telem, x.tc) + return x.genZeroValueR(telem) } funcs["isArray"] = func() bool { return t.Kind() == reflect.Array @@ -1128,15 +1355,33 @@ func (x *genRunner) decListFallback(varname string, rtid uintptr, t reflect.Type func (x *genRunner) decMapFallback(varname string, rtid uintptr, t reflect.Type) { type tstruc struct { TempVar string + Sfx string Rand string Varname string KTyp string Typ string + Size int } telem := t.Elem() tkey := t.Key() - ts := tstruc{genTempVarPfx, x.varsfx(), varname, x.genTypeName(tkey), x.genTypeName(telem)} + ts := tstruc{ + genTempVarPfx, x.xs, x.varsfx(), varname, x.genTypeName(tkey), + x.genTypeName(telem), int(telem.Size() + tkey.Size()), + } + funcs := make(template.FuncMap) + funcs["decElemZero"] = func() string { + return x.genZeroValueR(telem) + } + funcs["decElemKindImmutable"] = func() bool { + return genIsImmutable(telem) + } + funcs["decElemKindPtr"] = func() bool { + return telem.Kind() == reflect.Ptr + } + funcs["decElemKindIntf"] = func() bool { + return telem.Kind() == reflect.Interface + } funcs["decLineVarK"] = func(varname string) string { x.decVar(varname, tkey, false) return "" @@ -1167,7 +1412,7 @@ func (x *genRunner) decMapFallback(varname string, rtid uintptr, t reflect.Type) } func (x *genRunner) decStructMapSwitch(kName string, varname string, rtid uintptr, t reflect.Type) { - ti := getTypeInfo(rtid, t) + ti := x.ti.get(rtid, t) tisfi := ti.sfip // always use sequence from file. decStruct expects same thing. x.line("switch (" + kName + ") {") for _, si := range tisfi { @@ -1176,6 +1421,7 @@ func (x *genRunner) decStructMapSwitch(kName string, varname string, rtid uintpt if si.i != -1 { t2 = t.Field(int(si.i)) } else { + //we must accomodate anonymous fields, where the embedded field is a nil pointer in the value. // t2 = t.FieldByIndex(si.is) t2typ := t varname3 := varname @@ -1187,8 +1433,7 @@ func (x *genRunner) decStructMapSwitch(kName string, varname string, rtid uintpt t2typ = t2.Type varname3 = varname3 + "." + t2.Name if t2typ.Kind() == reflect.Ptr { - x.line("if " + varname3 + " == nil {" + - varname3 + " = new(" + x.genTypeName(t2typ.Elem()) + ") }") + x.linef("if %s == nil { %s = new(%s) }", varname3, varname3, x.genTypeName(t2typ.Elem())) } } } @@ -1197,11 +1442,10 @@ func (x *genRunner) decStructMapSwitch(kName string, varname string, rtid uintpt x.line("default:") // pass the slice here, so that the string will not escape, and maybe save allocation x.line("z.DecStructFieldNotFound(-1, " + kName + ")") - // x.line("z.DecStructFieldNotFoundB(" + kName + "Slc)") x.line("} // end switch " + kName) } -func (x *genRunner) decStructMap(varname, lenvarname string, rtid uintptr, t reflect.Type, style uint8) { +func (x *genRunner) decStructMap(varname, lenvarname string, rtid uintptr, t reflect.Type, style genStructMapStyle) { tpfx := genTempVarPfx i := x.varsfx() kName := tpfx + "s" + i @@ -1223,28 +1467,21 @@ func (x *genRunner) decStructMap(varname, lenvarname string, rtid uintptr, t ref x.line("var " + kName + "Slc = z.DecScratchBuffer() // default slice to decode into") - // x.line("var " + kName + " string // default string to decode into") - // x.line("_ = " + kName) x.line("_ = " + kName + "Slc") - // x.linef("var %sb%s bool", tpfx, i) // break switch style { - case 1: + case genStructMapStyleLenPrefix: x.linef("for %sj%s := 0; %sj%s < %s; %sj%s++ {", tpfx, i, tpfx, i, lenvarname, tpfx, i) - case 2: + case genStructMapStyleCheckBreak: x.linef("for %sj%s := 0; !r.CheckBreak(); %sj%s++ {", tpfx, i, tpfx, i) - x.linef("if %sj%s > 0 { r.ReadMapEntrySeparator() }", 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.linef("} else { if r.CheckBreak() { break }; if %sj%s > 0 { r.ReadMapEntrySeparator() } }", - tpfx, i) + x.line("} else { if r.CheckBreak() { break }; }") } - // x.line(kName + " = z.ReadStringAsBytes(" + kName + ")") - // x.line(kName + " = z.ReadString()") + x.linef("z.DecSendContainerState(codecSelfer_containerMapKey%s)", x.xs) x.line(kName + "Slc = r.DecodeBytes(" + kName + "Slc, true, true)") // let string be scoped to this loop alone, so it doesn't escape. - // x.line(kName + " := " + x.cpfx + "GenBytesToStringRO(" + kName + "Slc)") if x.unsafe { x.line(kName + "SlcHdr := codecSelferUnsafeString" + x.xs + "{uintptr(unsafe.Pointer(&" + kName + "Slc[0])), len(" + kName + "Slc)}") @@ -1252,53 +1489,50 @@ func (x *genRunner) decStructMap(varname, lenvarname string, rtid uintptr, t ref } else { x.line(kName + " := string(" + kName + "Slc)") } - switch style { - case 1: - case 2: - x.line("r.ReadMapKVSeparator()") - default: - x.linef("if !%shl%s { r.ReadMapKVSeparator() }", tpfx, i) - } + x.linef("z.DecSendContainerState(codecSelfer_containerMapValue%s)", x.xs) x.decStructMapSwitch(kName, varname, rtid, t) x.line("} // end for " + tpfx + "j" + i) - switch style { - case 1: - case 2: - x.line("r.ReadMapEnd()") - default: - x.linef("if !%shl%s { r.ReadMapEnd() }", tpfx, i) - } + x.linef("z.DecSendContainerState(codecSelfer_containerMapEnd%s)", x.xs) } func (x *genRunner) decStructArray(varname, lenvarname, breakString string, rtid uintptr, t reflect.Type) { tpfx := genTempVarPfx i := x.varsfx() - ti := getTypeInfo(rtid, t) + ti := x.ti.get(rtid, t) tisfi := ti.sfip // always use sequence from file. decStruct expects same thing. x.linef("var %sj%s int", tpfx, i) - x.linef("var %sb%s bool", tpfx, i) // break - // x.linef("var %sl%s := r.ReadArrayStart()", tpfx, i) + x.linef("var %sb%s bool", tpfx, i) // break x.linef("var %shl%s bool = %s >= 0", tpfx, i, lenvarname) // has length - for j, si := range tisfi { + for _, si := range tisfi { var t2 reflect.StructField if si.i != -1 { t2 = t.Field(int(si.i)) } else { - t2 = t.FieldByIndex(si.is) + //we must accomodate anonymous fields, where the embedded field is a nil pointer in the value. + // t2 = t.FieldByIndex(si.is) + t2typ := t + varname3 := varname + for _, ix := range si.is { + for t2typ.Kind() == reflect.Ptr { + t2typ = t2typ.Elem() + } + t2 = t2typ.Field(ix) + t2typ = t2.Type + varname3 = varname3 + "." + t2.Name + if t2typ.Kind() == reflect.Ptr { + x.linef("if %s == nil { %s = new(%s) }", varname3, varname3, x.genTypeName(t2typ.Elem())) + } + } } x.linef("%sj%s++; if %shl%s { %sb%s = %sj%s > %s } else { %sb%s = r.CheckBreak() }", tpfx, i, tpfx, i, tpfx, i, tpfx, i, lenvarname, tpfx, i) - // x.line("if " + tpfx + "j" + i + "++; " + tpfx + "j" + - // i + " <= " + tpfx + "l" + i + " {") - x.linef("if %sb%s { r.ReadArrayEnd(); %s }", tpfx, i, breakString) - if j > 0 { - x.line("r.ReadArrayEntrySeparator()") - } + x.linef("if %sb%s { z.DecSendContainerState(codecSelfer_containerArrayEnd%s); %s }", + tpfx, i, x.xs, breakString) + x.linef("z.DecSendContainerState(codecSelfer_containerArrayElem%s)", x.xs) x.decVar(varname+"."+t2.Name, t2.Type, true) - // x.line("} // end if " + tpfx + "j" + i + " <= " + tpfx + "l" + i) } // read remaining values and throw away. x.line("for {") @@ -1306,20 +1540,20 @@ func (x *genRunner) decStructArray(varname, lenvarname, breakString string, rtid tpfx, i, tpfx, i, tpfx, i, tpfx, i, lenvarname, tpfx, i) x.linef("if %sb%s { break }", tpfx, i) - x.linef("if %sj%s > 1 { r.ReadArrayEntrySeparator() }", tpfx, i) + x.linef("z.DecSendContainerState(codecSelfer_containerArrayElem%s)", x.xs) x.linef(`z.DecStructFieldNotFound(%sj%s - 1, "")`, tpfx, i) x.line("}") - x.line("r.ReadArrayEnd()") + x.linef("z.DecSendContainerState(codecSelfer_containerArrayEnd%s)", x.xs) } func (x *genRunner) decStruct(varname string, rtid uintptr, t reflect.Type) { // if container is map - // x.line("if z.DecContainerIsMap() { ") i := x.varsfx() - x.line("if r.IsContainerType(codecSelverValueTypeMap" + x.xs + ") {") + x.linef("%sct%s := r.ContainerType()", genTempVarPfx, i) + x.linef("if %sct%s == codecSelferValueTypeMap%s {", genTempVarPfx, i, x.xs) x.line(genTempVarPfx + "l" + i + " := r.ReadMapStart()") x.linef("if %sl%s == 0 {", genTempVarPfx, i) - x.line("r.ReadMapEnd()") + x.linef("z.DecSendContainerState(codecSelfer_containerMapEnd%s)", x.xs) if genUseOneFunctionForDecStructMap { x.line("} else { ") x.linef("x.codecDecodeSelfFromMap(%sl%s, d)", genTempVarPfx, i) @@ -1332,29 +1566,44 @@ func (x *genRunner) decStruct(varname string, rtid uintptr, t reflect.Type) { x.line("}") // else if container is array - // x.line("} else if z.DecContainerIsArray() { ") - x.line("} else if r.IsContainerType(codecSelverValueTypeArray" + x.xs + ") {") + x.linef("} else if %sct%s == codecSelferValueTypeArray%s {", genTempVarPfx, i, x.xs) x.line(genTempVarPfx + "l" + i + " := r.ReadArrayStart()") x.linef("if %sl%s == 0 {", genTempVarPfx, i) - x.line("r.ReadArrayEnd()") + x.linef("z.DecSendContainerState(codecSelfer_containerArrayEnd%s)", x.xs) x.line("} else { ") x.linef("x.codecDecodeSelfFromArray(%sl%s, d)", genTempVarPfx, i) x.line("}") // else panic x.line("} else { ") x.line("panic(codecSelferOnlyMapOrArrayEncodeToStructErr" + x.xs + ")") - // x.line("panic(`only encoded map or array can be decoded into a struct`)") x.line("} ") } // -------- type genV struct { - // genV is either a primitive (Primitive != "") or a slice (Slice = true) or a map. - Slice bool + // genV is either a primitive (Primitive != "") or a map (MapKey != "") or a slice MapKey string Elem string Primitive string + Size int +} + +func (x *genRunner) newGenV(t reflect.Type) (v genV) { + switch t.Kind() { + case reflect.Slice, reflect.Array: + te := t.Elem() + v.Elem = x.genTypeName(te) + v.Size = int(te.Size()) + case reflect.Map: + te, tk := t.Elem(), t.Key() + v.Elem = x.genTypeName(te) + v.MapKey = x.genTypeName(tk) + v.Size = int(te.Size() + tk.Size()) + default: + panic("unexpected type for newGenV. Requires map or slice type") + } + return } func (x *genV) MethodNamePfx(prefix string, prim bool) string { @@ -1365,7 +1614,7 @@ func (x *genV) MethodNamePfx(prefix string, prim bool) string { if prim { name = append(name, genTitleCaseName(x.Primitive)...) } else { - if x.Slice { + if x.MapKey == "" { name = append(name, "Slice"...) } else { name = append(name, "Map"...) @@ -1377,6 +1626,47 @@ func (x *genV) MethodNamePfx(prefix string, prim bool) string { } +// genImportPath returns import path of a non-predeclared named typed, or an empty string otherwise. +// +// This handles the misbehaviour that occurs when 1.5-style vendoring is enabled, +// where PkgPath returns the full path, including the vendoring pre-fix that should have been stripped. +// We strip it here. +func genImportPath(t reflect.Type) (s string) { + s = t.PkgPath() + if genCheckVendor { + // HACK: Misbehaviour occurs in go 1.5. May have to re-visit this later. + // if s contains /vendor/ OR startsWith vendor/, then return everything after it. + const vendorStart = "vendor/" + const vendorInline = "/vendor/" + if i := strings.LastIndex(s, vendorInline); i >= 0 { + s = s[i+len(vendorInline):] + } else if strings.HasPrefix(s, vendorStart) { + s = s[len(vendorStart):] + } + } + return +} + +// A go identifier is (letter|_)[letter|number|_]* +func genGoIdentifier(s string, checkFirstChar bool) string { + b := make([]byte, 0, len(s)) + t := make([]byte, 4) + var n int + for i, r := range s { + if checkFirstChar && i == 0 && !unicode.IsLetter(r) { + b = append(b, '_') + } + // r must be unicode_letter, unicode_digit or _ + if unicode.IsLetter(r) || unicode.IsDigit(r) { + n = utf8.EncodeRune(t, r) + b = append(b, t[:n]...) + } else { + b = append(b, '_') + } + } + return string(b) +} + func genNonPtr(t reflect.Type) reflect.Type { for t.Kind() == reflect.Ptr { t = t.Elem() @@ -1386,66 +1676,24 @@ func genNonPtr(t reflect.Type) reflect.Type { func genTitleCaseName(s string) string { switch s { - case "interface{}": + case "interface{}", "interface {}": return "Intf" default: return strings.ToUpper(s[0:1]) + s[1:] } } -func genTypeNamePrimitiveKind(t reflect.Type, tRef reflect.Type) (n string) { - if tRef != nil && t.PkgPath() == tRef.PkgPath() && t.Name() != "" { - return t.Name() - } else { - return t.String() // best way to get the package name inclusive - } -} - -func genTypeName(t reflect.Type, tRef reflect.Type) (n string) { - // 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. - // We cannot depend on t.String() because it includes current package, - // or t.PkgPath because it includes full import path, - // - var ptrPfx string - for t.Kind() == reflect.Ptr { - ptrPfx += "*" - t = t.Elem() - } - if tn := t.Name(); tn != "" { - return ptrPfx + genTypeNamePrimitiveKind(t, tRef) - } - switch t.Kind() { - case reflect.Map: - return ptrPfx + "map[" + genTypeName(t.Key(), tRef) + "]" + genTypeName(t.Elem(), tRef) - case reflect.Slice: - return ptrPfx + "[]" + genTypeName(t.Elem(), tRef) - case reflect.Array: - return ptrPfx + "[" + strconv.FormatInt(int64(t.Len()), 10) + "]" + genTypeName(t.Elem(), tRef) - case reflect.Chan: - return ptrPfx + t.ChanDir().String() + " " + genTypeName(t.Elem(), tRef) - default: - if t == intfTyp { - return ptrPfx + "interface{}" - } else { - return ptrPfx + genTypeNamePrimitiveKind(t, tRef) - } - } -} - func genMethodNameT(t reflect.Type, tRef reflect.Type) (n string) { var ptrPfx string for t.Kind() == reflect.Ptr { ptrPfx += "Ptrto" t = t.Elem() } + tstr := t.String() if tn := t.Name(); tn != "" { - if tRef != nil && t.PkgPath() == tRef.PkgPath() { + if tRef != nil && genImportPath(t) == genImportPath(tRef) { return ptrPfx + tn } else { - tstr := t.String() if genQNameRegex.MatchString(tstr) { return ptrPfx + strings.Replace(tstr, ".", "_", 1000) } else { @@ -1475,17 +1723,16 @@ func genMethodNameT(t reflect.Type, tRef reflect.Type) (n string) { if t == intfTyp { return ptrPfx + "Interface" } else { - if tRef != nil && t.PkgPath() == tRef.PkgPath() { + if tRef != nil && genImportPath(t) == genImportPath(tRef) { if t.Name() != "" { return ptrPfx + t.Name() } else { - return ptrPfx + genCustomTypeName(t.String()) + return ptrPfx + genCustomTypeName(tstr) } } else { // best way to get the package name inclusive - // return ptrPfx + strings.Replace(t.String(), ".", "_", 1000) - // return ptrPfx + genBase64enc.EncodeToString([]byte(t.String())) - tstr := t.String() + // return ptrPfx + strings.Replace(tstr, ".", "_", 1000) + // return ptrPfx + genBase64enc.EncodeToString([]byte(tstr)) if t.Name() != "" && genQNameRegex.MatchString(tstr) { return ptrPfx + strings.Replace(tstr, ".", "_", 1000) } else { @@ -1513,24 +1760,7 @@ func genCustomTypeName(tstr string) string { } func genIsImmutable(t reflect.Type) (v bool) { - return isMutableKind(t.Kind()) -} - -func genZeroValueR(t reflect.Type, tRef reflect.Type) string { - // if t is a named type, w - switch t.Kind() { - case reflect.Ptr, reflect.Interface, reflect.Chan, reflect.Func, - reflect.Slice, reflect.Map, reflect.Invalid: - return "nil" - case reflect.Bool: - return "false" - case reflect.String: - return `""` - case reflect.Struct, reflect.Array: - return genTypeName(t, tRef) + "{}" - default: // all numbers - return "0" - } + return isImmutableKind(t.Kind()) } type genInternal struct { @@ -1549,7 +1779,7 @@ func (x genInternal) FastpathLen() (l int) { func genInternalZeroValue(s string) string { switch s { - case "interface{}": + case "interface{}", "interface {}": return "nil" case "bool": return "false" @@ -1593,6 +1823,8 @@ func genInternalDecCommandAsString(s string) string { return "uint32(dd.DecodeUint(32))" case "uint64": return "dd.DecodeUint(64)" + case "uintptr": + return "uintptr(dd.DecodeUint(uintBitsize))" case "int": return "int(dd.DecodeInt(intBitsize))" case "int8": @@ -1613,9 +1845,24 @@ func genInternalDecCommandAsString(s string) string { case "bool": return "dd.DecodeBool()" default: - panic(errors.New("unknown type for decode: " + s)) + 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"} { + if strings.HasPrefix(s, v) { + if elem { + if v == "int" || v == "uint" || v == "float" { + return v + "64" + } else { + return v + } + } + return v + "Slice" + } + } + panic("sorttype: unexpected type: " + s) } // var genInternalMu sync.Mutex @@ -1634,6 +1881,7 @@ func genInternalInit() { "uint16", "uint32", "uint64", + "uintptr", "int", "int8", "int16", @@ -1651,6 +1899,7 @@ func genInternalInit() { "uint16", "uint32", "uint64", + "uintptr", "int", "int8", "int16", @@ -1660,23 +1909,39 @@ func genInternalInit() { "float64", "bool", } - mapvaltypes2 := make(map[string]bool) - for _, s := range mapvaltypes { - mapvaltypes2[s] = true + wordSizeBytes := int(intBitsize) / 8 + + mapvaltypes2 := map[string]int{ + "interface{}": 2 * wordSizeBytes, + "string": 2 * wordSizeBytes, + "uint": 1 * wordSizeBytes, + "uint8": 1, + "uint16": 2, + "uint32": 4, + "uint64": 8, + "uintptr": 1 * wordSizeBytes, + "int": 1 * wordSizeBytes, + "int8": 1, + "int16": 2, + "int32": 4, + "int64": 8, + "float32": 4, + "float64": 8, + "bool": 1, } var gt genInternal // For each slice or map type, there must be a (symetrical) Encode and Decode fast-path function for _, s := range types { - gt.Values = append(gt.Values, genV{false, "", "", s}) + gt.Values = append(gt.Values, genV{Primitive: s, Size: mapvaltypes2[s]}) if s != "uint8" { // do not generate fast path for slice of bytes. Treat specially already. - gt.Values = append(gt.Values, genV{true, "", s, ""}) + gt.Values = append(gt.Values, genV{Elem: s, Size: mapvaltypes2[s]}) } - if !mapvaltypes2[s] { - gt.Values = append(gt.Values, genV{false, s, 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, genV{false, s, ms, ""}) + gt.Values = append(gt.Values, genV{MapKey: s, Elem: ms, Size: mapvaltypes2[s] + mapvaltypes2[ms]}) } } @@ -1685,16 +1950,18 @@ func genInternalInit() { funcs["encmd"] = genInternalEncCommandAsString funcs["decmd"] = genInternalDecCommandAsString funcs["zerocmd"] = genInternalZeroValue + funcs["hasprefix"] = strings.HasPrefix + funcs["sorttype"] = genInternalSortType genInternalV = gt genInternalTmplFuncs = funcs } -// GenInternalGoFile is used to generate source files from templates. +// genInternalGoFile is used to generate source files from templates. // It is run by the program author alone. // Unfortunately, it has to be exported so that it can be called from a command line tool. // *** DO NOT USE *** -func GenInternalGoFile(r io.Reader, w io.Writer, safe bool) (err error) { +func genInternalGoFile(r io.Reader, w io.Writer, safe bool) (err error) { genInternalOnce.Do(genInternalInit) gt := genInternalV diff --git a/_vendor/vendor/github.com/ugorji/go/codec/gen_15.go b/_vendor/vendor/github.com/ugorji/go/codec/gen_15.go new file mode 100644 index 0000000..ab76c31 --- /dev/null +++ b/_vendor/vendor/github.com/ugorji/go/codec/gen_15.go @@ -0,0 +1,12 @@ +// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Use of this source code is governed by a MIT license found in the LICENSE file. + +// +build go1.5,!go1.6 + +package codec + +import "os" + +func init() { + genCheckVendor = os.Getenv("GO15VENDOREXPERIMENT") == "1" +} diff --git a/_vendor/vendor/github.com/ugorji/go/codec/gen_16.go b/_vendor/vendor/github.com/ugorji/go/codec/gen_16.go new file mode 100644 index 0000000..87c04e2 --- /dev/null +++ b/_vendor/vendor/github.com/ugorji/go/codec/gen_16.go @@ -0,0 +1,12 @@ +// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Use of this source code is governed by a MIT license found in the LICENSE file. + +// +build go1.6 + +package codec + +import "os" + +func init() { + genCheckVendor = os.Getenv("GO15VENDOREXPERIMENT") != "0" +} diff --git a/cmd/vendor/github.com/ugorji/go/codec/helper.go b/_vendor/vendor/github.com/ugorji/go/codec/helper.go similarity index 56% rename from cmd/vendor/github.com/ugorji/go/codec/helper.go rename to _vendor/vendor/github.com/ugorji/go/codec/helper.go index 7848ea1..ec8dedf 100644 --- a/cmd/vendor/github.com/ugorji/go/codec/helper.go +++ b/_vendor/vendor/github.com/ugorji/go/codec/helper.go @@ -101,6 +101,7 @@ package codec // check for these error conditions. import ( + "bytes" "encoding" "encoding/binary" "errors" @@ -111,12 +112,11 @@ import ( "strings" "sync" "time" - "unicode" - "unicode/utf8" ) const ( scratchByteArrayLen = 32 + initCollectionCap = 32 // 32 is defensive. 16 is preferred. // Support encoding.(Binary|Text)(Unm|M)arshaler. // This constant flag will enable or disable it. @@ -137,20 +137,24 @@ const ( // Note that this will always cause rpc tests to fail, since they need io.EOF sent via panic. recoverPanicToErr = true - // Fast path functions try to create a fast path encode or decode implementation - // for common maps and slices, by by-passing reflection altogether. - fastpathEnabled = true - // if checkStructForEmptyValue, check structs fields to see if an empty value. // This could be an expensive call, so possibly disable it. checkStructForEmptyValue = false // if derefForIsEmptyValue, deref pointers and interfaces when checking isEmptyValue derefForIsEmptyValue = false + + // if resetSliceElemToZeroValue, then on decoding a slice, reset the element to a zero value first. + // Only concern is that, if the slice already contained some garbage, we will decode into that garbage. + // The chances of this are slim, so leave this "optimization". + // TODO: should this be true, to ensure that we always decode into a "zero" "empty" value? + resetSliceElemToZeroValue bool = false ) -var oneByteArr = [1]byte{0} -var zeroByteSlice = oneByteArr[:0:0] +var ( + oneByteArr = [1]byte{0} + zeroByteSlice = oneByteArr[:0:0] +) type charEncoding uint8 @@ -193,16 +197,78 @@ const ( seqTypeChan ) +// note that containerMapStart and containerArraySend are not sent. +// This is because the ReadXXXStart and EncodeXXXStart already does these. +type containerState uint8 + +const ( + _ containerState = iota + + containerMapStart // slot left open, since Driver method already covers it + containerMapKey + containerMapValue + containerMapEnd + containerArrayStart // slot left open, since Driver methods already cover it + containerArrayElem + containerArrayEnd +) + +// sfiIdx used for tracking where a fieldName is seen in a []*structFieldInfo +type sfiIdx struct { + fieldName 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, +// so as not to cause an infinite loop. +const rgetMaxRecursion = 2 + +// Anecdotally, we believe most types have <= 12 fields. +// Java's PMD rules set TooManyFields threshold to 15. +const rgetPoolTArrayLen = 12 + +type rgetT struct { + fNames []string + encNames []string + etypes []uintptr + sfis []*structFieldInfo +} + +type rgetPoolT struct { + fNames [rgetPoolTArrayLen]string + encNames [rgetPoolTArrayLen]string + etypes [rgetPoolTArrayLen]uintptr + sfis [rgetPoolTArrayLen]*structFieldInfo + sfiidx [rgetPoolTArrayLen]sfiIdx +} + +var rgetPool = sync.Pool{ + New: func() interface{} { return new(rgetPoolT) }, +} + +type containerStateRecv interface { + sendContainerState(containerState) +} + +// mirror json.Marshaler and json.Unmarshaler here, +// so we don't import the encoding/json package +type jsonMarshaler interface { + MarshalJSON() ([]byte, error) +} +type jsonUnmarshaler interface { + UnmarshalJSON([]byte) error +} + var ( bigen = binary.BigEndian structInfoFieldName = "_struct" - cachedTypeInfo = make(map[uintptr]*typeInfo, 64) - cachedTypeInfoMutex sync.RWMutex - - // mapStrIntfTyp = reflect.TypeOf(map[string]interface{}(nil)) - intfSliceTyp = reflect.TypeOf([]interface{}(nil)) - intfTyp = intfSliceTyp.Elem() + mapStrIntfTyp = reflect.TypeOf(map[string]interface{}(nil)) + mapIntfIntfTyp = reflect.TypeOf(map[interface{}]interface{}(nil)) + intfSliceTyp = reflect.TypeOf([]interface{}(nil)) + intfTyp = intfSliceTyp.Elem() stringTyp = reflect.TypeOf("") timeTyp = reflect.TypeOf(time.Time{}) @@ -217,6 +283,9 @@ var ( textMarshalerTyp = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem() textUnmarshalerTyp = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem() + jsonMarshalerTyp = reflect.TypeOf((*jsonMarshaler)(nil)).Elem() + jsonUnmarshalerTyp = reflect.TypeOf((*jsonUnmarshaler)(nil)).Elem() + selferTyp = reflect.TypeOf((*Selfer)(nil)).Elem() uint8SliceTypId = reflect.ValueOf(uint8SliceTyp).Pointer() @@ -225,6 +294,9 @@ var ( timeTypId = reflect.ValueOf(timeTyp).Pointer() stringTypId = reflect.ValueOf(stringTyp).Pointer() + mapStrIntfTypId = reflect.ValueOf(mapStrIntfTyp).Pointer() + mapIntfIntfTypId = reflect.ValueOf(mapIntfIntfTyp).Pointer() + intfSliceTypId = reflect.ValueOf(intfSliceTyp).Pointer() // mapBySliceTypId = reflect.ValueOf(mapBySliceTyp).Pointer() intBitsize uint8 = uint8(reflect.TypeOf(int(0)).Bits()) @@ -238,6 +310,8 @@ var ( noFieldNameToStructFieldInfoErr = errors.New("no field name passed to parseStructFieldInfo") ) +var defTypeInfos = NewTypeInfos([]string{"codec", "json"}) + // 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. @@ -263,6 +337,11 @@ type MapBySlice interface { // // BasicHandle encapsulates the common options and extension functions. type BasicHandle struct { + // TypeInfos is used to get the type info for any type. + // + // If not configured, the default TypeInfos is used, which uses struct tag keys: codec, json + TypeInfos *TypeInfos + extHandle EncodeOptions DecodeOptions @@ -272,6 +351,13 @@ func (x *BasicHandle) getBasicHandle() *BasicHandle { return x } +func (x *BasicHandle) getTypeInfo(rtid uintptr, rt reflect.Type) (pti *typeInfo) { + if x.TypeInfos != nil { + return x.TypeInfos.get(rtid, rt) + } + return defTypeInfos.get(rtid, rt) +} + // Handle is the interface for a specific encoding format. // // Typically, a Handle is pre-configured before first time use, @@ -298,33 +384,45 @@ type RawExt struct { Value interface{} } -// Ext handles custom (de)serialization of custom types / extensions. -type Ext interface { +// BytesExt handles custom (de)serialization of types to/from []byte. +// It is used by codecs (e.g. binc, msgpack, simple) which do custom serialization of the types. +type BytesExt interface { // WriteExt converts a value to a []byte. - // It is used by codecs (e.g. binc, msgpack, simple) which do custom serialization of the types. + // + // Note: v *may* be a pointer to the extension type, if the extension type was a struct or array. WriteExt(v interface{}) []byte // ReadExt updates a value from a []byte. - // It is used by codecs (e.g. binc, msgpack, simple) which do custom serialization of the types. ReadExt(dst interface{}, src []byte) +} +// InterfaceExt handles custom (de)serialization of types to/from another interface{} value. +// The Encoder or Decoder will then handle the further (de)serialization of that known type. +// +// It is used by codecs (e.g. cbor, json) which use the format to do custom serialization of the types. +type InterfaceExt interface { // ConvertExt converts a value into a simpler interface for easy encoding e.g. convert time.Time to int64. - // It is used by codecs (e.g. cbor) which use the format to do custom serialization of the types. + // + // Note: v *may* be a pointer to the extension type, if the extension type was a struct or array. ConvertExt(v interface{}) interface{} // UpdateExt updates a value from a simpler interface for easy decoding e.g. convert int64 to time.Time. - // It is used by codecs (e.g. cbor) which use the format to do custom serialization of the types. UpdateExt(dst interface{}, src interface{}) } -// bytesExt is a wrapper implementation to support former AddExt exported method. -type bytesExt struct { +// Ext handles custom (de)serialization of custom types / extensions. +type Ext interface { + BytesExt + InterfaceExt +} + +// addExtWrapper is a wrapper implementation to support former AddExt exported method. +type addExtWrapper struct { encFn func(reflect.Value) ([]byte, error) decFn func(reflect.Value, []byte) error } -func (x bytesExt) WriteExt(v interface{}) []byte { - // fmt.Printf(">>>>>>>>>> WriteExt: %T, %v\n", v, v) +func (x addExtWrapper) WriteExt(v interface{}) []byte { bs, err := x.encFn(reflect.ValueOf(v)) if err != nil { panic(err) @@ -332,21 +430,56 @@ func (x bytesExt) WriteExt(v interface{}) []byte { return bs } -func (x bytesExt) ReadExt(v interface{}, bs []byte) { - // fmt.Printf(">>>>>>>>>> ReadExt: %T, %v\n", v, v) +func (x addExtWrapper) ReadExt(v interface{}, bs []byte) { if err := x.decFn(reflect.ValueOf(v), bs); err != nil { panic(err) } } -func (x bytesExt) ConvertExt(v interface{}) interface{} { +func (x addExtWrapper) ConvertExt(v interface{}) interface{} { return x.WriteExt(v) } -func (x bytesExt) UpdateExt(dest interface{}, v interface{}) { +func (x addExtWrapper) UpdateExt(dest interface{}, v interface{}) { x.ReadExt(dest, v.([]byte)) } +type setExtWrapper struct { + b BytesExt + i InterfaceExt +} + +func (x *setExtWrapper) WriteExt(v interface{}) []byte { + if x.b == nil { + panic("BytesExt.WriteExt is not supported") + } + return x.b.WriteExt(v) +} + +func (x *setExtWrapper) ReadExt(v interface{}, bs []byte) { + if x.b == nil { + panic("BytesExt.WriteExt is not supported") + + } + x.b.ReadExt(v, bs) +} + +func (x *setExtWrapper) ConvertExt(v interface{}) interface{} { + if x.i == nil { + panic("InterfaceExt.ConvertExt is not supported") + + } + return x.i.ConvertExt(v) +} + +func (x *setExtWrapper) UpdateExt(dest interface{}, v interface{}) { + if x.i == nil { + panic("InterfaceExxt.UpdateExt is not supported") + + } + x.i.UpdateExt(dest, v) +} + // type errorString string // func (x errorString) Error() string { return string(x) } @@ -399,9 +532,9 @@ type extTypeTagFn struct { ext Ext } -type extHandle []*extTypeTagFn +type extHandle []extTypeTagFn -// DEPRECATED: AddExt is deprecated in favor of SetExt. It exists for compatibility only. +// DEPRECATED: Use SetBytesExt or SetInterfaceExt on the Handle instead. // // AddExt registes an encode and decode function for a reflect.Type. // AddExt internally calls SetExt. @@ -413,10 +546,10 @@ func (o *extHandle) AddExt( if encfn == nil || decfn == nil { return o.SetExt(rt, uint64(tag), nil) } - return o.SetExt(rt, uint64(tag), bytesExt{encfn, decfn}) + return o.SetExt(rt, uint64(tag), addExtWrapper{encfn, decfn}) } -// SetExt registers a tag and Ext for a reflect.Type. +// DEPRECATED: Use SetBytesExt or SetInterfaceExt on the Handle instead. // // Note that the type must be a named type, and specifically not // a pointer or Interface. An error is returned if that is not honored. @@ -425,7 +558,7 @@ func (o *extHandle) AddExt( func (o *extHandle) SetExt(rt reflect.Type, tag uint64, ext Ext) (err error) { // o is a pointer, because we may need to initialize it if rt.PkgPath() == "" || rt.Kind() == reflect.Interface { - err = fmt.Errorf("codec.Handle.AddExt: Takes named type, especially not a pointer or interface: %T", + err = fmt.Errorf("codec.Handle.AddExt: Takes named type, not a pointer or interface: %T", reflect.Zero(rt).Interface()) return } @@ -438,12 +571,17 @@ func (o *extHandle) SetExt(rt reflect.Type, tag uint64, ext Ext) (err error) { } } - *o = append(*o, &extTypeTagFn{rtid, rt, tag, ext}) + if *o == nil { + *o = make([]extTypeTagFn, 0, 4) + } + *o = append(*o, extTypeTagFn{rtid, rt, tag, ext}) return } func (o extHandle) getExt(rtid uintptr) *extTypeTagFn { - for _, v := range o { + var v *extTypeTagFn + for i := range o { + v = &o[i] if v.rtid == rtid { return v } @@ -452,7 +590,9 @@ func (o extHandle) getExt(rtid uintptr) *extTypeTagFn { } func (o extHandle) getExtForTag(tag uint64) *extTypeTagFn { - for _, v := range o { + var v *extTypeTagFn + for i := range o { + v = &o[i] if v.tag == tag { return v } @@ -461,7 +601,8 @@ func (o extHandle) getExtForTag(tag uint64) *extTypeTagFn { } type structFieldInfo struct { - encName string // encode name + encName string // encode name + fieldName string // field name // only one of 'i' or 'is' can be set. If 'i' is -1, then 'is' has been set. @@ -471,6 +612,10 @@ type structFieldInfo struct { toArray bool // if field is _struct, is the toArray set? } +// func (si *structFieldInfo) isZero() bool { +// return si.encName == "" && len(si.is) == 0 && si.i == 0 && !si.omitEmpty && !si.toArray +// } + // rv returns the field of the struct. // If anonymous, it returns an Invalid func (si *structFieldInfo) field(v reflect.Value, update bool) (rv2 reflect.Value) { @@ -516,9 +661,9 @@ func (si *structFieldInfo) setToZeroValue(v reflect.Value) { } func parseStructFieldInfo(fname string, stag string) *structFieldInfo { - if fname == "" { - panic(noFieldNameToStructFieldInfoErr) - } + // if fname == "" { + // panic(noFieldNameToStructFieldInfoErr) + // } si := structFieldInfo{ encName: fname, } @@ -571,6 +716,8 @@ type typeInfo struct { rt reflect.Type rtid uintptr + numMeth uint16 // number of methods + // baseId gives pointer to the base reflect.Type, after deferencing // the pointers. E.g. base type of ***time.Time is time.Time. base reflect.Type @@ -589,6 +736,11 @@ type typeInfo struct { tmIndir int8 // number of indirections to get to textMarshaler type tunmIndir int8 // number of indirections to get to textUnmarshaler type + jm bool // base type (T or *T) is a jsonMarshaler + junm bool // base type (T or *T) is a jsonUnmarshaler + jmIndir int8 // number of indirections to get to jsonMarshaler type + junmIndir int8 // number of indirections to get to jsonUnmarshaler type + cs bool // base type (T or *T) is a Selfer csIndir int8 // number of indirections to get to Selfer type @@ -596,6 +748,7 @@ type typeInfo struct { } func (ti *typeInfo) indexForEncName(name string) int { + // NOTE: name may be a stringView, so don't pass it to another function. //tisfi := ti.sfi const binarySearchThreshold = 16 if sfilen := len(ti.sfi); sfilen < binarySearchThreshold { @@ -623,33 +776,49 @@ func (ti *typeInfo) indexForEncName(name string) int { return -1 } -func getStructTag(t reflect.StructTag) (s string) { +// TypeInfos caches typeInfo for each type on first inspection. +// +// It is configured with a set of tag keys, which are used to get +// configuration for the type. +type TypeInfos struct { + infos map[uintptr]*typeInfo + mu sync.RWMutex + tags []string +} + +// NewTypeInfos creates a TypeInfos given a set of struct tags keys. +// +// This allows users customize the struct tag keys which contain configuration +// of their types. +func NewTypeInfos(tags []string) *TypeInfos { + return &TypeInfos{tags: tags, infos: make(map[uintptr]*typeInfo, 64)} +} + +func (x *TypeInfos) structTag(t reflect.StructTag) (s string) { // check for tags: codec, json, in that order. // this allows seamless support for many configured structs. - s = t.Get("codec") - if s == "" { - s = t.Get("json") + for _, x := range x.tags { + s = t.Get(x) + if s != "" { + return s + } } return } -func getTypeInfo(rtid uintptr, rt reflect.Type) (pti *typeInfo) { +func (x *TypeInfos) get(rtid uintptr, rt reflect.Type) (pti *typeInfo) { var ok bool - cachedTypeInfoMutex.RLock() - pti, ok = cachedTypeInfo[rtid] - cachedTypeInfoMutex.RUnlock() + x.mu.RLock() + pti, ok = x.infos[rtid] + x.mu.RUnlock() if ok { return } - cachedTypeInfoMutex.Lock() - defer cachedTypeInfoMutex.Unlock() - if pti, ok = cachedTypeInfo[rtid]; ok { - return - } - + // do not hold lock while computing this. + // it may lead to duplication, but that's ok. ti := typeInfo{rt: rt, rtid: rtid} - pti = &ti + ti.numMeth = uint16(rt.NumMethod()) var indir int8 if ok, indir = implementsIntf(rt, binaryMarshalerTyp); ok { @@ -664,6 +833,12 @@ func getTypeInfo(rtid uintptr, rt reflect.Type) (pti *typeInfo) { if ok, indir = implementsIntf(rt, textUnmarshalerTyp); ok { ti.tunm, ti.tunmIndir = true, indir } + if ok, indir = implementsIntf(rt, jsonMarshalerTyp); ok { + ti.jm, ti.jmIndir = true, indir + } + if ok, indir = implementsIntf(rt, jsonUnmarshalerTyp); ok { + ti.junm, ti.junmIndir = true, indir + } if ok, indir = implementsIntf(rt, selferTyp); ok { ti.cs, ti.csIndir = true, indir } @@ -688,79 +863,184 @@ func getTypeInfo(rtid uintptr, rt reflect.Type) (pti *typeInfo) { } if rt.Kind() == reflect.Struct { - var siInfo *structFieldInfo + var omitEmpty bool if f, ok := rt.FieldByName(structInfoFieldName); ok { - siInfo = parseStructFieldInfo(structInfoFieldName, getStructTag(f.Tag)) + siInfo := parseStructFieldInfo(structInfoFieldName, x.structTag(f.Tag)) ti.toArray = siInfo.toArray + omitEmpty = siInfo.omitEmpty } - sfip := make([]*structFieldInfo, 0, rt.NumField()) - rgetTypeInfo(rt, nil, make(map[string]bool, 16), &sfip, siInfo) - - ti.sfip = make([]*structFieldInfo, len(sfip)) - ti.sfi = make([]*structFieldInfo, len(sfip)) - copy(ti.sfip, sfip) - sort.Sort(sfiSortedByEncName(sfip)) - copy(ti.sfi, sfip) + pi := rgetPool.Get() + pv := pi.(*rgetPoolT) + pv.etypes[0] = ti.baseId + vv := rgetT{pv.fNames[:0], pv.encNames[:0], pv.etypes[:1], pv.sfis[:0]} + x.rget(rt, rtid, omitEmpty, nil, &vv) + ti.sfip, ti.sfi = rgetResolveSFI(vv.sfis, pv.sfiidx[:0]) + rgetPool.Put(pi) } // sfi = sfip - cachedTypeInfo[rtid] = pti + + x.mu.Lock() + if pti, ok = x.infos[rtid]; !ok { + pti = &ti + x.infos[rtid] = pti + } + x.mu.Unlock() return } -func rgetTypeInfo(rt reflect.Type, indexstack []int, fnameToHastag map[string]bool, - sfi *[]*structFieldInfo, siInfo *structFieldInfo, +func (x *TypeInfos) rget(rt reflect.Type, rtid uintptr, omitEmpty bool, + indexstack []int, pv *rgetT, ) { - for j := 0; j < rt.NumField(); j++ { + // Read up fields and store how to access the value. + // + // It uses go's rules for message selectors, + // which say that the field with the shallowest depth is selected. + // + // Note: we consciously use slices, not a map, to simulate a set. + // Typically, types have < 16 fields, + // and iteration using equals is faster than maps there + +LOOP: + for j, jlen := 0, rt.NumField(); j < jlen; j++ { f := rt.Field(j) - // func types are skipped. - if tk := f.Type.Kind(); tk == reflect.Func { + fkind := f.Type.Kind() + // skip if a func type, or is unexported, or structTag value == "-" + switch fkind { + case reflect.Func, reflect.Complex64, reflect.Complex128, reflect.UnsafePointer: + continue LOOP + } + + // if r1, _ := utf8.DecodeRuneInString(f.Name); + // r1 == utf8.RuneError || !unicode.IsUpper(r1) { + if f.PkgPath != "" && !f.Anonymous { // unexported, not embedded continue } - stag := getStructTag(f.Tag) + stag := x.structTag(f.Tag) if stag == "-" { continue } - if r1, _ := utf8.DecodeRuneInString(f.Name); r1 == utf8.RuneError || !unicode.IsUpper(r1) { - continue - } - // if anonymous and there is no struct tag and its a struct (or pointer to struct), inline it. - if f.Anonymous && stag == "" { - ft := f.Type - for ft.Kind() == reflect.Ptr { - ft = ft.Elem() + var si *structFieldInfo + // if anonymous and no struct tag (or it's blank), + // and a struct (or pointer to struct), inline it. + if f.Anonymous && fkind != reflect.Interface { + doInline := stag == "" + if !doInline { + si = parseStructFieldInfo("", stag) + doInline = si.encName == "" + // doInline = si.isZero() } - if ft.Kind() == reflect.Struct { - indexstack2 := make([]int, len(indexstack)+1, len(indexstack)+4) - copy(indexstack2, indexstack) - indexstack2[len(indexstack)] = j - // indexstack2 := append(append(make([]int, 0, len(indexstack)+4), indexstack...), j) - rgetTypeInfo(ft, indexstack2, fnameToHastag, sfi, siInfo) - continue + if doInline { + ft := f.Type + for ft.Kind() == reflect.Ptr { + ft = ft.Elem() + } + if ft.Kind() == reflect.Struct { + // if etypes contains this, don't call rget again (as fields are already seen here) + ftid := reflect.ValueOf(ft).Pointer() + // We cannot recurse forever, but we need to track other field depths. + // So - we break if we see a type twice (not the first time). + // This should be sufficient to handle an embedded type that refers to its + // owning type, which then refers to its embedded type. + processIt := true + numk := 0 + for _, k := range pv.etypes { + if k == ftid { + numk++ + if numk == rgetMaxRecursion { + processIt = false + break + } + } + } + if processIt { + pv.etypes = append(pv.etypes, ftid) + indexstack2 := make([]int, len(indexstack)+1) + copy(indexstack2, indexstack) + indexstack2[len(indexstack)] = j + // indexstack2 := append(append(make([]int, 0, len(indexstack)+4), indexstack...), j) + x.rget(ft, ftid, omitEmpty, indexstack2, pv) + } + continue + } } } - // do not let fields with same name in embedded structs override field at higher level. - // this must be done after anonymous check, to allow anonymous field - // still include their child fields - if _, ok := fnameToHastag[f.Name]; ok { + + // after the anonymous dance: if an unexported field, skip + if f.PkgPath != "" { // unexported continue } - si := parseStructFieldInfo(f.Name, stag) + + if f.Name == "" { + panic(noFieldNameToStructFieldInfoErr) + } + + pv.fNames = append(pv.fNames, f.Name) + + if si == nil { + si = parseStructFieldInfo(f.Name, stag) + } else if si.encName == "" { + si.encName = f.Name + } + si.fieldName = f.Name + + pv.encNames = append(pv.encNames, si.encName) + // si.ikind = int(f.Type.Kind()) if len(indexstack) == 0 { si.i = int16(j) } else { si.i = -1 - si.is = append(append(make([]int, 0, len(indexstack)+4), indexstack...), j) + si.is = make([]int, len(indexstack)+1) + copy(si.is, indexstack) + si.is[len(indexstack)] = j + // si.is = append(append(make([]int, 0, len(indexstack)+4), indexstack...), j) } - if siInfo != nil { - if siInfo.omitEmpty { - si.omitEmpty = true + if omitEmpty { + si.omitEmpty = true + } + pv.sfis = append(pv.sfis, si) + } +} + +// resolves the struct field info get from a call to rget2. +// Returns a trimmed, unsorted and sorted []*structFieldInfo. +func rgetResolveSFI(x []*structFieldInfo, pv []sfiIdx) (y, z []*structFieldInfo) { + var n int + for i, v := range x { + xf := v.fieldName + var found bool + for _, k := range pv { + if k.fieldName == xf { + if len(v.is) < len(x[k.index].is) { + x[k.index] = nil + k.index = i + n++ + } + found = true + break } } - *sfi = append(*sfi, si) - fnameToHastag[f.Name] = stag != "" + if !found { + pv = append(pv, sfiIdx{xf, i}) + } } + + // remove all the nils + y = make([]*structFieldInfo, len(x)-n) + n = 0 + for _, v := range x { + if v == nil { + continue + } + y[n] = v + n++ + } + + z = make([]*structFieldInfo, len(y)) + copy(z, y) + sort.Sort(sfiSortedByEncName(z)) + return } func panicToErr(err *error) { @@ -779,8 +1059,9 @@ func panicToErr(err *error) { // panic(fmt.Errorf("%s: "+format, params2...)) // } -func isMutableKind(k reflect.Kind) (v bool) { - return k == reflect.Int || +func isImmutableKind(k reflect.Kind) (v bool) { + return false || + k == reflect.Int || k == reflect.Int8 || k == reflect.Int16 || k == reflect.Int32 || @@ -790,6 +1071,7 @@ func isMutableKind(k reflect.Kind) (v bool) { k == reflect.Uint16 || k == reflect.Uint32 || k == reflect.Uint64 || + k == reflect.Uintptr || k == reflect.Float32 || k == reflect.Float64 || k == reflect.Bool || @@ -844,3 +1126,184 @@ func (_ checkOverflow) SignedInt(v uint64) (i int64, overflow bool) { i = int64(v) return } + +// ------------------ SORT ----------------- + +func isNaN(f float64) bool { return f != f } + +// ----------------------- + +type intSlice []int64 +type uintSlice []uint64 +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[i] < p[j] } +func (p intSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +func (p uintSlice) Len() int { return len(p) } +func (p uintSlice) Less(i, j int) bool { return p[i] < p[j] } +func (p uintSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +func (p floatSlice) Len() int { return len(p) } +func (p floatSlice) Less(i, j int) bool { + return p[i] < p[j] || isNaN(p[i]) && !isNaN(p[j]) +} +func (p floatSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +func (p stringSlice) Len() int { return len(p) } +func (p stringSlice) Less(i, j int) bool { return p[i] < p[j] } +func (p stringSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +func (p bytesSlice) Len() int { return len(p) } +func (p bytesSlice) Less(i, j int) bool { return bytes.Compare(p[i], p[j]) == -1 } +func (p bytesSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +func (p boolSlice) Len() int { return len(p) } +func (p boolSlice) Less(i, j int) bool { return !p[i] && p[j] } +func (p boolSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +// --------------------- + +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 + +func (p intRvSlice) Len() int { return len(p) } +func (p intRvSlice) Less(i, j int) bool { return p[i].v < p[j].v } +func (p intRvSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +func (p uintRvSlice) Len() int { return len(p) } +func (p uintRvSlice) Less(i, j int) bool { return p[i].v < p[j].v } +func (p uintRvSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +func (p floatRvSlice) Len() int { return len(p) } +func (p floatRvSlice) Less(i, j int) bool { + return p[i].v < p[j].v || isNaN(p[i].v) && !isNaN(p[j].v) +} +func (p floatRvSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +func (p stringRvSlice) Len() int { return len(p) } +func (p stringRvSlice) Less(i, j int) bool { return p[i].v < p[j].v } +func (p stringRvSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +func (p bytesRvSlice) Len() int { return len(p) } +func (p bytesRvSlice) Less(i, j int) bool { return bytes.Compare(p[i].v, p[j].v) == -1 } +func (p bytesRvSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +func (p boolRvSlice) Len() int { return len(p) } +func (p boolRvSlice) Less(i, j int) bool { return !p[i].v && p[j].v } +func (p boolRvSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +// ----------------- + +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[i].v, p[j].v) == -1 } +func (p bytesISlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +// ----------------- + +type set []uintptr + +func (s *set) add(v uintptr) (exists bool) { + // e.ci is always nil, or len >= 1 + // defer func() { fmt.Printf("$$$$$$$$$$$ cirRef Add: %v, exists: %v\n", v, exists) }() + x := *s + if x == nil { + x = make([]uintptr, 1, 8) + x[0] = v + *s = x + return + } + // typically, length will be 1. make this perform. + if len(x) == 1 { + if j := x[0]; j == 0 { + x[0] = v + } else if j == v { + exists = true + } else { + x = append(x, v) + *s = x + } + return + } + // check if it exists + for _, j := range x { + if j == v { + exists = true + return + } + } + // try to replace a "deleted" slot + for i, j := range x { + if j == 0 { + x[i] = v + return + } + } + // if unable to replace deleted slot, just append it. + x = append(x, v) + *s = x + return +} + +func (s *set) remove(v uintptr) (exists bool) { + // defer func() { fmt.Printf("$$$$$$$$$$$ cirRef Rm: %v, exists: %v\n", v, exists) }() + x := *s + if len(x) == 0 { + return + } + if len(x) == 1 { + if x[0] == v { + x[0] = 0 + } + return + } + for i, j := range x { + if j == v { + exists = true + x[i] = 0 // set it to 0, as way to delete it. + // copy(x[i:], x[i+1:]) + // x = x[:len(x)-1] + return + } + } + return +} diff --git a/cmd/vendor/github.com/ugorji/go/codec/helper_internal.go b/_vendor/vendor/github.com/ugorji/go/codec/helper_internal.go similarity index 61% rename from cmd/vendor/github.com/ugorji/go/codec/helper_internal.go rename to _vendor/vendor/github.com/ugorji/go/codec/helper_internal.go index c865246..dea981f 100644 --- a/cmd/vendor/github.com/ugorji/go/codec/helper_internal.go +++ b/_vendor/vendor/github.com/ugorji/go/codec/helper_internal.go @@ -149,3 +149,94 @@ func halfFloatToFloatBits(yy uint16) (d uint32) { m = m << 13 return (s << 31) | (e << 23) | m } + +// GrowCap will return a new capacity for a slice, given the following: +// - oldCap: current capacity +// - unit: in-memory size of an element +// - num: number of elements to add +func growCap(oldCap, unit, num int) (newCap int) { + // appendslice logic (if cap < 1024, *2, else *1.25): + // leads to many copy calls, especially when copying bytes. + // bytes.Buffer model (2*cap + n): much better for bytes. + // smarter way is to take the byte-size of the appended element(type) into account + + // maintain 3 thresholds: + // t1: if cap <= t1, newcap = 2x + // t2: if cap <= t2, newcap = 1.75x + // t3: if cap <= t3, newcap = 1.5x + // else newcap = 1.25x + // + // t1, t2, t3 >= 1024 always. + // i.e. if unit size >= 16, then always do 2x or 1.25x (ie t1, t2, t3 are all same) + // + // With this, appending for bytes increase by: + // 100% up to 4K + // 75% up to 8K + // 50% up to 16K + // 25% beyond that + + // unit can be 0 e.g. for struct{}{}; handle that appropriately + var t1, t2, t3 int // thresholds + if unit <= 1 { + t1, t2, t3 = 4*1024, 8*1024, 16*1024 + } else if unit < 16 { + t3 = 16 / unit * 1024 + t1 = t3 * 1 / 4 + t2 = t3 * 2 / 4 + } else { + t1, t2, t3 = 1024, 1024, 1024 + } + + var x int // temporary variable + + // x is multiplier here: one of 5, 6, 7 or 8; incr of 25%, 50%, 75% or 100% respectively + if oldCap <= t1 { // [0,t1] + x = 8 + } else if oldCap > t3 { // (t3,infinity] + x = 5 + } else if oldCap <= t2 { // (t1,t2] + x = 7 + } else { // (t2,t3] + x = 6 + } + newCap = x * oldCap / 4 + + if num > 0 { + newCap += num + } + + // ensure newCap is a multiple of 64 (if it is > 64) or 16. + if newCap > 64 { + if x = newCap % 64; x != 0 { + x = newCap / 64 + newCap = 64 * (x + 1) + } + } else { + if x = newCap % 16; x != 0 { + x = newCap / 16 + newCap = 16 * (x + 1) + } + } + return +} + +func expandSliceValue(s reflect.Value, num int) reflect.Value { + if num <= 0 { + return s + } + l0 := s.Len() + l1 := l0 + num // new slice length + if l1 < l0 { + panic("ExpandSlice: slice overflow") + } + c0 := s.Cap() + if l1 <= c0 { + return s.Slice(0, l1) + } + st := s.Type() + c1 := growCap(c0, int(st.Elem().Size()), num) + s2 := reflect.MakeSlice(st, l1, c1) + // println("expandslicevalue: cap-old: ", c0, ", cap-new: ", c1, ", len-new: ", l1) + reflect.Copy(s2, s) + return s2 +} diff --git a/cmd/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go b/_vendor/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go similarity index 100% rename from cmd/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go rename to _vendor/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go diff --git a/cmd/vendor/github.com/ugorji/go/codec/helper_unsafe.go b/_vendor/vendor/github.com/ugorji/go/codec/helper_unsafe.go similarity index 69% rename from cmd/vendor/github.com/ugorji/go/codec/helper_unsafe.go rename to _vendor/vendor/github.com/ugorji/go/codec/helper_unsafe.go index d799496..2928e4f 100644 --- a/cmd/vendor/github.com/ugorji/go/codec/helper_unsafe.go +++ b/_vendor/vendor/github.com/ugorji/go/codec/helper_unsafe.go @@ -16,7 +16,7 @@ type unsafeString struct { Len int } -type unsafeBytes struct { +type unsafeSlice struct { Data uintptr Len int Cap int @@ -26,14 +26,24 @@ type unsafeBytes struct { // In unsafe mode, it doesn't incur allocation and copying caused by conversion. // In regular safe mode, it is an allocation and copy. func stringView(v []byte) string { - x := unsafeString{uintptr(unsafe.Pointer(&v[0])), len(v)} - return *(*string)(unsafe.Pointer(&x)) + if len(v) == 0 { + return "" + } + + bx := (*unsafeSlice)(unsafe.Pointer(&v)) + sx := unsafeString{bx.Data, bx.Len} + return *(*string)(unsafe.Pointer(&sx)) } // bytesView returns a view of the string as a []byte. // In unsafe mode, it doesn't incur allocation and copying caused by conversion. // In regular safe mode, it is an allocation and copy. func bytesView(v string) []byte { - x := unsafeBytes{uintptr(unsafe.Pointer(&v)), len(v), len(v)} - return *(*[]byte)(unsafe.Pointer(&x)) + if len(v) == 0 { + return zeroByteSlice + } + + sx := (*unsafeString)(unsafe.Pointer(&v)) + bx := unsafeSlice{sx.Data, sx.Len, sx.Len} + return *(*[]byte)(unsafe.Pointer(&bx)) } diff --git a/cmd/vendor/github.com/ugorji/go/codec/json.go b/_vendor/vendor/github.com/ugorji/go/codec/json.go similarity index 56% rename from cmd/vendor/github.com/ugorji/go/codec/json.go rename to _vendor/vendor/github.com/ugorji/go/codec/json.go index cb370d4..a04dfcb 100644 --- a/cmd/vendor/github.com/ugorji/go/codec/json.go +++ b/_vendor/vendor/github.com/ugorji/go/codec/json.go @@ -3,8 +3,9 @@ package codec -// This json support uses base64 encoding for bytes, because you cannot +// By default, this json support uses base64 encoding for bytes, because you cannot // store and read any arbitrary string in json (only unicode). +// However, the user can configre how to encode/decode bytes. // // This library specifically supports UTF-8 for encoding and decoding only. // @@ -27,10 +28,14 @@ package codec // - encode does not beautify. There is no whitespace when encoding. // - rpc calls which take single integer arguments or write single numeric arguments will need care. +// Top-level methods of json(End|Dec)Driver (which are implementations of (en|de)cDriver +// MUST not call one-another. + import ( "bytes" "encoding/base64" "fmt" + "reflect" "strconv" "unicode/utf16" "unicode/utf8" @@ -38,26 +43,32 @@ import ( //-------------------------------- -var jsonLiterals = [...]byte{'t', 'r', 'u', 'e', 'f', 'a', 'l', 's', 'e', 'n', 'u', 'l', 'l'} +var ( + jsonLiterals = [...]byte{'t', 'r', 'u', 'e', 'f', 'a', 'l', 's', 'e', 'n', 'u', 'l', 'l'} -var jsonFloat64Pow10 = [...]float64{ - 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, - 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, - 1e20, 1e21, 1e22, -} + jsonFloat64Pow10 = [...]float64{ + 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, + 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, + 1e20, 1e21, 1e22, + } -var jsonUint64Pow10 = [...]uint64{ - 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, - 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, -} + jsonUint64Pow10 = [...]uint64{ + 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, + 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, + } + + // jsonTabs and jsonSpaces are used as caches for indents + jsonTabs, jsonSpaces string +) const ( - // if jsonTrackSkipWhitespace, we track Whitespace and reduce the number of redundant checks. - // Make it a const flag, so that it can be elided during linking if false. + // jsonUnreadAfterDecNum controls whether we unread after decoding a number. // - // It is not a clear win, because we continually set a flag behind a pointer - // and then check it each time, as opposed to just 4 conditionals on a stack variable. - jsonTrackSkipWhitespace = true + // instead of unreading, just update d.tok (iff it's not a whitespace char) + // However, doing this means that we may HOLD onto some data which belongs to another stream. + // Thus, it is safest to unread the data when done. + // keep behind a constant flag for now. + jsonUnreadAfterDecNum = true // If !jsonValidateSymbols, decoding will be faster, by skipping some checks: // - If we see first character of null, false or true, @@ -79,17 +90,100 @@ const ( jsonNumUintMaxVal = 1< 1<<53 || v < -(1<<53)) { + e.w.writen1('"') + e.w.writeb(strconv.AppendInt(e.b[:0], v, 10)) + e.w.writen1('"') + return + } e.w.writeb(strconv.AppendInt(e.b[:0], v, 10)) } func (e *jsonEncDriver) EncodeUint(v uint64) { + if x := e.h.IntegerAsString; x == 'A' || x == 'L' && v > 1<<53 { + e.w.writen1('"') + e.w.writeb(strconv.AppendUint(e.b[:0], v, 10)) + e.w.writen1('"') + return + } e.w.writeb(strconv.AppendUint(e.b[:0], v, 10)) } func (e *jsonEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext, en *Encoder) { if v := ext.ConvertExt(rv); v == nil { - e.EncodeNil() + e.w.writeb(jsonLiterals[9:13]) // null // e.EncodeNil() } else { en.encode(v) } @@ -130,38 +236,26 @@ func (e *jsonEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext, en *Enco func (e *jsonEncDriver) EncodeRawExt(re *RawExt, en *Encoder) { // only encodes re.Value (never re.Data) if re.Value == nil { - e.EncodeNil() + e.w.writeb(jsonLiterals[9:13]) // null // e.EncodeNil() } else { en.encode(re.Value) } } func (e *jsonEncDriver) EncodeArrayStart(length int) { + if e.d { + e.dl++ + } e.w.writen1('[') -} - -func (e *jsonEncDriver) EncodeArrayEntrySeparator() { - e.w.writen1(',') -} - -func (e *jsonEncDriver) EncodeArrayEnd() { - e.w.writen1(']') + e.c = containerArrayStart } func (e *jsonEncDriver) EncodeMapStart(length int) { + if e.d { + e.dl++ + } e.w.writen1('{') -} - -func (e *jsonEncDriver) EncodeMapEntrySeparator() { - e.w.writen1(',') -} - -func (e *jsonEncDriver) EncodeMapKVSeparator() { - e.w.writen1(':') -} - -func (e *jsonEncDriver) EncodeMapEnd() { - e.w.writen1('}') + e.c = containerMapStart } func (e *jsonEncDriver) EncodeString(c charEncoding, v string) { @@ -175,11 +269,13 @@ func (e *jsonEncDriver) EncodeSymbol(v string) { } func (e *jsonEncDriver) EncodeStringBytes(c charEncoding, v []byte) { + // if encoding raw bytes and RawBytesExt is configured, use it to encode + if c == c_RAW && e.se.i != nil { + e.EncodeExt(v, 0, &e.se, e.e) + return + } if c == c_RAW { slen := base64.StdEncoding.EncodedLen(len(v)) - if e.bs == nil { - e.bs = e.b[:] - } if cap(e.bs) >= slen { e.bs = e.bs[:slen] } else { @@ -195,6 +291,10 @@ func (e *jsonEncDriver) EncodeStringBytes(c charEncoding, v []byte) { } } +func (e *jsonEncDriver) EncodeAsis(v []byte) { + e.w.writeb(v) +} + func (e *jsonEncDriver) quoteStr(s string) { // adapted from std pkg encoding/json const hex = "0123456789abcdef" @@ -266,7 +366,7 @@ func (e *jsonEncDriver) quoteStr(s string) { //-------------------------------- type jsonNum struct { - bytes []byte // may have [+-.eE0-9] + // bytes []byte // may have [+-.eE0-9] mantissa uint64 // where mantissa ends, and maybe dot begins. exponent int16 // exponent value. manOverflow bool @@ -276,7 +376,6 @@ type jsonNum struct { } func (x *jsonNum) reset() { - x.bytes = x.bytes[:0] x.manOverflow = false x.neg = false x.dot = false @@ -309,29 +408,26 @@ func (x *jsonNum) uintExp() (n uint64, overflow bool) { // return } -func (x *jsonNum) floatVal() (f float64) { +// these constants are only used withn floatVal. +// They are brought out, so that floatVal can be inlined. +const ( + jsonUint64MantissaBits = 52 + jsonMaxExponent = int16(len(jsonFloat64Pow10)) - 1 +) + +func (x *jsonNum) floatVal() (f float64, parseUsingStrConv bool) { // We do not want to lose precision. // Consequently, we will delegate to strconv.ParseFloat if any of the following happen: // - There are more digits than in math.MaxUint64: 18446744073709551615 (20 digits) // We expect up to 99.... (19 digits) // - The mantissa cannot fit into a 52 bits of uint64 // - The exponent is beyond our scope ie beyong 22. - const uint64MantissaBits = 52 - const maxExponent = int16(len(jsonFloat64Pow10)) - 1 + parseUsingStrConv = x.manOverflow || + x.exponent > jsonMaxExponent || + (x.exponent < 0 && -(x.exponent) > jsonMaxExponent) || + x.mantissa>>jsonUint64MantissaBits != 0 - parseUsingStrConv := x.manOverflow || - x.exponent > maxExponent || - (x.exponent < 0 && -(x.exponent) > maxExponent) || - x.mantissa>>uint64MantissaBits != 0 if parseUsingStrConv { - var err error - if f, err = strconv.ParseFloat(stringView(x.bytes), 64); err != nil { - panic(fmt.Errorf("parse float: %s, %v", x.bytes, err)) - return - } - if x.neg { - f = -f - } return } @@ -350,162 +446,230 @@ func (x *jsonNum) floatVal() (f float64) { } type jsonDecDriver struct { - d *Decoder - h *JsonHandle - r decReader // *bytesDecReader decReader - ct valueType // container type. one of unset, array or map. - bstr [8]byte // scratch used for string \UXXX parsing - b [64]byte // scratch + noBuiltInTypes + d *Decoder + h *JsonHandle + r decReader - wsSkipped bool // whitespace skipped + c containerState + // tok is used to store the token read right after skipWhiteSpace. + tok uint8 + + bstr [8]byte // scratch used for string \UXXX parsing + b [64]byte // scratch, used for parsing strings or numbers + b2 [64]byte // scratch, used only for decodeBytes (after base64) + bs []byte // scratch. Initialized from b. Used for parsing strings or numbers. + + se setExtWrapper n jsonNum - noBuiltInTypes } -// This will skip whitespace characters and return the next byte to read. -// The next byte determines what the value will be one of. -func (d *jsonDecDriver) skipWhitespace(unread bool) (b byte) { - // as initReadNext is not called all the time, we set ct to unSet whenever - // we skipwhitespace, as this is the signal that something new is about to be read. - d.ct = valueTypeUnset - b = d.r.readn1() - if !jsonTrackSkipWhitespace || !d.wsSkipped { - for ; b == ' ' || b == '\t' || b == '\r' || b == '\n'; b = d.r.readn1() { - } - if jsonTrackSkipWhitespace { - d.wsSkipped = true - } - } - if unread { +func jsonIsWS(b byte) bool { + return b == ' ' || b == '\t' || b == '\r' || b == '\n' +} + +// // This will skip whitespace characters and return the next byte to read. +// // The next byte determines what the value will be one of. +// func (d *jsonDecDriver) skipWhitespace() { +// // fast-path: do not enter loop. Just check first (in case no whitespace). +// b := d.r.readn1() +// if jsonIsWS(b) { +// r := d.r +// for b = r.readn1(); jsonIsWS(b); b = r.readn1() { +// } +// } +// d.tok = b +// } + +func (d *jsonDecDriver) uncacheRead() { + if d.tok != 0 { d.r.unreadn1() + d.tok = 0 } - return b +} + +func (d *jsonDecDriver) sendContainerState(c containerState) { + if d.tok == 0 { + var b byte + r := d.r + for b = r.readn1(); jsonIsWS(b); b = r.readn1() { + } + d.tok = b + } + var xc uint8 // char expected + if c == containerMapKey { + if d.c != containerMapStart { + xc = ',' + } + } else if c == containerMapValue { + xc = ':' + } else if c == containerMapEnd { + xc = '}' + } else if c == containerArrayElem { + if d.c != containerArrayStart { + xc = ',' + } + } else if c == containerArrayEnd { + xc = ']' + } + if xc != 0 { + if d.tok != xc { + d.d.errorf("json: expect char '%c' but got char '%c'", xc, d.tok) + } + d.tok = 0 + } + d.c = c } func (d *jsonDecDriver) CheckBreak() bool { - b := d.skipWhitespace(true) - return b == '}' || b == ']' + if d.tok == 0 { + var b byte + r := d.r + for b = r.readn1(); jsonIsWS(b); b = r.readn1() { + } + d.tok = b + } + if d.tok == '}' || d.tok == ']' { + // d.tok = 0 // only checking, not consuming + return true + } + return false } func (d *jsonDecDriver) readStrIdx(fromIdx, toIdx uint8) { bs := d.r.readx(int(toIdx - fromIdx)) + d.tok = 0 if jsonValidateSymbols { if !bytes.Equal(bs, jsonLiterals[fromIdx:toIdx]) { d.d.errorf("json: expecting %s: got %s", jsonLiterals[fromIdx:toIdx], bs) return } } - if jsonTrackSkipWhitespace { - d.wsSkipped = false - } } func (d *jsonDecDriver) TryDecodeAsNil() bool { - b := d.skipWhitespace(true) - if b == 'n' { - d.readStrIdx(9, 13) // null - d.ct = valueTypeNil + if d.tok == 0 { + var b byte + r := d.r + for b = r.readn1(); jsonIsWS(b); b = r.readn1() { + } + d.tok = b + } + if d.tok == 'n' { + d.readStrIdx(10, 13) // ull return true } return false } func (d *jsonDecDriver) DecodeBool() bool { - b := d.skipWhitespace(false) - if b == 'f' { + if d.tok == 0 { + var b byte + r := d.r + for b = r.readn1(); jsonIsWS(b); b = r.readn1() { + } + d.tok = b + } + if d.tok == 'f' { d.readStrIdx(5, 9) // alse return false } - if b == 't' { + if d.tok == 't' { d.readStrIdx(1, 4) // rue return true } - d.d.errorf("json: decode bool: got first char %c", b) + d.d.errorf("json: decode bool: got first char %c", d.tok) return false // "unreachable" } func (d *jsonDecDriver) ReadMapStart() int { - d.expectChar('{') - d.ct = valueTypeMap + if d.tok == 0 { + var b byte + r := d.r + for b = r.readn1(); jsonIsWS(b); b = r.readn1() { + } + d.tok = b + } + if d.tok != '{' { + d.d.errorf("json: expect char '%c' but got char '%c'", '{', d.tok) + } + d.tok = 0 + d.c = containerMapStart return -1 } func (d *jsonDecDriver) ReadArrayStart() int { - d.expectChar('[') - d.ct = valueTypeArray + if d.tok == 0 { + var b byte + r := d.r + for b = r.readn1(); jsonIsWS(b); b = r.readn1() { + } + d.tok = b + } + if d.tok != '[' { + d.d.errorf("json: expect char '%c' but got char '%c'", '[', d.tok) + } + d.tok = 0 + d.c = containerArrayStart return -1 } -func (d *jsonDecDriver) ReadMapEnd() { - d.expectChar('}') -} -func (d *jsonDecDriver) ReadArrayEnd() { - d.expectChar(']') -} -func (d *jsonDecDriver) ReadArrayEntrySeparator() { - d.expectChar(',') -} -func (d *jsonDecDriver) ReadMapEntrySeparator() { - d.expectChar(',') -} -func (d *jsonDecDriver) ReadMapKVSeparator() { - d.expectChar(':') -} -func (d *jsonDecDriver) expectChar(c uint8) { - b := d.skipWhitespace(false) - if b != c { - d.d.errorf("json: expect char %c but got char %c", c, b) - return - } - if jsonTrackSkipWhitespace { - d.wsSkipped = false - } -} -func (d *jsonDecDriver) IsContainerType(vt valueType) bool { +func (d *jsonDecDriver) ContainerType() (vt valueType) { // check container type by checking the first char - if d.ct == valueTypeUnset { - b := d.skipWhitespace(true) - if b == '{' { - d.ct = valueTypeMap - } else if b == '[' { - d.ct = valueTypeArray - } else if b == 'n' { - d.ct = valueTypeNil - } else if b == '"' { - d.ct = valueTypeString + if d.tok == 0 { + var b byte + r := d.r + for b = r.readn1(); jsonIsWS(b); b = r.readn1() { } + d.tok = b } - if vt == valueTypeNil || vt == valueTypeBytes || vt == valueTypeString || - vt == valueTypeArray || vt == valueTypeMap { - return d.ct == vt + if b := d.tok; b == '{' { + return valueTypeMap + } else if b == '[' { + return valueTypeArray + } else if b == 'n' { + return valueTypeNil + } else if b == '"' { + return valueTypeString } - // ugorji: made switch into conditionals, so that IsContainerType can be inlined. - // switch vt { - // case valueTypeNil, valueTypeBytes, valueTypeString, valueTypeArray, valueTypeMap: - // return d.ct == vt - // } - d.d.errorf("isContainerType: unsupported parameter: %v", vt) - return false // "unreachable" + return valueTypeUnset + // d.d.errorf("isContainerType: unsupported parameter: %v", vt) + // return false // "unreachable" } func (d *jsonDecDriver) decNum(storeBytes bool) { - // storeBytes = true // TODO: remove. - // If it is has a . or an e|E, decode as a float; else decode as an int. - b := d.skipWhitespace(false) + if d.tok == 0 { + var b byte + r := d.r + for b = r.readn1(); jsonIsWS(b); b = r.readn1() { + } + d.tok = b + } + b := d.tok + var str bool + if b == '"' { + str = true + b = d.r.readn1() + } if !(b == '+' || b == '-' || b == '.' || (b >= '0' && b <= '9')) { d.d.errorf("json: decNum: got first char '%c'", b) return } + d.tok = 0 const cutoff = (1<<64-1)/uint64(10) + 1 // cutoff64(base) const jsonNumUintMaxVal = 1<= slen { + if slen <= cap(bs) { bsOut = bs[:slen] + } else if zerocopy && slen <= cap(d.b2) { + bsOut = d.b2[:slen] } else { bsOut = make([]byte, slen) } @@ -745,17 +944,36 @@ func (d *jsonDecDriver) DecodeBytes(bs []byte, isstring, zerocopy bool) (bsOut [ } func (d *jsonDecDriver) DecodeString() (s string) { - return string(d.appendStringAsBytes(d.b[:0])) + d.appendStringAsBytes() + // if x := d.s.sc; x != nil && x.so && x.st == '}' { // map key + if d.c == containerMapKey { + return d.d.string(d.bs) + } + return string(d.bs) } -func (d *jsonDecDriver) appendStringAsBytes(v []byte) []byte { - d.expectChar('"') +func (d *jsonDecDriver) appendStringAsBytes() { + if d.tok == 0 { + var b byte + r := d.r + for b = r.readn1(); jsonIsWS(b); b = r.readn1() { + } + d.tok = b + } + if d.tok != '"' { + d.d.errorf("json: expect char '%c' but got char '%c'", '"', d.tok) + } + d.tok = 0 + + v := d.bs[:0] + var c uint8 + r := d.r for { - c := d.r.readn1() + c = r.readn1() if c == '"' { break } else if c == '\\' { - c = d.r.readn1() + c = r.readn1() switch c { case '"', '\\', '/', '\'': v = append(v, c) @@ -779,27 +997,24 @@ func (d *jsonDecDriver) appendStringAsBytes(v []byte) []byte { v = append(v, d.bstr[:w2]...) default: d.d.errorf("json: unsupported escaped value: %c", c) - return nil } } else { v = append(v, c) } } - if jsonTrackSkipWhitespace { - d.wsSkipped = false - } - return v + d.bs = v } func (d *jsonDecDriver) jsonU4(checkSlashU bool) rune { - if checkSlashU && !(d.r.readn1() == '\\' && d.r.readn1() == 'u') { + r := d.r + if checkSlashU && !(r.readn1() == '\\' && r.readn1() == 'u') { d.d.errorf(`json: unquoteStr: invalid unicode sequence. Expecting \u`) return 0 } // u, _ := strconv.ParseUint(string(d.bstr[:4]), 16, 64) var u uint32 for i := 0; i < 4; i++ { - v := d.r.readn1() + v := r.readn1() if '0' <= v && v <= '9' { v = v - '0' } else if 'a' <= v && v <= 'z' { @@ -815,69 +1030,83 @@ func (d *jsonDecDriver) jsonU4(checkSlashU bool) rune { return rune(u) } -func (d *jsonDecDriver) DecodeNaked() (v interface{}, vt valueType, decodeFurther bool) { - n := d.skipWhitespace(true) - switch n { +func (d *jsonDecDriver) DecodeNaked() { + z := &d.d.n + // var decodeFurther bool + + if d.tok == 0 { + var b byte + r := d.r + for b = r.readn1(); jsonIsWS(b); b = r.readn1() { + } + d.tok = b + } + switch d.tok { case 'n': - d.readStrIdx(9, 13) // null - vt = valueTypeNil + d.readStrIdx(10, 13) // ull + z.v = valueTypeNil case 'f': - d.readStrIdx(4, 9) // false - vt = valueTypeBool - v = false + d.readStrIdx(5, 9) // alse + z.v = valueTypeBool + z.b = false case 't': - d.readStrIdx(0, 4) // true - vt = valueTypeBool - v = true + d.readStrIdx(1, 4) // rue + z.v = valueTypeBool + z.b = true case '{': - vt = valueTypeMap - decodeFurther = true + z.v = valueTypeMap + // d.tok = 0 // don't consume. kInterfaceNaked will call ReadMapStart + // decodeFurther = true case '[': - vt = valueTypeArray - decodeFurther = true + z.v = valueTypeArray + // d.tok = 0 // don't consume. kInterfaceNaked will call ReadArrayStart + // decodeFurther = true case '"': - vt = valueTypeString - v = d.DecodeString() + z.v = valueTypeString + z.s = d.DecodeString() default: // number d.decNum(true) n := &d.n // if the string had a any of [.eE], then decode as float. switch { case n.explicitExponent, n.dot, n.exponent < 0, n.manOverflow: - vt = valueTypeFloat - v = n.floatVal() + z.v = valueTypeFloat + z.f = d.floatVal() case n.exponent == 0: u := n.mantissa switch { case n.neg: - vt = valueTypeInt - v = -int64(u) + z.v = valueTypeInt + z.i = -int64(u) case d.h.SignedInteger: - vt = valueTypeInt - v = int64(u) + z.v = valueTypeInt + z.i = int64(u) default: - vt = valueTypeUint - v = u + z.v = valueTypeUint + z.u = u } default: u, overflow := n.uintExp() switch { case overflow: - vt = valueTypeFloat - v = n.floatVal() + z.v = valueTypeFloat + z.f = d.floatVal() case n.neg: - vt = valueTypeInt - v = -int64(u) + z.v = valueTypeInt + z.i = -int64(u) case d.h.SignedInteger: - vt = valueTypeInt - v = int64(u) + z.v = valueTypeInt + z.i = int64(u) default: - vt = valueTypeUint - v = u + z.v = valueTypeUint + z.u = u } } // fmt.Printf("DecodeNaked: Number: %T, %v\n", v, v) } + // if decodeFurther { + // d.s.sc.retryRead() + // } return } @@ -887,7 +1116,8 @@ func (d *jsonDecDriver) DecodeNaked() (v interface{}, vt valueType, decodeFurthe // // Json is comprehensively supported: // - decodes numbers into interface{} as int, uint or float64 -// - encodes and decodes []byte using base64 Std Encoding +// - configurable way to encode/decode []byte . +// by default, encodes and decodes []byte using base64 Std Encoding // - UTF-8 support for encoding and decoding // // It has better performance than the json library in the standard library, @@ -899,21 +1129,80 @@ func (d *jsonDecDriver) DecodeNaked() (v interface{}, vt valueType, decodeFurthe // For example, a user can read a json value, then a cbor value, then a msgpack value, // all from the same stream in sequence. type JsonHandle struct { - BasicHandle textEncodingType + BasicHandle + // RawBytesExt, if configured, is used to encode and decode raw bytes in a custom way. + // If not configured, raw bytes are encoded to/from base64 text. + RawBytesExt InterfaceExt + + // Indent indicates how a value is encoded. + // - If positive, indent by that number of spaces. + // - If negative, indent by that number of tabs. + Indent int8 + + // IntegerAsString controls how integers (signed and unsigned) are encoded. + // + // Per the JSON Spec, JSON numbers are 64-bit floating point numbers. + // Consequently, integers > 2^53 cannot be represented as a JSON number without losing precision. + // This can be mitigated by configuring how to encode integers. + // + // IntegerAsString interpretes the following values: + // - if 'L', then encode integers > 2^53 as a json string. + // - if 'A', then encode all integers as a json string + // containing the exact integer representation as a decimal. + // - else encode all integers as a json number (default) + IntegerAsString uint8 +} + +func (h *JsonHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) { + return h.SetExt(rt, tag, &setExtWrapper{i: ext}) } func (h *JsonHandle) newEncDriver(e *Encoder) encDriver { - return &jsonEncDriver{e: e, w: e.w, h: h} + hd := jsonEncDriver{e: e, h: h} + hd.bs = hd.b[:0] + + hd.reset() + + return &hd } func (h *JsonHandle) newDecDriver(d *Decoder) decDriver { // d := jsonDecDriver{r: r.(*bytesDecReader), h: h} - hd := jsonDecDriver{d: d, r: d.r, h: h} - hd.n.bytes = d.b[:] + hd := jsonDecDriver{d: d, h: h} + hd.bs = hd.b[:0] + hd.reset() return &hd } +func (e *jsonEncDriver) reset() { + e.w = e.e.w + e.se.i = e.h.RawBytesExt + if e.bs != nil { + e.bs = e.bs[:0] + } + e.d, e.dt, e.dl, e.ds = false, false, 0, "" + e.c = 0 + if e.h.Indent > 0 { + e.d = true + e.ds = jsonSpaces[:e.h.Indent] + } else if e.h.Indent < 0 { + e.d = true + e.dt = true + e.ds = jsonTabs[:-(e.h.Indent)] + } +} + +func (d *jsonDecDriver) reset() { + d.r = d.d.r + d.se.i = d.h.RawBytesExt + if d.bs != nil { + d.bs = d.bs[:0] + } + d.c, d.tok = 0, 0 + d.n.reset() +} + var jsonEncodeTerminate = []byte{' '} func (h *JsonHandle) rpcEncodeTerminate() []byte { diff --git a/cmd/vendor/github.com/ugorji/go/codec/msgpack.go b/_vendor/vendor/github.com/ugorji/go/codec/msgpack.go similarity index 88% rename from cmd/vendor/github.com/ugorji/go/codec/msgpack.go rename to _vendor/vendor/github.com/ugorji/go/codec/msgpack.go index 5cfc2a2..f9f8723 100644 --- a/cmd/vendor/github.com/ugorji/go/codec/msgpack.go +++ b/_vendor/vendor/github.com/ugorji/go/codec/msgpack.go @@ -24,6 +24,7 @@ import ( "io" "math" "net/rpc" + "reflect" ) const ( @@ -102,11 +103,11 @@ var ( //--------------------------------------------- type msgpackEncDriver struct { + noBuiltInTypes + encNoSeparator e *Encoder w encWriter h *MsgpackHandle - noBuiltInTypes - encNoSeparator x [8]byte } @@ -270,7 +271,6 @@ type msgpackDecDriver struct { bd byte bdRead bool br bool // bytes reader - bdType valueType noBuiltInTypes noStreamingCodec decNoSeparator @@ -281,106 +281,100 @@ type msgpackDecDriver struct { // It is called when a nil interface{} is passed, leaving it up to the DecDriver // to introspect the stream and decide how best to decode. // It deciphers the value by looking at the stream first. -func (d *msgpackDecDriver) DecodeNaked() (v interface{}, vt valueType, decodeFurther bool) { +func (d *msgpackDecDriver) DecodeNaked() { if !d.bdRead { d.readNextBd() } bd := d.bd + n := &d.d.n + var decodeFurther bool switch bd { case mpNil: - vt = valueTypeNil + n.v = valueTypeNil d.bdRead = false case mpFalse: - vt = valueTypeBool - v = false + n.v = valueTypeBool + n.b = false case mpTrue: - vt = valueTypeBool - v = true + n.v = valueTypeBool + n.b = true case mpFloat: - vt = valueTypeFloat - v = float64(math.Float32frombits(bigen.Uint32(d.r.readx(4)))) + n.v = valueTypeFloat + n.f = float64(math.Float32frombits(bigen.Uint32(d.r.readx(4)))) case mpDouble: - vt = valueTypeFloat - v = math.Float64frombits(bigen.Uint64(d.r.readx(8))) + n.v = valueTypeFloat + n.f = math.Float64frombits(bigen.Uint64(d.r.readx(8))) case mpUint8: - vt = valueTypeUint - v = uint64(d.r.readn1()) + n.v = valueTypeUint + n.u = uint64(d.r.readn1()) case mpUint16: - vt = valueTypeUint - v = uint64(bigen.Uint16(d.r.readx(2))) + n.v = valueTypeUint + n.u = uint64(bigen.Uint16(d.r.readx(2))) case mpUint32: - vt = valueTypeUint - v = uint64(bigen.Uint32(d.r.readx(4))) + n.v = valueTypeUint + n.u = uint64(bigen.Uint32(d.r.readx(4))) case mpUint64: - vt = valueTypeUint - v = uint64(bigen.Uint64(d.r.readx(8))) + n.v = valueTypeUint + n.u = uint64(bigen.Uint64(d.r.readx(8))) case mpInt8: - vt = valueTypeInt - v = int64(int8(d.r.readn1())) + n.v = valueTypeInt + n.i = int64(int8(d.r.readn1())) case mpInt16: - vt = valueTypeInt - v = int64(int16(bigen.Uint16(d.r.readx(2)))) + n.v = valueTypeInt + n.i = int64(int16(bigen.Uint16(d.r.readx(2)))) case mpInt32: - vt = valueTypeInt - v = int64(int32(bigen.Uint32(d.r.readx(4)))) + n.v = valueTypeInt + n.i = int64(int32(bigen.Uint32(d.r.readx(4)))) case mpInt64: - vt = valueTypeInt - v = int64(int64(bigen.Uint64(d.r.readx(8)))) + n.v = valueTypeInt + n.i = int64(int64(bigen.Uint64(d.r.readx(8)))) default: switch { case bd >= mpPosFixNumMin && bd <= mpPosFixNumMax: // positive fixnum (always signed) - vt = valueTypeInt - v = int64(int8(bd)) + n.v = valueTypeInt + n.i = int64(int8(bd)) case bd >= mpNegFixNumMin && bd <= mpNegFixNumMax: // negative fixnum - vt = valueTypeInt - v = int64(int8(bd)) + n.v = valueTypeInt + n.i = int64(int8(bd)) case bd == mpStr8, bd == mpStr16, bd == mpStr32, bd >= mpFixStrMin && bd <= mpFixStrMax: if d.h.RawToString { - var rvm string - vt = valueTypeString - v = &rvm + n.v = valueTypeString + n.s = d.DecodeString() } else { - var rvm = zeroByteSlice - vt = valueTypeBytes - v = &rvm + n.v = valueTypeBytes + n.l = d.DecodeBytes(nil, false, false) } - decodeFurther = true case bd == mpBin8, bd == mpBin16, bd == mpBin32: - var rvm = zeroByteSlice - vt = valueTypeBytes - v = &rvm - decodeFurther = true + n.v = valueTypeBytes + n.l = d.DecodeBytes(nil, false, false) case bd == mpArray16, bd == mpArray32, bd >= mpFixArrayMin && bd <= mpFixArrayMax: - vt = valueTypeArray + n.v = valueTypeArray decodeFurther = true case bd == mpMap16, bd == mpMap32, bd >= mpFixMapMin && bd <= mpFixMapMax: - vt = valueTypeMap + n.v = valueTypeMap decodeFurther = true case bd >= mpFixExt1 && bd <= mpFixExt16, bd >= mpExt8 && bd <= mpExt32: + n.v = valueTypeExt clen := d.readExtLen() - var re RawExt - re.Tag = uint64(d.r.readn1()) - re.Data = d.r.readx(clen) - v = &re - vt = valueTypeExt + n.u = uint64(d.r.readn1()) + n.l = d.r.readx(clen) default: d.d.errorf("Nil-Deciphered DecodeValue: %s: hex: %x, dec: %d", msgBadDesc, bd, bd) - return } } if !decodeFurther { d.bdRead = false } - if vt == valueTypeUint && d.h.SignedInteger { - d.bdType = valueTypeInt - v = int64(v.(uint64)) + if n.v == valueTypeUint && d.h.SignedInteger { + n.v = valueTypeInt + n.i = int64(n.u) } return } @@ -536,15 +530,11 @@ func (d *msgpackDecDriver) DecodeBytes(bs []byte, isstring, zerocopy bool) (bsOu d.readNextBd() } var clen int - if isstring { - clen = d.readContainerLen(msgpackContainerStr) + // ignore isstring. Expect that the bytes may be found from msgpackContainerStr or msgpackContainerBin + if bd := d.bd; bd == mpBin8 || bd == mpBin16 || bd == mpBin32 { + clen = d.readContainerLen(msgpackContainerBin) } else { - // bytes can be decoded from msgpackContainerStr or msgpackContainerBin - if bd := d.bd; bd == mpBin8 || bd == mpBin16 || bd == mpBin32 { - clen = d.readContainerLen(msgpackContainerBin) - } else { - clen = d.readContainerLen(msgpackContainerStr) - } + clen = d.readContainerLen(msgpackContainerStr) } // println("DecodeBytes: clen: ", clen) d.bdRead = false @@ -569,28 +559,27 @@ func (d *msgpackDecDriver) DecodeString() (s string) { func (d *msgpackDecDriver) readNextBd() { d.bd = d.r.readn1() d.bdRead = true - d.bdType = valueTypeUnset } -func (d *msgpackDecDriver) IsContainerType(vt valueType) bool { +func (d *msgpackDecDriver) ContainerType() (vt valueType) { bd := d.bd - switch vt { - case valueTypeNil: - return bd == mpNil - case valueTypeBytes: - return bd == mpBin8 || bd == mpBin16 || bd == mpBin32 || - (!d.h.RawToString && - (bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || (bd >= mpFixStrMin && bd <= mpFixStrMax))) - case valueTypeString: - return d.h.RawToString && - (bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || (bd >= mpFixStrMin && bd <= mpFixStrMax)) - case valueTypeArray: - return bd == mpArray16 || bd == mpArray32 || (bd >= mpFixArrayMin && bd <= mpFixArrayMax) - case valueTypeMap: - return bd == mpMap16 || bd == mpMap32 || (bd >= mpFixMapMin && bd <= mpFixMapMax) + if bd == mpNil { + return valueTypeNil + } else if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 || + (!d.h.RawToString && + (bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || (bd >= mpFixStrMin && bd <= mpFixStrMax))) { + return valueTypeBytes + } else if d.h.RawToString && + (bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || (bd >= mpFixStrMin && bd <= mpFixStrMax)) { + return valueTypeString + } else if bd == mpArray16 || bd == mpArray32 || (bd >= mpFixArrayMin && bd <= mpFixArrayMax) { + return valueTypeArray + } else if bd == mpMap16 || bd == mpMap32 || (bd >= mpFixMapMin && bd <= mpFixMapMax) { + return valueTypeMap + } else { + // d.d.errorf("isContainerType: unsupported parameter: %v", vt) } - d.d.errorf("isContainerType: unsupported parameter: %v", vt) - return false // "unreachable" + return valueTypeUnset } func (d *msgpackDecDriver) TryDecodeAsNil() (v bool) { @@ -617,7 +606,7 @@ func (d *msgpackDecDriver) readContainerLen(ct msgpackContainerType) (clen int) } else if (ct.bFixMin & bd) == ct.bFixMin { clen = int(ct.bFixMin ^ bd) } else { - d.d.errorf("readContainerLen: %s: hex: %x, dec: %d", msgBadDesc, bd, bd) + d.d.errorf("readContainerLen: %s: hex: %x, decimal: %d", msgBadDesc, bd, bd) return } d.bdRead = false @@ -704,7 +693,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 { BasicHandle - binaryEncodingType // RawToString controls how raw bytes are decoded into a nil interface{}. RawToString bool @@ -720,6 +708,11 @@ type MsgpackHandle struct { // type is provided (e.g. decoding into a nil interface{}), you get back // a []byte or string based on the setting of RawToString. WriteExt bool + binaryEncodingType +} + +func (h *MsgpackHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) { + return h.SetExt(rt, tag, &setExtWrapper{b: ext}) } func (h *MsgpackHandle) newEncDriver(e *Encoder) encDriver { @@ -730,6 +723,15 @@ func (h *MsgpackHandle) newDecDriver(d *Decoder) decDriver { return &msgpackDecDriver{d: d, r: d.r, h: h, br: d.bytes} } +func (e *msgpackEncDriver) reset() { + e.w = e.e.w +} + +func (d *msgpackDecDriver) reset() { + d.r = d.d.r + d.bd, d.bdRead = 0, false +} + //-------------------------------------------------- type msgpackSpecRpcCodec struct { diff --git a/_vendor/vendor/github.com/ugorji/go/codec/noop.go b/_vendor/vendor/github.com/ugorji/go/codec/noop.go new file mode 100644 index 0000000..cfee3d0 --- /dev/null +++ b/_vendor/vendor/github.com/ugorji/go/codec/noop.go @@ -0,0 +1,213 @@ +// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Use of this source code is governed by a MIT license found in the LICENSE file. + +package codec + +import ( + "math/rand" + "time" +) + +// NoopHandle returns a no-op handle. It basically does nothing. +// It is only useful for benchmarking, as it gives an idea of the +// overhead from the codec framework. +// +// LIBRARY USERS: *** DO NOT USE *** +func NoopHandle(slen int) *noopHandle { + h := noopHandle{} + h.rand = rand.New(rand.NewSource(time.Now().UnixNano())) + h.B = make([][]byte, slen) + h.S = make([]string, slen) + for i := 0; i < len(h.S); i++ { + b := make([]byte, i+1) + for j := 0; j < len(b); j++ { + b[j] = 'a' + byte(i) + } + h.B[i] = b + h.S[i] = string(b) + } + return &h +} + +// noopHandle does nothing. +// It is used to simulate the overhead of the codec framework. +type noopHandle struct { + BasicHandle + binaryEncodingType + noopDrv // noopDrv is unexported here, so we can get a copy of it when needed. +} + +type noopDrv struct { + d *Decoder + e *Encoder + i int + S []string + B [][]byte + mks []bool // stack. if map (true), else if array (false) + mk bool // top of stack. what container are we on? map or array? + ct valueType // last response for IsContainerType. + cb int // counter for ContainerType + rand *rand.Rand +} + +func (h *noopDrv) r(v int) int { return h.rand.Intn(v) } +func (h *noopDrv) m(v int) int { h.i++; return h.i % v } + +func (h *noopDrv) newEncDriver(e *Encoder) encDriver { h.e = e; return h } +func (h *noopDrv) newDecDriver(d *Decoder) decDriver { h.d = d; return h } + +func (h *noopDrv) reset() {} +func (h *noopDrv) uncacheRead() {} + +// --- encDriver + +// stack functions (for map and array) +func (h *noopDrv) start(b bool) { + // println("start", len(h.mks)+1) + h.mks = append(h.mks, b) + h.mk = b +} +func (h *noopDrv) end() { + // println("end: ", len(h.mks)-1) + h.mks = h.mks[:len(h.mks)-1] + if len(h.mks) > 0 { + h.mk = h.mks[len(h.mks)-1] + } else { + h.mk = false + } +} + +func (h *noopDrv) EncodeBuiltin(rt uintptr, v interface{}) {} +func (h *noopDrv) EncodeNil() {} +func (h *noopDrv) EncodeInt(i int64) {} +func (h *noopDrv) EncodeUint(i uint64) {} +func (h *noopDrv) EncodeBool(b bool) {} +func (h *noopDrv) EncodeFloat32(f float32) {} +func (h *noopDrv) EncodeFloat64(f float64) {} +func (h *noopDrv) EncodeRawExt(re *RawExt, e *Encoder) {} +func (h *noopDrv) EncodeArrayStart(length int) { h.start(true) } +func (h *noopDrv) EncodeMapStart(length int) { h.start(false) } +func (h *noopDrv) EncodeEnd() { h.end() } + +func (h *noopDrv) EncodeString(c charEncoding, v string) {} +func (h *noopDrv) EncodeSymbol(v string) {} +func (h *noopDrv) EncodeStringBytes(c charEncoding, v []byte) {} + +func (h *noopDrv) EncodeExt(rv interface{}, xtag uint64, ext Ext, e *Encoder) {} + +// ---- decDriver +func (h *noopDrv) initReadNext() {} +func (h *noopDrv) CheckBreak() bool { return false } +func (h *noopDrv) IsBuiltinType(rt uintptr) bool { return false } +func (h *noopDrv) DecodeBuiltin(rt uintptr, v interface{}) {} +func (h *noopDrv) DecodeInt(bitsize uint8) (i int64) { return int64(h.m(15)) } +func (h *noopDrv) DecodeUint(bitsize uint8) (ui uint64) { return uint64(h.m(35)) } +func (h *noopDrv) DecodeFloat(chkOverflow32 bool) (f float64) { return float64(h.m(95)) } +func (h *noopDrv) DecodeBool() (b bool) { return h.m(2) == 0 } +func (h *noopDrv) DecodeString() (s string) { return h.S[h.m(8)] } + +// func (h *noopDrv) DecodeStringAsBytes(bs []byte) []byte { return h.DecodeBytes(bs) } + +func (h *noopDrv) DecodeBytes(bs []byte, isstring, zerocopy bool) []byte { return h.B[h.m(len(h.B))] } + +func (h *noopDrv) ReadEnd() { h.end() } + +// toggle map/slice +func (h *noopDrv) ReadMapStart() int { h.start(true); return h.m(10) } +func (h *noopDrv) ReadArrayStart() int { h.start(false); return h.m(10) } + +func (h *noopDrv) ContainerType() (vt valueType) { + // return h.m(2) == 0 + // handle kStruct, which will bomb is it calls this and doesn't get back a map or array. + // consequently, if the return value is not map or array, reset it to one of them based on h.m(7) % 2 + // for kstruct: at least one out of every 2 times, return one of valueTypeMap or Array (else kstruct bombs) + // however, every 10th time it is called, we just return something else. + var vals = [...]valueType{valueTypeArray, valueTypeMap} + // ------------ TAKE ------------ + // if h.cb%2 == 0 { + // if h.ct == valueTypeMap || h.ct == valueTypeArray { + // } else { + // h.ct = vals[h.m(2)] + // } + // } else if h.cb%5 == 0 { + // h.ct = valueType(h.m(8)) + // } else { + // h.ct = vals[h.m(2)] + // } + // ------------ TAKE ------------ + // if h.cb%16 == 0 { + // h.ct = valueType(h.cb % 8) + // } else { + // h.ct = vals[h.cb%2] + // } + h.ct = vals[h.cb%2] + h.cb++ + return h.ct + + // if h.ct == valueTypeNil || h.ct == valueTypeString || h.ct == valueTypeBytes { + // return h.ct + // } + // return valueTypeUnset + // TODO: may need to tweak this so it works. + // if h.ct == valueTypeMap && vt == valueTypeArray || h.ct == valueTypeArray && vt == valueTypeMap { + // h.cb = !h.cb + // h.ct = vt + // return h.cb + // } + // // go in a loop and check it. + // h.ct = vt + // h.cb = h.m(7) == 0 + // return h.cb +} +func (h *noopDrv) TryDecodeAsNil() bool { + if h.mk { + return false + } else { + return h.m(8) == 0 + } +} +func (h *noopDrv) DecodeExt(rv interface{}, xtag uint64, ext Ext) uint64 { + return 0 +} + +func (h *noopDrv) DecodeNaked() { + // use h.r (random) not h.m() because h.m() could cause the same value to be given. + var sk int + if h.mk { + // if mapkey, do not support values of nil OR bytes, array, map or rawext + sk = h.r(7) + 1 + } else { + sk = h.r(12) + } + n := &h.d.n + switch sk { + case 0: + n.v = valueTypeNil + case 1: + n.v, n.b = valueTypeBool, false + case 2: + n.v, n.b = valueTypeBool, true + case 3: + n.v, n.i = valueTypeInt, h.DecodeInt(64) + case 4: + n.v, n.u = valueTypeUint, h.DecodeUint(64) + case 5: + n.v, n.f = valueTypeFloat, h.DecodeFloat(true) + case 6: + n.v, n.f = valueTypeFloat, h.DecodeFloat(false) + case 7: + n.v, n.s = valueTypeString, h.DecodeString() + case 8: + n.v, n.l = valueTypeBytes, h.B[h.m(len(h.B))] + case 9: + n.v = valueTypeArray + case 10: + n.v = valueTypeMap + default: + n.v = valueTypeExt + n.u = h.DecodeUint(64) + n.l = h.B[h.m(len(h.B))] + } + h.ct = n.v + return +} diff --git a/cmd/vendor/github.com/ugorji/go/codec/prebuild.go b/_vendor/vendor/github.com/ugorji/go/codec/prebuild.go similarity index 100% rename from cmd/vendor/github.com/ugorji/go/codec/prebuild.go rename to _vendor/vendor/github.com/ugorji/go/codec/prebuild.go diff --git a/cmd/vendor/github.com/ugorji/go/codec/rpc.go b/_vendor/vendor/github.com/ugorji/go/codec/rpc.go similarity index 100% rename from cmd/vendor/github.com/ugorji/go/codec/rpc.go rename to _vendor/vendor/github.com/ugorji/go/codec/rpc.go diff --git a/cmd/vendor/github.com/ugorji/go/codec/simple.go b/_vendor/vendor/github.com/ugorji/go/codec/simple.go similarity index 86% rename from cmd/vendor/github.com/ugorji/go/codec/simple.go rename to _vendor/vendor/github.com/ugorji/go/codec/simple.go index e73beee..7c0ba7a 100644 --- a/cmd/vendor/github.com/ugorji/go/codec/simple.go +++ b/_vendor/vendor/github.com/ugorji/go/codec/simple.go @@ -3,7 +3,10 @@ package codec -import "math" +import ( + "math" + "reflect" +) const ( _ uint8 = iota @@ -26,12 +29,12 @@ const ( ) type simpleEncDriver struct { + noBuiltInTypes + encNoSeparator e *Encoder h *SimpleHandle w encWriter - noBuiltInTypes b [8]byte - encNoSeparator } func (e *simpleEncDriver) EncodeNil() { @@ -150,7 +153,6 @@ type simpleDecDriver struct { h *SimpleHandle r decReader bdRead bool - bdType valueType bd byte br bool // bytes reader noBuiltInTypes @@ -162,28 +164,27 @@ type simpleDecDriver struct { func (d *simpleDecDriver) readNextBd() { d.bd = d.r.readn1() d.bdRead = true - d.bdType = valueTypeUnset } -func (d *simpleDecDriver) IsContainerType(vt valueType) bool { - switch vt { - case valueTypeNil: - return d.bd == simpleVdNil - case valueTypeBytes: - const x uint8 = simpleVdByteArray - return d.bd == x || d.bd == x+1 || d.bd == x+2 || d.bd == x+3 || d.bd == x+4 - case valueTypeString: - const x uint8 = simpleVdString - return d.bd == x || d.bd == x+1 || d.bd == x+2 || d.bd == x+3 || d.bd == x+4 - case valueTypeArray: - const x uint8 = simpleVdArray - return d.bd == x || d.bd == x+1 || d.bd == x+2 || d.bd == x+3 || d.bd == x+4 - case valueTypeMap: - const x uint8 = simpleVdMap - return d.bd == x || d.bd == x+1 || d.bd == x+2 || d.bd == x+3 || d.bd == x+4 +func (d *simpleDecDriver) ContainerType() (vt valueType) { + if d.bd == simpleVdNil { + return valueTypeNil + } else if d.bd == simpleVdByteArray || d.bd == simpleVdByteArray+1 || + d.bd == simpleVdByteArray+2 || d.bd == simpleVdByteArray+3 || d.bd == simpleVdByteArray+4 { + return valueTypeBytes + } else if d.bd == simpleVdString || d.bd == simpleVdString+1 || + d.bd == simpleVdString+2 || d.bd == simpleVdString+3 || d.bd == simpleVdString+4 { + return valueTypeString + } else if d.bd == simpleVdArray || d.bd == simpleVdArray+1 || + d.bd == simpleVdArray+2 || d.bd == simpleVdArray+3 || d.bd == simpleVdArray+4 { + return valueTypeArray + } else if d.bd == simpleVdMap || d.bd == simpleVdMap+1 || + d.bd == simpleVdMap+2 || d.bd == simpleVdMap+3 || d.bd == simpleVdMap+4 { + return valueTypeMap + } else { + // d.d.errorf("isContainerType: unsupported parameter: %v", vt) } - d.d.errorf("isContainerType: unsupported parameter: %v", vt) - return false // "unreachable" + return valueTypeUnset } func (d *simpleDecDriver) TryDecodeAsNil() bool { @@ -407,59 +408,59 @@ func (d *simpleDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs [ return } -func (d *simpleDecDriver) DecodeNaked() (v interface{}, vt valueType, decodeFurther bool) { +func (d *simpleDecDriver) DecodeNaked() { if !d.bdRead { d.readNextBd() } + n := &d.d.n + var decodeFurther bool + switch d.bd { case simpleVdNil: - vt = valueTypeNil + n.v = valueTypeNil case simpleVdFalse: - vt = valueTypeBool - v = false + n.v = valueTypeBool + n.b = false case simpleVdTrue: - vt = valueTypeBool - v = true + n.v = valueTypeBool + n.b = true case simpleVdPosInt, simpleVdPosInt + 1, simpleVdPosInt + 2, simpleVdPosInt + 3: if d.h.SignedInteger { - vt = valueTypeInt - v = d.DecodeInt(64) + n.v = valueTypeInt + n.i = d.DecodeInt(64) } else { - vt = valueTypeUint - v = d.DecodeUint(64) + n.v = valueTypeUint + n.u = d.DecodeUint(64) } case simpleVdNegInt, simpleVdNegInt + 1, simpleVdNegInt + 2, simpleVdNegInt + 3: - vt = valueTypeInt - v = d.DecodeInt(64) + n.v = valueTypeInt + n.i = d.DecodeInt(64) case simpleVdFloat32: - vt = valueTypeFloat - v = d.DecodeFloat(true) + n.v = valueTypeFloat + n.f = d.DecodeFloat(true) case simpleVdFloat64: - vt = valueTypeFloat - v = d.DecodeFloat(false) + n.v = valueTypeFloat + n.f = d.DecodeFloat(false) case simpleVdString, simpleVdString + 1, simpleVdString + 2, simpleVdString + 3, simpleVdString + 4: - vt = valueTypeString - v = d.DecodeString() + n.v = valueTypeString + n.s = d.DecodeString() case simpleVdByteArray, simpleVdByteArray + 1, simpleVdByteArray + 2, simpleVdByteArray + 3, simpleVdByteArray + 4: - vt = valueTypeBytes - v = d.DecodeBytes(nil, false, false) + n.v = valueTypeBytes + n.l = d.DecodeBytes(nil, false, false) case simpleVdExt, simpleVdExt + 1, simpleVdExt + 2, simpleVdExt + 3, simpleVdExt + 4: - vt = valueTypeExt + n.v = valueTypeExt l := d.decLen() - var re RawExt - re.Tag = uint64(d.r.readn1()) - re.Data = d.r.readx(l) - v = &re + n.u = uint64(d.r.readn1()) + n.l = d.r.readx(l) case simpleVdArray, simpleVdArray + 1, simpleVdArray + 2, simpleVdArray + 3, simpleVdArray + 4: - vt = valueTypeArray + n.v = valueTypeArray decodeFurther = true case simpleVdMap, simpleVdMap + 1, simpleVdMap + 2, simpleVdMap + 3, simpleVdMap + 4: - vt = valueTypeMap + n.v = valueTypeMap decodeFurther = true default: d.d.errorf("decodeNaked: Unrecognized d.bd: 0x%x", d.bd) - return } if !decodeFurther { @@ -493,6 +494,10 @@ type SimpleHandle struct { binaryEncodingType } +func (h *SimpleHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) { + return h.SetExt(rt, tag, &setExtWrapper{b: ext}) +} + func (h *SimpleHandle) newEncDriver(e *Encoder) encDriver { return &simpleEncDriver{e: e, w: e.w, h: h} } @@ -501,5 +506,14 @@ func (h *SimpleHandle) newDecDriver(d *Decoder) decDriver { return &simpleDecDriver{d: d, r: d.r, h: h, br: d.bytes} } +func (e *simpleEncDriver) reset() { + e.w = e.e.w +} + +func (d *simpleDecDriver) reset() { + d.r = d.d.r + d.bd, d.bdRead = 0, false +} + var _ decDriver = (*simpleDecDriver)(nil) var _ encDriver = (*simpleEncDriver)(nil) diff --git a/cmd/vendor/github.com/ugorji/go/codec/time.go b/_vendor/vendor/github.com/ugorji/go/codec/time.go similarity index 86% rename from cmd/vendor/github.com/ugorji/go/codec/time.go rename to _vendor/vendor/github.com/ugorji/go/codec/time.go index 733fc3f..718b731 100644 --- a/cmd/vendor/github.com/ugorji/go/codec/time.go +++ b/_vendor/vendor/github.com/ugorji/go/codec/time.go @@ -4,13 +4,53 @@ package codec import ( + "fmt" + "reflect" "time" ) var ( - timeDigits = [...]byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'} + timeDigits = [...]byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'} + timeExtEncFn = func(rv reflect.Value) (bs []byte, err error) { + defer panicToErr(&err) + bs = timeExt{}.WriteExt(rv.Interface()) + return + } + timeExtDecFn = func(rv reflect.Value, bs []byte) (err error) { + defer panicToErr(&err) + timeExt{}.ReadExt(rv.Interface(), bs) + return + } ) +type timeExt struct{} + +func (x timeExt) WriteExt(v interface{}) (bs []byte) { + switch v2 := v.(type) { + case time.Time: + bs = encodeTime(v2) + case *time.Time: + bs = encodeTime(*v2) + default: + panic(fmt.Errorf("unsupported format for time conversion: expecting time.Time; got %T", v2)) + } + return +} +func (x timeExt) ReadExt(v interface{}, bs []byte) { + tt, err := decodeTime(bs) + if err != nil { + panic(err) + } + *(v.(*time.Time)) = tt +} + +func (x timeExt) ConvertExt(v interface{}) interface{} { + return x.WriteExt(v) +} +func (x timeExt) UpdateExt(v interface{}, src interface{}) { + x.ReadExt(v, src.([]byte)) +} + // EncodeTime encodes a time.Time as a []byte, including // information on the instant in time and UTC offset. // diff --git a/cmd/Godeps/Godeps.json b/cmd/Godeps/Godeps.json deleted file mode 100644 index cc427b4..0000000 --- a/cmd/Godeps/Godeps.json +++ /dev/null @@ -1,135 +0,0 @@ -{ - "ImportPath": "github.com/siddontang/ledisdb", - "GoVersion": "go1.6", - "GodepVersion": "v62", - "Packages": [ - "./..." - ], - "Deps": [ - { - "ImportPath": "github.com/BurntSushi/toml", - "Comment": "v0.1.0-21-g056c9bc", - "Rev": "056c9bc7be7190eaa7715723883caffa5f8fa3e4" - }, - { - "ImportPath": "github.com/cupcake/rdb", - "Rev": "3454dcabd33cb8ea8261ffd6a45f4d836eb504cc" - }, - { - "ImportPath": "github.com/cupcake/rdb/crc64", - "Rev": "3454dcabd33cb8ea8261ffd6a45f4d836eb504cc" - }, - { - "ImportPath": "github.com/cupcake/rdb/nopdecoder", - "Rev": "3454dcabd33cb8ea8261ffd6a45f4d836eb504cc" - }, - { - "ImportPath": "github.com/edsrzf/mmap-go", - "Rev": "f9d5617258fa999241e93b43f2ff89e4507cc3f2" - }, - { - "ImportPath": "github.com/golang/snappy", - "Rev": "723cc1e459b8eea2dea4583200fd60757d40097a" - }, - { - "ImportPath": "github.com/peterh/liner", - "Rev": "d5e5aeeb67ca5aeeddeb0b6c3af05421ff63a0b6" - }, - { - "ImportPath": "github.com/siddontang/go/bson", - "Rev": "354e14e6c093c661abb29fd28403b3c19cff5514" - }, - { - "ImportPath": "github.com/siddontang/go/filelock", - "Rev": "354e14e6c093c661abb29fd28403b3c19cff5514" - }, - { - "ImportPath": "github.com/siddontang/go/hack", - "Rev": "354e14e6c093c661abb29fd28403b3c19cff5514" - }, - { - "ImportPath": "github.com/siddontang/go/ioutil2", - "Rev": "354e14e6c093c661abb29fd28403b3c19cff5514" - }, - { - "ImportPath": "github.com/siddontang/go/log", - "Rev": "354e14e6c093c661abb29fd28403b3c19cff5514" - }, - { - "ImportPath": "github.com/siddontang/go/num", - "Rev": "354e14e6c093c661abb29fd28403b3c19cff5514" - }, - { - "ImportPath": "github.com/siddontang/go/snappy", - "Rev": "354e14e6c093c661abb29fd28403b3c19cff5514" - }, - { - "ImportPath": "github.com/siddontang/go/sync2", - "Rev": "354e14e6c093c661abb29fd28403b3c19cff5514" - }, - { - "ImportPath": "github.com/siddontang/golua", - "Rev": "f73e23294ebf29412e1e96bb6163be152700d250" - }, - { - "ImportPath": "github.com/siddontang/goredis", - "Rev": "760763f78400635ed7b9b115511b8ed06035e908" - }, - { - "ImportPath": "github.com/siddontang/rdb", - "Rev": "fc89ed2e418d27e3ea76e708e54276d2b44ae9cf" - }, - { - "ImportPath": "github.com/syndtr/goleveldb/leveldb", - "Rev": "cfa635847112c5dc4782e128fa7e0d05fdbfb394" - }, - { - "ImportPath": "github.com/syndtr/goleveldb/leveldb/cache", - "Rev": "cfa635847112c5dc4782e128fa7e0d05fdbfb394" - }, - { - "ImportPath": "github.com/syndtr/goleveldb/leveldb/comparer", - "Rev": "cfa635847112c5dc4782e128fa7e0d05fdbfb394" - }, - { - "ImportPath": "github.com/syndtr/goleveldb/leveldb/errors", - "Rev": "cfa635847112c5dc4782e128fa7e0d05fdbfb394" - }, - { - "ImportPath": "github.com/syndtr/goleveldb/leveldb/filter", - "Rev": "cfa635847112c5dc4782e128fa7e0d05fdbfb394" - }, - { - "ImportPath": "github.com/syndtr/goleveldb/leveldb/iterator", - "Rev": "cfa635847112c5dc4782e128fa7e0d05fdbfb394" - }, - { - "ImportPath": "github.com/syndtr/goleveldb/leveldb/journal", - "Rev": "cfa635847112c5dc4782e128fa7e0d05fdbfb394" - }, - { - "ImportPath": "github.com/syndtr/goleveldb/leveldb/memdb", - "Rev": "cfa635847112c5dc4782e128fa7e0d05fdbfb394" - }, - { - "ImportPath": "github.com/syndtr/goleveldb/leveldb/opt", - "Rev": "cfa635847112c5dc4782e128fa7e0d05fdbfb394" - }, - { - "ImportPath": "github.com/syndtr/goleveldb/leveldb/storage", - "Rev": "cfa635847112c5dc4782e128fa7e0d05fdbfb394" - }, - { - "ImportPath": "github.com/syndtr/goleveldb/leveldb/table", - "Rev": "cfa635847112c5dc4782e128fa7e0d05fdbfb394" - }, - { - "ImportPath": "github.com/syndtr/goleveldb/leveldb/util", - "Rev": "cfa635847112c5dc4782e128fa7e0d05fdbfb394" - }, - { - "ImportPath": "github.com/ugorji/go/codec", - "Rev": "5abd4e96a45c386928ed2ca2a7ef63e2533e18ec" - } - ] -} diff --git a/cmd/Godeps/Readme b/cmd/Godeps/Readme deleted file mode 100644 index 4cdaa53..0000000 --- a/cmd/Godeps/Readme +++ /dev/null @@ -1,5 +0,0 @@ -This directory tree is generated automatically by godep. - -Please do not edit. - -See https://github.com/tools/godep for more information. diff --git a/cmd/vendor/github.com/BurntSushi/toml/.gitignore b/cmd/vendor/github.com/BurntSushi/toml/.gitignore deleted file mode 100644 index 0cd3800..0000000 --- a/cmd/vendor/github.com/BurntSushi/toml/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -TAGS -tags -.*.swp -tomlcheck/tomlcheck -toml.test diff --git a/cmd/vendor/github.com/BurntSushi/toml/.travis.yml b/cmd/vendor/github.com/BurntSushi/toml/.travis.yml deleted file mode 100644 index 43caf6d..0000000 --- a/cmd/vendor/github.com/BurntSushi/toml/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: go -go: - - 1.1 - - 1.2 - - tip -install: - - go install ./... - - go get github.com/BurntSushi/toml-test -script: - - export PATH="$PATH:$HOME/gopath/bin" - - make test - diff --git a/cmd/vendor/github.com/BurntSushi/toml/COMPATIBLE b/cmd/vendor/github.com/BurntSushi/toml/COMPATIBLE deleted file mode 100644 index 21e0938..0000000 --- a/cmd/vendor/github.com/BurntSushi/toml/COMPATIBLE +++ /dev/null @@ -1,3 +0,0 @@ -Compatible with TOML version -[v0.2.0](https://github.com/mojombo/toml/blob/master/versions/toml-v0.2.0.md) - diff --git a/cmd/vendor/github.com/BurntSushi/toml/Makefile b/cmd/vendor/github.com/BurntSushi/toml/Makefile deleted file mode 100644 index 3600848..0000000 --- a/cmd/vendor/github.com/BurntSushi/toml/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -install: - go install ./... - -test: install - go test -v - toml-test toml-test-decoder - toml-test -encoder toml-test-encoder - -fmt: - gofmt -w *.go */*.go - colcheck *.go */*.go - -tags: - find ./ -name '*.go' -print0 | xargs -0 gotags > TAGS - -push: - git push origin master - git push github master - diff --git a/cmd/vendor/github.com/BurntSushi/toml/README.md b/cmd/vendor/github.com/BurntSushi/toml/README.md deleted file mode 100644 index 5a5df63..0000000 --- a/cmd/vendor/github.com/BurntSushi/toml/README.md +++ /dev/null @@ -1,220 +0,0 @@ -## TOML parser and encoder for Go with reflection - -TOML stands for Tom's Obvious, Minimal Language. This Go package provides a -reflection interface similar to Go's standard library `json` and `xml` -packages. This package also supports the `encoding.TextUnmarshaler` and -`encoding.TextMarshaler` interfaces so that you can define custom data -representations. (There is an example of this below.) - -Spec: https://github.com/mojombo/toml - -Compatible with TOML version -[v0.2.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.2.0.md) - -Documentation: http://godoc.org/github.com/BurntSushi/toml - -Installation: - -```bash -go get github.com/BurntSushi/toml -``` - -Try the toml validator: - -```bash -go get github.com/BurntSushi/toml/cmd/tomlv -tomlv some-toml-file.toml -``` - -[![Build status](https://api.travis-ci.org/BurntSushi/toml.png)](https://travis-ci.org/BurntSushi/toml) - - -### Testing - -This package passes all tests in -[toml-test](https://github.com/BurntSushi/toml-test) for both the decoder -and the encoder. - -### Examples - -This package works similarly to how the Go standard library handles `XML` -and `JSON`. Namely, data is loaded into Go values via reflection. - -For the simplest example, consider some TOML file as just a list of keys -and values: - -```toml -Age = 25 -Cats = [ "Cauchy", "Plato" ] -Pi = 3.14 -Perfection = [ 6, 28, 496, 8128 ] -DOB = 1987-07-05T05:45:00Z -``` - -Which could be defined in Go as: - -```go -type Config struct { - Age int - Cats []string - Pi float64 - Perfection []int - DOB time.Time // requires `import time` -} -``` - -And then decoded with: - -```go -var conf Config -if _, err := toml.Decode(tomlData, &conf); err != nil { - // handle error -} -``` - -You can also use struct tags if your struct field name doesn't map to a TOML -key value directly: - -```toml -some_key_NAME = "wat" -``` - -```go -type TOML struct { - ObscureKey string `toml:"some_key_NAME"` -} -``` - -### Using the `encoding.TextUnmarshaler` interface - -Here's an example that automatically parses duration strings into -`time.Duration` values: - -```toml -[[song]] -name = "Thunder Road" -duration = "4m49s" - -[[song]] -name = "Stairway to Heaven" -duration = "8m03s" -``` - -Which can be decoded with: - -```go -type song struct { - Name string - Duration duration -} -type songs struct { - Song []song -} -var favorites songs -if _, err := toml.Decode(blob, &favorites); err != nil { - log.Fatal(err) -} - -for _, s := range favorites.Song { - fmt.Printf("%s (%s)\n", s.Name, s.Duration) -} -``` - -And you'll also need a `duration` type that satisfies the -`encoding.TextUnmarshaler` interface: - -```go -type duration struct { - time.Duration -} - -func (d *duration) UnmarshalText(text []byte) error { - var err error - d.Duration, err = time.ParseDuration(string(text)) - return err -} -``` - -### More complex usage - -Here's an example of how to load the example from the official spec page: - -```toml -# This is a TOML document. Boom. - -title = "TOML Example" - -[owner] -name = "Tom Preston-Werner" -organization = "GitHub" -bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." -dob = 1979-05-27T07:32:00Z # First class dates? Why not? - -[database] -server = "192.168.1.1" -ports = [ 8001, 8001, 8002 ] -connection_max = 5000 -enabled = true - -[servers] - - # You can indent as you please. Tabs or spaces. TOML don't care. - [servers.alpha] - ip = "10.0.0.1" - dc = "eqdc10" - - [servers.beta] - ip = "10.0.0.2" - dc = "eqdc10" - -[clients] -data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it - -# Line breaks are OK when inside arrays -hosts = [ - "alpha", - "omega" -] -``` - -And the corresponding Go types are: - -```go -type tomlConfig struct { - Title string - Owner ownerInfo - DB database `toml:"database"` - Servers map[string]server - Clients clients -} - -type ownerInfo struct { - Name string - Org string `toml:"organization"` - Bio string - DOB time.Time -} - -type database struct { - Server string - Ports []int - ConnMax int `toml:"connection_max"` - Enabled bool -} - -type server struct { - IP string - DC string -} - -type clients struct { - Data [][]interface{} - Hosts []string -} -``` - -Note that a case insensitive match will be tried if an exact match can't be -found. - -A working example of the above can be found in `_examples/example.{go,toml}`. - diff --git a/cmd/vendor/github.com/BurntSushi/toml/session.vim b/cmd/vendor/github.com/BurntSushi/toml/session.vim deleted file mode 100644 index 562164b..0000000 --- a/cmd/vendor/github.com/BurntSushi/toml/session.vim +++ /dev/null @@ -1 +0,0 @@ -au BufWritePost *.go silent!make tags > /dev/null 2>&1 diff --git a/cmd/vendor/github.com/cupcake/rdb/.gitignore b/cmd/vendor/github.com/cupcake/rdb/.gitignore deleted file mode 100644 index fcc1e66..0000000 --- a/cmd/vendor/github.com/cupcake/rdb/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe - -# Project-specific files -diff diff --git a/cmd/vendor/github.com/cupcake/rdb/.travis.yml b/cmd/vendor/github.com/cupcake/rdb/.travis.yml deleted file mode 100644 index 7362f08..0000000 --- a/cmd/vendor/github.com/cupcake/rdb/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -language: go -go: - - 1.1 - - tip -before_install: - - go get launchpad.net/gocheck diff --git a/cmd/vendor/github.com/cupcake/rdb/README.md b/cmd/vendor/github.com/cupcake/rdb/README.md deleted file mode 100644 index 5c19212..0000000 --- a/cmd/vendor/github.com/cupcake/rdb/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# rdb [![Build Status](https://travis-ci.org/cupcake/rdb.png?branch=master)](https://travis-ci.org/cupcake/rdb) - -rdb is a Go package that implements parsing and encoding of the -[Redis](http://redis.io) [RDB file -format](https://github.com/sripathikrishnan/redis-rdb-tools/blob/master/docs/RDB_File_Format.textile). - -This package was heavily inspired by -[redis-rdb-tools](https://github.com/sripathikrishnan/redis-rdb-tools) by -[Sripathi Krishnan](https://github.com/sripathikrishnan). - -[**Documentation**](http://godoc.org/github.com/cupcake/rdb) - -## Installation - -``` -go get github.com/cupcake/rdb -``` diff --git a/cmd/vendor/github.com/edsrzf/mmap-go/.gitignore b/cmd/vendor/github.com/edsrzf/mmap-go/.gitignore deleted file mode 100644 index 9aa02c1..0000000 --- a/cmd/vendor/github.com/edsrzf/mmap-go/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.out -*.5 -*.6 -*.8 -*.swp -_obj -_test -testdata diff --git a/cmd/vendor/github.com/edsrzf/mmap-go/README.md b/cmd/vendor/github.com/edsrzf/mmap-go/README.md deleted file mode 100644 index 4cc2bfe..0000000 --- a/cmd/vendor/github.com/edsrzf/mmap-go/README.md +++ /dev/null @@ -1,12 +0,0 @@ -mmap-go -======= - -mmap-go is a portable mmap package for the [Go programming language](http://golang.org). -It has been tested on Linux (386, amd64), OS X, and Windows (386). It should also -work on other Unix-like platforms, but hasn't been tested with them. I'm interested -to hear about the results. - -I haven't been able to add more features without adding significant complexity, -so mmap-go doesn't support mprotect, mincore, and maybe a few other things. -If you're running on a Unix-like platform and need some of these features, -I suggest Gustavo Niemeyer's [gommap](http://labix.org/gommap). diff --git a/cmd/vendor/github.com/golang/snappy/AUTHORS b/cmd/vendor/github.com/golang/snappy/AUTHORS deleted file mode 100644 index 824bf2e..0000000 --- a/cmd/vendor/github.com/golang/snappy/AUTHORS +++ /dev/null @@ -1,14 +0,0 @@ -# This is the official list of Snappy-Go authors for copyright purposes. -# This file is distinct from the CONTRIBUTORS files. -# See the latter for an explanation. - -# Names should be added to this file as -# Name or Organization -# The email address is not required for organizations. - -# Please keep the list sorted. - -Damian Gryski -Google Inc. -Jan Mercl <0xjnml@gmail.com> -Sebastien Binet diff --git a/cmd/vendor/github.com/golang/snappy/CONTRIBUTORS b/cmd/vendor/github.com/golang/snappy/CONTRIBUTORS deleted file mode 100644 index 9f54f21..0000000 --- a/cmd/vendor/github.com/golang/snappy/CONTRIBUTORS +++ /dev/null @@ -1,36 +0,0 @@ -# This is the official list of people who can contribute -# (and typically have contributed) code to the Snappy-Go repository. -# The AUTHORS file lists the copyright holders; this file -# lists people. For example, Google employees are listed here -# but not in AUTHORS, because Google holds the copyright. -# -# The submission process automatically checks to make sure -# that people submitting code are listed in this file (by email address). -# -# Names should be added to this file only after verifying that -# the individual or the individual's organization has agreed to -# the appropriate Contributor License Agreement, found here: -# -# http://code.google.com/legal/individual-cla-v1.0.html -# http://code.google.com/legal/corporate-cla-v1.0.html -# -# The agreement for individuals can be filled out on the web. -# -# When adding J Random Contributor's name to this file, -# either J's name or J's organization's name should be -# added to the AUTHORS file, depending on whether the -# individual or corporate CLA was used. - -# Names should be added to this file like so: -# Name - -# Please keep the list sorted. - -Damian Gryski -Jan Mercl <0xjnml@gmail.com> -Kai Backman -Marc-Antoine Ruel -Nigel Tao -Rob Pike -Russ Cox -Sebastien Binet diff --git a/cmd/vendor/github.com/golang/snappy/README b/cmd/vendor/github.com/golang/snappy/README deleted file mode 100644 index 5074bba..0000000 --- a/cmd/vendor/github.com/golang/snappy/README +++ /dev/null @@ -1,7 +0,0 @@ -The Snappy compression format in the Go programming language. - -To download and install from source: -$ go get github.com/golang/snappy - -Unless otherwise noted, the Snappy-Go source files are distributed -under the BSD-style license found in the LICENSE file. diff --git a/cmd/vendor/github.com/golang/snappy/encode.go b/cmd/vendor/github.com/golang/snappy/encode.go deleted file mode 100644 index f3b5484..0000000 --- a/cmd/vendor/github.com/golang/snappy/encode.go +++ /dev/null @@ -1,254 +0,0 @@ -// Copyright 2011 The Snappy-Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package snappy - -import ( - "encoding/binary" - "io" -) - -// We limit how far copy back-references can go, the same as the C++ code. -const maxOffset = 1 << 15 - -// emitLiteral writes a literal chunk and returns the number of bytes written. -func emitLiteral(dst, lit []byte) int { - i, n := 0, uint(len(lit)-1) - switch { - case n < 60: - dst[0] = uint8(n)<<2 | tagLiteral - i = 1 - case n < 1<<8: - dst[0] = 60<<2 | tagLiteral - dst[1] = uint8(n) - i = 2 - case n < 1<<16: - dst[0] = 61<<2 | tagLiteral - dst[1] = uint8(n) - dst[2] = uint8(n >> 8) - i = 3 - case n < 1<<24: - dst[0] = 62<<2 | tagLiteral - dst[1] = uint8(n) - dst[2] = uint8(n >> 8) - dst[3] = uint8(n >> 16) - i = 4 - case int64(n) < 1<<32: - dst[0] = 63<<2 | tagLiteral - dst[1] = uint8(n) - dst[2] = uint8(n >> 8) - dst[3] = uint8(n >> 16) - dst[4] = uint8(n >> 24) - i = 5 - default: - panic("snappy: source buffer is too long") - } - if copy(dst[i:], lit) != len(lit) { - panic("snappy: destination buffer is too short") - } - return i + len(lit) -} - -// emitCopy writes a copy chunk and returns the number of bytes written. -func emitCopy(dst []byte, offset, length int) int { - i := 0 - for length > 0 { - x := length - 4 - if 0 <= x && x < 1<<3 && offset < 1<<11 { - dst[i+0] = uint8(offset>>8)&0x07<<5 | uint8(x)<<2 | tagCopy1 - dst[i+1] = uint8(offset) - i += 2 - break - } - - x = length - if x > 1<<6 { - x = 1 << 6 - } - dst[i+0] = uint8(x-1)<<2 | tagCopy2 - dst[i+1] = uint8(offset) - dst[i+2] = uint8(offset >> 8) - i += 3 - length -= x - } - return i -} - -// Encode returns the encoded form of src. The returned slice may be a sub- -// slice of dst if dst was large enough to hold the entire encoded block. -// Otherwise, a newly allocated slice will be returned. -// It is valid to pass a nil dst. -func Encode(dst, src []byte) []byte { - if n := MaxEncodedLen(len(src)); len(dst) < n { - dst = make([]byte, n) - } - - // The block starts with the varint-encoded length of the decompressed bytes. - d := binary.PutUvarint(dst, uint64(len(src))) - - // Return early if src is short. - if len(src) <= 4 { - if len(src) != 0 { - d += emitLiteral(dst[d:], src) - } - return dst[:d] - } - - // Initialize the hash table. Its size ranges from 1<<8 to 1<<14 inclusive. - const maxTableSize = 1 << 14 - shift, tableSize := uint(32-8), 1<<8 - for tableSize < maxTableSize && tableSize < len(src) { - shift-- - tableSize *= 2 - } - var table [maxTableSize]int - - // Iterate over the source bytes. - var ( - s int // The iterator position. - t int // The last position with the same hash as s. - lit int // The start position of any pending literal bytes. - ) - for s+3 < len(src) { - // Update the hash table. - b0, b1, b2, b3 := src[s], src[s+1], src[s+2], src[s+3] - h := uint32(b0) | uint32(b1)<<8 | uint32(b2)<<16 | uint32(b3)<<24 - p := &table[(h*0x1e35a7bd)>>shift] - // We need to to store values in [-1, inf) in table. To save - // some initialization time, (re)use the table's zero value - // and shift the values against this zero: add 1 on writes, - // subtract 1 on reads. - t, *p = *p-1, s+1 - // If t is invalid or src[s:s+4] differs from src[t:t+4], accumulate a literal byte. - if t < 0 || s-t >= maxOffset || b0 != src[t] || b1 != src[t+1] || b2 != src[t+2] || b3 != src[t+3] { - s++ - continue - } - // Otherwise, we have a match. First, emit any pending literal bytes. - if lit != s { - d += emitLiteral(dst[d:], src[lit:s]) - } - // Extend the match to be as long as possible. - s0 := s - s, t = s+4, t+4 - for s < len(src) && src[s] == src[t] { - s++ - t++ - } - // Emit the copied bytes. - d += emitCopy(dst[d:], s-t, s-s0) - lit = s - } - - // Emit any final pending literal bytes and return. - if lit != len(src) { - d += emitLiteral(dst[d:], src[lit:]) - } - return dst[:d] -} - -// MaxEncodedLen returns the maximum length of a snappy block, given its -// uncompressed length. -func MaxEncodedLen(srcLen int) int { - // Compressed data can be defined as: - // compressed := item* literal* - // item := literal* copy - // - // The trailing literal sequence has a space blowup of at most 62/60 - // since a literal of length 60 needs one tag byte + one extra byte - // for length information. - // - // Item blowup is trickier to measure. Suppose the "copy" op copies - // 4 bytes of data. Because of a special check in the encoding code, - // we produce a 4-byte copy only if the offset is < 65536. Therefore - // the copy op takes 3 bytes to encode, and this type of item leads - // to at most the 62/60 blowup for representing literals. - // - // Suppose the "copy" op copies 5 bytes of data. If the offset is big - // enough, it will take 5 bytes to encode the copy op. Therefore the - // worst case here is a one-byte literal followed by a five-byte copy. - // That is, 6 bytes of input turn into 7 bytes of "compressed" data. - // - // This last factor dominates the blowup, so the final estimate is: - return 32 + srcLen + srcLen/6 -} - -// NewWriter returns a new Writer that compresses to w, using the framing -// format described at -// https://github.com/google/snappy/blob/master/framing_format.txt -func NewWriter(w io.Writer) *Writer { - return &Writer{ - w: w, - enc: make([]byte, MaxEncodedLen(maxUncompressedChunkLen)), - } -} - -// Writer is an io.Writer than can write Snappy-compressed bytes. -type Writer struct { - w io.Writer - err error - enc []byte - buf [checksumSize + chunkHeaderSize]byte - wroteHeader bool -} - -// Reset discards the writer's state and switches the Snappy writer to write to -// w. This permits reusing a Writer rather than allocating a new one. -func (w *Writer) Reset(writer io.Writer) { - w.w = writer - w.err = nil - w.wroteHeader = false -} - -// Write satisfies the io.Writer interface. -func (w *Writer) Write(p []byte) (n int, errRet error) { - if w.err != nil { - return 0, w.err - } - if !w.wroteHeader { - copy(w.enc, magicChunk) - if _, err := w.w.Write(w.enc[:len(magicChunk)]); err != nil { - w.err = err - return n, err - } - w.wroteHeader = true - } - for len(p) > 0 { - var uncompressed []byte - if len(p) > maxUncompressedChunkLen { - uncompressed, p = p[:maxUncompressedChunkLen], p[maxUncompressedChunkLen:] - } else { - uncompressed, p = p, nil - } - checksum := crc(uncompressed) - - // Compress the buffer, discarding the result if the improvement - // isn't at least 12.5%. - chunkType := uint8(chunkTypeCompressedData) - chunkBody := Encode(w.enc, uncompressed) - if len(chunkBody) >= len(uncompressed)-len(uncompressed)/8 { - chunkType, chunkBody = chunkTypeUncompressedData, uncompressed - } - - chunkLen := 4 + len(chunkBody) - w.buf[0] = chunkType - w.buf[1] = uint8(chunkLen >> 0) - w.buf[2] = uint8(chunkLen >> 8) - w.buf[3] = uint8(chunkLen >> 16) - w.buf[4] = uint8(checksum >> 0) - w.buf[5] = uint8(checksum >> 8) - w.buf[6] = uint8(checksum >> 16) - w.buf[7] = uint8(checksum >> 24) - if _, err := w.w.Write(w.buf[:]); err != nil { - w.err = err - return n, err - } - if _, err := w.w.Write(chunkBody); err != nil { - w.err = err - return n, err - } - n += len(uncompressed) - } - return n, nil -} diff --git a/cmd/vendor/github.com/peterh/liner/README.md b/cmd/vendor/github.com/peterh/liner/README.md deleted file mode 100644 index 9148b24..0000000 --- a/cmd/vendor/github.com/peterh/liner/README.md +++ /dev/null @@ -1,100 +0,0 @@ -Liner -===== - -Liner is a command line editor with history. It was inspired by linenoise; -everything Unix-like is a VT100 (or is trying very hard to be). If your -terminal is not pretending to be a VT100, change it. Liner also support -Windows. - -Liner is released under the X11 license (which is similar to the new BSD -license). - -Line Editing ------------- - -The following line editing commands are supported on platforms and terminals -that Liner supports: - -Keystroke | Action ---------- | ------ -Ctrl-A, Home | Move cursor to beginning of line -Ctrl-E, End | Move cursor to end of line -Ctrl-B, Left | Move cursor one character left -Ctrl-F, Right| Move cursor one character right -Ctrl-Left, Alt-B | Move cursor to previous word -Ctrl-Right, Alt-F | Move cursor to next word -Ctrl-D, Del | (if line is *not* empty) Delete character under cursor -Ctrl-D | (if line *is* empty) End of File - usually quits application -Ctrl-C | Reset input (create new empty prompt) -Ctrl-L | Clear screen (line is unmodified) -Ctrl-T | Transpose previous character with current character -Ctrl-H, BackSpace | Delete character before cursor -Ctrl-W | Delete word leading up to cursor -Ctrl-K | Delete from cursor to end of line -Ctrl-U | Delete from start of line to cursor -Ctrl-P, Up | Previous match from history -Ctrl-N, Down | Next match from history -Ctrl-R | Reverse Search history (Ctrl-S forward, Ctrl-G cancel) -Ctrl-Y | Paste from Yank buffer (Alt-Y to paste next yank instead) -Tab | Next completion -Shift-Tab | (after Tab) Previous completion - -Getting started ------------------ - -```go -package main - -import ( - "log" - "os" - "path/filepath" - "strings" - - "github.com/peterh/liner" -) - -var ( - history_fn = filepath.Join(os.TempDir(), ".liner_example_history") - names = []string{"john", "james", "mary", "nancy"} -) - -func main() { - line := liner.NewLiner() - defer line.Close() - - line.SetCtrlCAborts(true) - - line.SetCompleter(func(line string) (c []string) { - for _, n := range names { - if strings.HasPrefix(n, strings.ToLower(line)) { - c = append(c, n) - } - } - return - }) - - if f, err := os.Open(history_fn); err == nil { - line.ReadHistory(f) - f.Close() - } - - if name, err := line.Prompt("What is your name? "); err == nil { - log.Print("Got: ", name) - line.AppendHistory(name) - } else if err == liner.ErrPromptAborted { - log.Print("Aborted") - } else { - log.Print("Error reading line: ", err) - } - - if f, err := os.Create(history_fn); err != nil { - log.Print("Error writing history file: ", err) - } else { - line.WriteHistory(f) - f.Close() - } -} -``` - -For documentation, see http://godoc.org/github.com/peterh/liner diff --git a/cmd/vendor/github.com/peterh/liner/signal.go b/cmd/vendor/github.com/peterh/liner/signal.go deleted file mode 100644 index 0cba79e..0000000 --- a/cmd/vendor/github.com/peterh/liner/signal.go +++ /dev/null @@ -1,12 +0,0 @@ -// +build go1.1,!windows - -package liner - -import ( - "os" - "os/signal" -) - -func stopSignal(c chan<- os.Signal) { - signal.Stop(c) -} diff --git a/cmd/vendor/github.com/peterh/liner/signal_legacy.go b/cmd/vendor/github.com/peterh/liner/signal_legacy.go deleted file mode 100644 index fa3672d..0000000 --- a/cmd/vendor/github.com/peterh/liner/signal_legacy.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build !go1.1,!windows - -package liner - -import ( - "os" -) - -func stopSignal(c chan<- os.Signal) { - // signal.Stop does not exist before Go 1.1 -} diff --git a/cmd/vendor/github.com/siddontang/golua/golua_license b/cmd/vendor/github.com/siddontang/golua/golua_license deleted file mode 100644 index 12a8196..0000000 --- a/cmd/vendor/github.com/siddontang/golua/golua_license +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License - -Copyright (c) 2010 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/cmd/vendor/github.com/siddontang/goredis/garyburd_license b/cmd/vendor/github.com/siddontang/goredis/garyburd_license deleted file mode 100644 index 8867881..0000000 --- a/cmd/vendor/github.com/siddontang/goredis/garyburd_license +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 Gary Burd -// -// Licensed under the Apache License, Version 2.0 (the "License"): you may -// not use this file except in compliance with the License. You may obtain -// a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// License for the specific language governing permissions and limitations -// under the License. \ No newline at end of file diff --git a/cmd/vendor/github.com/siddontang/rdb/README.md b/cmd/vendor/github.com/siddontang/rdb/README.md deleted file mode 100644 index aa1582e..0000000 --- a/cmd/vendor/github.com/siddontang/rdb/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# rdb - -Handling Redis RDB format. diff --git a/cmd/vendor/github.com/siddontang/rdb/wandoujia-license b/cmd/vendor/github.com/siddontang/rdb/wandoujia-license deleted file mode 100644 index 23320dc..0000000 --- a/cmd/vendor/github.com/siddontang/rdb/wandoujia-license +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Wandoujia Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/batch.go b/cmd/vendor/github.com/syndtr/goleveldb/leveldb/batch.go deleted file mode 100644 index 5010067..0000000 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/batch.go +++ /dev/null @@ -1,262 +0,0 @@ -// Copyright (c) 2012, Suryandaru Triandana -// All rights reserved. -// -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package leveldb - -import ( - "encoding/binary" - "fmt" - - "github.com/syndtr/goleveldb/leveldb/errors" - "github.com/syndtr/goleveldb/leveldb/memdb" - "github.com/syndtr/goleveldb/leveldb/storage" -) - -// ErrBatchCorrupted records reason of batch corruption. -type ErrBatchCorrupted struct { - Reason string -} - -func (e *ErrBatchCorrupted) Error() string { - return fmt.Sprintf("leveldb: batch corrupted: %s", e.Reason) -} - -func newErrBatchCorrupted(reason string) error { - return errors.NewErrCorrupted(storage.FileDesc{}, &ErrBatchCorrupted{reason}) -} - -const ( - batchHdrLen = 8 + 4 - batchGrowRec = 3000 -) - -// BatchReplay wraps basic batch operations. -type BatchReplay interface { - Put(key, value []byte) - Delete(key []byte) -} - -// Batch is a write batch. -type Batch struct { - data []byte - rLen, bLen int - seq uint64 - sync bool -} - -func (b *Batch) grow(n int) { - off := len(b.data) - if off == 0 { - off = batchHdrLen - if b.data != nil { - b.data = b.data[:off] - } - } - if cap(b.data)-off < n { - if b.data == nil { - b.data = make([]byte, off, off+n) - } else { - odata := b.data - div := 1 - if b.rLen > batchGrowRec { - div = b.rLen / batchGrowRec - } - b.data = make([]byte, off, off+n+(off-batchHdrLen)/div) - copy(b.data, odata) - } - } -} - -func (b *Batch) appendRec(kt keyType, key, value []byte) { - n := 1 + binary.MaxVarintLen32 + len(key) - if kt == keyTypeVal { - n += binary.MaxVarintLen32 + len(value) - } - b.grow(n) - off := len(b.data) - data := b.data[:off+n] - data[off] = byte(kt) - off++ - off += binary.PutUvarint(data[off:], uint64(len(key))) - copy(data[off:], key) - off += len(key) - if kt == keyTypeVal { - off += binary.PutUvarint(data[off:], uint64(len(value))) - copy(data[off:], value) - off += len(value) - } - b.data = data[:off] - b.rLen++ - // Include 8-byte ikey header - b.bLen += len(key) + len(value) + 8 -} - -// Put appends 'put operation' of the given key/value pair to the batch. -// It is safe to modify the contents of the argument after Put returns. -func (b *Batch) Put(key, value []byte) { - b.appendRec(keyTypeVal, key, value) -} - -// Delete appends 'delete operation' of the given key to the batch. -// It is safe to modify the contents of the argument after Delete returns. -func (b *Batch) Delete(key []byte) { - b.appendRec(keyTypeDel, key, nil) -} - -// Dump dumps batch contents. The returned slice can be loaded into the -// batch using Load method. -// The returned slice is not its own copy, so the contents should not be -// modified. -func (b *Batch) Dump() []byte { - return b.encode() -} - -// Load loads given slice into the batch. Previous contents of the batch -// will be discarded. -// The given slice will not be copied and will be used as batch buffer, so -// it is not safe to modify the contents of the slice. -func (b *Batch) Load(data []byte) error { - return b.decode(0, data) -} - -// Replay replays batch contents. -func (b *Batch) Replay(r BatchReplay) error { - return b.decodeRec(func(i int, kt keyType, key, value []byte) error { - switch kt { - case keyTypeVal: - r.Put(key, value) - case keyTypeDel: - r.Delete(key) - } - return nil - }) -} - -// Len returns number of records in the batch. -func (b *Batch) Len() int { - return b.rLen -} - -// Reset resets the batch. -func (b *Batch) Reset() { - b.data = b.data[:0] - b.seq = 0 - b.rLen = 0 - b.bLen = 0 - b.sync = false -} - -func (b *Batch) init(sync bool) { - b.sync = sync -} - -func (b *Batch) append(p *Batch) { - if p.rLen > 0 { - b.grow(len(p.data) - batchHdrLen) - b.data = append(b.data, p.data[batchHdrLen:]...) - b.rLen += p.rLen - b.bLen += p.bLen - } - if p.sync { - b.sync = true - } -} - -// size returns sums of key/value pair length plus 8-bytes ikey. -func (b *Batch) size() int { - return b.bLen -} - -func (b *Batch) encode() []byte { - b.grow(0) - binary.LittleEndian.PutUint64(b.data, b.seq) - binary.LittleEndian.PutUint32(b.data[8:], uint32(b.rLen)) - - return b.data -} - -func (b *Batch) decode(prevSeq uint64, data []byte) error { - if len(data) < batchHdrLen { - return newErrBatchCorrupted("too short") - } - - b.seq = binary.LittleEndian.Uint64(data) - if b.seq < prevSeq { - return newErrBatchCorrupted("invalid sequence number") - } - b.rLen = int(binary.LittleEndian.Uint32(data[8:])) - if b.rLen < 0 { - return newErrBatchCorrupted("invalid records length") - } - // No need to be precise at this point, it won't be used anyway - b.bLen = len(data) - batchHdrLen - b.data = data - - return nil -} - -func (b *Batch) decodeRec(f func(i int, kt keyType, key, value []byte) error) error { - off := batchHdrLen - for i := 0; i < b.rLen; i++ { - if off >= len(b.data) { - return newErrBatchCorrupted("invalid records length") - } - - kt := keyType(b.data[off]) - if kt > keyTypeVal { - panic(kt) - return newErrBatchCorrupted("bad record: invalid type") - } - off++ - - x, n := binary.Uvarint(b.data[off:]) - off += n - if n <= 0 || off+int(x) > len(b.data) { - return newErrBatchCorrupted("bad record: invalid key length") - } - key := b.data[off : off+int(x)] - off += int(x) - var value []byte - if kt == keyTypeVal { - x, n := binary.Uvarint(b.data[off:]) - off += n - if n <= 0 || off+int(x) > len(b.data) { - return newErrBatchCorrupted("bad record: invalid value length") - } - value = b.data[off : off+int(x)] - off += int(x) - } - - if err := f(i, kt, key, value); err != nil { - return err - } - } - - return nil -} - -func (b *Batch) memReplay(to *memdb.DB) error { - var ikScratch []byte - return b.decodeRec(func(i int, kt keyType, key, value []byte) error { - ikScratch = makeInternalKey(ikScratch, key, b.seq+uint64(i), kt) - return to.Put(ikScratch, value) - }) -} - -func (b *Batch) memDecodeAndReplay(prevSeq uint64, data []byte, to *memdb.DB) error { - if err := b.decode(prevSeq, data); err != nil { - return err - } - return b.memReplay(to) -} - -func (b *Batch) revertMemReplay(to *memdb.DB) error { - var ikScratch []byte - return b.decodeRec(func(i int, kt keyType, key, value []byte) error { - ikScratch := makeInternalKey(ikScratch, key, b.seq+uint64(i), kt) - return to.Delete(ikScratch) - }) -} diff --git a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_write.go b/cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_write.go deleted file mode 100644 index 5576761..0000000 --- a/cmd/vendor/github.com/syndtr/goleveldb/leveldb/db_write.go +++ /dev/null @@ -1,358 +0,0 @@ -// Copyright (c) 2012, Suryandaru Triandana -// All rights reserved. -// -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package leveldb - -import ( - "time" - - "github.com/syndtr/goleveldb/leveldb/memdb" - "github.com/syndtr/goleveldb/leveldb/opt" - "github.com/syndtr/goleveldb/leveldb/util" -) - -func (db *DB) writeJournal(b *Batch) error { - w, err := db.journal.Next() - if err != nil { - return err - } - if _, err := w.Write(b.encode()); err != nil { - return err - } - if err := db.journal.Flush(); err != nil { - return err - } - if b.sync { - return db.journalWriter.Sync() - } - return nil -} - -func (db *DB) jWriter() { - defer db.closeW.Done() - for { - select { - case b := <-db.journalC: - if b != nil { - db.journalAckC <- db.writeJournal(b) - } - case _, _ = <-db.closeC: - return - } - } -} - -func (db *DB) rotateMem(n int, wait bool) (mem *memDB, err error) { - // Wait for pending memdb compaction. - err = db.compTriggerWait(db.mcompCmdC) - if err != nil { - return - } - - // Create new memdb and journal. - mem, err = db.newMem(n) - if err != nil { - return - } - - // Schedule memdb compaction. - if wait { - err = db.compTriggerWait(db.mcompCmdC) - } else { - db.compTrigger(db.mcompCmdC) - } - return -} - -func (db *DB) flush(n int) (mdb *memDB, mdbFree int, err error) { - delayed := false - flush := func() (retry bool) { - v := db.s.version() - defer v.release() - mdb = db.getEffectiveMem() - defer func() { - if retry { - mdb.decref() - mdb = nil - } - }() - mdbFree = mdb.Free() - switch { - case v.tLen(0) >= db.s.o.GetWriteL0SlowdownTrigger() && !delayed: - delayed = true - time.Sleep(time.Millisecond) - case mdbFree >= n: - return false - case v.tLen(0) >= db.s.o.GetWriteL0PauseTrigger(): - delayed = true - err = db.compTriggerWait(db.tcompCmdC) - if err != nil { - return false - } - default: - // Allow memdb to grow if it has no entry. - if mdb.Len() == 0 { - mdbFree = n - } else { - mdb.decref() - mdb, err = db.rotateMem(n, false) - if err == nil { - mdbFree = mdb.Free() - } else { - mdbFree = 0 - } - } - return false - } - return true - } - start := time.Now() - for flush() { - } - if delayed { - db.writeDelay += time.Since(start) - db.writeDelayN++ - } else if db.writeDelayN > 0 { - db.logf("db@write was delayed N·%d T·%v", db.writeDelayN, db.writeDelay) - db.writeDelay = 0 - db.writeDelayN = 0 - } - return -} - -// Write apply the given batch to the DB. The batch will be applied -// sequentially. -// -// It is safe to modify the contents of the arguments after Write returns. -func (db *DB) Write(b *Batch, wo *opt.WriteOptions) (err error) { - err = db.ok() - if err != nil || b == nil || b.Len() == 0 { - return - } - - b.init(wo.GetSync() && !db.s.o.GetNoSync()) - - if b.size() > db.s.o.GetWriteBuffer() && !db.s.o.GetDisableLargeBatchTransaction() { - // Writes using transaction. - tr, err1 := db.OpenTransaction() - if err1 != nil { - return err1 - } - if err1 := tr.Write(b, wo); err1 != nil { - tr.Discard() - return err1 - } - return tr.Commit() - } - - // The write happen synchronously. - select { - case db.writeC <- b: - if <-db.writeMergedC { - return <-db.writeAckC - } - // Continue, the write lock already acquired by previous writer - // and handed out to us. - case db.writeLockC <- struct{}{}: - case err = <-db.compPerErrC: - return - case _, _ = <-db.closeC: - return ErrClosed - } - - merged := 0 - danglingMerge := false - defer func() { - for i := 0; i < merged; i++ { - db.writeAckC <- err - } - if danglingMerge { - // Only one dangling merge at most, so this is safe. - db.writeMergedC <- false - } else { - <-db.writeLockC - } - }() - - mdb, mdbFree, err := db.flush(b.size()) - if err != nil { - return - } - defer mdb.decref() - - // Calculate maximum size of the batch. - m := 1 << 20 - if x := b.size(); x <= 128<<10 { - m = x + (128 << 10) - } - m = minInt(m, mdbFree) - - // Merge with other batch. -drain: - for b.size() < m && !b.sync { - select { - case nb := <-db.writeC: - if b.size()+nb.size() <= m { - b.append(nb) - db.writeMergedC <- true - merged++ - } else { - danglingMerge = true - break drain - } - default: - break drain - } - } - - // Set batch first seq number relative from last seq. - b.seq = db.seq + 1 - - // Write journal concurrently if it is large enough. - if b.size() >= (128 << 10) { - // Push the write batch to the journal writer - select { - case db.journalC <- b: - // Write into memdb - if berr := b.memReplay(mdb.DB); berr != nil { - panic(berr) - } - case err = <-db.compPerErrC: - return - case _, _ = <-db.closeC: - err = ErrClosed - return - } - // Wait for journal writer - select { - case err = <-db.journalAckC: - if err != nil { - // Revert memdb if error detected - if berr := b.revertMemReplay(mdb.DB); berr != nil { - panic(berr) - } - return - } - case _, _ = <-db.closeC: - err = ErrClosed - return - } - } else { - err = db.writeJournal(b) - if err != nil { - return - } - if berr := b.memReplay(mdb.DB); berr != nil { - panic(berr) - } - } - - // Set last seq number. - db.addSeq(uint64(b.Len())) - - if b.size() >= mdbFree { - db.rotateMem(0, false) - } - return -} - -// Put sets the value for the given key. It overwrites any previous value -// for that key; a DB is not a multi-map. -// -// It is safe to modify the contents of the arguments after Put returns. -func (db *DB) Put(key, value []byte, wo *opt.WriteOptions) error { - b := new(Batch) - b.Put(key, value) - return db.Write(b, wo) -} - -// Delete deletes the value for the given key. -// -// It is safe to modify the contents of the arguments after Delete returns. -func (db *DB) Delete(key []byte, wo *opt.WriteOptions) error { - b := new(Batch) - b.Delete(key) - return db.Write(b, wo) -} - -func isMemOverlaps(icmp *iComparer, mem *memdb.DB, min, max []byte) bool { - iter := mem.NewIterator(nil) - defer iter.Release() - return (max == nil || (iter.First() && icmp.uCompare(max, internalKey(iter.Key()).ukey()) >= 0)) && - (min == nil || (iter.Last() && icmp.uCompare(min, internalKey(iter.Key()).ukey()) <= 0)) -} - -// CompactRange compacts the underlying DB for the given key range. -// In particular, deleted and overwritten versions are discarded, -// and the data is rearranged to reduce the cost of operations -// needed to access the data. This operation should typically only -// be invoked by users who understand the underlying implementation. -// -// A nil Range.Start is treated as a key before all keys in the DB. -// And a nil Range.Limit is treated as a key after all keys in the DB. -// Therefore if both is nil then it will compact entire DB. -func (db *DB) CompactRange(r util.Range) error { - if err := db.ok(); err != nil { - return err - } - - // Lock writer. - select { - case db.writeLockC <- struct{}{}: - case err := <-db.compPerErrC: - return err - case _, _ = <-db.closeC: - return ErrClosed - } - - // Check for overlaps in memdb. - mdb := db.getEffectiveMem() - defer mdb.decref() - if isMemOverlaps(db.s.icmp, mdb.DB, r.Start, r.Limit) { - // Memdb compaction. - if _, err := db.rotateMem(0, false); err != nil { - <-db.writeLockC - return err - } - <-db.writeLockC - if err := db.compTriggerWait(db.mcompCmdC); err != nil { - return err - } - } else { - <-db.writeLockC - } - - // Table compaction. - return db.compTriggerRange(db.tcompCmdC, -1, r.Start, r.Limit) -} - -// SetReadOnly makes DB read-only. It will stay read-only until reopened. -func (db *DB) SetReadOnly() error { - if err := db.ok(); err != nil { - return err - } - - // Lock writer. - select { - case db.writeLockC <- struct{}{}: - db.compWriteLocking = true - case err := <-db.compPerErrC: - return err - case _, _ = <-db.closeC: - return ErrClosed - } - - // Set compaction read-only. - select { - case db.compErrSetC <- ErrReadOnly: - case perr := <-db.compPerErrC: - return perr - case _, _ = <-db.closeC: - return ErrClosed - } - - return nil -} diff --git a/cmd/vendor/github.com/ugorji/go/codec/README.md b/cmd/vendor/github.com/ugorji/go/codec/README.md deleted file mode 100644 index a790a52..0000000 --- a/cmd/vendor/github.com/ugorji/go/codec/README.md +++ /dev/null @@ -1,148 +0,0 @@ -# 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 understands the `unsafe` tag, to allow using unsafe semantics: - - - When decoding into a struct, you need to read the field name as a string - so you can find the struct field it is mapped to. - Using `unsafe` will bypass the allocation and copying overhead of `[]byte->string` conversion. - -To use it, you must pass the `unsafe` tag during install: - -``` -go install -tags=unsafe github.com/ugorji/go/codec -``` - -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 - - Very High Performance. - Our extensive benchmarks show us outperforming Gob, Json, Bson, etc by 2-4X. - - Multiple conversions: - Package coerces types where appropriate - e.g. decode an int in the stream into a float, 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 - - 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{} - - Encode a struct as an array, and decode struct from an array in the data stream - - 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 idiosynchracies 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. - -## 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) - diff --git a/cmd/vendor/github.com/ugorji/go/codec/decode.go b/cmd/vendor/github.com/ugorji/go/codec/decode.go deleted file mode 100644 index a2e35d7..0000000 --- a/cmd/vendor/github.com/ugorji/go/codec/decode.go +++ /dev/null @@ -1,1552 +0,0 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "encoding" - "errors" - "fmt" - "io" - "reflect" -) - -// Some tagging information for error messages. -const ( - msgBadDesc = "Unrecognized descriptor byte" - msgDecCannotExpandArr = "cannot expand go array from %v to stream length: %v" -) - -var ( - onlyMapOrArrayCanDecodeIntoStructErr = errors.New("only encoded map or array can be decoded into a struct") - cannotDecodeIntoNilErr = errors.New("cannot decode into nil") -) - -// 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 { - // TODO: - // Add method to get num bytes read. - // This will be used to annotate errors, so user knows at what point the error occurred. - - 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 - readn1eof() (v uint8, eof bool) -} - -type decReaderByteScanner interface { - io.Reader - io.ByteScanner -} - -type decDriver interface { - // this will check if the next token is a break. - CheckBreak() bool - TryDecodeAsNil() bool - // check if a container type: vt is one of: Bytes, String, Nil, Slice or Map. - // if vt param == valueTypeNil, and nil is seen in stream, consume the nil. - IsContainerType(vt valueType) bool - IsBuiltinType(rt uintptr) bool - DecodeBuiltin(rt uintptr, v interface{}) - //decodeNaked: Numbers are decoded as int64, uint64, float64 only (no smaller sized number types). - //for extensions, decodeNaked must completely decode them as a *RawExt. - //extensions should also use readx to decode them, for efficiency. - //kInterface will extract the detached byte slice if it has to pass it outside its realm. - DecodeNaked() (v interface{}, vt valueType, decodeFurther bool) - DecodeInt(bitsize uint8) (i int64) - DecodeUint(bitsize uint8) (ui uint64) - DecodeFloat(chkOverflow32 bool) (f float64) - DecodeBool() (b bool) - // 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) - - // DecodeBytes may be called directly, without going through reflection. - // Consequently, it must be designed to handle possible nil. - 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) (realxtag uint64) - // decodeExt(verifyTag bool, tag byte) (xtag byte, xbs []byte) - ReadMapStart() int - ReadArrayStart() int - ReadMapEnd() - ReadArrayEnd() - ReadArrayEntrySeparator() - ReadMapEntrySeparator() - ReadMapKVSeparator() -} - -type decNoSeparator struct{} - -func (_ decNoSeparator) ReadMapEnd() {} -func (_ decNoSeparator) ReadArrayEnd() {} -func (_ decNoSeparator) ReadArrayEntrySeparator() {} -func (_ decNoSeparator) ReadMapEntrySeparator() {} -func (_ decNoSeparator) ReadMapKVSeparator() {} - -type DecodeOptions struct { - // MapType specifies type to use during schema-less decoding of a map in the stream. - // If nil, we use map[interface{}]interface{} - MapType reflect.Type - - // SliceType specifies type to use during schema-less decoding of an array in the stream. - // If nil, we use []interface{} - SliceType reflect.Type - - // If ErrorIfNoField, return an error when decoding a map - // from a codec stream into a struct, and no matching struct field is found. - ErrorIfNoField bool - - // If ErrorIfNoArrayExpand, return an error when decoding a slice/array that cannot be expanded. - // For example, the stream contains an array of 8 items, but you are decoding into a [4]T array, - // or you are decoding into a slice of length 4 which is non-addressable (and so cannot be set). - ErrorIfNoArrayExpand bool - - // If SignedInteger, use the int64 during schema-less decoding of unsigned values (not uint64). - SignedInteger bool -} - -// ------------------------------------ - -// ioDecByteScanner implements Read(), ReadByte(...), UnreadByte(...) methods -// of io.Reader, io.ByteScanner. -type ioDecByteScanner struct { - r io.Reader - l byte // last byte - ls byte // last byte status. 0: init-canDoNothing, 1: canRead, 2: canUnread - b [1]byte // tiny buffer for reading single bytes -} - -func (z *ioDecByteScanner) Read(p []byte) (n int, err error) { - var firstByte bool - if z.ls == 1 { - z.ls = 2 - 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 = 2 - } - if firstByte { - n++ - } - return -} - -func (z *ioDecByteScanner) ReadByte() (c byte, err error) { - n, err := z.Read(z.b[:]) - 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 *ioDecByteScanner) UnreadByte() (err error) { - x := z.ls - if x == 0 { - err = errors.New("cannot unread - nothing has been read") - } else if x == 1 { - err = errors.New("cannot unread - last byte has not been read") - } else if x == 2 { - z.ls = 1 - } - return -} - -// ioDecReader is a decReader that reads off an io.Reader -type ioDecReader struct { - br decReaderByteScanner - // temp byte array re-used internally for efficiency during read. - // shares buffer with Decoder, so we keep size of struct within 8 words. - x *[scratchByteArrayLen]byte - bs ioDecByteScanner -} - -func (z *ioDecReader) readx(n int) (bs []byte) { - if n <= 0 { - return - } - if n < len(z.x) { - bs = z.x[:n] - } else { - bs = make([]byte, n) - } - if _, err := io.ReadAtLeast(z.br, bs, n); err != nil { - panic(err) - } - return -} - -func (z *ioDecReader) readb(bs []byte) { - if len(bs) == 0 { - return - } - if _, err := io.ReadAtLeast(z.br, bs, len(bs)); err != nil { - panic(err) - } -} - -func (z *ioDecReader) readn1() (b uint8) { - b, err := z.br.ReadByte() - if err != nil { - panic(err) - } - return b -} - -func (z *ioDecReader) readn1eof() (b uint8, eof bool) { - b, err := z.br.ReadByte() - if err == nil { - } else if err == io.EOF { - eof = true - } else { - panic(err) - } - return -} - -func (z *ioDecReader) unreadn1() { - if err := z.br.UnreadByte(); err != nil { - panic(err) - } -} - -// ------------------------------------ - -var bytesDecReaderCannotUnreadErr = 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 int // cursor - a int // available -} - -func (z *bytesDecReader) unreadn1() { - if z.c == 0 || len(z.b) == 0 { - panic(bytesDecReaderCannotUnreadErr) - } - z.c-- - z.a++ - return -} - -func (z *bytesDecReader) readx(n int) (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 -} - -func (z *bytesDecReader) readn1() (v uint8) { - if z.a == 0 { - panic(io.EOF) - } - v = z.b[z.c] - z.c++ - z.a-- - return -} - -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) readb(bs []byte) { - copy(bs, z.readx(len(bs))) -} - -// ------------------------------------ - -type decFnInfoX struct { - d *Decoder - ti *typeInfo - xfFn Ext - xfTag uint64 - seq seqType -} - -// decFnInfo has methods for handling decoding of a specific type -// based on some characteristics (builtin, extension, reflect Kind, etc) -type decFnInfo struct { - // use decFnInfo as a value receiver. - // keep most of it less-used variables accessible via a pointer (*decFnInfoX). - // As sweet spot for value-receiver is 3 words, keep everything except - // decDriver (which everyone needs) directly accessible. - // ensure decFnInfoX is set for everyone who needs it i.e. - // rawExt, ext, builtin, (selfer|binary|text)Marshal, kSlice, kStruct, kMap, kInterface, fastpath - - dd decDriver - *decFnInfoX -} - -// ---------------------------------------- - -type decFn struct { - i decFnInfo - f func(decFnInfo, reflect.Value) -} - -func (f decFnInfo) builtin(rv reflect.Value) { - f.dd.DecodeBuiltin(f.ti.rtid, rv.Addr().Interface()) -} - -func (f decFnInfo) rawExt(rv reflect.Value) { - f.dd.DecodeExt(rv.Addr().Interface(), 0, nil) -} - -func (f decFnInfo) ext(rv reflect.Value) { - f.dd.DecodeExt(rv.Addr().Interface(), f.xfTag, f.xfFn) -} - -func (f decFnInfo) getValueForUnmarshalInterface(rv reflect.Value, indir int8) (v interface{}) { - if indir == -1 { - v = rv.Addr().Interface() - } else if indir == 0 { - v = rv.Interface() - } else { - for j := int8(0); j < indir; j++ { - if rv.IsNil() { - rv.Set(reflect.New(rv.Type().Elem())) - } - rv = rv.Elem() - } - v = rv.Interface() - } - return -} - -func (f decFnInfo) selferUnmarshal(rv reflect.Value) { - f.getValueForUnmarshalInterface(rv, f.ti.csIndir).(Selfer).CodecDecodeSelf(f.d) -} - -func (f decFnInfo) binaryUnmarshal(rv reflect.Value) { - bm := f.getValueForUnmarshalInterface(rv, f.ti.bunmIndir).(encoding.BinaryUnmarshaler) - xbs := f.dd.DecodeBytes(nil, false, true) - if fnerr := bm.UnmarshalBinary(xbs); fnerr != nil { - panic(fnerr) - } -} - -func (f decFnInfo) textUnmarshal(rv reflect.Value) { - tm := f.getValueForUnmarshalInterface(rv, f.ti.tunmIndir).(encoding.TextUnmarshaler) - fnerr := tm.UnmarshalText(f.dd.DecodeBytes(f.d.b[:], true, true)) - // fnerr := tm.UnmarshalText(f.dd.DecodeStringAsBytes(f.d.b[:])) - - // var fnerr error - // if sb, sbok := f.dd.(decDriverStringAsBytes); sbok { - // fnerr = tm.UnmarshalText(sb.decStringAsBytes(f.d.b[:0])) - // } else { - // fnerr = tm.UnmarshalText([]byte(f.dd.decodeString())) - // } - if fnerr != nil { - panic(fnerr) - } -} - -func (f decFnInfo) kErr(rv reflect.Value) { - f.d.errorf("no decoding function defined for kind %v", rv.Kind()) -} - -func (f decFnInfo) kString(rv reflect.Value) { - rv.SetString(f.dd.DecodeString()) -} - -func (f decFnInfo) kBool(rv reflect.Value) { - rv.SetBool(f.dd.DecodeBool()) -} - -func (f decFnInfo) kInt(rv reflect.Value) { - rv.SetInt(f.dd.DecodeInt(intBitsize)) -} - -func (f decFnInfo) kInt64(rv reflect.Value) { - rv.SetInt(f.dd.DecodeInt(64)) -} - -func (f decFnInfo) kInt32(rv reflect.Value) { - rv.SetInt(f.dd.DecodeInt(32)) -} - -func (f decFnInfo) kInt8(rv reflect.Value) { - rv.SetInt(f.dd.DecodeInt(8)) -} - -func (f decFnInfo) kInt16(rv reflect.Value) { - rv.SetInt(f.dd.DecodeInt(16)) -} - -func (f decFnInfo) kFloat32(rv reflect.Value) { - rv.SetFloat(f.dd.DecodeFloat(true)) -} - -func (f decFnInfo) kFloat64(rv reflect.Value) { - rv.SetFloat(f.dd.DecodeFloat(false)) -} - -func (f decFnInfo) kUint8(rv reflect.Value) { - rv.SetUint(f.dd.DecodeUint(8)) -} - -func (f decFnInfo) kUint64(rv reflect.Value) { - rv.SetUint(f.dd.DecodeUint(64)) -} - -func (f decFnInfo) kUint(rv reflect.Value) { - rv.SetUint(f.dd.DecodeUint(uintBitsize)) -} - -func (f decFnInfo) kUint32(rv reflect.Value) { - rv.SetUint(f.dd.DecodeUint(32)) -} - -func (f decFnInfo) kUint16(rv reflect.Value) { - rv.SetUint(f.dd.DecodeUint(16)) -} - -// func (f decFnInfo) kPtr(rv reflect.Value) { -// debugf(">>>>>>> ??? decode kPtr called - shouldn't get called") -// if rv.IsNil() { -// rv.Set(reflect.New(rv.Type().Elem())) -// } -// f.d.decodeValue(rv.Elem()) -// } - -// var kIntfCtr uint64 - -func (f decFnInfo) kInterfaceNaked() (rvn reflect.Value) { - // nil interface: - // use some hieristics to decode it appropriately - // based on the detected next value in the stream. - v, vt, decodeFurther := f.dd.DecodeNaked() - if vt == valueTypeNil { - return - } - // We cannot decode non-nil stream value into nil interface with methods (e.g. io.Reader). - if num := f.ti.rt.NumMethod(); num > 0 { - f.d.errorf("cannot decode non-nil codec value into nil %v (%v methods)", f.ti.rt, num) - return - } - var useRvn bool - switch vt { - case valueTypeMap: - if f.d.h.MapType == nil { - var m2 map[interface{}]interface{} - v = &m2 - } else { - rvn = reflect.New(f.d.h.MapType).Elem() - useRvn = true - } - case valueTypeArray: - if f.d.h.SliceType == nil { - var m2 []interface{} - v = &m2 - } else { - rvn = reflect.New(f.d.h.SliceType).Elem() - useRvn = true - } - case valueTypeExt: - re := v.(*RawExt) - bfn := f.d.h.getExtForTag(re.Tag) - if bfn == nil { - re.Data = detachZeroCopyBytes(f.d.bytes, nil, re.Data) - rvn = reflect.ValueOf(*re) - } else { - rvnA := reflect.New(bfn.rt) - rvn = rvnA.Elem() - if re.Data != nil { - bfn.ext.ReadExt(rvnA.Interface(), re.Data) - } else { - bfn.ext.UpdateExt(rvnA.Interface(), re.Value) - } - } - return - } - if decodeFurther { - if useRvn { - f.d.decodeValue(rvn, decFn{}) - } else if v != nil { - // this v is a pointer, so we need to dereference it when done - f.d.decode(v) - rvn = reflect.ValueOf(v).Elem() - useRvn = true - } - } - - if !useRvn && v != nil { - rvn = reflect.ValueOf(v) - } - return -} - -func (f decFnInfo) kInterface(rv reflect.Value) { - // debugf("\t===> kInterface") - - // Note: - // A consequence of how kInterface works, is that - // if an interface already contains something, we try - // to decode into what was there before. - // We do not replace with a generic value (as got from decodeNaked). - - if rv.IsNil() { - rvn := f.kInterfaceNaked() - if rvn.IsValid() { - rv.Set(rvn) - } - } else { - rve := rv.Elem() - // Note: interface{} is settable, but underlying type may not be. - // Consequently, we have to set the reflect.Value directly. - // if underlying type is settable (e.g. ptr or interface), - // we just decode into it. - // Else we create a settable value, decode into it, and set on the interface. - if rve.CanSet() { - f.d.decodeValue(rve, decFn{}) - } else { - rve2 := reflect.New(rve.Type()).Elem() - rve2.Set(rve) - f.d.decodeValue(rve2, decFn{}) - rv.Set(rve2) - } - } -} - -func (f decFnInfo) kStruct(rv reflect.Value) { - fti := f.ti - d := f.d - if f.dd.IsContainerType(valueTypeMap) { - containerLen := f.dd.ReadMapStart() - if containerLen == 0 { - f.dd.ReadMapEnd() - return - } - tisfi := fti.sfi - hasLen := containerLen >= 0 - if hasLen { - for j := 0; j < containerLen; j++ { - // rvkencname := f.dd.DecodeString() - rvkencname := stringView(f.dd.DecodeBytes(f.d.b[:], true, true)) - // rvksi := ti.getForEncName(rvkencname) - if k := fti.indexForEncName(rvkencname); k > -1 { - si := tisfi[k] - if f.dd.TryDecodeAsNil() { - si.setToZeroValue(rv) - } else { - d.decodeValue(si.field(rv, true), decFn{}) - } - } else { - d.structFieldNotFound(-1, rvkencname) - } - } - } else { - for j := 0; !f.dd.CheckBreak(); j++ { - if j > 0 { - f.dd.ReadMapEntrySeparator() - } - // rvkencname := f.dd.DecodeString() - rvkencname := stringView(f.dd.DecodeBytes(f.d.b[:], true, true)) - f.dd.ReadMapKVSeparator() - // rvksi := ti.getForEncName(rvkencname) - if k := fti.indexForEncName(rvkencname); k > -1 { - si := tisfi[k] - if f.dd.TryDecodeAsNil() { - si.setToZeroValue(rv) - } else { - d.decodeValue(si.field(rv, true), decFn{}) - } - } else { - d.structFieldNotFound(-1, rvkencname) - } - } - f.dd.ReadMapEnd() - } - } else if f.dd.IsContainerType(valueTypeArray) { - containerLen := f.dd.ReadArrayStart() - if containerLen == 0 { - f.dd.ReadArrayEnd() - return - } - // Not much gain from doing it two ways for array. - // Arrays are not used as much for structs. - hasLen := containerLen >= 0 - for j, si := range fti.sfip { - if hasLen { - if j == containerLen { - break - } - } else if f.dd.CheckBreak() { - break - } - if j > 0 { - f.dd.ReadArrayEntrySeparator() - } - if f.dd.TryDecodeAsNil() { - si.setToZeroValue(rv) - } else { - d.decodeValue(si.field(rv, true), decFn{}) - } - // if si.i != -1 { - // d.decodeValue(rv.Field(int(si.i)), decFn{}) - // } else { - // d.decEmbeddedField(rv, si.is) - // } - } - if containerLen > len(fti.sfip) { - // read remaining values and throw away - for j := len(fti.sfip); j < containerLen; j++ { - if j > 0 { - f.dd.ReadArrayEntrySeparator() - } - d.structFieldNotFound(j, "") - } - } - f.dd.ReadArrayEnd() - } else { - f.d.error(onlyMapOrArrayCanDecodeIntoStructErr) - return - } -} - -func (f decFnInfo) kSlice(rv reflect.Value) { - // A slice can be set from a map or array in stream. - // This way, the order can be kept (as order is lost with map). - ti := f.ti - d := f.d - if f.dd.IsContainerType(valueTypeBytes) || f.dd.IsContainerType(valueTypeString) { - if ti.rtid == uint8SliceTypId || ti.rt.Elem().Kind() == reflect.Uint8 { - if f.seq == seqTypeChan { - bs2 := f.dd.DecodeBytes(nil, false, true) - ch := rv.Interface().(chan<- byte) - for _, b := range bs2 { - ch <- b - } - } else { - rvbs := rv.Bytes() - bs2 := f.dd.DecodeBytes(rvbs, false, false) - if rvbs == nil && bs2 != nil || rvbs != nil && bs2 == nil || len(bs2) != len(rvbs) { - if rv.CanSet() { - rv.SetBytes(bs2) - } else { - copy(rvbs, bs2) - } - } - } - return - } - } - - // array := f.seq == seqTypeChan - - slh, containerLenS := d.decSliceHelperStart() - - // an array can never return a nil slice. so no need to check f.array here. - if rv.IsNil() { - // either chan or slice - if f.seq == seqTypeSlice { - if containerLenS <= 0 { - rv.Set(reflect.MakeSlice(ti.rt, 0, 0)) - } else { - rv.Set(reflect.MakeSlice(ti.rt, containerLenS, containerLenS)) - } - } else if f.seq == seqTypeChan { - if containerLenS <= 0 { - rv.Set(reflect.MakeChan(ti.rt, 0)) - } else { - rv.Set(reflect.MakeChan(ti.rt, containerLenS)) - } - } - } - - rvlen := rv.Len() - if containerLenS == 0 { - if f.seq == seqTypeSlice && rvlen != 0 { - rv.SetLen(0) - } - // slh.End() // f.dd.ReadArrayEnd() - return - } - - rtelem0 := ti.rt.Elem() - rtelem := rtelem0 - for rtelem.Kind() == reflect.Ptr { - rtelem = rtelem.Elem() - } - fn := d.getDecFn(rtelem, true, true) - - rv0 := rv - rvChanged := false - - rvcap := rv.Cap() - - // for j := 0; j < containerLenS; j++ { - - hasLen := containerLenS >= 0 - if hasLen { - if f.seq == seqTypeChan { - // handle chan specially: - for j := 0; j < containerLenS; j++ { - rv0 := reflect.New(rtelem0).Elem() - d.decodeValue(rv0, fn) - rv.Send(rv0) - } - } else { - numToRead := containerLenS - if containerLenS > rvcap { - if f.seq == seqTypeArray { - d.arrayCannotExpand(rv.Len(), containerLenS) - numToRead = rvlen - } else { - rv = reflect.MakeSlice(ti.rt, containerLenS, containerLenS) - if rvlen > 0 && !isMutableKind(ti.rt.Kind()) { - rv1 := rv0 - rv1.SetLen(rvcap) - reflect.Copy(rv, rv1) - } - rvChanged = true - rvlen = containerLenS - } - } else if containerLenS != rvlen { - if f.seq == seqTypeSlice { - rv.SetLen(containerLenS) - rvlen = containerLenS - } - } - j := 0 - for ; j < numToRead; j++ { - d.decodeValue(rv.Index(j), fn) - } - if f.seq == seqTypeArray { - for ; j < containerLenS; j++ { - d.swallow() - } - } - } - } else { - for j := 0; !f.dd.CheckBreak(); j++ { - var decodeIntoBlank bool - // if indefinite, etc, then expand the slice if necessary - 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)) - rvlen++ - rvChanged = true - } - } - if j > 0 { - slh.Sep(j) - } - if f.seq == seqTypeChan { - rv0 := reflect.New(rtelem0).Elem() - d.decodeValue(rv0, fn) - rv.Send(rv0) - } else if decodeIntoBlank { - d.swallow() - } else { - d.decodeValue(rv.Index(j), fn) - } - } - slh.End() - } - - if rvChanged { - rv0.Set(rv) - } -} - -func (f decFnInfo) kArray(rv reflect.Value) { - // f.d.decodeValue(rv.Slice(0, rv.Len())) - f.kSlice(rv.Slice(0, rv.Len())) -} - -func (f decFnInfo) kMap(rv reflect.Value) { - containerLen := f.dd.ReadMapStart() - - ti := f.ti - if rv.IsNil() { - rv.Set(reflect.MakeMap(ti.rt)) - } - - if containerLen == 0 { - // f.dd.ReadMapEnd() - return - } - - d := f.d - - ktype, vtype := ti.rt.Key(), ti.rt.Elem() - ktypeId := reflect.ValueOf(ktype).Pointer() - var keyFn, valFn decFn - var xtyp reflect.Type - for xtyp = ktype; xtyp.Kind() == reflect.Ptr; xtyp = xtyp.Elem() { - } - keyFn = d.getDecFn(xtyp, true, true) - for xtyp = vtype; xtyp.Kind() == reflect.Ptr; xtyp = xtyp.Elem() { - } - valFn = d.getDecFn(xtyp, true, true) - // for j := 0; j < containerLen; j++ { - if containerLen > 0 { - for j := 0; j < containerLen; j++ { - rvk := reflect.New(ktype).Elem() - d.decodeValue(rvk, keyFn) - - // special case if a byte array. - if ktypeId == intfTypId { - rvk = rvk.Elem() - if rvk.Type() == uint8SliceTyp { - rvk = reflect.ValueOf(string(rvk.Bytes())) - } - } - rvv := rv.MapIndex(rvk) - // TODO: is !IsValid check required? - if !rvv.IsValid() { - rvv = reflect.New(vtype).Elem() - } - d.decodeValue(rvv, valFn) - rv.SetMapIndex(rvk, rvv) - } - } else { - for j := 0; !f.dd.CheckBreak(); j++ { - if j > 0 { - f.dd.ReadMapEntrySeparator() - } - rvk := reflect.New(ktype).Elem() - d.decodeValue(rvk, keyFn) - - // special case if a byte array. - if ktypeId == intfTypId { - rvk = rvk.Elem() - if rvk.Type() == uint8SliceTyp { - rvk = reflect.ValueOf(string(rvk.Bytes())) - } - } - rvv := rv.MapIndex(rvk) - if !rvv.IsValid() { - rvv = reflect.New(vtype).Elem() - } - f.dd.ReadMapKVSeparator() - d.decodeValue(rvv, valFn) - rv.SetMapIndex(rvk, rvv) - } - f.dd.ReadMapEnd() - } -} - -type rtidDecFn struct { - rtid uintptr - fn decFn -} - -// A Decoder reads and decodes an object from an input stream in the codec format. -type Decoder struct { - // hopefully, reduce derefencing cost by laying the decReader inside the Decoder. - // Try to put things that go together to fit within a cache line (8 words). - - d decDriver - r decReader - //sa [32]rtidDecFn - s []rtidDecFn - h *BasicHandle - - rb bytesDecReader - hh Handle - be bool // is binary encoding - bytes bool // is bytes reader - - ri ioDecReader - f map[uintptr]decFn - _ uintptr // for alignment purposes, so next one starts from a cache line - - b [scratchByteArrayLen]byte -} - -// NewDecoder returns a Decoder for decoding a stream of bytes from an io.Reader. -// -// For efficiency, Users are encouraged to pass in a memory buffered reader -// (eg bufio.Reader, bytes.Buffer). -func NewDecoder(r io.Reader, h Handle) (d *Decoder) { - d = &Decoder{hh: h, h: h.getBasicHandle(), be: h.isBinary()} - //d.s = d.sa[:0] - d.ri.x = &d.b - d.ri.bs.r = r - var ok bool - d.ri.br, ok = r.(decReaderByteScanner) - if !ok { - d.ri.br = &d.ri.bs - } - d.r = &d.ri - d.d = h.newDecDriver(d) - return -} - -// NewDecoderBytes returns a Decoder which efficiently decodes directly -// from a byte slice with zero copying. -func NewDecoderBytes(in []byte, h Handle) (d *Decoder) { - d = &Decoder{hh: h, h: h.getBasicHandle(), be: h.isBinary(), bytes: true} - //d.s = d.sa[:0] - d.rb.b = in - d.rb.a = len(in) - d.r = &d.rb - d.d = h.newDecDriver(d) - // d.d = h.newDecDriver(decReaderT{true, &d.rb, &d.ri}) - return -} - -// Decode decodes the stream from reader and stores the result in the -// value pointed to by v. v cannot be a nil pointer. v can also be -// a reflect.Value of a pointer. -// -// Note that a pointer to a nil interface is not a nil pointer. -// If you do not know what type of stream it is, pass in a pointer to a nil interface. -// We will decode and store a value in that nil interface. -// -// Sample usages: -// // Decoding into a non-nil typed value -// var f float32 -// err = codec.NewDecoder(r, handle).Decode(&f) -// -// // Decoding into nil interface -// var v interface{} -// dec := codec.NewDecoder(r, handle) -// err = dec.Decode(&v) -// -// When decoding into a nil interface{}, we will decode into an appropriate value based -// on the contents of the stream: -// - Numbers are decoded as float64, int64 or uint64. -// - Other values are decoded appropriately depending on the type: -// bool, string, []byte, time.Time, etc -// - Extensions are decoded as RawExt (if no ext function registered for the tag) -// Configurations exist on the Handle to override defaults -// (e.g. for MapType, SliceType and how to decode raw bytes). -// -// When decoding into a non-nil interface{} value, the mode of encoding is based on the -// type of the value. When a value is seen: -// - If an extension is registered for it, call that extension function -// - If it implements BinaryUnmarshaler, call its UnmarshalBinary(data []byte) error -// - Else decode it based on its reflect.Kind -// -// There are some special rules when decoding into containers (slice/array/map/struct). -// Decode will typically use the stream contents to UPDATE the container. -// - A map can be decoded from a stream map, by updating matching keys. -// - A slice can be decoded from a stream array, -// by updating the first n elements, where n is length of the stream. -// - A slice can be decoded from a stream map, by decoding as if -// it contains a sequence of key-value pairs. -// - A struct can be decoded from a stream map, by updating matching fields. -// - A struct can be decoded from a stream array, -// by updating fields as they occur in the struct (by index). -// -// When decoding a stream map or array with length of 0 into a nil map or slice, -// we reset the destination map or slice to a zero-length value. -// -// However, when decoding a stream nil, we reset the destination container -// to its "zero" value (e.g. nil for slice/map, etc). -// -func (d *Decoder) Decode(v interface{}) (err error) { - defer panicToErr(&err) - d.decode(v) - return -} - -// this is not a smart swallow, as it allocates objects and does unnecessary work. -func (d *Decoder) swallowViaHammer() { - var blank interface{} - d.decodeValue(reflect.ValueOf(&blank).Elem(), decFn{}) -} - -func (d *Decoder) swallow() { - // smarter decode that just swallows the content - dd := d.d - switch { - case dd.TryDecodeAsNil(): - case dd.IsContainerType(valueTypeMap): - containerLen := dd.ReadMapStart() - clenGtEqualZero := containerLen >= 0 - for j := 0; ; j++ { - if clenGtEqualZero { - if j >= containerLen { - break - } - } else if dd.CheckBreak() { - break - } - if j > 0 { - dd.ReadMapEntrySeparator() - } - d.swallow() - dd.ReadMapKVSeparator() - d.swallow() - } - dd.ReadMapEnd() - case dd.IsContainerType(valueTypeArray): - containerLenS := dd.ReadArrayStart() - clenGtEqualZero := containerLenS >= 0 - for j := 0; ; j++ { - if clenGtEqualZero { - if j >= containerLenS { - break - } - } else if dd.CheckBreak() { - break - } - if j > 0 { - dd.ReadArrayEntrySeparator() - } - d.swallow() - } - dd.ReadArrayEnd() - case dd.IsContainerType(valueTypeBytes): - dd.DecodeBytes(d.b[:], false, true) - case dd.IsContainerType(valueTypeString): - dd.DecodeBytes(d.b[:], true, true) - // dd.DecodeStringAsBytes(d.b[:]) - default: - // these are all primitives, which we can get from decodeNaked - dd.DecodeNaked() - } -} - -// 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{}) { - d.decode(v) -} - -func (d *Decoder) decode(iv interface{}) { - // if ics, ok := iv.(Selfer); ok { - // ics.CodecDecodeSelf(d) - // return - // } - - if d.d.TryDecodeAsNil() { - switch v := iv.(type) { - case nil: - case *string: - *v = "" - case *bool: - *v = false - case *int: - *v = 0 - case *int8: - *v = 0 - case *int16: - *v = 0 - case *int32: - *v = 0 - case *int64: - *v = 0 - case *uint: - *v = 0 - case *uint8: - *v = 0 - case *uint16: - *v = 0 - case *uint32: - *v = 0 - case *uint64: - *v = 0 - case *float32: - *v = 0 - case *float64: - *v = 0 - case *[]uint8: - *v = nil - case reflect.Value: - d.chkPtrValue(v) - v = v.Elem() - if v.IsValid() { - v.Set(reflect.Zero(v.Type())) - } - default: - rv := reflect.ValueOf(iv) - d.chkPtrValue(rv) - rv = rv.Elem() - if rv.IsValid() { - rv.Set(reflect.Zero(rv.Type())) - } - } - return - } - - switch v := iv.(type) { - case nil: - d.error(cannotDecodeIntoNilErr) - return - - case Selfer: - v.CodecDecodeSelf(d) - - case reflect.Value: - d.chkPtrValue(v) - d.decodeValueNotNil(v.Elem(), decFn{}) - - case *string: - - *v = d.d.DecodeString() - case *bool: - *v = d.d.DecodeBool() - case *int: - *v = int(d.d.DecodeInt(intBitsize)) - case *int8: - *v = int8(d.d.DecodeInt(8)) - case *int16: - *v = int16(d.d.DecodeInt(16)) - case *int32: - *v = int32(d.d.DecodeInt(32)) - case *int64: - *v = d.d.DecodeInt(64) - case *uint: - *v = uint(d.d.DecodeUint(uintBitsize)) - case *uint8: - *v = uint8(d.d.DecodeUint(8)) - case *uint16: - *v = uint16(d.d.DecodeUint(16)) - case *uint32: - *v = uint32(d.d.DecodeUint(32)) - case *uint64: - *v = d.d.DecodeUint(64) - case *float32: - *v = float32(d.d.DecodeFloat(true)) - case *float64: - *v = d.d.DecodeFloat(false) - case *[]uint8: - *v = d.d.DecodeBytes(*v, false, false) - - case *interface{}: - d.decodeValueNotNil(reflect.ValueOf(iv).Elem(), decFn{}) - - default: - if !fastpathDecodeTypeSwitch(iv, d) { - d.decodeI(iv, true, false, false, false) - } - } -} - -func (d *Decoder) preDecodeValue(rv reflect.Value, tryNil bool) (rv2 reflect.Value, proceed bool) { - if tryNil && d.d.TryDecodeAsNil() { - // No need to check if a ptr, recursively, to determine - // whether to set value to nil. - // Just always set value to its zero type. - if rv.IsValid() { // rv.CanSet() // always settable, except it's invalid - rv.Set(reflect.Zero(rv.Type())) - } - return - } - - // If stream is not containing a nil value, then we can deref to the base - // non-pointer value, and decode into that. - for rv.Kind() == reflect.Ptr { - if rv.IsNil() { - rv.Set(reflect.New(rv.Type().Elem())) - } - rv = rv.Elem() - } - return rv, true -} - -func (d *Decoder) decodeI(iv interface{}, checkPtr, tryNil, checkFastpath, checkCodecSelfer bool) { - rv := reflect.ValueOf(iv) - if checkPtr { - d.chkPtrValue(rv) - } - rv, proceed := d.preDecodeValue(rv, tryNil) - if proceed { - fn := d.getDecFn(rv.Type(), checkFastpath, checkCodecSelfer) - fn.f(fn.i, rv) - } -} - -func (d *Decoder) decodeValue(rv reflect.Value, fn decFn) { - if rv, proceed := d.preDecodeValue(rv, true); proceed { - if fn.f == nil { - fn = d.getDecFn(rv.Type(), true, true) - } - fn.f(fn.i, rv) - } -} - -func (d *Decoder) decodeValueNotNil(rv reflect.Value, fn decFn) { - if rv, proceed := d.preDecodeValue(rv, false); proceed { - if fn.f == nil { - fn = d.getDecFn(rv.Type(), true, true) - } - fn.f(fn.i, rv) - } -} - -func (d *Decoder) getDecFn(rt reflect.Type, checkFastpath, checkCodecSelfer bool) (fn decFn) { - rtid := reflect.ValueOf(rt).Pointer() - - // retrieve or register a focus'ed function for this type - // to eliminate need to do the retrieval multiple times - - // if d.f == nil && d.s == nil { debugf("---->Creating new dec f map for type: %v\n", rt) } - var ok bool - if useMapForCodecCache { - fn, ok = d.f[rtid] - } else { - for _, v := range d.s { - if v.rtid == rtid { - fn, ok = v.fn, true - break - } - } - } - if ok { - return - } - - // debugf("\tCreating new dec fn for type: %v\n", rt) - ti := getTypeInfo(rtid, rt) - var fi decFnInfo - fi.dd = d.d - // fi.decFnInfoX = new(decFnInfoX) - - // An extension can be registered for any type, regardless of the Kind - // (e.g. type BitSet int64, type MyStruct { / * unexported fields * / }, type X []int, etc. - // - // We can't check if it's an extension byte here first, because the user may have - // registered a pointer or non-pointer type, meaning we may have to recurse first - // before matching a mapped type, even though the extension byte is already detected. - // - // NOTE: if decoding into a nil interface{}, we return a non-nil - // value except even if the container registers a length of 0. - if checkCodecSelfer && ti.cs { - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti} - fn.f = (decFnInfo).selferUnmarshal - } else if rtid == rawExtTypId { - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti} - fn.f = (decFnInfo).rawExt - } else if d.d.IsBuiltinType(rtid) { - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti} - fn.f = (decFnInfo).builtin - } else if xfFn := d.h.getExt(rtid); xfFn != nil { - // fi.decFnInfoX = &decFnInfoX{xfTag: xfFn.tag, xfFn: xfFn.ext} - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti} - fi.xfTag, fi.xfFn = xfFn.tag, xfFn.ext - fn.f = (decFnInfo).ext - } else if supportMarshalInterfaces && d.be && ti.bunm { - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti} - fn.f = (decFnInfo).binaryUnmarshal - } else if supportMarshalInterfaces && !d.be && ti.tunm { - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti} - fn.f = (decFnInfo).textUnmarshal - } else { - rk := rt.Kind() - if fastpathEnabled && checkFastpath && (rk == reflect.Map || rk == reflect.Slice) { - if rt.PkgPath() == "" { - if idx := fastpathAV.index(rtid); idx != -1 { - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti} - fn.f = fastpathAV[idx].decfn - } - } else { - // use mapping for underlying type if there - ok = false - var rtu reflect.Type - if rk == reflect.Map { - rtu = reflect.MapOf(rt.Key(), rt.Elem()) - } else { - rtu = reflect.SliceOf(rt.Elem()) - } - rtuid := reflect.ValueOf(rtu).Pointer() - if idx := fastpathAV.index(rtuid); idx != -1 { - xfnf := fastpathAV[idx].decfn - xrt := fastpathAV[idx].rt - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti} - fn.f = func(xf decFnInfo, xrv reflect.Value) { - // xfnf(xf, xrv.Convert(xrt)) - xfnf(xf, xrv.Addr().Convert(reflect.PtrTo(xrt)).Elem()) - } - } - } - } - if fn.f == nil { - switch rk { - case reflect.String: - fn.f = (decFnInfo).kString - case reflect.Bool: - fn.f = (decFnInfo).kBool - case reflect.Int: - fn.f = (decFnInfo).kInt - case reflect.Int64: - fn.f = (decFnInfo).kInt64 - case reflect.Int32: - fn.f = (decFnInfo).kInt32 - case reflect.Int8: - fn.f = (decFnInfo).kInt8 - case reflect.Int16: - fn.f = (decFnInfo).kInt16 - case reflect.Float32: - fn.f = (decFnInfo).kFloat32 - case reflect.Float64: - fn.f = (decFnInfo).kFloat64 - case reflect.Uint8: - fn.f = (decFnInfo).kUint8 - case reflect.Uint64: - fn.f = (decFnInfo).kUint64 - case reflect.Uint: - fn.f = (decFnInfo).kUint - case reflect.Uint32: - fn.f = (decFnInfo).kUint32 - case reflect.Uint16: - fn.f = (decFnInfo).kUint16 - // case reflect.Ptr: - // fn.f = (decFnInfo).kPtr - case reflect.Interface: - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti} - fn.f = (decFnInfo).kInterface - case reflect.Struct: - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti} - fn.f = (decFnInfo).kStruct - case reflect.Chan: - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti, seq: seqTypeChan} - fn.f = (decFnInfo).kSlice - case reflect.Slice: - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti, seq: seqTypeSlice} - fn.f = (decFnInfo).kSlice - case reflect.Array: - // fi.decFnInfoX = &decFnInfoX{array: true} - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti, seq: seqTypeArray} - fn.f = (decFnInfo).kArray - case reflect.Map: - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti} - fn.f = (decFnInfo).kMap - default: - fn.f = (decFnInfo).kErr - } - } - } - fn.i = fi - - if useMapForCodecCache { - if d.f == nil { - d.f = make(map[uintptr]decFn, 32) - } - d.f[rtid] = fn - } else { - if d.s == nil { - d.s = make([]rtidDecFn, 0, 32) - } - d.s = append(d.s, rtidDecFn{rtid, fn}) - } - return -} - -func (d *Decoder) structFieldNotFound(index int, rvkencname string) { - if d.h.ErrorIfNoField { - if index >= 0 { - d.errorf("no matching struct field found when decoding stream array at index %v", index) - return - } else if rvkencname != "" { - d.errorf("no matching struct field found when decoding stream map with key %s", rvkencname) - return - } - } - d.swallow() -} - -func (d *Decoder) arrayCannotExpand(sliceLen, streamLen int) { - if d.h.ErrorIfNoArrayExpand { - d.errorf("cannot expand array len during decode from %v to %v", sliceLen, streamLen) - } -} - -func (d *Decoder) chkPtrValue(rv reflect.Value) { - // We can only decode into a non-nil pointer - if rv.Kind() == reflect.Ptr && !rv.IsNil() { - return - } - if !rv.IsValid() { - d.error(cannotDecodeIntoNilErr) - return - } - if !rv.CanInterface() { - d.errorf("cannot decode into a value without an interface: %v", rv) - return - } - rvi := rv.Interface() - d.errorf("cannot decode into non-pointer or nil pointer. Got: %v, %T, %v", rv.Kind(), rvi, rvi) -} - -func (d *Decoder) error(err error) { - panic(err) -} - -func (d *Decoder) errorf(format string, params ...interface{}) { - err := fmt.Errorf(format, params...) - panic(err) -} - -// -------------------------------------------------- - -// 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. -type decSliceHelper struct { - dd decDriver - ct valueType -} - -func (d *Decoder) decSliceHelperStart() (x decSliceHelper, clen int) { - x.dd = d.d - if x.dd.IsContainerType(valueTypeArray) { - x.ct = valueTypeArray - clen = x.dd.ReadArrayStart() - } else if x.dd.IsContainerType(valueTypeMap) { - x.ct = valueTypeMap - clen = x.dd.ReadMapStart() * 2 - } else { - d.errorf("only encoded map or array can be decoded into a slice") - } - return -} - -func (x decSliceHelper) Sep(index int) { - if x.ct == valueTypeArray { - x.dd.ReadArrayEntrySeparator() - } else { - if index%2 == 0 { - x.dd.ReadMapEntrySeparator() - } else { - x.dd.ReadMapKVSeparator() - } - } -} - -func (x decSliceHelper) End() { - if x.ct == valueTypeArray { - x.dd.ReadArrayEnd() - } else { - x.dd.ReadMapEnd() - } -} - -// func decErr(format string, params ...interface{}) { -// doPanic(msgTagDec, format, params...) -// } - -func decByteSlice(r decReader, clen int, bs []byte) (bsOut []byte) { - if clen == 0 { - return zeroByteSlice - } - if len(bs) == clen { - bsOut = bs - } else if cap(bs) >= clen { - bsOut = bs[:clen] - } else { - bsOut = make([]byte, clen) - } - r.readb(bsOut) - return -} - -func detachZeroCopyBytes(isBytesReader bool, dest []byte, in []byte) (out []byte) { - 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 - } - } - return in -} - -// // implement overall decReader wrapping both, for possible use inline: -// type decReaderT struct { -// bytes bool -// rb *bytesDecReader -// ri *ioDecReader -// } -// -// // implement *Decoder as a decReader. -// // Using decReaderT (defined just above) caused performance degradation -// // possibly because of constant copying the value, -// // and some value->interface conversion causing allocation. -// func (d *Decoder) unreadn1() { -// if d.bytes { -// d.rb.unreadn1() -// } else { -// d.ri.unreadn1() -// } -// } - -// func (d *Decoder) readb(b []byte) { -// if d.bytes { -// d.rb.readb(b) -// } else { -// d.ri.readb(b) -// } -// } - -// func (d *Decoder) readx(n int) []byte { -// if d.bytes { -// return d.rb.readx(n) -// } else { -// return d.ri.readx(n) -// } -// } - -// func (d *Decoder) readn1() uint8 { -// if d.bytes { -// return d.rb.readn1() -// } else { -// return d.ri.readn1() -// } -// } - -// func (d *Decoder) readn1eof() (v uint8, eof bool) { -// if d.bytes { -// return d.rb.readn1eof() -// } else { -// return d.ri.readn1eof() -// } -// } - -// var _ decReader = (*Decoder)(nil) // decReaderT{} // diff --git a/cmd/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl b/cmd/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl deleted file mode 100644 index 9f0adcc..0000000 --- a/cmd/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl +++ /dev/null @@ -1,442 +0,0 @@ -// //+build ignore - -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// ************************************************************ -// DO NOT EDIT. -// THIS FILE IS AUTO-GENERATED from fast-path.go.tmpl -// ************************************************************ - -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 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. -// -// The advantage of fast paths is: -// - Many calls bypass reflection altogether -// -// Currently support -// - slice of all builtin types, -// - map of all builtin types to string or interface value -// - symetrical maps of all builtin types (e.g. str-str, uint8-uint8) -// This should provide adequate "typical" implementations. -// -// Note that fast track decode functions must handle values for which an address cannot be obtained. -// For example: -// m2 := map[string]int{} -// p2 := []interface{}{m2} -// // decoding into p2 will bomb if fast track functions do not treat like unaddressable. -// - -import ( - "reflect" - "sort" -) - -const fastpathCheckNilFalse = false // for reflect -const fastpathCheckNilTrue = true // for type switch - -type fastpathT struct {} - -var fastpathTV fastpathT - -type fastpathE struct { - rtid uintptr - rt reflect.Type - encfn func(encFnInfo, reflect.Value) - decfn func(decFnInfo, reflect.Value) -} - -type fastpathA [{{ .FastpathLen }}]fastpathE - -func (x *fastpathA) index(rtid uintptr) int { - // use binary search to grab the index (adapted from sort/search.go) - h, i, j := 0, 0, {{ .FastpathLen }} // len(x) - for i < j { - h = i + (j-i)/2 - if x[h].rtid < rtid { - i = h + 1 - } else { - j = h - } - } - if i < {{ .FastpathLen }} && x[i].rtid == rtid { - return i - } - return -1 -} - -type fastpathAslice []fastpathE - -func (x fastpathAslice) Len() int { return len(x) } -func (x fastpathAslice) Less(i, j int) bool { return x[i].rtid < x[j].rtid } -func (x fastpathAslice) Swap(i, j int) { x[i], x[j] = x[j], x[i] } - -var fastpathAV fastpathA - -// due to possible initialization loop error, make fastpath in an init() -func init() { - if !fastpathEnabled { - return - } - i := 0 - fn := func(v interface{}, fe func(encFnInfo, reflect.Value), fd func(decFnInfo, reflect.Value)) (f fastpathE) { - xrt := reflect.TypeOf(v) - xptr := reflect.ValueOf(xrt).Pointer() - fastpathAV[i] = fastpathE{xptr, xrt, fe, fd} - i++ - return - } - - {{range .Values}}{{if not .Primitive}}{{if .Slice }} - fn([]{{ .Elem }}(nil), (encFnInfo).{{ .MethodNamePfx "fastpathEnc" false }}R, (decFnInfo).{{ .MethodNamePfx "fastpathDec" false }}R){{end}}{{end}}{{end}} - - {{range .Values}}{{if not .Primitive}}{{if not .Slice }} - fn(map[{{ .MapKey }}]{{ .Elem }}(nil), (encFnInfo).{{ .MethodNamePfx "fastpathEnc" false }}R, (decFnInfo).{{ .MethodNamePfx "fastpathDec" false }}R){{end}}{{end}}{{end}} - - sort.Sort(fastpathAslice(fastpathAV[:])) -} - -// -- encode - -// -- -- fast path type switch -func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { - switch v := iv.(type) { -{{range .Values}}{{if not .Primitive}}{{if .Slice }} - case []{{ .Elem }}:{{else}} - case map[{{ .MapKey }}]{{ .Elem }}:{{end}} - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, fastpathCheckNilTrue, e){{if .Slice }} - case *[]{{ .Elem }}:{{else}} - case *map[{{ .MapKey }}]{{ .Elem }}:{{end}} - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, fastpathCheckNilTrue, e) -{{end}}{{end}} - default: - return false - } - return true -} - -func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { - switch v := iv.(type) { -{{range .Values}}{{if not .Primitive}}{{if .Slice }} - case []{{ .Elem }}: - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, fastpathCheckNilTrue, e) - case *[]{{ .Elem }}: - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, fastpathCheckNilTrue, e) -{{end}}{{end}}{{end}} - default: - return false - } - return true -} - -func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { - switch v := iv.(type) { -{{range .Values}}{{if not .Primitive}}{{if not .Slice }} - case map[{{ .MapKey }}]{{ .Elem }}: - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, fastpathCheckNilTrue, e) - case *map[{{ .MapKey }}]{{ .Elem }}: - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, fastpathCheckNilTrue, e) -{{end}}{{end}}{{end}} - default: - return false - } - return true -} - -// -- -- fast path functions -{{range .Values}}{{if not .Primitive}}{{if .Slice }} - -func (f encFnInfo) {{ .MethodNamePfx "fastpathEnc" false }}R(rv reflect.Value) { - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(rv.Interface().([]{{ .Elem }}), fastpathCheckNilFalse, f.e) -} -func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v []{{ .Elem }}, checkNil bool, e *Encoder) { - ee := e.e - if checkNil && v == nil { - ee.EncodeNil() - return - } - ee.EncodeArrayStart(len(v)) - if e.be { - for _, v2 := range v { - {{ encmd .Elem "v2"}} - } - } else { - for j, v2 := range v { - if j > 0 { - ee.EncodeArrayEntrySeparator() - } - {{ encmd .Elem "v2"}} - } - ee.EncodeArrayEnd() - } -} - -{{end}}{{end}}{{end}} - -{{range .Values}}{{if not .Primitive}}{{if not .Slice }} - -func (f encFnInfo) {{ .MethodNamePfx "fastpathEnc" false }}R(rv reflect.Value) { - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(rv.Interface().(map[{{ .MapKey }}]{{ .Elem }}), fastpathCheckNilFalse, f.e) -} -func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v map[{{ .MapKey }}]{{ .Elem }}, checkNil bool, e *Encoder) { - ee := e.e - if checkNil && v == nil { - ee.EncodeNil() - return - } - ee.EncodeMapStart(len(v)) - {{if eq .MapKey "string"}}asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0{{end}} - if e.be { - for k2, v2 := range v { - {{if eq .MapKey "string"}}if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - }{{else}}{{ encmd .MapKey "k2"}}{{end}} - {{ encmd .Elem "v2"}} - } - } else { - j := 0 - for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() - } - {{if eq .MapKey "string"}}if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - }{{else}}{{ encmd .MapKey "k2"}}{{end}} - ee.EncodeMapKVSeparator() - {{ encmd .Elem "v2"}} - j++ - } - ee.EncodeMapEnd() - } -} - -{{end}}{{end}}{{end}} - -// -- decode - -// -- -- fast path type switch -func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { - switch v := iv.(type) { -{{range .Values}}{{if not .Primitive}}{{if .Slice }} - case []{{ .Elem }}:{{else}} - case map[{{ .MapKey }}]{{ .Elem }}:{{end}} - fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, fastpathCheckNilFalse, false, d){{if .Slice }} - case *[]{{ .Elem }}:{{else}} - case *map[{{ .MapKey }}]{{ .Elem }}:{{end}} - v2, changed2 := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*v, fastpathCheckNilFalse, true, d) - if changed2 { - *v = v2 - } -{{end}}{{end}} - default: - return false - } - return true -} - -// -- -- fast path functions -{{range .Values}}{{if not .Primitive}}{{if .Slice }} -{{/* -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 (f decFnInfo) {{ .MethodNamePfx "fastpathDec" false }}R(rv reflect.Value) { - array := f.seq == seqTypeArray - if !array && rv.CanAddr() { // CanSet => CanAddr + Exported - vp := rv.Addr().Interface().(*[]{{ .Elem }}) - v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*vp, fastpathCheckNilFalse, !array, f.d) - if changed { - *vp = v - } - } else { - v := rv.Interface().([]{{ .Elem }}) - fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, fastpathCheckNilFalse, false, f.d) - } -} - -func (f fastpathT) {{ .MethodNamePfx "Dec" false }}X(vp *[]{{ .Elem }}, checkNil bool, d *Decoder) { - v, changed := f.{{ .MethodNamePfx "Dec" false }}V(*vp, checkNil, true, d) - if changed { - *vp = v - } -} -func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v []{{ .Elem }}, checkNil bool, canChange bool, - d *Decoder) (_ []{{ .Elem }}, changed bool) { - dd := d.d - // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() - if checkNil && dd.TryDecodeAsNil() { - if v != nil { - changed = true - } - return nil, changed - } - - slh, containerLenS := d.decSliceHelperStart() - if canChange && v == nil { - if containerLenS <= 0 { - v = []{{ .Elem }}{} - } else { - v = make([]{{ .Elem }}, containerLenS, containerLenS) - } - changed = true - } - if containerLenS == 0 { - if canChange && len(v) != 0 { - v = v[:0] - changed = true - }{{/* - // slh.End() // dd.ReadArrayEnd() - */}} - return v, changed - } - - // for j := 0; j < containerLenS; j++ { - if containerLenS > 0 { - decLen := containerLenS - if containerLenS > cap(v) { - if canChange { - s := make([]{{ .Elem }}, containerLenS, containerLenS) - // copy(s, v[:cap(v)]) - v = s - changed = true - } else { - d.arrayCannotExpand(len(v), containerLenS) - decLen = len(v) - } - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true - } - // all checks done. cannot go past len. - j := 0 - for ; j < decLen; j++ { - {{ if eq .Elem "interface{}" }}d.decode(&v[j]){{ else }}v[j] = {{ decmd .Elem }}{{ end }} - } - if !canChange { - for ; j < containerLenS; j++ { - d.swallow() - } - } - } else { - j := 0 - for ; !dd.CheckBreak(); j++ { - if j >= len(v) { - if canChange { - v = append(v, {{ zerocmd .Elem }}) - changed = true - } else { - d.arrayCannotExpand(len(v), j+1) - } - } - if j > 0 { - slh.Sep(j) - } - if j < len(v) { // all checks done. cannot go past len. - {{ if eq .Elem "interface{}" }}d.decode(&v[j]) - {{ else }}v[j] = {{ decmd .Elem }}{{ end }} - } else { - d.swallow() - } - } - slh.End() - } - return v, changed -} - -{{end}}{{end}}{{end}} - - -{{range .Values}}{{if not .Primitive}}{{if not .Slice }} -{{/* -Maps can change if they are -- addressable (from a ptr) -- settable (e.g. contained in an interface{}) -*/}} -func (f decFnInfo) {{ .MethodNamePfx "fastpathDec" false }}R(rv reflect.Value) { - if rv.CanAddr() { - vp := rv.Addr().Interface().(*map[{{ .MapKey }}]{{ .Elem }}) - v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*vp, fastpathCheckNilFalse, true, f.d) - if changed { - *vp = v - } - } else { - v := rv.Interface().(map[{{ .MapKey }}]{{ .Elem }}) - fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, fastpathCheckNilFalse, false, f.d) - } -} -func (f fastpathT) {{ .MethodNamePfx "Dec" false }}X(vp *map[{{ .MapKey }}]{{ .Elem }}, checkNil bool, d *Decoder) { - v, changed := f.{{ .MethodNamePfx "Dec" false }}V(*vp, checkNil, true, d) - if changed { - *vp = v - } -} -func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v map[{{ .MapKey }}]{{ .Elem }}, checkNil bool, canChange bool, - d *Decoder) (_ map[{{ .MapKey }}]{{ .Elem }}, changed bool) { - dd := d.d - // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() - if checkNil && dd.TryDecodeAsNil() { - if v != nil { - changed = true - } - return nil, changed - } - - containerLen := dd.ReadMapStart() - if canChange && v == nil { - if containerLen > 0 { - v = make(map[{{ .MapKey }}]{{ .Elem }}, containerLen) - } else { - v = make(map[{{ .MapKey }}]{{ .Elem }}) // supports indefinite-length, etc - } - changed = true - } - if containerLen > 0 { - for j := 0; j < containerLen; j++ { - {{ if eq .MapKey "interface{}" }}var mk interface{} - d.decode(&mk) - if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. - }{{ else }}mk := {{ decmd .MapKey }}{{ end }} - mv := v[mk] - {{ if eq .Elem "interface{}" }}d.decode(&mv) - {{ else }}mv = {{ decmd .Elem }}{{ end }} - if v != nil { - v[mk] = mv - } - } - } else if containerLen < 0 { - for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() - } - {{ if eq .MapKey "interface{}" }}var mk interface{} - d.decode(&mk) - if bv, bok := mk.([]byte); bok { - mk = string(bv) // maps cannot have []byte as key. switch to string. - }{{ else }}mk := {{ decmd .MapKey }}{{ end }} - dd.ReadMapKVSeparator() - mv := v[mk] - {{ if eq .Elem "interface{}" }}d.decode(&mv) - {{ else }}mv = {{ decmd .Elem }}{{ end }} - if v != nil { - v[mk] = mv - } - } - dd.ReadMapEnd() - } - return v, changed -} - -{{end}}{{end}}{{end}} diff --git a/cmd/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl b/cmd/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl deleted file mode 100644 index 0f4ea91..0000000 --- a/cmd/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl +++ /dev/null @@ -1,80 +0,0 @@ -{{var "v"}} := {{ if not isArray}}*{{ end }}{{ .Varname }} -{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() - -var {{var "c"}} bool -_ = {{var "c"}} - -{{ if not isArray }}if {{var "v"}} == nil { - if {{var "l"}} <= 0 { - {{var "v"}} = make({{ .CTyp }}, 0) - } else { - {{var "v"}} = make({{ .CTyp }}, {{var "l"}}) - } - {{var "c"}} = true -} -{{ end }} -if {{var "l"}} == 0 { {{ if isSlice }} - if len({{var "v"}}) != 0 { - {{var "v"}} = {{var "v"}}[:0] - {{var "c"}} = true - } {{ end }} -} else if {{var "l"}} > 0 { - {{ if isChan }} - for {{var "r"}} := 0; {{var "r"}} < {{var "l"}}; {{var "r"}}++ { - var {{var "t"}} {{ .Typ }} - {{ $x := printf "%st%s" .TempVar .Rand }}{{ decLineVar $x }} - {{var "v"}} <- {{var "t"}} - {{ else }} - {{var "n"}} := {{var "l"}} - if {{var "l"}} > cap({{var "v"}}) { - {{ if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "l"}}) - {{var "n"}} = len({{var "v"}}) - {{ else }}{{ if .Immutable }} - {{var "v2"}} := {{var "v"}} - {{var "v"}} = make([]{{ .Typ }}, {{var "l"}}, {{var "l"}}) - if len({{var "v"}}) > 0 { - copy({{var "v"}}, {{var "v2"}}[:cap({{var "v2"}})]) - } - {{ else }}{{var "v"}} = make([]{{ .Typ }}, {{var "l"}}, {{var "l"}}) - {{ end }}{{var "c"}} = true - {{ end }} - } else if {{var "l"}} != len({{var "v"}}) { - {{ if isSlice }}{{var "v"}} = {{var "v"}}[:{{var "l"}}] - {{var "c"}} = true {{ end }} - } - {{var "j"}} := 0 - for ; {{var "j"}} < {{var "n"}} ; {{var "j"}}++ { - {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }} - } {{ if isArray }} - for ; {{var "j"}} < {{var "l"}} ; {{var "j"}}++ { - z.DecSwallow() - }{{ end }} - {{ end }}{{/* closing if not chan */}} -} else { - for {{var "j"}} := 0; !r.CheckBreak(); {{var "j"}}++ { - if {{var "j"}} >= len({{var "v"}}) { - {{ if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "j"}}+1) - {{ else if isSlice}}{{var "v"}} = append({{var "v"}}, {{zero}})// var {{var "z"}} {{ .Typ }} - {{var "c"}} = true {{ end }} - } - if {{var "j"}} > 0 { - {{var "h"}}.Sep({{var "j"}}) - } - {{ if isChan}} - var {{var "t"}} {{ .Typ }} - {{ $x := printf "%st%s" .TempVar .Rand }}{{ decLineVar $x }} - {{var "v"}} <- {{var "t"}} - {{ else }} - if {{var "j"}} < len({{var "v"}}) { - {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }} - } else { - z.DecSwallow() - } - {{ end }} - } - {{var "h"}}.End() -} -{{ if not isArray }}if {{var "c"}} { - *{{ .Varname }} = {{var "v"}} -}{{ end }} - diff --git a/cmd/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl b/cmd/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl deleted file mode 100644 index 9f8dafa..0000000 --- a/cmd/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl +++ /dev/null @@ -1,46 +0,0 @@ -{{var "v"}} := *{{ .Varname }} -{{var "l"}} := r.ReadMapStart() -if {{var "v"}} == nil { - if {{var "l"}} > 0 { - {{var "v"}} = make(map[{{ .KTyp }}]{{ .Typ }}, {{var "l"}}) - } else { - {{var "v"}} = make(map[{{ .KTyp }}]{{ .Typ }}) // supports indefinite-length, etc - } - *{{ .Varname }} = {{var "v"}} -} -if {{var "l"}} > 0 { -for {{var "j"}} := 0; {{var "j"}} < {{var "l"}}; {{var "j"}}++ { - var {{var "mk"}} {{ .KTyp }} - {{ $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 }} - {{var "mv"}} := {{var "v"}}[{{var "mk"}}] - {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ decLineVar $x }} - if {{var "v"}} != nil { - {{var "v"}}[{{var "mk"}}] = {{var "mv"}} - } -} -} else if {{var "l"}} < 0 { -for {{var "j"}} := 0; !r.CheckBreak(); {{var "j"}}++ { - if {{var "j"}} > 0 { - r.ReadMapEntrySeparator() - } - var {{var "mk"}} {{ .KTyp }} - {{ $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 }} - r.ReadMapKVSeparator() - {{var "mv"}} := {{var "v"}}[{{var "mk"}}] - {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ decLineVar $x }} - if {{var "v"}} != nil { - {{var "v"}}[{{var "mk"}}] = {{var "mv"}} - } -} -r.ReadMapEnd() -} // else len==0: TODO: Should we clear map entries? diff --git a/cmd/vendor/github.com/ugorji/go/codec/gen-helper.generated.go b/cmd/vendor/github.com/ugorji/go/codec/gen-helper.generated.go deleted file mode 100644 index ecf3ee5..0000000 --- a/cmd/vendor/github.com/ugorji/go/codec/gen-helper.generated.go +++ /dev/null @@ -1,102 +0,0 @@ -// //+build ignore - -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// ************************************************************ -// DO NOT EDIT. -// THIS FILE IS AUTO-GENERATED from gen-helper.go.tmpl -// ************************************************************ - -package codec - -// 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 continously and without notice. -// -// To help enforce this, we create an unexported type with exported members. -// The only way to get the type is via the one exported type that we control (somewhat). -// -// When static codecs are created for types, they will use this value -// to perform encoding or decoding of primitives or known slice or map types. - -// GenHelperEncoder is exported so that it can be used externally by codecgen. -// Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE. -func GenHelperEncoder(e *Encoder) (genHelperEncoder, encDriver) { - return genHelperEncoder{e: e}, e.e -} - -// GenHelperDecoder is exported so that it can be used externally by codecgen. -// Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE. -func GenHelperDecoder(d *Decoder) (genHelperDecoder, decDriver) { - return genHelperDecoder{d: d}, d.d -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -type genHelperEncoder struct { - e *Encoder - F fastpathT -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -type genHelperDecoder struct { - d *Decoder - F fastpathT -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncBasicHandle() *BasicHandle { - return f.e.h -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncBinary() bool { - return f.e.be // f.e.hh.isBinaryEncoding() -} - -// 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) -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecBasicHandle() *BasicHandle { - return f.d.h -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecBinary() bool { - return f.d.be // f.d.hh.isBinaryEncoding() -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecSwallow() { - f.d.swallow() -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecScratchBuffer() []byte { - return f.d.b[:] -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecFallback(iv interface{}, chkPtr bool) { - // println(">>>>>>>>> DecFallback") - f.d.decodeI(iv, chkPtr, false, false, false) -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecSliceHelperStart() (decSliceHelper, int) { - return f.d.decSliceHelperStart() -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecStructFieldNotFound(index int, name string) { - f.d.structFieldNotFound(index, name) -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecArrayCannotExpand(sliceLen, streamLen int) { - f.d.arrayCannotExpand(sliceLen, streamLen) -} diff --git a/cmd/vendor/github.com/ugorji/go/codec/gen.generated.go b/cmd/vendor/github.com/ugorji/go/codec/gen.generated.go deleted file mode 100644 index 8cc254e..0000000 --- a/cmd/vendor/github.com/ugorji/go/codec/gen.generated.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -// DO NOT EDIT. THIS FILE IS AUTO-GENERATED FROM gen-dec-(map|array).go.tmpl - -const genDecMapTmpl = ` -{{var "v"}} := *{{ .Varname }} -{{var "l"}} := r.ReadMapStart() -if {{var "v"}} == nil { - if {{var "l"}} > 0 { - {{var "v"}} = make(map[{{ .KTyp }}]{{ .Typ }}, {{var "l"}}) - } else { - {{var "v"}} = make(map[{{ .KTyp }}]{{ .Typ }}) // supports indefinite-length, etc - } - *{{ .Varname }} = {{var "v"}} -} -if {{var "l"}} > 0 { -for {{var "j"}} := 0; {{var "j"}} < {{var "l"}}; {{var "j"}}++ { - var {{var "mk"}} {{ .KTyp }} - {{ $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 }} - {{var "mv"}} := {{var "v"}}[{{var "mk"}}] - {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ decLineVar $x }} - if {{var "v"}} != nil { - {{var "v"}}[{{var "mk"}}] = {{var "mv"}} - } -} -} else if {{var "l"}} < 0 { -for {{var "j"}} := 0; !r.CheckBreak(); {{var "j"}}++ { - if {{var "j"}} > 0 { - r.ReadMapEntrySeparator() - } - var {{var "mk"}} {{ .KTyp }} - {{ $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 }} - r.ReadMapKVSeparator() - {{var "mv"}} := {{var "v"}}[{{var "mk"}}] - {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ decLineVar $x }} - if {{var "v"}} != nil { - {{var "v"}}[{{var "mk"}}] = {{var "mv"}} - } -} -r.ReadMapEnd() -} // else len==0: TODO: Should we clear map entries? -` - -const genDecListTmpl = ` -{{var "v"}} := {{ if not isArray}}*{{ end }}{{ .Varname }} -{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() - -var {{var "c"}} bool -_ = {{var "c"}} - -{{ if not isArray }}if {{var "v"}} == nil { - if {{var "l"}} <= 0 { - {{var "v"}} = make({{ .CTyp }}, 0) - } else { - {{var "v"}} = make({{ .CTyp }}, {{var "l"}}) - } - {{var "c"}} = true -} -{{ end }} -if {{var "l"}} == 0 { {{ if isSlice }} - if len({{var "v"}}) != 0 { - {{var "v"}} = {{var "v"}}[:0] - {{var "c"}} = true - } {{ end }} -} else if {{var "l"}} > 0 { - {{ if isChan }} - for {{var "r"}} := 0; {{var "r"}} < {{var "l"}}; {{var "r"}}++ { - var {{var "t"}} {{ .Typ }} - {{ $x := printf "%st%s" .TempVar .Rand }}{{ decLineVar $x }} - {{var "v"}} <- {{var "t"}} - {{ else }} - {{var "n"}} := {{var "l"}} - if {{var "l"}} > cap({{var "v"}}) { - {{ if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "l"}}) - {{var "n"}} = len({{var "v"}}) - {{ else }}{{ if .Immutable }} - {{var "v2"}} := {{var "v"}} - {{var "v"}} = make([]{{ .Typ }}, {{var "l"}}, {{var "l"}}) - if len({{var "v"}}) > 0 { - copy({{var "v"}}, {{var "v2"}}[:cap({{var "v2"}})]) - } - {{ else }}{{var "v"}} = make([]{{ .Typ }}, {{var "l"}}, {{var "l"}}) - {{ end }}{{var "c"}} = true - {{ end }} - } else if {{var "l"}} != len({{var "v"}}) { - {{ if isSlice }}{{var "v"}} = {{var "v"}}[:{{var "l"}}] - {{var "c"}} = true {{ end }} - } - {{var "j"}} := 0 - for ; {{var "j"}} < {{var "n"}} ; {{var "j"}}++ { - {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }} - } {{ if isArray }} - for ; {{var "j"}} < {{var "l"}} ; {{var "j"}}++ { - z.DecSwallow() - }{{ end }} - {{ end }}{{/* closing if not chan */}} -} else { - for {{var "j"}} := 0; !r.CheckBreak(); {{var "j"}}++ { - if {{var "j"}} >= len({{var "v"}}) { - {{ if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "j"}}+1) - {{ else if isSlice}}{{var "v"}} = append({{var "v"}}, {{zero}})// var {{var "z"}} {{ .Typ }} - {{var "c"}} = true {{ end }} - } - if {{var "j"}} > 0 { - {{var "h"}}.Sep({{var "j"}}) - } - {{ if isChan}} - var {{var "t"}} {{ .Typ }} - {{ $x := printf "%st%s" .TempVar .Rand }}{{ decLineVar $x }} - {{var "v"}} <- {{var "t"}} - {{ else }} - if {{var "j"}} < len({{var "v"}}) { - {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }} - } else { - z.DecSwallow() - } - {{ end }} - } - {{var "h"}}.End() -} -{{ if not isArray }}if {{var "c"}} { - *{{ .Varname }} = {{var "v"}} -}{{ end }} - -` - diff --git a/cmd/vendor/github.com/ugorji/go/codec/noop.go b/cmd/vendor/github.com/ugorji/go/codec/noop.go deleted file mode 100644 index 25bef4f..0000000 --- a/cmd/vendor/github.com/ugorji/go/codec/noop.go +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "math/rand" - "time" -) - -// NoopHandle returns a no-op handle. It basically does nothing. -// It is only useful for benchmarking, as it gives an idea of the -// overhead from the codec framework. -// LIBRARY USERS: *** DO NOT USE *** -func NoopHandle(slen int) *noopHandle { - h := noopHandle{} - h.rand = rand.New(rand.NewSource(time.Now().UnixNano())) - h.B = make([][]byte, slen) - h.S = make([]string, slen) - for i := 0; i < len(h.S); i++ { - b := make([]byte, i+1) - for j := 0; j < len(b); j++ { - b[j] = 'a' + byte(i) - } - h.B[i] = b - h.S[i] = string(b) - } - return &h -} - -// noopHandle does nothing. -// It is used to simulate the overhead of the codec framework. -type noopHandle struct { - BasicHandle - binaryEncodingType - noopDrv // noopDrv is unexported here, so we can get a copy of it when needed. -} - -type noopDrv struct { - i int - S []string - B [][]byte - mk bool // are we about to read a map key? - ct valueType // last request for IsContainerType. - cb bool // last response for IsContainerType. - rand *rand.Rand -} - -func (h *noopDrv) r(v int) int { return h.rand.Intn(v) } -func (h *noopDrv) m(v int) int { h.i++; return h.i % v } - -func (h *noopDrv) newEncDriver(_ *Encoder) encDriver { return h } -func (h *noopDrv) newDecDriver(_ *Decoder) decDriver { return h } - -// --- encDriver - -func (h *noopDrv) EncodeBuiltin(rt uintptr, v interface{}) {} -func (h *noopDrv) EncodeNil() {} -func (h *noopDrv) EncodeInt(i int64) {} -func (h *noopDrv) EncodeUint(i uint64) {} -func (h *noopDrv) EncodeBool(b bool) {} -func (h *noopDrv) EncodeFloat32(f float32) {} -func (h *noopDrv) EncodeFloat64(f float64) {} -func (h *noopDrv) EncodeRawExt(re *RawExt, e *Encoder) {} -func (h *noopDrv) EncodeArrayStart(length int) {} -func (h *noopDrv) EncodeArrayEnd() {} -func (h *noopDrv) EncodeArrayEntrySeparator() {} -func (h *noopDrv) EncodeMapStart(length int) {} -func (h *noopDrv) EncodeMapEnd() {} -func (h *noopDrv) EncodeMapEntrySeparator() {} -func (h *noopDrv) EncodeMapKVSeparator() {} -func (h *noopDrv) EncodeString(c charEncoding, v string) {} -func (h *noopDrv) EncodeSymbol(v string) {} -func (h *noopDrv) EncodeStringBytes(c charEncoding, v []byte) {} - -func (h *noopDrv) EncodeExt(rv interface{}, xtag uint64, ext Ext, e *Encoder) {} - -// ---- decDriver -func (h *noopDrv) initReadNext() {} -func (h *noopDrv) CheckBreak() bool { return false } -func (h *noopDrv) IsBuiltinType(rt uintptr) bool { return false } -func (h *noopDrv) DecodeBuiltin(rt uintptr, v interface{}) {} -func (h *noopDrv) DecodeInt(bitsize uint8) (i int64) { return int64(h.m(15)) } -func (h *noopDrv) DecodeUint(bitsize uint8) (ui uint64) { return uint64(h.m(35)) } -func (h *noopDrv) DecodeFloat(chkOverflow32 bool) (f float64) { return float64(h.m(95)) } -func (h *noopDrv) DecodeBool() (b bool) { return h.m(2) == 0 } -func (h *noopDrv) DecodeString() (s string) { return h.S[h.m(8)] } - -// func (h *noopDrv) DecodeStringAsBytes(bs []byte) []byte { return h.DecodeBytes(bs) } - -func (h *noopDrv) DecodeBytes(bs []byte, isstring, zerocopy bool) []byte { return h.B[h.m(len(h.B))] } - -func (h *noopDrv) ReadMapEnd() { h.mk = false } -func (h *noopDrv) ReadArrayEnd() {} -func (h *noopDrv) ReadArrayEntrySeparator() {} -func (h *noopDrv) ReadMapEntrySeparator() { h.mk = true } -func (h *noopDrv) ReadMapKVSeparator() { h.mk = false } - -// toggle map/slice -func (h *noopDrv) ReadMapStart() int { h.mk = true; return h.m(10) } -func (h *noopDrv) ReadArrayStart() int { return h.m(10) } - -func (h *noopDrv) IsContainerType(vt valueType) bool { - // return h.m(2) == 0 - // handle kStruct - if h.ct == valueTypeMap && vt == valueTypeArray || h.ct == valueTypeArray && vt == valueTypeMap { - h.cb = !h.cb - h.ct = vt - return h.cb - } - // go in a loop and check it. - h.ct = vt - h.cb = h.m(7) == 0 - return h.cb -} -func (h *noopDrv) TryDecodeAsNil() bool { - if h.mk { - return false - } else { - return h.m(8) == 0 - } -} -func (h *noopDrv) DecodeExt(rv interface{}, xtag uint64, ext Ext) uint64 { - return 0 -} - -func (h *noopDrv) DecodeNaked() (v interface{}, vt valueType, decodeFurther bool) { - // use h.r (random) not h.m() because h.m() could cause the same value to be given. - var sk int - if h.mk { - // if mapkey, do not support values of nil OR bytes, array, map or rawext - sk = h.r(7) + 1 - } else { - sk = h.r(12) - } - switch sk { - case 0: - vt = valueTypeNil - case 1: - vt, v = valueTypeBool, false - case 2: - vt, v = valueTypeBool, true - case 3: - vt, v = valueTypeInt, h.DecodeInt(64) - case 4: - vt, v = valueTypeUint, h.DecodeUint(64) - case 5: - vt, v = valueTypeFloat, h.DecodeFloat(true) - case 6: - vt, v = valueTypeFloat, h.DecodeFloat(false) - case 7: - vt, v = valueTypeString, h.DecodeString() - case 8: - vt, v = valueTypeBytes, h.B[h.m(len(h.B))] - case 9: - vt, decodeFurther = valueTypeArray, true - case 10: - vt, decodeFurther = valueTypeMap, true - default: - vt, v = valueTypeExt, &RawExt{Tag: h.DecodeUint(64), Data: h.B[h.m(len(h.B))]} - } - h.ct = vt - return -} diff --git a/cmd/vendor/github.com/ugorji/go/codec/prebuild.sh b/cmd/vendor/github.com/ugorji/go/codec/prebuild.sh deleted file mode 100644 index c1916f3..0000000 --- a/cmd/vendor/github.com/ugorji/go/codec/prebuild.sh +++ /dev/null @@ -1,193 +0,0 @@ -#!/bin/bash - -# _needgen is a helper function to tell if we need to generate files for msgp, codecgen. -_needgen() { - local a="$1" - zneedgen=0 - if [[ ! -e "$a" ]] - then - zneedgen=1 - echo 1 - return 0 - fi - for i in `ls -1 *.go.tmpl gen.go values_test.go` - do - if [[ "$a" -ot "$i" ]] - then - zneedgen=1 - echo 1 - return 0 - fi - done - echo 0 -} - -# _build generates fast-path.go and gen-helper.go. -# -# It is needed because there is some dependency between the generated code -# and the other classes. Consequently, we have to totally remove the -# generated files and put stubs in place, before calling "go run" again -# to recreate them. -_build() { - if ! [[ "${zforce}" == "1" || - "1" == $( _needgen "fast-path.generated.go" ) || - "1" == $( _needgen "gen-helper.generated.go" ) || - "1" == $( _needgen "gen.generated.go" ) || - 1 == 0 ]] - then - return 0 - fi - - # echo "Running prebuild" - if [ "${zbak}" == "1" ] - then - # echo "Backing up old generated files" - _zts=`date '+%m%d%Y_%H%M%S'` - _gg=".generated.go" - [ -e "gen-helper${_gg}" ] && mv gen-helper${_gg} gen-helper${_gg}__${_zts}.bak - [ -e "fast-path${_gg}" ] && mv fast-path${_gg} fast-path${_gg}__${_zts}.bak - # [ -e "safe${_gg}" ] && mv safe${_gg} safe${_gg}__${_zts}.bak - # [ -e "unsafe${_gg}" ] && mv unsafe${_gg} unsafe${_gg}__${_zts}.bak - else - rm -f fast-path.generated.go gen.generated.go gen-helper.generated.go *safe.generated.go *_generated_test.go *.generated_ffjson_expose.go - fi - - cat > gen.generated.go <> gen.generated.go < gen-dec-map.go.tmpl - - cat >> gen.generated.go <> gen.generated.go < gen-dec-array.go.tmpl - - cat >> gen.generated.go < fast-path.generated.go < gen-from-tmpl.generated.go < 0 - if stopTimeSec > 0: - def myStopRpcServer(): - server.stop() - t = threading.Timer(stopTimeSec, myStopRpcServer) - t.start() - server.start() - -def doRpcClientToPythonSvc(port): - address = msgpackrpc.Address('localhost', port) - client = msgpackrpc.Client(address, unpack_encoding='utf-8') - print client.call("Echo123", "A1", "B2", "C3") - print client.call("EchoStruct", {"A" :"Aa", "B":"Bb", "C":"Cc"}) - -def doRpcClientToGoSvc(port): - # print ">>>> port: ", port, " <<<<<" - address = msgpackrpc.Address('localhost', port) - client = msgpackrpc.Client(address, unpack_encoding='utf-8') - print client.call("TestRpcInt.Echo123", ["A1", "B2", "C3"]) - print client.call("TestRpcInt.EchoStruct", {"A" :"Aa", "B":"Bb", "C":"Cc"}) - -def doMain(args): - if len(args) == 2 and args[0] == "testdata": - build_test_data(args[1]) - elif len(args) == 3 and args[0] == "rpc-server": - doRpcServer(int(args[1]), int(args[2])) - elif len(args) == 2 and args[0] == "rpc-client-python-service": - doRpcClientToPythonSvc(int(args[1])) - elif len(args) == 2 and args[0] == "rpc-client-go-service": - doRpcClientToGoSvc(int(args[1])) - else: - print("Usage: test.py " + - "[testdata|rpc-server|rpc-client-python-service|rpc-client-go-service] ...") - -if __name__ == "__main__": - doMain(sys.argv[1:]) - diff --git a/glide.lock b/glide.lock new file mode 100644 index 0000000..6968478 --- /dev/null +++ b/glide.lock @@ -0,0 +1,53 @@ +hash: b1848c39932685b6791ef2b3eaf9840bfe4591706f0a53cc83b52833be63d545 +updated: 2017-03-12T16:13:15.751664496+08:00 +imports: +- name: github.com/BurntSushi/toml + version: bbd5bb678321a0d6e58f1099321dfa73391c1b6f +- name: github.com/cupcake/rdb + version: 43ba34106c765f2111c0dc7b74cdf8ee437411e0 + subpackages: + - crc64 + - nopdecoder +- name: github.com/edsrzf/mmap-go + version: 935e0e8a636ca4ba70b713f3e38a19e1b77739e8 +- name: github.com/golang/snappy + version: 553a641470496b2327abcac10b36396bd98e45c9 +- name: github.com/peterh/liner + version: bf27d3ba8e1d9899d45a457ffac16c953eb2d647 +- name: github.com/siddontang/go + version: 354e14e6c093c661abb29fd28403b3c19cff5514 + subpackages: + - bson + - filelock + - hack + - ioutil2 + - log + - num + - snappy + - sync2 +- name: github.com/siddontang/golua + version: f73e23294ebf29412e1e96bb6163be152700d250 +- name: github.com/siddontang/goredis + version: 760763f78400635ed7b9b115511b8ed06035e908 +- name: github.com/siddontang/rdb + version: fc89ed2e418d27e3ea76e708e54276d2b44ae9cf +- name: github.com/syndtr/goleveldb + version: 3c5717caf1475fd25964109a0fc640bd150fce43 + subpackages: + - leveldb + - leveldb/cache + - leveldb/comparer + - leveldb/errors + - leveldb/filter + - leveldb/iterator + - leveldb/journal + - leveldb/memdb + - leveldb/opt + - leveldb/storage + - leveldb/table + - leveldb/util +- name: github.com/ugorji/go + version: b94837a2404ab90efe9289e77a70694c355739cb + subpackages: + - codec +testImports: [] diff --git a/glide.yaml b/glide.yaml new file mode 100644 index 0000000..6eda9db --- /dev/null +++ b/glide.yaml @@ -0,0 +1,39 @@ +package: github.com/siddontang/ledisdb +import: +- package: github.com/BurntSushi/toml + version: bbd5bb678321a0d6e58f1099321dfa73391c1b6f +- package: github.com/edsrzf/mmap-go + version: 935e0e8a636ca4ba70b713f3e38a19e1b77739e8 +- package: github.com/peterh/liner + version: bf27d3ba8e1d9899d45a457ffac16c953eb2d647 +- package: github.com/siddontang/go + version: 354e14e6c093c661abb29fd28403b3c19cff5514 + subpackages: + - bson + - filelock + - hack + - ioutil2 + - log + - num + - snappy + - sync2 +- package: github.com/siddontang/golua + version: f73e23294ebf29412e1e96bb6163be152700d250 +- package: github.com/siddontang/goredis + version: 760763f78400635ed7b9b115511b8ed06035e908 +- package: github.com/siddontang/rdb + version: fc89ed2e418d27e3ea76e708e54276d2b44ae9cf +- package: github.com/syndtr/goleveldb + version: 3c5717caf1475fd25964109a0fc640bd150fce43 + subpackages: + - leveldb + - leveldb/cache + - leveldb/filter + - leveldb/iterator + - leveldb/opt + - leveldb/storage + - leveldb/util +- package: github.com/ugorji/go + version: b94837a2404ab90efe9289e77a70694c355739cb + subpackages: + - codec diff --git a/ledis/event.go b/ledis/event.go index e7a175c..d14309d 100644 --- a/ledis/event.go +++ b/ledis/event.go @@ -86,20 +86,6 @@ func formatEventKey(buf []byte, k []byte) ([]byte, error) { buf = append(buf, ' ') buf = strconv.AppendInt(buf, score, 10) } - // case BitType: - // if key, seq, err := db.bDecodeBinKey(k); err != nil { - // return nil, err - // } else { - // buf = strconv.AppendQuote(buf, hack.String(key)) - // buf = append(buf, ' ') - // buf = strconv.AppendUint(buf, uint64(seq), 10) - // } - // case BitMetaType: - // if key, err := db.bDecodeMetaKey(k); err != nil { - // return nil, err - // } else { - // buf = strconv.AppendQuote(buf, hack.String(key)) - // } case SetType: if key, member, err := db.sDecodeSetKey(k); err != nil { return nil, err diff --git a/ledis/t_bit.go b/ledis/t_bit.go deleted file mode 100644 index ebb099c..0000000 --- a/ledis/t_bit.go +++ /dev/null @@ -1,931 +0,0 @@ -package ledis - -// import ( -// "encoding/binary" -// "errors" -// "github.com/siddontang/go/log" -// "github.com/siddontang/go/num" -// "github.com/siddontang/ledisdb/store" -// "sort" -// "time" -// ) - -// /* -// We will not maintain bitmap anymore, and will add bit operations for kv type later. -// Use your own risk. -// */ - -// const ( -// OPand uint8 = iota + 1 -// OPor -// OPxor -// OPnot -// ) - -// type BitPair struct { -// Pos int32 -// Val uint8 -// } - -// type segBitInfo struct { -// Seq uint32 -// Off uint32 -// Val uint8 -// } - -// type segBitInfoArray []segBitInfo - -// const ( -// // byte -// segByteWidth uint32 = 9 -// segByteSize uint32 = 1 << segByteWidth - -// // bit -// segBitWidth uint32 = segByteWidth + 3 -// segBitSize uint32 = segByteSize << 3 - -// maxByteSize uint32 = 8 << 20 -// maxSegCount uint32 = maxByteSize / segByteSize - -// minSeq uint32 = 0 -// maxSeq uint32 = uint32((maxByteSize << 3) - 1) -// ) - -// var fillBits = [...]uint8{1, 3, 7, 15, 31, 63, 127, 255} - -// var emptySegment []byte = make([]byte, segByteSize, segByteSize) - -// var fillSegment []byte = func() []byte { -// data := make([]byte, segByteSize, segByteSize) -// for i := uint32(0); i < segByteSize; i++ { -// data[i] = 0xff -// } -// return data -// }() - -// var errBinKey = errors.New("invalid bin key") -// var errOffset = errors.New("invalid offset") -// var errDuplicatePos = errors.New("duplicate bit pos") - -// func getBit(sz []byte, offset uint32) uint8 { -// index := offset >> 3 -// if index >= uint32(len(sz)) { -// return 0 // error("overflow") -// } - -// offset -= index << 3 -// return sz[index] >> offset & 1 -// } - -// func setBit(sz []byte, offset uint32, val uint8) bool { -// if val != 1 && val != 0 { -// return false // error("invalid val") -// } - -// index := offset >> 3 -// if index >= uint32(len(sz)) { -// return false // error("overflow") -// } - -// offset -= index << 3 -// if sz[index]>>offset&1 != val { -// sz[index] ^= (1 << offset) -// } -// return true -// } - -// func (datas segBitInfoArray) Len() int { -// return len(datas) -// } - -// func (datas segBitInfoArray) Less(i, j int) bool { -// res := (datas)[i].Seq < (datas)[j].Seq -// if !res && (datas)[i].Seq == (datas)[j].Seq { -// res = (datas)[i].Off < (datas)[j].Off -// } -// return res -// } - -// func (datas segBitInfoArray) Swap(i, j int) { -// datas[i], datas[j] = datas[j], datas[i] -// } - -// func (db *DB) bEncodeMetaKey(key []byte) []byte { -// mk := make([]byte, len(key)+2) -// mk[0] = db.index -// mk[1] = BitMetaType - -// copy(mk[2:], key) -// return mk -// } - -// func (db *DB) bDecodeMetaKey(bkey []byte) ([]byte, error) { -// if len(bkey) < 2 || bkey[0] != db.index || bkey[1] != BitMetaType { -// return nil, errBinKey -// } - -// return bkey[2:], nil -// } - -// func (db *DB) bEncodeBinKey(key []byte, seq uint32) []byte { -// bk := make([]byte, len(key)+8) - -// pos := 0 -// bk[pos] = db.index -// pos++ -// bk[pos] = BitType -// pos++ - -// binary.BigEndian.PutUint16(bk[pos:], uint16(len(key))) -// pos += 2 - -// copy(bk[pos:], key) -// pos += len(key) - -// binary.BigEndian.PutUint32(bk[pos:], seq) - -// return bk -// } - -// func (db *DB) bDecodeBinKey(bkey []byte) (key []byte, seq uint32, err error) { -// if len(bkey) < 8 || bkey[0] != db.index { -// err = errBinKey -// return -// } - -// keyLen := binary.BigEndian.Uint16(bkey[2:4]) -// if int(keyLen+8) != len(bkey) { -// err = errBinKey -// return -// } - -// key = bkey[4 : 4+keyLen] -// seq = uint32(binary.BigEndian.Uint32(bkey[4+keyLen:])) -// return -// } - -// func (db *DB) bCapByteSize(seq uint32, off uint32) uint32 { -// var offByteSize uint32 = (off >> 3) + 1 -// if offByteSize > segByteSize { -// offByteSize = segByteSize -// } - -// return seq<= 0 { -// offset += int32((uint32(tailSeq)<> segBitWidth -// off &= (segBitSize - 1) -// return -// } - -// func (db *DB) bGetMeta(key []byte) (tailSeq int32, tailOff int32, err error) { -// var v []byte - -// mk := db.bEncodeMetaKey(key) -// v, err = db.bucket.Get(mk) -// if err != nil { -// return -// } - -// if v != nil { -// tailSeq = int32(binary.LittleEndian.Uint32(v[0:4])) -// tailOff = int32(binary.LittleEndian.Uint32(v[4:8])) -// } else { -// tailSeq = -1 -// tailOff = -1 -// } -// return -// } - -// func (db *DB) bSetMeta(t *batch, key []byte, tailSeq uint32, tailOff uint32) { -// ek := db.bEncodeMetaKey(key) - -// buf := make([]byte, 8) -// binary.LittleEndian.PutUint32(buf[0:4], tailSeq) -// binary.LittleEndian.PutUint32(buf[4:8], tailOff) - -// t.Put(ek, buf) -// return -// } - -// func (db *DB) bUpdateMeta(t *batch, key []byte, seq uint32, off uint32) (tailSeq uint32, tailOff uint32, err error) { -// var tseq, toff int32 -// var update bool = false - -// if tseq, toff, err = db.bGetMeta(key); err != nil { -// return -// } else if tseq < 0 { -// update = true -// } else { -// tailSeq = uint32(num.MaxInt32(tseq, 0)) -// tailOff = uint32(num.MaxInt32(toff, 0)) -// update = (seq > tailSeq || (seq == tailSeq && off > tailOff)) -// } - -// if update { -// db.bSetMeta(t, key, seq, off) -// tailSeq = seq -// tailOff = off -// } -// return -// } - -// func (db *DB) bDelete(t *batch, key []byte) (drop int64) { -// mk := db.bEncodeMetaKey(key) -// t.Delete(mk) - -// minKey := db.bEncodeBinKey(key, minSeq) -// maxKey := db.bEncodeBinKey(key, maxSeq) -// it := db.bucket.RangeIterator(minKey, maxKey, store.RangeClose) -// for ; it.Valid(); it.Next() { -// t.Delete(it.RawKey()) -// drop++ -// } -// it.Close() - -// return drop -// } - -// func (db *DB) bGetSegment(key []byte, seq uint32) ([]byte, []byte, error) { -// bk := db.bEncodeBinKey(key, seq) -// segment, err := db.bucket.Get(bk) -// if err != nil { -// return bk, nil, err -// } -// return bk, segment, nil -// } - -// func (db *DB) bAllocateSegment(key []byte, seq uint32) ([]byte, []byte, error) { -// bk, segment, err := db.bGetSegment(key, seq) -// if err == nil && segment == nil { -// segment = make([]byte, segByteSize, segByteSize) -// } -// return bk, segment, err -// } - -// func (db *DB) bIterator(key []byte) *store.RangeLimitIterator { -// sk := db.bEncodeBinKey(key, minSeq) -// ek := db.bEncodeBinKey(key, maxSeq) -// return db.bucket.RangeIterator(sk, ek, store.RangeClose) -// } - -// func (db *DB) bSegAnd(a []byte, b []byte, res *[]byte) { -// if a == nil || b == nil { -// *res = nil -// return -// } - -// data := *res -// if data == nil { -// data = make([]byte, segByteSize, segByteSize) -// *res = data -// } - -// for i := uint32(0); i < segByteSize; i++ { -// data[i] = a[i] & b[i] -// } -// return -// } - -// func (db *DB) bSegOr(a []byte, b []byte, res *[]byte) { -// if a == nil || b == nil { -// if a == nil && b == nil { -// *res = nil -// } else if a == nil { -// *res = b -// } else { -// *res = a -// } -// return -// } - -// data := *res -// if data == nil { -// data = make([]byte, segByteSize, segByteSize) -// *res = data -// } - -// for i := uint32(0); i < segByteSize; i++ { -// data[i] = a[i] | b[i] -// } -// return -// } - -// func (db *DB) bSegXor(a []byte, b []byte, res *[]byte) { -// if a == nil && b == nil { -// *res = fillSegment -// return -// } - -// if a == nil { -// a = emptySegment -// } - -// if b == nil { -// b = emptySegment -// } - -// data := *res -// if data == nil { -// data = make([]byte, segByteSize, segByteSize) -// *res = data -// } - -// for i := uint32(0); i < segByteSize; i++ { -// data[i] = a[i] ^ b[i] -// } - -// return -// } - -// func (db *DB) bExpireAt(key []byte, when int64) (int64, error) { -// t := db.binBatch -// t.Lock() -// defer t.Unlock() - -// if seq, _, err := db.bGetMeta(key); err != nil || seq < 0 { -// return 0, err -// } else { -// db.expireAt(t, BitType, key, when) -// if err := t.Commit(); err != nil { -// return 0, err -// } -// } -// return 1, nil -// } - -// func (db *DB) bCountByte(val byte, soff uint32, eoff uint32) int32 { -// if soff > eoff { -// soff, eoff = eoff, soff -// } - -// mask := uint8(0) -// if soff > 0 { -// mask |= fillBits[soff-1] -// } -// if eoff < 7 { -// mask |= (fillBits[7] ^ fillBits[eoff]) -// } -// mask = fillBits[7] ^ mask - -// return bitsInByte[val&mask] -// } - -// func (db *DB) bCountSeg(key []byte, seq uint32, soff uint32, eoff uint32) (cnt int32, err error) { -// if soff >= segBitSize || soff < 0 || -// eoff >= segBitSize || eoff < 0 { -// return -// } - -// var segment []byte -// if _, segment, err = db.bGetSegment(key, seq); err != nil { -// return -// } - -// if segment == nil { -// return -// } - -// if soff > eoff { -// soff, eoff = eoff, soff -// } - -// headIdx := int(soff >> 3) -// endIdx := int(eoff >> 3) -// sByteOff := soff - ((soff >> 3) << 3) -// eByteOff := eoff - ((eoff >> 3) << 3) - -// if headIdx == endIdx { -// cnt = db.bCountByte(segment[headIdx], sByteOff, eByteOff) -// } else { -// cnt = db.bCountByte(segment[headIdx], sByteOff, 7) + -// db.bCountByte(segment[endIdx], 0, eByteOff) -// } - -// // sum up following bytes -// for idx, end := headIdx+1, endIdx-1; idx <= end; idx += 1 { -// cnt += bitsInByte[segment[idx]] -// if idx == end { -// break -// } -// } - -// return -// } - -// func (db *DB) BGet(key []byte) (data []byte, err error) { -// log.Error("bitmap type will be deprecated later, please use bit operations in kv type") - -// if err = checkKeySize(key); err != nil { -// return -// } - -// var ts, to int32 -// if ts, to, err = db.bGetMeta(key); err != nil || ts < 0 { -// return -// } - -// var tailSeq, tailOff = uint32(ts), uint32(to) -// var capByteSize uint32 = db.bCapByteSize(tailSeq, tailOff) -// data = make([]byte, capByteSize, capByteSize) - -// minKey := db.bEncodeBinKey(key, minSeq) -// maxKey := db.bEncodeBinKey(key, tailSeq) -// it := db.bucket.RangeIterator(minKey, maxKey, store.RangeClose) - -// var seq, s, e uint32 -// for ; it.Valid(); it.Next() { -// if _, seq, err = db.bDecodeBinKey(it.RawKey()); err != nil { -// data = nil -// break -// } - -// s = seq << segByteWidth -// e = num.MinUint32(s+segByteSize, capByteSize) -// copy(data[s:e], it.RawValue()) -// } -// it.Close() - -// return -// } - -// func (db *DB) BDelete(key []byte) (drop int64, err error) { -// log.Error("bitmap type will be deprecated later, please use bit operations in kv type") - -// if err = checkKeySize(key); err != nil { -// return -// } - -// t := db.binBatch -// t.Lock() -// defer t.Unlock() - -// drop = db.bDelete(t, key) -// db.rmExpire(t, BitType, key) - -// err = t.Commit() -// return -// } - -// func (db *DB) BSetBit(key []byte, offset int32, val uint8) (ori uint8, err error) { -// log.Error("bitmap type will be deprecated later, please use bit operations in kv type") - -// if err = checkKeySize(key); err != nil { -// return -// } - -// // todo : check offset -// var seq, off uint32 -// if seq, off, err = db.bParseOffset(key, offset); err != nil { -// return 0, err -// } - -// var bk, segment []byte -// if bk, segment, err = db.bAllocateSegment(key, seq); err != nil { -// return 0, err -// } - -// if segment != nil { -// ori = getBit(segment, off) -// if setBit(segment, off, val) { -// t := db.binBatch -// t.Lock() -// defer t.Unlock() - -// t.Put(bk, segment) -// if _, _, e := db.bUpdateMeta(t, key, seq, off); e != nil { -// err = e -// return -// } - -// err = t.Commit() -// } -// } - -// return -// } - -// func (db *DB) BMSetBit(key []byte, args ...BitPair) (place int64, err error) { -// log.Error("bitmap type will be deprecated later, please use bit operations in kv type") - -// if err = checkKeySize(key); err != nil { -// return -// } - -// // (ps : so as to aviod wasting memory copy while calling db.Get() and batch.Put(), -// // here we sequence the params by pos, so that we can merge the execution of -// // diff pos setting which targets on the same segment respectively. ) - -// // #1 : sequence request data -// var argCnt = len(args) -// var bitInfos segBitInfoArray = make(segBitInfoArray, argCnt) -// var seq, off uint32 - -// for i, info := range args { -// if seq, off, err = db.bParseOffset(key, info.Pos); err != nil { -// return -// } - -// bitInfos[i].Seq = seq -// bitInfos[i].Off = off -// bitInfos[i].Val = info.Val -// } - -// sort.Sort(bitInfos) - -// for i := 1; i < argCnt; i++ { -// if bitInfos[i].Seq == bitInfos[i-1].Seq && bitInfos[i].Off == bitInfos[i-1].Off { -// return 0, errDuplicatePos -// } -// } - -// // #2 : execute bit set in order -// t := db.binBatch -// t.Lock() -// defer t.Unlock() - -// var curBinKey, curSeg []byte -// var curSeq, maxSeq, maxOff uint32 - -// for _, info := range bitInfos { -// if curSeg != nil && info.Seq != curSeq { -// t.Put(curBinKey, curSeg) -// curSeg = nil -// } - -// if curSeg == nil { -// curSeq = info.Seq -// if curBinKey, curSeg, err = db.bAllocateSegment(key, info.Seq); err != nil { -// return -// } - -// if curSeg == nil { -// continue -// } -// } - -// if setBit(curSeg, info.Off, info.Val) { -// maxSeq = info.Seq -// maxOff = info.Off -// place++ -// } -// } - -// if curSeg != nil { -// t.Put(curBinKey, curSeg) -// } - -// // finally, update meta -// if place > 0 { -// if _, _, err = db.bUpdateMeta(t, key, maxSeq, maxOff); err != nil { -// return -// } - -// err = t.Commit() -// } - -// return -// } - -// func (db *DB) BGetBit(key []byte, offset int32) (uint8, error) { -// log.Error("bitmap type will be deprecated later, please use bit operations in kv type") - -// if seq, off, err := db.bParseOffset(key, offset); err != nil { -// return 0, err -// } else { -// _, segment, err := db.bGetSegment(key, seq) -// if err != nil { -// return 0, err -// } - -// if segment == nil { -// return 0, nil -// } else { -// return getBit(segment, off), nil -// } -// } -// } - -// // func (db *DB) BGetRange(key []byte, start int32, end int32) ([]byte, error) { -// // section := make([]byte) - -// // return -// // } - -// func (db *DB) BCount(key []byte, start int32, end int32) (cnt int32, err error) { -// log.Error("bitmap type will be deprecated later, please use bit operations in kv type") - -// var sseq, soff uint32 -// if sseq, soff, err = db.bParseOffset(key, start); err != nil { -// return -// } - -// var eseq, eoff uint32 -// if eseq, eoff, err = db.bParseOffset(key, end); err != nil { -// return -// } - -// if sseq > eseq || (sseq == eseq && soff > eoff) { -// sseq, eseq = eseq, sseq -// soff, eoff = eoff, soff -// } - -// var segCnt int32 -// if eseq == sseq { -// if segCnt, err = db.bCountSeg(key, sseq, soff, eoff); err != nil { -// return 0, err -// } - -// cnt = segCnt - -// } else { -// if segCnt, err = db.bCountSeg(key, sseq, soff, segBitSize-1); err != nil { -// return 0, err -// } else { -// cnt += segCnt -// } - -// if segCnt, err = db.bCountSeg(key, eseq, 0, eoff); err != nil { -// return 0, err -// } else { -// cnt += segCnt -// } -// } - -// // middle segs -// var segment []byte -// skey := db.bEncodeBinKey(key, sseq) -// ekey := db.bEncodeBinKey(key, eseq) - -// it := db.bucket.RangeIterator(skey, ekey, store.RangeOpen) -// for ; it.Valid(); it.Next() { -// segment = it.RawValue() -// for _, bt := range segment { -// cnt += bitsInByte[bt] -// } -// } -// it.Close() - -// return -// } - -// func (db *DB) BTail(key []byte) (int32, error) { -// log.Error("bitmap type will be deprecated later, please use bit operations in kv type") - -// // effective length of data, the highest bit-pos set in history -// tailSeq, tailOff, err := db.bGetMeta(key) -// if err != nil { -// return 0, err -// } - -// tail := int32(-1) -// if tailSeq >= 0 { -// tail = int32(uint32(tailSeq)< maxDstSeq || (seq == maxDstSeq && off > maxDstOff) { -// maxDstSeq = seq -// maxDstOff = off -// } -// } - -// if (op == OPnot && validKeyNum != 1) || -// (op != OPnot && validKeyNum < 2) { -// return // with not enough existing source key -// } - -// var srcIdx int -// for srcIdx = 0; srcIdx < keyNum; srcIdx++ { -// if srckeys[srcIdx] != nil { -// break -// } -// } - -// // init - data -// var segments = make([][]byte, maxDstSeq+1) - -// if op == OPnot { -// // ps : -// // ( ~num == num ^ 0x11111111 ) -// // we init the result segments with all bit set, -// // then we can calculate through the way of 'xor'. - -// // ahead segments bin format : 1111 ... 1111 -// for i := uint32(0); i < maxDstSeq; i++ { -// segments[i] = fillSegment -// } - -// // last segment bin format : 1111..1100..0000 -// var tailSeg = make([]byte, segByteSize, segByteSize) -// var fillByte = fillBits[7] -// var tailSegLen = db.bCapByteSize(uint32(0), maxDstOff) -// for i := uint32(0); i < tailSegLen-1; i++ { -// tailSeg[i] = fillByte -// } -// tailSeg[tailSegLen-1] = fillBits[maxDstOff-(tailSegLen-1)<<3] -// segments[maxDstSeq] = tailSeg - -// } else { -// // ps : init segments by data corresponding to the 1st valid source key -// it := db.bIterator(srckeys[srcIdx]) -// for ; it.Valid(); it.Next() { -// if _, seq, err = db.bDecodeBinKey(it.RawKey()); err != nil { -// // to do ... -// it.Close() -// return -// } -// segments[seq] = it.Value() -// } -// it.Close() -// srcIdx++ -// } - -// // operation with following keys -// var res []byte -// for i := srcIdx; i < keyNum; i++ { -// if srckeys[i] == nil { -// continue -// } - -// it := db.bIterator(srckeys[i]) -// for idx, end := uint32(0), false; !end; it.Next() { -// end = !it.Valid() -// if !end { -// if _, seq, err = db.bDecodeBinKey(it.RawKey()); err != nil { -// // to do ... -// it.Close() -// return -// } -// } else { -// seq = maxDstSeq + 1 -// } - -// // todo : -// // operation 'and' can be optimize here : -// // if seq > max_segments_idx, this loop can be break, -// // which can avoid cost from Key() and bDecodeBinKey() - -// for ; idx < seq; idx++ { -// res = nil -// exeOp(segments[idx], nil, &res) -// segments[idx] = res -// } - -// if !end { -// res = it.Value() -// exeOp(segments[seq], res, &res) -// segments[seq] = res -// idx++ -// } -// } -// it.Close() -// } - -// // clear the old data in case -// db.bDelete(t, dstkey) -// db.rmExpire(t, BitType, dstkey) - -// // set data -// db.bSetMeta(t, dstkey, maxDstSeq, maxDstOff) - -// var bk []byte -// for seq, segt := range segments { -// if segt != nil { -// bk = db.bEncodeBinKey(dstkey, uint32(seq)) -// t.Put(bk, segt) -// } -// } - -// err = t.Commit() -// if err == nil { -// // blen = int32(db.bCapByteSize(maxDstOff, maxDstOff)) -// blen = int32(maxDstSeq< 0 { -// bytes++ -// } - -// return make([]byte, bytes, bytes) -// } - -// func TestBinary(t *testing.T) { -// testSimple(t) -// testSimpleII(t) -// testCount(t) -// testOpAndOr(t) -// testOpXor(t) -// testOpNot(t) -// testMSetBit(t) -// testBitExpire(t) -// testBFlush(t) -// } - -// func testSimple(t *testing.T) { -// db := getTestDB() - -// key := []byte("test_bin") - -// if v, _ := db.BGetBit(key, 100); v != 0 { -// t.Error(v) -// } - -// if ori, _ := db.BSetBit(key, 50, 1); ori != 0 { -// t.Error(ori) -// } - -// if v, _ := db.BGetBit(key, 50); v != 1 { -// t.Error(v) -// } - -// if ori, _ := db.BSetBit(key, 50, 0); ori != 1 { -// t.Error(ori) -// } - -// if v, _ := db.BGetBit(key, 50); v != 0 { -// t.Error(v) -// } - -// db.BSetBit(key, 7, 1) -// db.BSetBit(key, 8, 1) -// db.BSetBit(key, 9, 1) -// db.BSetBit(key, 10, 1) - -// if sum, _ := db.BCount(key, 0, -1); sum != 4 { -// t.Error(sum) -// } - -// data, _ := db.BGet(key) -// if cmpBytes(data, []byte{0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00}) { -// t.Error(data) -// } - -// if tail, _ := db.BTail(key); tail != int32(50) { -// t.Error(tail) -// } -// } - -// func testSimpleII(t *testing.T) { -// db := getTestDB() -// db.FlushAll() - -// key := []byte("test_bin_2") - -// pos := int32(1234567) -// if ori, _ := db.BSetBit(key, pos, 1); ori != 0 { -// t.Error(ori) -// } - -// if v, _ := db.BGetBit(key, pos); v != 1 { -// t.Error(v) -// } - -// if v, _ := db.BGetBit(key, pos-1); v != 0 { -// t.Error(v) -// } - -// if v, _ := db.BGetBit(key, pos+1); v != 0 { -// t.Error(v) -// } - -// if tail, _ := db.BTail(key); tail != pos { -// t.Error(tail) -// } - -// data, _ := db.BGet(key) -// stdData := newBytes(pos + 1) -// stdData[pos/8] = uint8(1 << (uint(pos) % 8)) - -// if cmpBytes(data, stdData) { -// t.Error(len(data)) -// } - -// if drop, _ := db.BDelete(key); drop != 1 { -// t.Error(false) -// } - -// if data, _ := db.BGet(key); data != nil { -// t.Error(data) -// } -// } - -// func testCount(t *testing.T) { -// db := getTestDB() -// db.FlushAll() - -// key := []byte("test_bin_count") - -// if ori, _ := db.BSetBit(key, 0, 1); ori != 0 { -// t.Error(ori) -// } - -// if ori, _ := db.BSetBit(key, 10, 1); ori != 0 { -// t.Error(ori) -// } - -// if ori, _ := db.BSetBit(key, 262140, 1); ori != 0 { -// t.Error(ori) -// } - -// // count - -// if sum, _ := db.BCount(key, 0, -1); sum != 3 { -// t.Error(sum) -// } - -// if sum, _ := db.BCount(key, 0, 9); sum != 1 { -// t.Error(sum) -// } - -// if sum, _ := db.BCount(key, 0, 10); sum != 2 { -// t.Error(sum) -// } - -// if sum, _ := db.BCount(key, 0, 11); sum != 2 { -// t.Error(sum) -// } - -// if sum, _ := db.BCount(key, 0, 262139); sum != 2 { -// t.Error(sum) -// } - -// if sum, _ := db.BCount(key, 0, 262140); sum != 3 { -// t.Error(sum) -// } - -// if sum, _ := db.BCount(key, 0, 262141); sum != 3 { -// t.Error(sum) -// } - -// if sum, _ := db.BCount(key, 10, 262140); sum != 2 { -// t.Error(sum) -// } - -// if sum, _ := db.BCount(key, 11, 262140); sum != 1 { -// t.Error(sum) -// } - -// if sum, _ := db.BCount(key, 11, 262139); sum != 0 { -// t.Error(sum) -// } - -// key = []byte("test_bin_count_2") - -// db.BSetBit(key, 1, 1) -// db.BSetBit(key, 2, 1) -// db.BSetBit(key, 4, 1) -// db.BSetBit(key, 6, 1) - -// if sum, _ := db.BCount(key, 0, -1); sum != 4 { -// t.Error(sum) -// } - -// if sum, _ := db.BCount(key, 1, 1); sum != 1 { -// t.Error(sum) -// } - -// if sum, _ := db.BCount(key, 0, 7); sum != 4 { -// t.Error(sum) -// } - -// if ori, _ := db.BSetBit(key, 8, 1); ori != 0 { -// t.Error(ori) -// } - -// if ori, _ := db.BSetBit(key, 11, 1); ori != 0 { -// t.Error(ori) -// } - -// if sum, _ := db.BCount(key, 0, -1); sum != 6 { -// t.Error(sum) -// } - -// if sum, _ := db.BCount(key, 0, 16); sum != 6 { -// t.Error(sum) -// } -// } - -// func testOpAndOr(t *testing.T) { -// db := getTestDB() -// db.FlushAll() - -// dstKey := []byte("test_bin_op_and_or") - -// k0 := []byte("op_0") -// k1 := []byte("op_01") -// k2 := []byte("op_10") -// k3 := []byte("op_11") -// srcKeys := [][]byte{k2, k0, k1, k3} - -// /* -// -// - ... -// 0 - [10000000] ... [00000001] -// 1 - nil -// 2 - [00000000] ... [11111111] ... [00000000] -// 3 - [01010101] ... [10000001] [10101010] -// 4 - [10000000] ... [00000000] -// 5 - [00000000] ... [00000011] [00000001] -// ... -// */ -// // (k0 - seg:0) -// db.BSetBit(k0, int32(0), 1) -// db.BSetBit(k0, int32(segBitSize-1), 1) -// // (k0 - seg:2) -// pos := segBitSize*2 + segBitSize/2 -// for i := uint32(0); i < 8; i++ { -// db.BSetBit(k0, int32(pos+i), 1) -// } -// // (k0 - seg:3) -// pos = segBitSize * 3 -// db.BSetBit(k0, int32(pos+8), 1) -// db.BSetBit(k0, int32(pos+15), 1) -// for i := uint32(1); i < 8; i += 2 { -// db.BSetBit(k0, int32(pos+i), 1) -// } -// pos = segBitSize*4 - 8 -// for i := uint32(0); i < 8; i += 2 { -// db.BSetBit(k0, int32(pos+i), 1) -// } -// // (k0 - seg:4) -// db.BSetBit(k0, int32(segBitSize*5-1), 1) -// // (k0 - seg:5) -// db.BSetBit(k0, int32(segBitSize*5), 1) -// db.BSetBit(k0, int32(segBitSize*5+8), 1) -// db.BSetBit(k0, int32(segBitSize*5+9), 1) - -// /* -// -// 0 - nil -// 1 - [00000001] ... [10000000] -// 2 - nil -// 3 - [10101010] ... [10000001] [01010101] -// ... -// */ -// // (k1 - seg:1) -// db.BSetBit(k1, int32(segBitSize+7), 1) -// db.BSetBit(k1, int32(segBitSize*2-8), 1) -// // (k1 - seg:3) -// pos = segBitSize * 3 -// db.BSetBit(k1, int32(pos+8), 1) -// db.BSetBit(k1, int32(pos+15), 1) -// for i := uint32(0); i < 8; i += 2 { -// db.BSetBit(k0, int32(pos+i), 1) -// } -// pos = segBitSize*4 - 8 -// for i := uint32(1); i < 8; i += 2 { -// db.BSetBit(k0, int32(pos+i), 1) -// } - -// var stdData []byte -// var data []byte -// var tmpKeys [][]byte - -// // op - or -// db.BOperation(OPor, dstKey, srcKeys...) - -// stdData = make([]byte, 5*segByteSize+2) -// stdData[0] = uint8(0x01) -// stdData[segByteSize-1] = uint8(0x80) -// stdData[segByteSize] = uint8(0x80) -// stdData[segByteSize*2-1] = uint8(0x01) -// stdData[segByteSize*2+segByteSize/2] = uint8(0xff) -// stdData[segByteSize*3] = uint8(0xff) -// stdData[segByteSize*3+1] = uint8(0x81) -// stdData[segByteSize*4-1] = uint8(0xff) -// stdData[segByteSize*5-1] = uint8(0x80) -// stdData[segByteSize*5] = uint8(0x01) -// stdData[segByteSize*5+1] = uint8(0x03) - -// data, _ = db.BGet(dstKey) -// if cmpBytes(data, stdData) { -// t.Fatal(false) -// } - -// tmpKeys = [][]byte{k0, dstKey, k1} -// db.BOperation(OPor, dstKey, tmpKeys...) - -// data, _ = db.BGet(dstKey) -// if cmpBytes(data, stdData) { -// t.Fatal(false) -// } - -// // op - and -// db.BOperation(OPand, dstKey, srcKeys...) - -// stdData = make([]byte, 5*segByteSize+2) -// stdData[segByteSize*3+1] = uint8(0x81) - -// data, _ = db.BGet(dstKey) -// if cmpBytes(data, stdData) { -// t.Fatal(false) -// } - -// tmpKeys = [][]byte{k0, dstKey, k1} -// db.BOperation(OPand, dstKey, tmpKeys...) - -// data, _ = db.BGet(dstKey) -// if cmpBytes(data, stdData) { -// t.Fatal(false) -// } - -// } - -// func testOpAnd(t *testing.T) { -// db := getTestDB() -// db.FlushAll() - -// dstKey := []byte("test_bin_or") - -// k0 := []byte("op_or_0") -// k1 := []byte("op_or_01") -// srcKeys := [][]byte{k0, k1} - -// db.BSetBit(k0, 0, 1) -// db.BSetBit(k0, 2, 1) - -// db.BSetBit(k1, 1, 1) - -// if blen, _ := db.BOperation(OPand, dstKey, srcKeys...); blen != 3 { -// t.Fatal(blen) -// } - -// if cnt, _ := db.BCount(dstKey, 0, -1); cnt != 1 { -// t.Fatal(1) -// } -// } - -// func testOpXor(t *testing.T) { -// db := getTestDB() -// db.FlushAll() - -// dstKey := []byte("test_bin_op_xor") - -// k0 := []byte("op_xor_00") -// k1 := []byte("op_xor_01") -// srcKeys := [][]byte{k0, k1} - -// reqs := make([]BitPair, 4) -// reqs[0] = BitPair{0, 1} -// reqs[1] = BitPair{7, 1} -// reqs[2] = BitPair{int32(segBitSize - 1), 1} -// reqs[3] = BitPair{int32(segBitSize - 8), 1} -// db.BMSetBit(k0, reqs...) - -// reqs = make([]BitPair, 2) -// reqs[0] = BitPair{7, 1} -// reqs[1] = BitPair{int32(segBitSize - 8), 1} -// db.BMSetBit(k1, reqs...) - -// var stdData []byte -// var data []byte - -// // op - xor -// db.BOperation(OPxor, dstKey, srcKeys...) - -// stdData = make([]byte, segByteSize) -// stdData[0] = uint8(0x01) -// stdData[segByteSize-1] = uint8(0x80) - -// data, _ = db.BGet(dstKey) -// if cmpBytes(data, stdData) { -// t.Fatal(false) -// } -// } - -// func testOpNot(t *testing.T) { -// db := getTestDB() -// db.FlushAll() - -// // intputs -// dstKey := []byte("test_bin_op_not") - -// k0 := []byte("op_not_0") -// srcKeys := [][]byte{k0} - -// db.BSetBit(k0, int32(0), 1) -// db.BSetBit(k0, int32(7), 1) - -// pos := segBitSize -// for i := uint32(8); i >= 1; i -= 2 { -// db.BSetBit(k0, int32(pos-i), 1) -// } - -// db.BSetBit(k0, int32(3*segBitSize-10), 1) - -// // std -// stdData := make([]byte, segByteSize*3-1) -// for i, _ := range stdData { -// stdData[i] = 255 -// } -// stdData[0] = uint8(0x7e) -// stdData[segByteSize-1] = uint8(0xaa) -// stdData[segByteSize*3-2] = uint8(0x3f) - -// // op - not -// db.BOperation(OPnot, dstKey, srcKeys...) - -// data, _ := db.BGet(dstKey) -// if cmpBytes(data, stdData) { -// t.Fatal(false) -// } - -// k1 := []byte("op_not_2") -// srcKeys = [][]byte{k1} - -// db.BSetBit(k1, 0, 1) -// db.BSetBit(k1, 2, 1) -// db.BSetBit(k1, 4, 1) -// db.BSetBit(k1, 6, 1) - -// if blen, _ := db.BOperation(OPnot, dstKey, srcKeys...); blen != 7 { -// t.Fatal(blen) -// } - -// if cnt, _ := db.BCount(dstKey, 0, -1); cnt != 3 { -// t.Fatal(cnt) -// } -// } - -// func testMSetBit(t *testing.T) { -// db := getTestDB() -// db.FlushAll() - -// key := []byte("test_mset") - -// var datas = make([]BitPair, 8) - -// // 1st -// datas[0] = BitPair{1000, 1} -// datas[1] = BitPair{11, 1} -// datas[2] = BitPair{10, 1} -// datas[3] = BitPair{2, 1} -// datas[4] = BitPair{int32(segBitSize - 1), 1} -// datas[5] = BitPair{int32(segBitSize), 1} -// datas[6] = BitPair{int32(segBitSize + 1), 1} -// datas[7] = BitPair{int32(segBitSize) + 10, 0} - -// db.BMSetBit(key, datas...) - -// if sum, _ := db.BCount(key, 0, -1); sum != 7 { -// t.Error(sum) -// } - -// if tail, _ := db.BTail(key); tail != int32(segBitSize+10) { -// t.Error(tail) -// } - -// // 2nd -// datas = make([]BitPair, 5) - -// datas[0] = BitPair{1000, 0} -// datas[1] = BitPair{int32(segBitSize + 1), 0} -// datas[2] = BitPair{int32(segBitSize * 10), 1} -// datas[3] = BitPair{10, 0} -// datas[4] = BitPair{99, 0} - -// db.BMSetBit(key, datas...) - -// if sum, _ := db.BCount(key, 0, -1); sum != 7-3+1 { -// t.Error(sum) -// } - -// if tail, _ := db.BTail(key); tail != int32(segBitSize*10) { -// t.Error(tail) -// } - -// return -// } - -// func testBitExpire(t *testing.T) { -// db := getTestDB() -// db.FlushAll() - -// key := []byte("test_b_ttl") - -// db.BSetBit(key, 0, 1) - -// if res, err := db.BExpire(key, 100); res != 1 || err != nil { -// t.Fatal(false) -// } - -// if ttl, err := db.BTTL(key); ttl != 100 || err != nil { -// t.Fatal(false) -// } -// } - -// func testBFlush(t *testing.T) { -// db := getTestDB() -// db.FlushAll() - -// for i := 0; i < 2000; i++ { -// key := make([]byte, 4) -// binary.LittleEndian.PutUint32(key, uint32(i)) -// if _, err := db.BSetBit(key, 1, 1); err != nil { -// t.Fatal(err.Error()) -// } -// } - -// if v, err := db.BScan(nil, 3000, true, ""); err != nil { -// t.Fatal(err.Error()) -// } else if len(v) != 2000 { -// t.Fatal("invalid value ", len(v)) -// } - -// for i := 0; i < 2000; i++ { -// key := make([]byte, 4) -// binary.LittleEndian.PutUint32(key, uint32(i)) -// if v, err := db.BGetBit(key, 1); err != nil { -// t.Fatal(err.Error()) -// } else if v != 1 { -// t.Fatal("invalid value ", v) -// } -// } - -// if n, err := db.bFlush(); err != nil { -// t.Fatal(err.Error()) -// } else if n != 2000 { -// t.Fatal("invalid value ", n) -// } - -// if v, err := db.BScan(nil, 3000, true, ""); err != nil { -// t.Fatal(err.Error()) -// } else if len(v) != 0 { -// t.Fatal("invalid value length ", len(v)) -// } - -// for i := 0; i < 2000; i++ { -// key := make([]byte, 4) -// binary.LittleEndian.PutUint32(key, uint32(i)) -// if v, err := db.BGet(key); err != nil { -// t.Fatal(err.Error()) -// } else if v != nil { - -// t.Fatal("invalid value ", v) -// } -// } - -// } diff --git a/ledis/tx.go b/ledis/tx.go deleted file mode 100644 index b4ef9fb..0000000 --- a/ledis/tx.go +++ /dev/null @@ -1,114 +0,0 @@ -package ledis - -// import ( -// "errors" -// "fmt" -// "github.com/siddontang/go/log" -// "github.com/siddontang/ledisdb/store" -// ) - -// var ( -// ErrNestTx = errors.New("nest transaction not supported") -// ErrTxDone = errors.New("Transaction has already been committed or rolled back") -// ) - -// type Tx struct { -// *DB - -// tx *store.Tx - -// data *store.BatchData -// } - -// func (db *DB) IsTransaction() bool { -// return db.status == DBInTransaction -// } - -// // Begin a transaction, it will block all other write operations before calling Commit or Rollback. -// // You must be very careful to prevent long-time transaction. -// func (db *DB) Begin() (*Tx, error) { -// log.Warn("Transaction support will be removed later, use your own risk!!!") - -// if db.IsTransaction() { -// return nil, ErrNestTx -// } - -// tx := new(Tx) - -// tx.data = &store.BatchData{} - -// tx.DB = new(DB) -// tx.DB.l = db.l - -// tx.l.wLock.Lock() - -// tx.DB.sdb = db.sdb - -// var err error -// tx.tx, err = db.sdb.Begin() -// if err != nil { -// tx.l.wLock.Unlock() -// return nil, err -// } - -// tx.DB.bucket = tx.tx - -// tx.DB.status = DBInTransaction - -// tx.DB.index = db.index - -// tx.DB.kvBatch = tx.newBatch() -// tx.DB.listBatch = tx.newBatch() -// tx.DB.hashBatch = tx.newBatch() -// tx.DB.zsetBatch = tx.newBatch() -// tx.DB.setBatch = tx.newBatch() - -// tx.DB.lbkeys = db.lbkeys - -// return tx, nil -// } - -// func (tx *Tx) Commit() error { -// if tx.tx == nil { -// return ErrTxDone -// } - -// err := tx.l.handleCommit(tx.data, tx.tx) -// tx.data.Reset() - -// tx.tx = nil - -// tx.l.wLock.Unlock() - -// tx.DB.bucket = nil - -// return err -// } - -// func (tx *Tx) Rollback() error { -// if tx.tx == nil { -// return ErrTxDone -// } - -// err := tx.tx.Rollback() -// tx.data.Reset() -// tx.tx = nil - -// tx.l.wLock.Unlock() -// tx.DB.bucket = nil - -// return err -// } - -// func (tx *Tx) newBatch() *batch { -// return tx.l.newBatch(tx.tx.NewWriteBatch(), &txBatchLocker{}, tx) -// } - -// func (tx *Tx) Select(index int) error { -// if index < 0 || index >= int(tx.l.cfg.Databases) { -// return fmt.Errorf("invalid db index %d", index) -// } - -// tx.DB.index = uint8(index) -// return nil -// } diff --git a/ledis/tx_test.go b/ledis/tx_test.go deleted file mode 100644 index 40e6a74..0000000 --- a/ledis/tx_test.go +++ /dev/null @@ -1,224 +0,0 @@ -package ledis - -// import ( -// "github.com/siddontang/ledisdb/config" -// "os" -// "strings" -// "testing" -// ) - -// func testTxRollback(t *testing.T, db *DB) { -// var err error -// key1 := []byte("tx_key1") -// key2 := []byte("tx_key2") -// field2 := []byte("tx_field2") - -// err = db.Set(key1, []byte("value")) -// if err != nil { -// t.Fatal(err) -// } - -// _, err = db.HSet(key2, field2, []byte("value")) -// if err != nil { -// t.Fatal(err) -// } - -// var tx *Tx -// tx, err = db.Begin() -// if err != nil { -// t.Fatal(err) -// } - -// defer tx.Rollback() - -// err = tx.Set(key1, []byte("1")) - -// if err != nil { -// t.Fatal(err) -// } - -// _, err = tx.HSet(key2, field2, []byte("2")) - -// if err != nil { -// t.Fatal(err) -// } - -// _, err = tx.HSet([]byte("no_key"), field2, []byte("2")) - -// if err != nil { -// t.Fatal(err) -// } - -// if v, err := tx.Get(key1); err != nil { -// t.Fatal(err) -// } else if string(v) != "1" { -// t.Fatal(string(v)) -// } - -// if v, err := tx.HGet(key2, field2); err != nil { -// t.Fatal(err) -// } else if string(v) != "2" { -// t.Fatal(string(v)) -// } - -// err = tx.Rollback() -// if err != nil { -// t.Fatal(err) -// } - -// if v, err := db.Get(key1); err != nil { -// t.Fatal(err) -// } else if string(v) != "value" { -// t.Fatal(string(v)) -// } - -// if v, err := db.HGet(key2, field2); err != nil { -// t.Fatal(err) -// } else if string(v) != "value" { -// t.Fatal(string(v)) -// } -// } - -// func testTxCommit(t *testing.T, db *DB) { -// var err error -// key1 := []byte("tx_key1") -// key2 := []byte("tx_key2") -// field2 := []byte("tx_field2") - -// err = db.Set(key1, []byte("value")) -// if err != nil { -// t.Fatal(err) -// } - -// _, err = db.HSet(key2, field2, []byte("value")) -// if err != nil { -// t.Fatal(err) -// } - -// var tx *Tx -// tx, err = db.Begin() -// if err != nil { -// t.Fatal(err) -// } - -// defer tx.Rollback() - -// err = tx.Set(key1, []byte("1")) - -// if err != nil { -// t.Fatal(err) -// } - -// _, err = tx.HSet(key2, field2, []byte("2")) - -// if err != nil { -// t.Fatal(err) -// } - -// if v, err := tx.Get(key1); err != nil { -// t.Fatal(err) -// } else if string(v) != "1" { -// t.Fatal(string(v)) -// } - -// if v, err := tx.HGet(key2, field2); err != nil { -// t.Fatal(err) -// } else if string(v) != "2" { -// t.Fatal(string(v)) -// } - -// err = tx.Commit() -// if err != nil { -// t.Fatal(err) -// } - -// if v, err := db.Get(key1); err != nil { -// t.Fatal(err) -// } else if string(v) != "1" { -// t.Fatal(string(v)) -// } - -// if v, err := db.HGet(key2, field2); err != nil { -// t.Fatal(err) -// } else if string(v) != "2" { -// t.Fatal(string(v)) -// } -// } - -// func testTxSelect(t *testing.T, db *DB) { -// tx, err := db.Begin() -// if err != nil { -// t.Fatal(err) -// } - -// defer tx.Rollback() - -// tx.Set([]byte("tx_select_1"), []byte("a")) - -// tx.Select(1) - -// tx.Set([]byte("tx_select_2"), []byte("b")) - -// if err = tx.Commit(); err != nil { -// t.Fatal(err) -// } - -// if v, err := db.Get([]byte("tx_select_1")); err != nil { -// t.Fatal(err) -// } else if string(v) != "a" { -// t.Fatal(string(v)) -// } - -// if v, err := db.Get([]byte("tx_select_2")); err != nil { -// t.Fatal(err) -// } else if v != nil { -// t.Fatal("must nil") -// } - -// db, _ = db.l.Select(1) - -// if v, err := db.Get([]byte("tx_select_2")); err != nil { -// t.Fatal(err) -// } else if string(v) != "b" { -// t.Fatal(string(v)) -// } - -// if v, err := db.Get([]byte("tx_select_1")); err != nil { -// t.Fatal(err) -// } else if v != nil { -// t.Fatal("must nil") -// } -// } - -// func testTx(t *testing.T, name string) { -// cfg := config.NewConfigDefault() -// cfg.DataDir = "/tmp/ledis_test_tx" - -// cfg.DBName = name -// cfg.LMDB.MapSize = 10 * 1024 * 1024 -// //cfg.UseReplication = true - -// os.RemoveAll(cfg.DataDir) - -// l, err := Open(cfg) -// if err != nil { -// if strings.Contains(err.Error(), "not registered") { -// return -// } -// t.Fatal(err) -// } - -// defer l.Close() - -// db, _ := l.Select(0) - -// testTxRollback(t, db) -// testTxCommit(t, db) -// testTxSelect(t, db) -// } - -// //only lmdb, boltdb support Transaction -// func TestTx(t *testing.T) { -// testTx(t, "lmdb") -// testTx(t, "boltdb") -// } diff --git a/server/cmd_bit.go b/server/cmd_bit.go deleted file mode 100644 index cfe0a45..0000000 --- a/server/cmd_bit.go +++ /dev/null @@ -1,289 +0,0 @@ -package server - -// import ( -// "github.com/siddontang/go/hack" - -// "github.com/siddontang/ledisdb/ledis" -// "strings" -// ) - -// func bgetCommand(c *client) error { -// args := c.args -// if len(args) != 1 { -// return ErrCmdParams -// } - -// if v, err := c.db.BGet(args[0]); err != nil { -// return err -// } else { -// c.resp.writeBulk(v) -// } -// return nil -// } - -// func bdeleteCommand(c *client) error { -// args := c.args -// if len(args) != 1 { -// return ErrCmdParams -// } - -// if n, err := c.db.BDelete(args[0]); err != nil { -// return err -// } else { -// c.resp.writeInteger(n) -// } -// return nil -// } - -// func bsetbitCommand(c *client) error { -// args := c.args -// if len(args) != 3 { -// return ErrCmdParams -// } - -// var err error -// var offset int32 -// var val int8 - -// offset, err = ledis.StrInt32(args[1], nil) - -// if err != nil { -// return ErrOffset -// } - -// val, err = ledis.StrInt8(args[2], nil) -// if val != 0 && val != 1 { -// return ErrBool -// } - -// if err != nil { -// return ErrBool -// } - -// if ori, err := c.db.BSetBit(args[0], offset, uint8(val)); err != nil { -// return err -// } else { -// c.resp.writeInteger(int64(ori)) -// } -// return nil -// } - -// func bgetbitCommand(c *client) error { -// args := c.args -// if len(args) != 2 { -// return ErrCmdParams -// } - -// offset, err := ledis.StrInt32(args[1], nil) - -// if err != nil { -// return ErrOffset -// } - -// if v, err := c.db.BGetBit(args[0], offset); err != nil { -// return err -// } else { -// c.resp.writeInteger(int64(v)) -// } -// return nil -// } - -// func bmsetbitCommand(c *client) error { -// args := c.args -// if len(args) < 3 { -// return ErrCmdParams -// } - -// key := args[0] -// if len(args[1:])&1 != 0 { -// return ErrCmdParams -// } else { -// args = args[1:] -// } - -// var err error -// var offset int32 -// var val int8 - -// pairs := make([]ledis.BitPair, len(args)>>1) -// for i := 0; i < len(pairs); i++ { -// offset, err = ledis.StrInt32(args[i<<1], nil) - -// if err != nil { -// return ErrOffset -// } - -// val, err = ledis.StrInt8(args[i<<1+1], nil) -// if val != 0 && val != 1 { -// return ErrBool -// } - -// if err != nil { -// return ErrBool -// } - -// pairs[i].Pos = offset -// pairs[i].Val = uint8(val) -// } - -// if place, err := c.db.BMSetBit(key, pairs...); err != nil { -// return err -// } else { -// c.resp.writeInteger(place) -// } -// return nil -// } - -// func bcountCommand(c *client) error { -// args := c.args -// argCnt := len(args) - -// if !(argCnt > 0 && argCnt <= 3) { -// return ErrCmdParams -// } - -// // BCount(key []byte, start int32, end int32) (cnt int32, err error) { - -// var err error -// var start, end int32 = 0, -1 - -// if argCnt > 1 { -// start, err = ledis.StrInt32(args[1], nil) -// if err != nil { -// return ErrValue -// } -// } - -// if argCnt > 2 { -// end, err = ledis.StrInt32(args[2], nil) -// if err != nil { -// return ErrValue -// } -// } - -// if cnt, err := c.db.BCount(args[0], start, end); err != nil { -// return err -// } else { -// c.resp.writeInteger(int64(cnt)) -// } -// return nil -// } - -// func boptCommand(c *client) error { -// args := c.args -// if len(args) < 2 { -// return ErrCmdParams -// } - -// opDesc := strings.ToLower(hack.String(args[0])) -// dstKey := args[1] -// srcKeys := args[2:] - -// var op uint8 -// switch opDesc { -// case "and": -// op = ledis.OPand -// case "or": -// op = ledis.OPor -// case "xor": -// op = ledis.OPxor -// case "not": -// op = ledis.OPnot -// default: -// return ErrCmdParams -// } - -// if len(srcKeys) == 0 { -// return ErrCmdParams -// } -// if blen, err := c.db.BOperation(op, dstKey, srcKeys...); err != nil { -// return err -// } else { -// c.resp.writeInteger(int64(blen)) -// } -// return nil -// } - -// func bexpireCommand(c *client) error { -// args := c.args -// if len(args) != 2 { -// return ErrCmdParams -// } - -// duration, err := ledis.StrInt64(args[1], nil) -// if err != nil { -// return ErrValue -// } - -// if v, err := c.db.BExpire(args[0], duration); err != nil { -// return err -// } else { -// c.resp.writeInteger(v) -// } - -// return nil -// } - -// func bexpireAtCommand(c *client) error { -// args := c.args -// if len(args) != 2 { -// return ErrCmdParams -// } - -// when, err := ledis.StrInt64(args[1], nil) -// if err != nil { -// return ErrValue -// } - -// if v, err := c.db.BExpireAt(args[0], when); err != nil { -// return err -// } else { -// c.resp.writeInteger(v) -// } - -// return nil -// } - -// func bttlCommand(c *client) error { -// args := c.args -// if len(args) != 1 { -// return ErrCmdParams -// } - -// if v, err := c.db.BTTL(args[0]); err != nil { -// return err -// } else { -// c.resp.writeInteger(v) -// } - -// return nil -// } - -// func bpersistCommand(c *client) error { -// args := c.args -// if len(args) != 1 { -// return ErrCmdParams -// } - -// if n, err := c.db.BPersist(args[0]); err != nil { -// return err -// } else { -// c.resp.writeInteger(n) -// } - -// return nil -// } - -// func init() { -// register("bget", bgetCommand) -// register("bdelete", bdeleteCommand) -// register("bsetbit", bsetbitCommand) -// register("bgetbit", bgetbitCommand) -// register("bmsetbit", bmsetbitCommand) -// register("bcount", bcountCommand) -// register("bopt", boptCommand) -// register("bexpire", bexpireCommand) -// register("bexpireat", bexpireAtCommand) -// register("bttl", bttlCommand) -// register("bpersist", bpersistCommand) -// } diff --git a/server/cmd_bit_test.go b/server/cmd_bit_test.go deleted file mode 100644 index f67e0aa..0000000 --- a/server/cmd_bit_test.go +++ /dev/null @@ -1,367 +0,0 @@ -package server - -// import ( -// "github.com/siddontang/goredis" -// "testing" -// ) - -// func TestBit(t *testing.T) { -// testBitGetSet(t) -// testBitMset(t) -// testBitCount(t) -// testBitOpt(t) -// } - -// func testBitGetSet(t *testing.T) { -// c := getTestConn() -// defer c.Close() - -// key := []byte("test_cmd_bin_basic") - -// // get / set -// if v, err := goredis.Int(c.Do("bgetbit", key, 1024)); err != nil { -// t.Fatal(err) -// } else if v != 0 { -// t.Fatal(v) -// } - -// if ori, err := goredis.Int(c.Do("bsetbit", key, 1024, 1)); err != nil { -// t.Fatal(err) -// } else if ori != 0 { -// t.Fatal(ori) -// } - -// if v, err := goredis.Int(c.Do("bgetbit", key, 1024)); err != nil { -// t.Fatal(err) -// } else if v != 1 { -// t.Fatal(v) -// } - -// // fetch from revert pos -// c.Do("bsetbit", key, 1000, 1) - -// if v, err := goredis.Int(c.Do("bgetbit", key, -1)); err != nil { -// t.Fatal(err) -// } else if v != 1 { -// t.Fatal(v) -// } - -// if v, err := goredis.Int(c.Do("bgetbit", key, -25)); err != nil { -// t.Fatal(err) -// } else if v != 1 { -// t.Fatal(v) -// } - -// // delete -// if drop, err := goredis.Int(c.Do("bdelete", key)); err != nil { -// t.Fatal(err) -// } else if drop != 1 { -// t.Fatal(drop) -// } - -// if drop, err := goredis.Int(c.Do("bdelete", key)); err != nil { -// t.Fatal(err) -// } else if drop != 0 { -// t.Fatal(drop) -// } -// } - -// func testBitMset(t *testing.T) { -// c := getTestConn() -// defer c.Close() - -// key := []byte("test_cmd_bin_mset") - -// if n, err := goredis.Int( -// c.Do("bmsetbit", key, -// 500, 0, -// 100, 1, -// 200, 1, -// 1000, 1, -// 900, 0, -// 500000, 1, -// 600, 0, -// 300, 1, -// 100000, 1)); err != nil { -// t.Fatal(err) -// } else if n != 9 { -// t.Fatal(n) -// } - -// fillPos := []int{100, 200, 300, 1000, 100000, 500000} -// for _, pos := range fillPos { -// v, err := goredis.Int(c.Do("bgetbit", key, pos)) -// if err != nil || v != 1 { -// t.Fatal(pos) -// } -// } - -// // err -// if n, err := goredis.Int( -// c.Do("bmsetbit", key, 3, 0, 2, 1, 3, 0, 1, 1)); err == nil || n != 0 { -// t.Fatal(n) // duplication on pos -// } -// } - -// func testBitCount(t *testing.T) { -// c := getTestConn() -// defer c.Close() - -// key := []byte("test_cmd_bin_count") -// sum := 0 -// for pos := 1; pos < 1000000; pos += 10001 { -// c.Do("bsetbit", key, pos, 1) -// sum++ -// } - -// if n, err := goredis.Int(c.Do("bcount", key)); err != nil { -// t.Fatal(err) -// } else if n != sum { -// t.Fatal(n) -// } -// } - -// func testBitOpt(t *testing.T) { -// c := getTestConn() -// defer c.Close() - -// dstk := []byte("bin_op_res") -// kmiss := []byte("bin_op_miss") - -// k0 := []byte("bin_op_0") -// k1 := []byte("bin_op_1") -// c.Do("bmsetbit", k0, 10, 1, 30, 1, 50, 1, 70, 1, 100, 1) -// c.Do("bmsetbit", k1, 20, 1, 40, 1, 60, 1, 80, 1, 100, 1) - -// // case - lack of args -// // todo ... - -// // case - 'not' on inexisting key -// if blen, err := goredis.Int( -// c.Do("bopt", "not", dstk, kmiss)); err != nil { -// t.Fatal(err) -// } else if blen != 0 { -// t.Fatal(blen) -// } - -// if v, _ := goredis.String(c.Do("bget", dstk)); v != "" { -// t.Fatal(v) -// } - -// // case - 'and', 'or', 'xor' with inexisting key -// opts := []string{"and", "or", "xor"} -// for _, op := range opts { -// if blen, err := goredis.Int( -// c.Do("bopt", op, dstk, kmiss, k0)); err != nil { -// t.Fatal(err) -// } else if blen != 0 { -// t.Fatal(blen) -// } -// } - -// // case - 'and' -// if blen, err := goredis.Int( -// c.Do("bopt", "and", dstk, k0, k1)); err != nil { -// t.Fatal(err) -// } else if blen != 101 { -// t.Fatal(blen) -// } - -// if v, _ := goredis.Int(c.Do("bgetbit", dstk, 100)); v != 1 { -// t.Fatal(v) -// } - -// if v, _ := goredis.Int(c.Do("bgetbit", dstk, 20)); v != 0 { -// t.Fatal(v) -// } - -// if v, _ := goredis.Int(c.Do("bgetbit", dstk, 40)); v != 0 { -// t.Fatal(v) -// } - -// // case - 'or' -// if blen, err := goredis.Int( -// c.Do("bopt", "or", dstk, k0, k1)); err != nil { -// t.Fatal(err) -// } else if blen != 101 { -// t.Fatal(blen) -// } - -// if v, _ := goredis.Int(c.Do("bgetbit", dstk, 100)); v != 1 { -// t.Fatal(v) -// } - -// if v, _ := goredis.Int(c.Do("bgetbit", dstk, 20)); v != 1 { -// t.Fatal(v) -// } - -// if v, _ := goredis.Int(c.Do("bgetbit", dstk, 40)); v != 1 { -// t.Fatal(v) -// } - -// // case - 'xor' -// if blen, err := goredis.Int( -// c.Do("bopt", "xor", dstk, k0, k1)); err != nil { -// t.Fatal(err) -// } else if blen != 101 { -// t.Fatal(blen) -// } - -// if v, _ := goredis.Int(c.Do("bgetbit", dstk, 100)); v != 0 { -// t.Fatal(v) -// } - -// if v, _ := goredis.Int(c.Do("bgetbit", dstk, 20)); v != 1 { -// t.Fatal(v) -// } - -// if v, _ := goredis.Int(c.Do("bgetbit", dstk, 40)); v != 1 { -// t.Fatal(v) -// } - -// return -// } - -// func TestBitErrorParams(t *testing.T) { -// c := getTestConn() -// defer c.Close() - -// if _, err := c.Do("bget"); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// if _, err := c.Do("bdelete"); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// // bsetbit -// if _, err := c.Do("bsetbit"); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// if _, err := c.Do("bsetbit", "test_bsetbit"); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// if _, err := c.Do("bsetbit", "test_bsetbit", "o", "v"); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// if _, err := c.Do("bsetbit", "test_bsetbit", "o", 1); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// // if _, err := c.Do("bsetbit", "test_bsetbit", -1, 1); err == nil { -// // t.Fatal("invalid err of %v", err) -// // } - -// if _, err := c.Do("bsetbit", "test_bsetbit", 1, "v"); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// if _, err := c.Do("bsetbit", "test_bsetbit", 1, 2); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// //bgetbit -// if _, err := c.Do("bgetbit", "test_bgetbit"); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// if _, err := c.Do("bgetbit", "test_bgetbit", "o"); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// // if _, err := c.Do("bgetbit", "test_bgetbit", -1); err == nil { -// // t.Fatal("invalid err of %v", err) -// // } - -// //bmsetbit -// if _, err := c.Do("bmsetbit", "test_bmsetbit"); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// if _, err := c.Do("bmsetbit", "test_bmsetbit", 0, 1, 2); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// if _, err := c.Do("bmsetbit", "test_bmsetbit", "o", "v"); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// if _, err := c.Do("bmsetbit", "test_bmsetbit", "o", 1); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// // if _, err := c.Do("bmsetbit", "test_bmsetbit", -1, 1); err == nil { -// // t.Fatal("invalid err of %v", err) -// // } - -// if _, err := c.Do("bmsetbit", "test_bmsetbit", 1, "v"); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// if _, err := c.Do("bmsetbit", "test_bmsetbit", 1, 2); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// if _, err := c.Do("bmsetbit", "test_bmsetbit", 1, 0.1); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// //bcount - -// if _, err := c.Do("bcount"); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// if _, err := c.Do("bcount", "a", "b", "c"); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// if _, err := c.Do("bcount", 1, "a"); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// // if _, err := c.Do("bcount", 1); err == nil { -// // t.Fatal("invalid err of %v", err) -// // } - -// //bopt -// if _, err := c.Do("bopt"); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// if _, err := c.Do("bopt", "and", 1); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// if _, err := c.Do("bopt", "x", 1); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// if _, err := c.Do("bopt", ""); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// //bexpire -// if _, err := c.Do("bexpire", "test_bexpire"); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// //bexpireat -// if _, err := c.Do("bexpireat", "test_bexpireat"); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// //bttl -// if _, err := c.Do("bttl"); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// //bpersist -// if _, err := c.Do("bpersist"); err == nil { -// t.Fatal("invalid err of %v", err) -// } - -// } diff --git a/server/cmd_tx.go b/server/cmd_tx.go deleted file mode 100644 index 6782576..0000000 --- a/server/cmd_tx.go +++ /dev/null @@ -1,57 +0,0 @@ -package server - -// import ( -// "errors" -// ) - -// var errTxMiss = errors.New("transaction miss") - -// func beginCommand(c *client) error { -// tx, err := c.db.Begin() -// if err == nil { -// c.tx = tx -// c.db = tx.DB -// c.resp.writeStatus(OK) -// } - -// return err -// } - -// func commitCommand(c *client) error { -// if c.tx == nil { -// return errTxMiss -// } - -// err := c.tx.Commit() -// c.db, _ = c.ldb.Select(c.tx.Index()) -// c.tx = nil - -// if err == nil { -// c.resp.writeStatus(OK) -// } - -// return err -// } - -// func rollbackCommand(c *client) error { -// if c.tx == nil { -// return errTxMiss -// } - -// err := c.tx.Rollback() - -// c.db, _ = c.ldb.Select(c.tx.Index()) -// c.tx = nil - -// if err == nil { -// c.resp.writeStatus(OK) -// } - -// return err -// } - -// func init() { -// register("begin", beginCommand) -// register("commit", commitCommand) -// register("rollback", rollbackCommand) -// } diff --git a/store/store_test.go b/store/store_test.go index 7a3fe5f..d886b97 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -18,6 +18,7 @@ func TestStore(t *testing.T) { ns := driver.ListStores() for _, s := range ns { + t.Logf("store %s", s) cfg.DBName = s os.RemoveAll(getStorePath(cfg)) @@ -361,33 +362,9 @@ func testBatchData(db *DB, t *testing.T) { t.Fatal(len(kvs)) } else if !reflect.DeepEqual(kvs[0], BatchItem{[]byte("a"), []byte("1")}) { t.Fatal("must equal") - } else if !reflect.DeepEqual(kvs[1], BatchItem{[]byte("b"), []byte{}}) { - t.Fatal("must equal") + } else if !reflect.DeepEqual(kvs[1], BatchItem{[]byte("b"), []byte(nil)}) { + t.Fatalf("must equal") } else if !reflect.DeepEqual(kvs[2], BatchItem{[]byte("c"), nil}) { t.Fatal("must equal") } - - if err := d.Append(d); err != nil { - t.Fatal(err) - } else if d.Len() != 6 { - t.Fatal(d.Len()) - } - - if kvs, err := d.Items(); err != nil { - t.Fatal(err) - } else if len(kvs) != 6 { - t.Fatal(len(kvs)) - } else if !reflect.DeepEqual(kvs[0], BatchItem{[]byte("a"), []byte("1")}) { - t.Fatal("must equal") - } else if !reflect.DeepEqual(kvs[1], BatchItem{[]byte("b"), []byte{}}) { - t.Fatal("must equal") - } else if !reflect.DeepEqual(kvs[2], BatchItem{[]byte("c"), nil}) { - t.Fatal("must equal") - } else if !reflect.DeepEqual(kvs[3], BatchItem{[]byte("a"), []byte("1")}) { - t.Fatal("must equal") - } else if !reflect.DeepEqual(kvs[4], BatchItem{[]byte("b"), []byte{}}) { - t.Fatal("must equal") - } else if !reflect.DeepEqual(kvs[5], BatchItem{[]byte("c"), nil}) { - t.Fatal("must equal") - } } diff --git a/store/writebatch.go b/store/writebatch.go index 329bca1..7df7c7e 100644 --- a/store/writebatch.go +++ b/store/writebatch.go @@ -1,7 +1,6 @@ package store import ( - "encoding/binary" "time" "github.com/siddontang/ledisdb/store/driver" @@ -96,18 +95,6 @@ func NewBatchData(data []byte) (*BatchData, error) { return b, nil } -func (d *BatchData) Append(do *BatchData) error { - d1 := d.Dump() - d2 := do.Dump() - - n := d.Len() + do.Len() - - d1 = append(d1, d2[BatchDataHeadLen:]...) - binary.LittleEndian.PutUint32(d1[8:], uint32(n)) - - return d.Load(d1) -} - func (d *BatchData) Data() []byte { return d.Dump() } diff --git a/tools/build_config.sh b/tools/build_config.sh index c97e13d..22b7bf2 100755 --- a/tools/build_config.sh +++ b/tools/build_config.sh @@ -13,14 +13,6 @@ touch $OUTPUT source ./dev.sh -# Test godep install -godep path > /dev/null 2>&1 -if [ "$?" = 0 ]; then - echo "GO=godep go" >> $OUTPUT -else - echo "GO=go" >> $OUTPUT -fi - echo "CGO_CFLAGS=$CGO_CFLAGS" >> $OUTPUT echo "CGO_CXXFLAGS=$CGO_CXXFLAGS" >> $OUTPUT echo "CGO_LDFLAGS=$CGO_LDFLAGS" >> $OUTPUT