diff --git a/hack/vendor.sh b/hack/vendor.sh index 3d9c565be6..84a3a1b1cd 100755 --- a/hack/vendor.sh +++ b/hack/vendor.sh @@ -79,9 +79,9 @@ clone git github.com/vishvananda/netlink 631962935bff4f3d20ff32a72e8944f6d2836a2 clone git github.com/BurntSushi/toml f706d00e3de6abe700c994cdd545a1a4915af060 clone git github.com/samuel/go-zookeeper d0e0d8e11f318e000a8cc434616d69e329edc374 clone git github.com/deckarep/golang-set ef32fa3046d9f249d399f98ebaf9be944430fd1d -clone git github.com/coreos/etcd v2.2.0 +clone git github.com/coreos/etcd v2.3.2 fix_rewritten_imports github.com/coreos/etcd -clone git github.com/ugorji/go 5abd4e96a45c386928ed2ca2a7ef63e2533e18ec +clone git github.com/ugorji/go f1f1a805ed361a0e078bb537e4ea78cd37dcf065 clone git github.com/hashicorp/consul v0.5.2 clone git github.com/boltdb/bolt v1.2.1 clone git github.com/miekg/dns 75e6e86cc601825c5dbcd4e0c209eab180997cd7 diff --git a/vendor/src/github.com/coreos/etcd/client/README.md b/vendor/src/github.com/coreos/etcd/client/README.md index 672b8c13f0..e9e4be468e 100644 --- a/vendor/src/github.com/coreos/etcd/client/README.md +++ b/vendor/src/github.com/coreos/etcd/client/README.md @@ -35,9 +35,25 @@ func main() { log.Fatal(err) } kapi := client.NewKeysAPI(c) - resp, err := kapi.Set(context.Background(), "foo", "bar", nil) + // set "/foo" key with "bar" value + log.Print("Setting '/foo' key with 'bar' value") + resp, err := kapi.Set(context.Background(), "/foo", "bar", nil) if err != nil { log.Fatal(err) + } else { + // print common key info + log.Printf("Set is done. Metadata is %q\n", resp) + } + // get "/foo" key's value + log.Print("Getting '/foo' key value") + resp, err = kapi.Get(context.Background(), "/foo", nil) + if err != nil { + log.Fatal(err) + } else { + // print common key info + log.Printf("Get is done. Metadata is %q\n", resp) + // print value + log.Printf("%q key has %q value\n", resp.Node.Key, resp.Node.Value) } } ``` @@ -61,7 +77,7 @@ If the response gets from the cluster is invalid, a plain string error will be r Here is the example code to handle client errors: ```go -cfg := client.Config{Endpoints: []string{"http://etcd1:2379,http://etcd2:2379,http://etcd3:2379"}} +cfg := client.Config{Endpoints: []string{"http://etcd1:2379","http://etcd2:2379","http://etcd3:2379"}} c, err := client.New(cfg) if err != nil { log.Fatal(err) diff --git a/vendor/src/github.com/coreos/etcd/client/auth_role.go b/vendor/src/github.com/coreos/etcd/client/auth_role.go index 8de58afcf1..0f6748bdfa 100644 --- a/vendor/src/github.com/coreos/etcd/client/auth_role.go +++ b/vendor/src/github.com/coreos/etcd/client/auth_role.go @@ -56,22 +56,22 @@ func NewAuthRoleAPI(c Client) AuthRoleAPI { } type AuthRoleAPI interface { - // Add a role. + // AddRole adds a role. AddRole(ctx context.Context, role string) error - // Remove a role. + // RemoveRole removes a role. RemoveRole(ctx context.Context, role string) error - // Get role details. + // GetRole retrieves role details. GetRole(ctx context.Context, role string) (*Role, error) - // Grant a role some permission prefixes for the KV store. + // GrantRoleKV grants a role some permission prefixes for the KV store. GrantRoleKV(ctx context.Context, role string, prefixes []string, permType PermissionType) (*Role, error) - // Revoke some some permission prefixes for a role on the KV store. + // RevokeRoleKV revokes some permission prefixes for a role on the KV store. RevokeRoleKV(ctx context.Context, role string, prefixes []string, permType PermissionType) (*Role, error) - // List roles. + // ListRoles lists roles. ListRoles(ctx context.Context) ([]string, error) } @@ -115,17 +115,20 @@ func (r *httpAuthRoleAPI) ListRoles(ctx context.Context) ([]string, error) { if err != nil { return nil, err } - if err := assertStatusCode(resp.StatusCode, http.StatusOK); err != nil { + if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil { return nil, err } - var userList struct { - Roles []string `json:"roles"` + var roleList struct { + Roles []Role `json:"roles"` } - err = json.Unmarshal(body, &userList) - if err != nil { + if err = json.Unmarshal(body, &roleList); err != nil { return nil, err } - return userList.Roles, nil + ret := make([]string, 0, len(roleList.Roles)) + for _, r := range roleList.Roles { + ret = append(ret, r.Role) + } + return ret, nil } func (r *httpAuthRoleAPI) AddRole(ctx context.Context, rolename string) error { @@ -218,17 +221,16 @@ func (r *httpAuthRoleAPI) modRole(ctx context.Context, req *authRoleAPIAction) ( if err != nil { return nil, err } - if err := assertStatusCode(resp.StatusCode, http.StatusOK); err != nil { + if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil { var sec authError - err := json.Unmarshal(body, &sec) + err = json.Unmarshal(body, &sec) if err != nil { return nil, err } return nil, sec } var role Role - err = json.Unmarshal(body, &role) - if err != nil { + if err = json.Unmarshal(body, &role); err != nil { return nil, err } return &role, nil diff --git a/vendor/src/github.com/coreos/etcd/client/auth_user.go b/vendor/src/github.com/coreos/etcd/client/auth_user.go index 6e0e4c596c..0b0e091551 100644 --- a/vendor/src/github.com/coreos/etcd/client/auth_user.go +++ b/vendor/src/github.com/coreos/etcd/client/auth_user.go @@ -36,6 +36,21 @@ type User struct { Revoke []string `json:"revoke,omitempty"` } +// userListEntry is the user representation given by the server for ListUsers +type userListEntry struct { + User string `json:"user"` + Roles []Role `json:"roles"` +} + +type UserRoles struct { + User string `json:"user"` + Roles []Role `json:"roles"` +} + +type userName struct { + User string `json:"user"` +} + func v2AuthURL(ep url.URL, action string, name string) *url.URL { if name != "" { ep.Path = path.Join(ep.Path, defaultV2AuthPrefix, action, name) @@ -78,9 +93,9 @@ func (s *httpAuthAPI) enableDisable(ctx context.Context, req httpAction) error { if err != nil { return err } - if err := assertStatusCode(resp.StatusCode, http.StatusOK, http.StatusCreated); err != nil { + if err = assertStatusCode(resp.StatusCode, http.StatusOK, http.StatusCreated); err != nil { var sec authError - err := json.Unmarshal(body, &sec) + err = json.Unmarshal(body, &sec) if err != nil { return err } @@ -117,25 +132,25 @@ func NewAuthUserAPI(c Client) AuthUserAPI { } type AuthUserAPI interface { - // Add a user. + // AddUser adds a user. AddUser(ctx context.Context, username string, password string) error - // Remove a user. + // RemoveUser removes a user. RemoveUser(ctx context.Context, username string) error - // Get user details. + // GetUser retrieves user details. GetUser(ctx context.Context, username string) (*User, error) - // Grant a user some permission roles. + // GrantUser grants a user some permission roles. GrantUser(ctx context.Context, username string, roles []string) (*User, error) - // Revoke some permission roles from a user. + // RevokeUser revokes some permission roles from a user. RevokeUser(ctx context.Context, username string, roles []string) (*User, error) - // Change the user's password. + // ChangePassword changes the user's password. ChangePassword(ctx context.Context, username string, password string) (*User, error) - // List users. + // ListUsers lists the users. ListUsers(ctx context.Context) ([]string, error) } @@ -179,22 +194,28 @@ func (u *httpAuthUserAPI) ListUsers(ctx context.Context) ([]string, error) { if err != nil { return nil, err } - if err := assertStatusCode(resp.StatusCode, http.StatusOK); err != nil { + if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil { var sec authError - err := json.Unmarshal(body, &sec) + err = json.Unmarshal(body, &sec) if err != nil { return nil, err } return nil, sec } + var userList struct { - Users []string `json:"users"` + Users []userListEntry `json:"users"` } - err = json.Unmarshal(body, &userList) - if err != nil { + + if err = json.Unmarshal(body, &userList); err != nil { return nil, err } - return userList.Users, nil + + ret := make([]string, 0, len(userList.Users)) + for _, u := range userList.Users { + ret = append(ret, u.User) + } + return ret, nil } func (u *httpAuthUserAPI) AddUser(ctx context.Context, username string, password string) error { @@ -221,9 +242,9 @@ func (u *httpAuthUserAPI) addRemoveUser(ctx context.Context, req *authUserAPIAct if err != nil { return err } - if err := assertStatusCode(resp.StatusCode, http.StatusOK, http.StatusCreated); err != nil { + if err = assertStatusCode(resp.StatusCode, http.StatusOK, http.StatusCreated); err != nil { var sec authError - err := json.Unmarshal(body, &sec) + err = json.Unmarshal(body, &sec) if err != nil { return err } @@ -280,18 +301,24 @@ func (u *httpAuthUserAPI) modUser(ctx context.Context, req *authUserAPIAction) ( if err != nil { return nil, err } - if err := assertStatusCode(resp.StatusCode, http.StatusOK); err != nil { + if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil { var sec authError - err := json.Unmarshal(body, &sec) + err = json.Unmarshal(body, &sec) if err != nil { return nil, err } return nil, sec } var user User - err = json.Unmarshal(body, &user) - if err != nil { - return nil, err + if err = json.Unmarshal(body, &user); err != nil { + var userR UserRoles + if urerr := json.Unmarshal(body, &userR); urerr != nil { + return nil, err + } + user.User = userR.User + for _, r := range userR.Roles { + user.Roles = append(user.Roles, r.Role) + } } return &user, nil } diff --git a/vendor/src/github.com/coreos/etcd/client/client.go b/vendor/src/github.com/coreos/etcd/client/client.go index 34adb82b02..2aaa112ed3 100644 --- a/vendor/src/github.com/coreos/etcd/client/client.go +++ b/vendor/src/github.com/coreos/etcd/client/client.go @@ -24,6 +24,7 @@ import ( "net/url" "reflect" "sort" + "strconv" "sync" "time" @@ -34,6 +35,7 @@ var ( ErrNoEndpoints = errors.New("client: no endpoints available") ErrTooManyRedirects = errors.New("client: too many redirects") ErrClusterUnavailable = errors.New("client: etcd cluster is unavailable or misconfigured") + ErrNoLeaderEndpoint = errors.New("client: no leader endpoint available") errTooManyRedirectChecks = errors.New("client: too many redirect checks") ) @@ -48,6 +50,29 @@ var DefaultTransport CancelableTransport = &http.Transport{ TLSHandshakeTimeout: 10 * time.Second, } +type EndpointSelectionMode int + +const ( + // EndpointSelectionRandom is the default value of the 'SelectionMode'. + // As the name implies, the client object will pick a node from the members + // of the cluster in a random fashion. If the cluster has three members, A, B, + // and C, the client picks any node from its three members as its request + // destination. + EndpointSelectionRandom EndpointSelectionMode = iota + + // If 'SelectionMode' is set to 'EndpointSelectionPrioritizeLeader', + // requests are sent directly to the cluster leader. This reduces + // forwarding roundtrips compared to making requests to etcd followers + // who then forward them to the cluster leader. In the event of a leader + // failure, however, clients configured this way cannot prioritize among + // the remaining etcd followers. Therefore, when a client sets 'SelectionMode' + // to 'EndpointSelectionPrioritizeLeader', it must use 'client.AutoSync()' to + // maintain its knowledge of current cluster state. + // + // This mode should be used with Client.AutoSync(). + EndpointSelectionPrioritizeLeader +) + type Config struct { // Endpoints defines a set of URLs (schemes, hosts and ports only) // that can be used to communicate with a logical etcd cluster. For @@ -73,7 +98,7 @@ type Config struct { // CheckRedirect specifies the policy for handling HTTP redirects. // If CheckRedirect is not nil, the Client calls it before // following an HTTP redirect. The sole argument is the number of - // requests that have alrady been made. If CheckRedirect returns + // requests that have already been made. If CheckRedirect returns // an error, Client.Do will not make any further requests and return // the error back it to the caller. // @@ -99,11 +124,17 @@ type Config struct { // watch start. But if server is behind some kind of proxy, the response // header may be cached at proxy, and Client cannot rely on this behavior. // + // Especially, wait request will ignore this timeout. + // // One API call may send multiple requests to different etcd servers until it // succeeds. Use context of the API to specify the overall timeout. // // A HeaderTimeoutPerRequest of zero means no timeout. HeaderTimeoutPerRequest time.Duration + + // SelectionMode is an EndpointSelectionMode enum that specifies the + // policy for choosing the etcd cluster node to which requests are sent. + SelectionMode EndpointSelectionMode } func (cfg *Config) transport() CancelableTransport { @@ -162,6 +193,11 @@ type Client interface { // this may differ from the initial Endpoints provided in the Config. Endpoints() []string + // SetEndpoints sets the set of API endpoints used by Client to resolve + // HTTP requests. If the given endpoints are not valid, an error will be + // returned + SetEndpoints(eps []string) error + httpClient } @@ -169,6 +205,7 @@ func New(cfg Config) (Client, error) { c := &httpClusterClient{ clientFactory: newHTTPClientFactory(cfg.transport(), cfg.checkRedirect(), cfg.HeaderTimeoutPerRequest), rand: rand.New(rand.NewSource(int64(time.Now().Nanosecond()))), + selectionMode: cfg.SelectionMode, } if cfg.Username != "" { c.credentials = &credentials{ @@ -176,7 +213,7 @@ func New(cfg Config) (Client, error) { password: cfg.Password, } } - if err := c.reset(cfg.Endpoints); err != nil { + if err := c.SetEndpoints(cfg.Endpoints); err != nil { return nil, err } return c, nil @@ -216,10 +253,21 @@ type httpClusterClient struct { pinned int credentials *credentials sync.RWMutex - rand *rand.Rand + rand *rand.Rand + selectionMode EndpointSelectionMode } -func (c *httpClusterClient) reset(eps []string) error { +func (c *httpClusterClient) getLeaderEndpoint() (string, error) { + mAPI := NewMembersAPI(c) + leader, err := mAPI.Leader(context.Background()) + if err != nil { + return "", err + } + + return leader.ClientURLs[0], nil // TODO: how to handle multiple client URLs? +} + +func (c *httpClusterClient) SetEndpoints(eps []string) error { if len(eps) == 0 { return ErrNoEndpoints } @@ -233,9 +281,28 @@ func (c *httpClusterClient) reset(eps []string) error { neps[i] = *u } - c.endpoints = shuffleEndpoints(c.rand, neps) - // TODO: pin old endpoint if possible, and rebalance when new endpoint appears - c.pinned = 0 + switch c.selectionMode { + case EndpointSelectionRandom: + c.endpoints = shuffleEndpoints(c.rand, neps) + c.pinned = 0 + case EndpointSelectionPrioritizeLeader: + c.endpoints = neps + lep, err := c.getLeaderEndpoint() + if err != nil { + return ErrNoLeaderEndpoint + } + + for i := range c.endpoints { + if c.endpoints[i].String() == lep { + c.pinned = i + break + } + } + // If endpoints doesn't have the lu, just keep c.pinned = 0. + // Forwarding between follower and leader would be required but it works. + default: + return errors.New(fmt.Sprintf("invalid endpoint selection mode: %d", c.selectionMode)) + } return nil } @@ -275,7 +342,9 @@ func (c *httpClusterClient) Do(ctx context.Context, act httpAction) (*http.Respo resp, body, err = hc.Do(ctx, action) if err != nil { cerr.Errors = append(cerr.Errors, err) - // mask previous errors with context error, which is controlled by user + if err == ctx.Err() { + return nil, nil, ctx.Err() + } if err == context.Canceled || err == context.DeadlineExceeded { return nil, nil, err } @@ -341,7 +410,7 @@ func (c *httpClusterClient) Sync(ctx context.Context) error { return nil } - return c.reset(eps) + return c.SetEndpoints(eps) } func (c *httpClusterClient) AutoSync(ctx context.Context, interval time.Duration) error { @@ -378,9 +447,24 @@ func (c *simpleHTTPClient) Do(ctx context.Context, act httpAction) (*http.Respon return nil, nil, err } - hctx, hcancel := context.WithCancel(ctx) - if c.headerTimeout > 0 { + isWait := false + if req != nil && req.URL != nil { + ws := req.URL.Query().Get("wait") + if len(ws) != 0 { + var err error + isWait, err = strconv.ParseBool(ws) + if err != nil { + return nil, nil, fmt.Errorf("wrong wait value %s (%v for %+v)", ws, err, req) + } + } + } + + var hctx context.Context + var hcancel context.CancelFunc + if !isWait && c.headerTimeout > 0 { hctx, hcancel = context.WithTimeout(ctx, c.headerTimeout) + } else { + hctx, hcancel = context.WithCancel(ctx) } defer hcancel() diff --git a/vendor/src/github.com/coreos/etcd/client/discover.go b/vendor/src/github.com/coreos/etcd/client/discover.go index 269491c8dc..ae88659f42 100644 --- a/vendor/src/github.com/coreos/etcd/client/discover.go +++ b/vendor/src/github.com/coreos/etcd/client/discover.go @@ -16,6 +16,6 @@ package client // Discoverer is an interface that wraps the Discover method. type Discoverer interface { - // Dicover looks up the etcd servers for the domain. + // Discover looks up the etcd servers for the domain. Discover(domain string) ([]string, error) } diff --git a/vendor/src/github.com/coreos/etcd/client/keys.generated.go b/vendor/src/github.com/coreos/etcd/client/keys.generated.go index a897261f48..748283aa95 100644 --- a/vendor/src/github.com/coreos/etcd/client/keys.generated.go +++ b/vendor/src/github.com/coreos/etcd/client/keys.generated.go @@ -11,28 +11,36 @@ import ( codec1978 "github.com/ugorji/go/codec" "reflect" "runtime" - "time" + time "time" ) const ( - codecSelferC_UTF85311 = 1 - codecSelferC_RAW5311 = 0 - codecSelverValueTypeArray5311 = 10 - codecSelverValueTypeMap5311 = 9 + // ----- content types ---- + codecSelferC_UTF81819 = 1 + codecSelferC_RAW1819 = 0 + // ----- value types used ---- + codecSelferValueTypeArray1819 = 10 + codecSelferValueTypeMap1819 = 9 + // ----- containerStateValues ---- + codecSelfer_containerMapKey1819 = 2 + codecSelfer_containerMapValue1819 = 3 + codecSelfer_containerMapEnd1819 = 4 + codecSelfer_containerArrayElem1819 = 6 + codecSelfer_containerArrayEnd1819 = 7 ) var ( - codecSelferBitsize5311 = uint8(reflect.TypeOf(uint(0)).Bits()) - codecSelferOnlyMapOrArrayEncodeToStructErr5311 = errors.New(`only encoded map or array can be decoded into a struct`) + codecSelferBitsize1819 = uint8(reflect.TypeOf(uint(0)).Bits()) + codecSelferOnlyMapOrArrayEncodeToStructErr1819 = errors.New(`only encoded map or array can be decoded into a struct`) ) -type codecSelfer5311 struct{} +type codecSelfer1819 struct{} func init() { - if codec1978.GenVersion != 2 { + if codec1978.GenVersion != 5 { _, file, _, _ := runtime.Caller(0) err := fmt.Errorf("codecgen version mismatch: current: %v, need %v. Re-generate file: %v", - 2, codec1978.GenVersion, file) + 5, codec1978.GenVersion, file) panic(err) } if false { // reference the types, but skip this branch at build/run time @@ -42,148 +50,149 @@ func init() { } func (x *Response) CodecEncodeSelf(e *codec1978.Encoder) { - var h codecSelfer5311 + var h codecSelfer1819 z, r := codec1978.GenHelperEncoder(e) _, _, _ = h, z, r if x == nil { r.EncodeNil() } else { - yysep1 := !z.EncBinary() - yy2arr1 := z.EncBasicHandle().StructToArray - var yyfirst1 bool - var yyq1 [3]bool - _, _, _, _ = yysep1, yyfirst1, yyq1, yy2arr1 - const yyr1 bool = false - if yyr1 || yy2arr1 { - r.EncodeArrayStart(3) + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { } else { - var yynn1 int = 3 - for _, b := range yyq1 { - if b { - yynn1++ + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + var yyq2 [3]bool + _, _, _ = yysep2, yyq2, yy2arr2 + const yyr2 bool = false + var yynn2 int + if yyr2 || yy2arr2 { + r.EncodeArrayStart(3) + } else { + yynn2 = 3 + for _, b := range yyq2 { + if b { + yynn2++ + } + } + r.EncodeMapStart(yynn2) + yynn2 = 0 + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1819) + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferC_UTF81819, string(x.Action)) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1819) + r.EncodeString(codecSelferC_UTF81819, string("action")) + z.EncSendContainerState(codecSelfer_containerMapValue1819) + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferC_UTF81819, string(x.Action)) } } - r.EncodeMapStart(yynn1) - } - if yyr1 || yy2arr1 { - r.EncodeString(codecSelferC_UTF85311, string(x.Action)) - } else { - yyfirst1 = true - r.EncodeString(codecSelferC_UTF85311, string("action")) - if yysep1 { - r.EncodeMapKVSeparator() - } - r.EncodeString(codecSelferC_UTF85311, string(x.Action)) - } - if yyr1 || yy2arr1 { - if yysep1 { - r.EncodeArrayEntrySeparator() - } - if x.Node == nil { - r.EncodeNil() + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1819) + if x.Node == nil { + r.EncodeNil() + } else { + x.Node.CodecEncodeSelf(e) + } } else { - x.Node.CodecEncodeSelf(e) + z.EncSendContainerState(codecSelfer_containerMapKey1819) + r.EncodeString(codecSelferC_UTF81819, string("node")) + z.EncSendContainerState(codecSelfer_containerMapValue1819) + if x.Node == nil { + r.EncodeNil() + } else { + x.Node.CodecEncodeSelf(e) + } } - } else { - if yyfirst1 { - r.EncodeMapEntrySeparator() + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1819) + if x.PrevNode == nil { + r.EncodeNil() + } else { + x.PrevNode.CodecEncodeSelf(e) + } } else { - yyfirst1 = true + z.EncSendContainerState(codecSelfer_containerMapKey1819) + r.EncodeString(codecSelferC_UTF81819, string("prevNode")) + z.EncSendContainerState(codecSelfer_containerMapValue1819) + if x.PrevNode == nil { + r.EncodeNil() + } else { + x.PrevNode.CodecEncodeSelf(e) + } } - r.EncodeString(codecSelferC_UTF85311, string("node")) - if yysep1 { - r.EncodeMapKVSeparator() - } - if x.Node == nil { - r.EncodeNil() + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1819) } else { - x.Node.CodecEncodeSelf(e) - } - } - if yyr1 || yy2arr1 { - if yysep1 { - r.EncodeArrayEntrySeparator() - } - if x.PrevNode == nil { - r.EncodeNil() - } else { - x.PrevNode.CodecEncodeSelf(e) - } - } else { - if yyfirst1 { - r.EncodeMapEntrySeparator() - } else { - yyfirst1 = true - } - r.EncodeString(codecSelferC_UTF85311, string("prevNode")) - if yysep1 { - r.EncodeMapKVSeparator() - } - if x.PrevNode == nil { - r.EncodeNil() - } else { - x.PrevNode.CodecEncodeSelf(e) - } - } - if yysep1 { - if yyr1 || yy2arr1 { - r.EncodeArrayEnd() - } else { - r.EncodeMapEnd() + z.EncSendContainerState(codecSelfer_containerMapEnd1819) } } } } func (x *Response) CodecDecodeSelf(d *codec1978.Decoder) { - var h codecSelfer5311 + var h codecSelfer1819 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - if r.IsContainerType(codecSelverValueTypeMap5311) { - yyl5 := r.ReadMapStart() - if yyl5 == 0 { - r.ReadMapEnd() - } else { - x.codecDecodeSelfFromMap(yyl5, d) - } - } else if r.IsContainerType(codecSelverValueTypeArray5311) { - yyl5 := r.ReadArrayStart() - if yyl5 == 0 { - r.ReadArrayEnd() - } else { - x.codecDecodeSelfFromArray(yyl5, d) - } + yym8 := z.DecBinary() + _ = yym8 + if false { + } else if z.HasExtensions() && z.DecExt(x) { } else { - panic(codecSelferOnlyMapOrArrayEncodeToStructErr5311) + yyct9 := r.ContainerType() + if yyct9 == codecSelferValueTypeMap1819 { + yyl9 := r.ReadMapStart() + if yyl9 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1819) + } else { + x.codecDecodeSelfFromMap(yyl9, d) + } + } else if yyct9 == codecSelferValueTypeArray1819 { + yyl9 := r.ReadArrayStart() + if yyl9 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1819) + } else { + x.codecDecodeSelfFromArray(yyl9, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1819) + } } } func (x *Response) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { - var h codecSelfer5311 + var h codecSelfer1819 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yys6Slc = z.DecScratchBuffer() // default slice to decode into - _ = yys6Slc - var yyhl6 bool = l >= 0 - for yyj6 := 0; ; yyj6++ { - if yyhl6 { - if yyj6 >= l { + var yys10Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys10Slc + var yyhl10 bool = l >= 0 + for yyj10 := 0; ; yyj10++ { + if yyhl10 { + if yyj10 >= l { break } } else { if r.CheckBreak() { break } - if yyj6 > 0 { - r.ReadMapEntrySeparator() - } } - yys6Slc = r.DecodeBytes(yys6Slc, true, true) - yys6 := string(yys6Slc) - if !yyhl6 { - r.ReadMapKVSeparator() - } - switch yys6 { + z.DecSendContainerState(codecSelfer_containerMapKey1819) + yys10Slc = r.DecodeBytes(yys10Slc, true, true) + yys10 := string(yys10Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1819) + switch yys10 { case "action": if r.TryDecodeAsNil() { x.Action = "" @@ -213,47 +222,46 @@ func (x *Response) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { x.PrevNode.CodecDecodeSelf(d) } default: - z.DecStructFieldNotFound(-1, yys6) - } // end switch yys6 - } // end for yyj6 - if !yyhl6 { - r.ReadMapEnd() - } + z.DecStructFieldNotFound(-1, yys10) + } // end switch yys10 + } // end for yyj10 + z.DecSendContainerState(codecSelfer_containerMapEnd1819) } func (x *Response) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { - var h codecSelfer5311 + var h codecSelfer1819 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj10 int - var yyb10 bool - var yyhl10 bool = l >= 0 - yyj10++ - if yyhl10 { - yyb10 = yyj10 > l + var yyj14 int + var yyb14 bool + var yyhl14 bool = l >= 0 + yyj14++ + if yyhl14 { + yyb14 = yyj14 > l } else { - yyb10 = r.CheckBreak() + yyb14 = r.CheckBreak() } - if yyb10 { - r.ReadArrayEnd() + if yyb14 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1819) return } + z.DecSendContainerState(codecSelfer_containerArrayElem1819) if r.TryDecodeAsNil() { x.Action = "" } else { x.Action = string(r.DecodeString()) } - yyj10++ - if yyhl10 { - yyb10 = yyj10 > l + yyj14++ + if yyhl14 { + yyb14 = yyj14 > l } else { - yyb10 = r.CheckBreak() + yyb14 = r.CheckBreak() } - if yyb10 { - r.ReadArrayEnd() + if yyb14 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1819) return } - r.ReadArrayEntrySeparator() + z.DecSendContainerState(codecSelfer_containerArrayElem1819) if r.TryDecodeAsNil() { if x.Node != nil { x.Node = nil @@ -264,17 +272,17 @@ func (x *Response) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } x.Node.CodecDecodeSelf(d) } - yyj10++ - if yyhl10 { - yyb10 = yyj10 > l + yyj14++ + if yyhl14 { + yyb14 = yyj14 > l } else { - yyb10 = r.CheckBreak() + yyb14 = r.CheckBreak() } - if yyb10 { - r.ReadArrayEnd() + if yyb14 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1819) return } - r.ReadArrayEntrySeparator() + z.DecSendContainerState(codecSelfer_containerArrayElem1819) if r.TryDecodeAsNil() { if x.PrevNode != nil { x.PrevNode = nil @@ -286,272 +294,305 @@ func (x *Response) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { x.PrevNode.CodecDecodeSelf(d) } for { - yyj10++ - if yyhl10 { - yyb10 = yyj10 > l + yyj14++ + if yyhl14 { + yyb14 = yyj14 > l } else { - yyb10 = r.CheckBreak() + yyb14 = r.CheckBreak() } - if yyb10 { + if yyb14 { break } - if yyj10 > 1 { - r.ReadArrayEntrySeparator() - } - z.DecStructFieldNotFound(yyj10-1, "") + z.DecSendContainerState(codecSelfer_containerArrayElem1819) + z.DecStructFieldNotFound(yyj14-1, "") } - r.ReadArrayEnd() + z.DecSendContainerState(codecSelfer_containerArrayEnd1819) } func (x *Node) CodecEncodeSelf(e *codec1978.Encoder) { - var h codecSelfer5311 + var h codecSelfer1819 z, r := codec1978.GenHelperEncoder(e) _, _, _ = h, z, r if x == nil { r.EncodeNil() } else { - yysep14 := !z.EncBinary() - yy2arr14 := z.EncBasicHandle().StructToArray - var yyfirst14 bool - var yyq14 [8]bool - _, _, _, _ = yysep14, yyfirst14, yyq14, yy2arr14 - const yyr14 bool = false - yyq14[1] = x.Dir != false - yyq14[6] = x.Expiration != nil - yyq14[7] = x.TTL != 0 - if yyr14 || yy2arr14 { - r.EncodeArrayStart(8) + yym18 := z.EncBinary() + _ = yym18 + if false { + } else if z.HasExtensions() && z.EncExt(x) { } else { - var yynn14 int = 5 - for _, b := range yyq14 { - if b { - yynn14++ - } - } - r.EncodeMapStart(yynn14) - } - if yyr14 || yy2arr14 { - r.EncodeString(codecSelferC_UTF85311, string(x.Key)) - } else { - yyfirst14 = true - r.EncodeString(codecSelferC_UTF85311, string("key")) - if yysep14 { - r.EncodeMapKVSeparator() - } - r.EncodeString(codecSelferC_UTF85311, string(x.Key)) - } - if yyr14 || yy2arr14 { - if yysep14 { - r.EncodeArrayEntrySeparator() - } - if yyq14[1] { - r.EncodeBool(bool(x.Dir)) + yysep19 := !z.EncBinary() + yy2arr19 := z.EncBasicHandle().StructToArray + var yyq19 [8]bool + _, _, _ = yysep19, yyq19, yy2arr19 + const yyr19 bool = false + yyq19[1] = x.Dir != false + yyq19[6] = x.Expiration != nil + yyq19[7] = x.TTL != 0 + var yynn19 int + if yyr19 || yy2arr19 { + r.EncodeArrayStart(8) } else { - r.EncodeBool(false) + yynn19 = 5 + for _, b := range yyq19 { + if b { + yynn19++ + } + } + r.EncodeMapStart(yynn19) + yynn19 = 0 } - } else { - if yyq14[1] { - if yyfirst14 { - r.EncodeMapEntrySeparator() + if yyr19 || yy2arr19 { + z.EncSendContainerState(codecSelfer_containerArrayElem1819) + yym21 := z.EncBinary() + _ = yym21 + if false { } else { - yyfirst14 = true + r.EncodeString(codecSelferC_UTF81819, string(x.Key)) } - r.EncodeString(codecSelferC_UTF85311, string("dir")) - if yysep14 { - r.EncodeMapKVSeparator() + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1819) + r.EncodeString(codecSelferC_UTF81819, string("key")) + z.EncSendContainerState(codecSelfer_containerMapValue1819) + yym22 := z.EncBinary() + _ = yym22 + if false { + } else { + r.EncodeString(codecSelferC_UTF81819, string(x.Key)) } - r.EncodeBool(bool(x.Dir)) } - } - if yyr14 || yy2arr14 { - if yysep14 { - r.EncodeArrayEntrySeparator() - } - r.EncodeString(codecSelferC_UTF85311, string(x.Value)) - } else { - if yyfirst14 { - r.EncodeMapEntrySeparator() + if yyr19 || yy2arr19 { + z.EncSendContainerState(codecSelfer_containerArrayElem1819) + if yyq19[1] { + yym24 := z.EncBinary() + _ = yym24 + if false { + } else { + r.EncodeBool(bool(x.Dir)) + } + } else { + r.EncodeBool(false) + } } else { - yyfirst14 = true + if yyq19[1] { + z.EncSendContainerState(codecSelfer_containerMapKey1819) + r.EncodeString(codecSelferC_UTF81819, string("dir")) + z.EncSendContainerState(codecSelfer_containerMapValue1819) + yym25 := z.EncBinary() + _ = yym25 + if false { + } else { + r.EncodeBool(bool(x.Dir)) + } + } } - r.EncodeString(codecSelferC_UTF85311, string("value")) - if yysep14 { - r.EncodeMapKVSeparator() - } - r.EncodeString(codecSelferC_UTF85311, string(x.Value)) - } - if yyr14 || yy2arr14 { - if yysep14 { - r.EncodeArrayEntrySeparator() - } - if x.Nodes == nil { - r.EncodeNil() + if yyr19 || yy2arr19 { + z.EncSendContainerState(codecSelfer_containerArrayElem1819) + yym27 := z.EncBinary() + _ = yym27 + if false { + } else { + r.EncodeString(codecSelferC_UTF81819, string(x.Value)) + } } else { - h.encSlicePtrtoNode(([]*Node)(x.Nodes), e) + z.EncSendContainerState(codecSelfer_containerMapKey1819) + r.EncodeString(codecSelferC_UTF81819, string("value")) + z.EncSendContainerState(codecSelfer_containerMapValue1819) + yym28 := z.EncBinary() + _ = yym28 + if false { + } else { + r.EncodeString(codecSelferC_UTF81819, string(x.Value)) + } } - } else { - if yyfirst14 { - r.EncodeMapEntrySeparator() - } else { - yyfirst14 = true - } - r.EncodeString(codecSelferC_UTF85311, string("nodes")) - if yysep14 { - r.EncodeMapKVSeparator() - } - if x.Nodes == nil { - r.EncodeNil() - } else { - h.encSlicePtrtoNode(([]*Node)(x.Nodes), e) - } - } - if yyr14 || yy2arr14 { - if yysep14 { - r.EncodeArrayEntrySeparator() - } - r.EncodeUint(uint64(x.CreatedIndex)) - } else { - if yyfirst14 { - r.EncodeMapEntrySeparator() - } else { - yyfirst14 = true - } - r.EncodeString(codecSelferC_UTF85311, string("createdIndex")) - if yysep14 { - r.EncodeMapKVSeparator() - } - r.EncodeUint(uint64(x.CreatedIndex)) - } - if yyr14 || yy2arr14 { - if yysep14 { - r.EncodeArrayEntrySeparator() - } - r.EncodeUint(uint64(x.ModifiedIndex)) - } else { - if yyfirst14 { - r.EncodeMapEntrySeparator() - } else { - yyfirst14 = true - } - r.EncodeString(codecSelferC_UTF85311, string("modifiedIndex")) - if yysep14 { - r.EncodeMapKVSeparator() - } - r.EncodeUint(uint64(x.ModifiedIndex)) - } - if yyr14 || yy2arr14 { - if yysep14 { - r.EncodeArrayEntrySeparator() - } - if yyq14[6] { - if x.Expiration == nil { + if yyr19 || yy2arr19 { + z.EncSendContainerState(codecSelfer_containerArrayElem1819) + if x.Nodes == nil { r.EncodeNil() } else { - z.EncFallback(x.Expiration) + x.Nodes.CodecEncodeSelf(e) } } else { - r.EncodeNil() - } - } else { - if yyq14[6] { - if yyfirst14 { - r.EncodeMapEntrySeparator() - } else { - yyfirst14 = true - } - r.EncodeString(codecSelferC_UTF85311, string("expiration")) - if yysep14 { - r.EncodeMapKVSeparator() - } - if x.Expiration == nil { + z.EncSendContainerState(codecSelfer_containerMapKey1819) + r.EncodeString(codecSelferC_UTF81819, string("nodes")) + z.EncSendContainerState(codecSelfer_containerMapValue1819) + if x.Nodes == nil { r.EncodeNil() } else { - z.EncFallback(x.Expiration) + x.Nodes.CodecEncodeSelf(e) } } - } - if yyr14 || yy2arr14 { - if yysep14 { - r.EncodeArrayEntrySeparator() - } - if yyq14[7] { - r.EncodeInt(int64(x.TTL)) - } else { - r.EncodeInt(0) - } - } else { - if yyq14[7] { - if yyfirst14 { - r.EncodeMapEntrySeparator() + if yyr19 || yy2arr19 { + z.EncSendContainerState(codecSelfer_containerArrayElem1819) + yym31 := z.EncBinary() + _ = yym31 + if false { } else { - yyfirst14 = true + r.EncodeUint(uint64(x.CreatedIndex)) } - r.EncodeString(codecSelferC_UTF85311, string("ttl")) - if yysep14 { - r.EncodeMapKVSeparator() - } - r.EncodeInt(int64(x.TTL)) - } - } - if yysep14 { - if yyr14 || yy2arr14 { - r.EncodeArrayEnd() } else { - r.EncodeMapEnd() + z.EncSendContainerState(codecSelfer_containerMapKey1819) + r.EncodeString(codecSelferC_UTF81819, string("createdIndex")) + z.EncSendContainerState(codecSelfer_containerMapValue1819) + yym32 := z.EncBinary() + _ = yym32 + if false { + } else { + r.EncodeUint(uint64(x.CreatedIndex)) + } + } + if yyr19 || yy2arr19 { + z.EncSendContainerState(codecSelfer_containerArrayElem1819) + yym34 := z.EncBinary() + _ = yym34 + if false { + } else { + r.EncodeUint(uint64(x.ModifiedIndex)) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1819) + r.EncodeString(codecSelferC_UTF81819, string("modifiedIndex")) + z.EncSendContainerState(codecSelfer_containerMapValue1819) + yym35 := z.EncBinary() + _ = yym35 + if false { + } else { + r.EncodeUint(uint64(x.ModifiedIndex)) + } + } + if yyr19 || yy2arr19 { + z.EncSendContainerState(codecSelfer_containerArrayElem1819) + if yyq19[6] { + if x.Expiration == nil { + r.EncodeNil() + } else { + yym37 := z.EncBinary() + _ = yym37 + if false { + } else if yym38 := z.TimeRtidIfBinc(); yym38 != 0 { + r.EncodeBuiltin(yym38, x.Expiration) + } else if z.HasExtensions() && z.EncExt(x.Expiration) { + } else if yym37 { + z.EncBinaryMarshal(x.Expiration) + } else if !yym37 && z.IsJSONHandle() { + z.EncJSONMarshal(x.Expiration) + } else { + z.EncFallback(x.Expiration) + } + } + } else { + r.EncodeNil() + } + } else { + if yyq19[6] { + z.EncSendContainerState(codecSelfer_containerMapKey1819) + r.EncodeString(codecSelferC_UTF81819, string("expiration")) + z.EncSendContainerState(codecSelfer_containerMapValue1819) + if x.Expiration == nil { + r.EncodeNil() + } else { + yym39 := z.EncBinary() + _ = yym39 + if false { + } else if yym40 := z.TimeRtidIfBinc(); yym40 != 0 { + r.EncodeBuiltin(yym40, x.Expiration) + } else if z.HasExtensions() && z.EncExt(x.Expiration) { + } else if yym39 { + z.EncBinaryMarshal(x.Expiration) + } else if !yym39 && z.IsJSONHandle() { + z.EncJSONMarshal(x.Expiration) + } else { + z.EncFallback(x.Expiration) + } + } + } + } + if yyr19 || yy2arr19 { + z.EncSendContainerState(codecSelfer_containerArrayElem1819) + if yyq19[7] { + yym42 := z.EncBinary() + _ = yym42 + if false { + } else { + r.EncodeInt(int64(x.TTL)) + } + } else { + r.EncodeInt(0) + } + } else { + if yyq19[7] { + z.EncSendContainerState(codecSelfer_containerMapKey1819) + r.EncodeString(codecSelferC_UTF81819, string("ttl")) + z.EncSendContainerState(codecSelfer_containerMapValue1819) + yym43 := z.EncBinary() + _ = yym43 + if false { + } else { + r.EncodeInt(int64(x.TTL)) + } + } + } + if yyr19 || yy2arr19 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1819) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1819) } } } } func (x *Node) CodecDecodeSelf(d *codec1978.Decoder) { - var h codecSelfer5311 + var h codecSelfer1819 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - if r.IsContainerType(codecSelverValueTypeMap5311) { - yyl23 := r.ReadMapStart() - if yyl23 == 0 { - r.ReadMapEnd() - } else { - x.codecDecodeSelfFromMap(yyl23, d) - } - } else if r.IsContainerType(codecSelverValueTypeArray5311) { - yyl23 := r.ReadArrayStart() - if yyl23 == 0 { - r.ReadArrayEnd() - } else { - x.codecDecodeSelfFromArray(yyl23, d) - } + yym44 := z.DecBinary() + _ = yym44 + if false { + } else if z.HasExtensions() && z.DecExt(x) { } else { - panic(codecSelferOnlyMapOrArrayEncodeToStructErr5311) + yyct45 := r.ContainerType() + if yyct45 == codecSelferValueTypeMap1819 { + yyl45 := r.ReadMapStart() + if yyl45 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1819) + } else { + x.codecDecodeSelfFromMap(yyl45, d) + } + } else if yyct45 == codecSelferValueTypeArray1819 { + yyl45 := r.ReadArrayStart() + if yyl45 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1819) + } else { + x.codecDecodeSelfFromArray(yyl45, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1819) + } } } func (x *Node) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { - var h codecSelfer5311 + var h codecSelfer1819 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yys24Slc = z.DecScratchBuffer() // default slice to decode into - _ = yys24Slc - var yyhl24 bool = l >= 0 - for yyj24 := 0; ; yyj24++ { - if yyhl24 { - if yyj24 >= l { + var yys46Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys46Slc + var yyhl46 bool = l >= 0 + for yyj46 := 0; ; yyj46++ { + if yyhl46 { + if yyj46 >= l { break } } else { if r.CheckBreak() { break } - if yyj24 > 0 { - r.ReadMapEntrySeparator() - } } - yys24Slc = r.DecodeBytes(yys24Slc, true, true) - yys24 := string(yys24Slc) - if !yyhl24 { - r.ReadMapKVSeparator() - } - switch yys24 { + z.DecSendContainerState(codecSelfer_containerMapKey1819) + yys46Slc = r.DecodeBytes(yys46Slc, true, true) + yys46 := string(yys46Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1819) + switch yys46 { case "key": if r.TryDecodeAsNil() { x.Key = "" @@ -574,8 +615,8 @@ func (x *Node) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.Nodes = nil } else { - yyv28 := &x.Nodes - h.decSlicePtrtoNode((*[]*Node)(yyv28), d) + yyv50 := &x.Nodes + yyv50.CodecDecodeSelf(d) } case "createdIndex": if r.TryDecodeAsNil() { @@ -598,7 +639,19 @@ func (x *Node) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { if x.Expiration == nil { x.Expiration = new(time.Time) } - z.DecFallback(x.Expiration, false) + yym54 := z.DecBinary() + _ = yym54 + if false { + } else if yym55 := z.TimeRtidIfBinc(); yym55 != 0 { + r.DecodeBuiltin(yym55, x.Expiration) + } else if z.HasExtensions() && z.DecExt(x.Expiration) { + } else if yym54 { + z.DecBinaryUnmarshal(x.Expiration) + } else if !yym54 && z.IsJSONHandle() { + z.DecJSONUnmarshal(x.Expiration) + } else { + z.DecFallback(x.Expiration, false) + } } case "ttl": if r.TryDecodeAsNil() { @@ -607,128 +660,127 @@ func (x *Node) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { x.TTL = int64(r.DecodeInt(64)) } default: - z.DecStructFieldNotFound(-1, yys24) - } // end switch yys24 - } // end for yyj24 - if !yyhl24 { - r.ReadMapEnd() - } + z.DecStructFieldNotFound(-1, yys46) + } // end switch yys46 + } // end for yyj46 + z.DecSendContainerState(codecSelfer_containerMapEnd1819) } func (x *Node) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { - var h codecSelfer5311 + var h codecSelfer1819 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj33 int - var yyb33 bool - var yyhl33 bool = l >= 0 - yyj33++ - if yyhl33 { - yyb33 = yyj33 > l + var yyj57 int + var yyb57 bool + var yyhl57 bool = l >= 0 + yyj57++ + if yyhl57 { + yyb57 = yyj57 > l } else { - yyb33 = r.CheckBreak() + yyb57 = r.CheckBreak() } - if yyb33 { - r.ReadArrayEnd() + if yyb57 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1819) return } + z.DecSendContainerState(codecSelfer_containerArrayElem1819) if r.TryDecodeAsNil() { x.Key = "" } else { x.Key = string(r.DecodeString()) } - yyj33++ - if yyhl33 { - yyb33 = yyj33 > l + yyj57++ + if yyhl57 { + yyb57 = yyj57 > l } else { - yyb33 = r.CheckBreak() + yyb57 = r.CheckBreak() } - if yyb33 { - r.ReadArrayEnd() + if yyb57 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1819) return } - r.ReadArrayEntrySeparator() + z.DecSendContainerState(codecSelfer_containerArrayElem1819) if r.TryDecodeAsNil() { x.Dir = false } else { x.Dir = bool(r.DecodeBool()) } - yyj33++ - if yyhl33 { - yyb33 = yyj33 > l + yyj57++ + if yyhl57 { + yyb57 = yyj57 > l } else { - yyb33 = r.CheckBreak() + yyb57 = r.CheckBreak() } - if yyb33 { - r.ReadArrayEnd() + if yyb57 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1819) return } - r.ReadArrayEntrySeparator() + z.DecSendContainerState(codecSelfer_containerArrayElem1819) if r.TryDecodeAsNil() { x.Value = "" } else { x.Value = string(r.DecodeString()) } - yyj33++ - if yyhl33 { - yyb33 = yyj33 > l + yyj57++ + if yyhl57 { + yyb57 = yyj57 > l } else { - yyb33 = r.CheckBreak() + yyb57 = r.CheckBreak() } - if yyb33 { - r.ReadArrayEnd() + if yyb57 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1819) return } - r.ReadArrayEntrySeparator() + z.DecSendContainerState(codecSelfer_containerArrayElem1819) if r.TryDecodeAsNil() { x.Nodes = nil } else { - yyv37 := &x.Nodes - h.decSlicePtrtoNode((*[]*Node)(yyv37), d) + yyv61 := &x.Nodes + yyv61.CodecDecodeSelf(d) } - yyj33++ - if yyhl33 { - yyb33 = yyj33 > l + yyj57++ + if yyhl57 { + yyb57 = yyj57 > l } else { - yyb33 = r.CheckBreak() + yyb57 = r.CheckBreak() } - if yyb33 { - r.ReadArrayEnd() + if yyb57 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1819) return } - r.ReadArrayEntrySeparator() + z.DecSendContainerState(codecSelfer_containerArrayElem1819) if r.TryDecodeAsNil() { x.CreatedIndex = 0 } else { x.CreatedIndex = uint64(r.DecodeUint(64)) } - yyj33++ - if yyhl33 { - yyb33 = yyj33 > l + yyj57++ + if yyhl57 { + yyb57 = yyj57 > l } else { - yyb33 = r.CheckBreak() + yyb57 = r.CheckBreak() } - if yyb33 { - r.ReadArrayEnd() + if yyb57 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1819) return } - r.ReadArrayEntrySeparator() + z.DecSendContainerState(codecSelfer_containerArrayElem1819) if r.TryDecodeAsNil() { x.ModifiedIndex = 0 } else { x.ModifiedIndex = uint64(r.DecodeUint(64)) } - yyj33++ - if yyhl33 { - yyb33 = yyj33 > l + yyj57++ + if yyhl57 { + yyb57 = yyj57 > l } else { - yyb33 = r.CheckBreak() + yyb57 = r.CheckBreak() } - if yyb33 { - r.ReadArrayEnd() + if yyb57 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1819) return } - r.ReadArrayEntrySeparator() + z.DecSendContainerState(codecSelfer_containerArrayElem1819) if r.TryDecodeAsNil() { if x.Expiration != nil { x.Expiration = nil @@ -737,144 +789,195 @@ func (x *Node) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if x.Expiration == nil { x.Expiration = new(time.Time) } - z.DecFallback(x.Expiration, false) + yym65 := z.DecBinary() + _ = yym65 + if false { + } else if yym66 := z.TimeRtidIfBinc(); yym66 != 0 { + r.DecodeBuiltin(yym66, x.Expiration) + } else if z.HasExtensions() && z.DecExt(x.Expiration) { + } else if yym65 { + z.DecBinaryUnmarshal(x.Expiration) + } else if !yym65 && z.IsJSONHandle() { + z.DecJSONUnmarshal(x.Expiration) + } else { + z.DecFallback(x.Expiration, false) + } } - yyj33++ - if yyhl33 { - yyb33 = yyj33 > l + yyj57++ + if yyhl57 { + yyb57 = yyj57 > l } else { - yyb33 = r.CheckBreak() + yyb57 = r.CheckBreak() } - if yyb33 { - r.ReadArrayEnd() + if yyb57 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1819) return } - r.ReadArrayEntrySeparator() + z.DecSendContainerState(codecSelfer_containerArrayElem1819) if r.TryDecodeAsNil() { x.TTL = 0 } else { x.TTL = int64(r.DecodeInt(64)) } for { - yyj33++ - if yyhl33 { - yyb33 = yyj33 > l + yyj57++ + if yyhl57 { + yyb57 = yyj57 > l } else { - yyb33 = r.CheckBreak() + yyb57 = r.CheckBreak() } - if yyb33 { + if yyb57 { break } - if yyj33 > 1 { - r.ReadArrayEntrySeparator() - } - z.DecStructFieldNotFound(yyj33-1, "") + z.DecSendContainerState(codecSelfer_containerArrayElem1819) + z.DecStructFieldNotFound(yyj57-1, "") } - r.ReadArrayEnd() + z.DecSendContainerState(codecSelfer_containerArrayEnd1819) } -func (x codecSelfer5311) encSlicePtrtoNode(v []*Node, e *codec1978.Encoder) { - var h codecSelfer5311 +func (x Nodes) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1819 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym68 := z.EncBinary() + _ = yym68 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + h.encNodes((Nodes)(x), e) + } + } +} + +func (x *Nodes) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1819 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym69 := z.DecBinary() + _ = yym69 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + h.decNodes((*Nodes)(x), d) + } +} + +func (x codecSelfer1819) encNodes(v Nodes, e *codec1978.Encoder) { + var h codecSelfer1819 z, r := codec1978.GenHelperEncoder(e) _, _, _ = h, z, r r.EncodeArrayStart(len(v)) - yys42 := !z.EncBinary() - if yys42 { - for yyi42, yyv42 := range v { - if yyi42 > 0 { - r.EncodeArrayEntrySeparator() - } - if yyv42 == nil { - r.EncodeNil() - } else { - yyv42.CodecEncodeSelf(e) - } - } - r.EncodeArrayEnd() - } else { - for _, yyv42 := range v { - if yyv42 == nil { - r.EncodeNil() - } else { - yyv42.CodecEncodeSelf(e) - } + for _, yyv70 := range v { + z.EncSendContainerState(codecSelfer_containerArrayElem1819) + if yyv70 == nil { + r.EncodeNil() + } else { + yyv70.CodecEncodeSelf(e) } } + z.EncSendContainerState(codecSelfer_containerArrayEnd1819) } -func (x codecSelfer5311) decSlicePtrtoNode(v *[]*Node, d *codec1978.Decoder) { - var h codecSelfer5311 +func (x codecSelfer1819) decNodes(v *Nodes, d *codec1978.Decoder) { + var h codecSelfer1819 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - yyv43 := *v - yyh43, yyl43 := z.DecSliceHelperStart() - - var yyc43 bool - _ = yyc43 - - if yyv43 == nil { - if yyl43 <= 0 { - yyv43 = make([]*Node, 0) - } else { - yyv43 = make([]*Node, yyl43) + yyv71 := *v + yyh71, yyl71 := z.DecSliceHelperStart() + var yyc71 bool + if yyl71 == 0 { + if yyv71 == nil { + yyv71 = []*Node{} + yyc71 = true + } else if len(yyv71) != 0 { + yyv71 = yyv71[:0] + yyc71 = true } - yyc43 = true - } + } else if yyl71 > 0 { + var yyrr71, yyrl71 int + var yyrt71 bool + if yyl71 > cap(yyv71) { - if yyl43 == 0 { - if len(yyv43) != 0 { - yyv43 = yyv43[:0] - yyc43 = true - } - } else if yyl43 > 0 { - - yyn43 := yyl43 - if yyl43 > cap(yyv43) { - yyv43 = make([]*Node, yyl43, yyl43) - yyc43 = true - - } else if yyl43 != len(yyv43) { - yyv43 = yyv43[:yyl43] - yyc43 = true - } - yyj43 := 0 - for ; yyj43 < yyn43; yyj43++ { - if r.TryDecodeAsNil() { - if yyv43[yyj43] != nil { - *yyv43[yyj43] = Node{} + yyrg71 := len(yyv71) > 0 + yyv271 := yyv71 + yyrl71, yyrt71 = z.DecInferLen(yyl71, z.DecBasicHandle().MaxInitLen, 8) + if yyrt71 { + if yyrl71 <= cap(yyv71) { + yyv71 = yyv71[:yyrl71] + } else { + yyv71 = make([]*Node, yyrl71) } } else { - if yyv43[yyj43] == nil { - yyv43[yyj43] = new(Node) + yyv71 = make([]*Node, yyrl71) + } + yyc71 = true + yyrr71 = len(yyv71) + if yyrg71 { + copy(yyv71, yyv271) + } + } else if yyl71 != len(yyv71) { + yyv71 = yyv71[:yyl71] + yyc71 = true + } + yyj71 := 0 + for ; yyj71 < yyrr71; yyj71++ { + yyh71.ElemContainerState(yyj71) + if r.TryDecodeAsNil() { + if yyv71[yyj71] != nil { + *yyv71[yyj71] = Node{} } - yyw44 := yyv43[yyj43] - yyw44.CodecDecodeSelf(d) + } else { + if yyv71[yyj71] == nil { + yyv71[yyj71] = new(Node) + } + yyw72 := yyv71[yyj71] + yyw72.CodecDecodeSelf(d) } } + if yyrt71 { + for ; yyj71 < yyl71; yyj71++ { + yyv71 = append(yyv71, nil) + yyh71.ElemContainerState(yyj71) + if r.TryDecodeAsNil() { + if yyv71[yyj71] != nil { + *yyv71[yyj71] = Node{} + } + } else { + if yyv71[yyj71] == nil { + yyv71[yyj71] = new(Node) + } + yyw73 := yyv71[yyj71] + yyw73.CodecDecodeSelf(d) + } + + } + } } else { - for yyj43 := 0; !r.CheckBreak(); yyj43++ { - if yyj43 >= len(yyv43) { - yyv43 = append(yyv43, nil) // var yyz43 *Node - yyc43 = true - } - if yyj43 > 0 { - yyh43.Sep(yyj43) - } + yyj71 := 0 + for ; !r.CheckBreak(); yyj71++ { - if yyj43 < len(yyv43) { + if yyj71 >= len(yyv71) { + yyv71 = append(yyv71, nil) // var yyz71 *Node + yyc71 = true + } + yyh71.ElemContainerState(yyj71) + if yyj71 < len(yyv71) { if r.TryDecodeAsNil() { - if yyv43[yyj43] != nil { - *yyv43[yyj43] = Node{} + if yyv71[yyj71] != nil { + *yyv71[yyj71] = Node{} } } else { - if yyv43[yyj43] == nil { - yyv43[yyj43] = new(Node) + if yyv71[yyj71] == nil { + yyv71[yyj71] = new(Node) } - yyw45 := yyv43[yyj43] - yyw45.CodecDecodeSelf(d) + yyw74 := yyv71[yyj71] + yyw74.CodecDecodeSelf(d) } } else { @@ -882,10 +985,16 @@ func (x codecSelfer5311) decSlicePtrtoNode(v *[]*Node, d *codec1978.Decoder) { } } - yyh43.End() + if yyj71 < len(yyv71) { + yyv71 = yyv71[:yyj71] + yyc71 = true + } else if yyj71 == 0 && yyv71 == nil { + yyv71 = []*Node{} + yyc71 = true + } } - if yyc43 { - *v = yyv43 + yyh71.End() + if yyc71 { + *v = yyv71 } - } diff --git a/vendor/src/github.com/coreos/etcd/client/keys.go b/vendor/src/github.com/coreos/etcd/client/keys.go index bbf00a5c92..69dd83c665 100644 --- a/vendor/src/github.com/coreos/etcd/client/keys.go +++ b/vendor/src/github.com/coreos/etcd/client/keys.go @@ -14,7 +14,7 @@ package client -//go:generate codecgen -r "Node|Response" -o keys.generated.go keys.go +//go:generate codecgen -d 1819 -r "Node|Response|Nodes" -o keys.generated.go keys.go import ( "encoding/json" @@ -106,7 +106,7 @@ type KeysAPI interface { // Set assigns a new value to a Node identified by a given key. The caller // may define a set of conditions in the SetOptions. If SetOptions.Dir=true - // than value is ignored. + // then value is ignored. Set(ctx context.Context, key, value string, opts *SetOptions) (*Response, error) // Delete removes a Node identified by the given key, optionally destroying @@ -184,6 +184,11 @@ type SetOptions struct { // a TTL of 0. TTL time.Duration + // Refresh set to true means a TTL value can be updated + // without firing a watch or changing the node value. A + // value must not be provided when refreshing a key. + Refresh bool + // Dir specifies whether or not this Node should be created as a directory. Dir bool } @@ -234,7 +239,7 @@ type DeleteOptions struct { type Watcher interface { // Next blocks until an etcd event occurs, then returns a Response - // represeting that event. The behavior of Next depends on the + // representing that event. The behavior of Next depends on the // WatcherOptions used to construct the Watcher. Next is designed to // be called repeatedly, each time blocking until a subsequent event // is available. @@ -279,7 +284,7 @@ type Node struct { // Nodes holds the children of this Node, only if this Node is a directory. // This slice of will be arbitrarily deep (children, grandchildren, great- // grandchildren, etc.) if a recursive Get or Watch request were made. - Nodes []*Node `json:"nodes"` + Nodes Nodes `json:"nodes"` // CreatedIndex is the etcd index at-which this Node was created. CreatedIndex uint64 `json:"createdIndex"` @@ -303,6 +308,14 @@ func (n *Node) TTLDuration() time.Duration { return time.Duration(n.TTL) * time.Second } +type Nodes []*Node + +// interfaces for sorting + +func (ns Nodes) Len() int { return len(ns) } +func (ns Nodes) Less(i, j int) bool { return ns[i].Key < ns[j].Key } +func (ns Nodes) Swap(i, j int) { ns[i], ns[j] = ns[j], ns[i] } + type httpKeysAPI struct { client httpClient prefix string @@ -320,6 +333,7 @@ func (k *httpKeysAPI) Set(ctx context.Context, key, val string, opts *SetOptions act.PrevIndex = opts.PrevIndex act.PrevExist = opts.PrevExist act.TTL = opts.TTL + act.Refresh = opts.Refresh act.Dir = opts.Dir } @@ -511,6 +525,7 @@ type setAction struct { PrevIndex uint64 PrevExist PrevExistType TTL time.Duration + Refresh bool Dir bool } @@ -542,6 +557,10 @@ func (a *setAction) HTTPRequest(ep url.URL) *http.Request { form.Add("ttl", strconv.FormatUint(uint64(a.TTL.Seconds()), 10)) } + if a.Refresh { + form.Add("refresh", "true") + } + u.RawQuery = params.Encode() body := strings.NewReader(form.Encode()) diff --git a/vendor/src/github.com/coreos/etcd/client/members.go b/vendor/src/github.com/coreos/etcd/client/members.go index c1c78409ad..8b602db54b 100644 --- a/vendor/src/github.com/coreos/etcd/client/members.go +++ b/vendor/src/github.com/coreos/etcd/client/members.go @@ -29,6 +29,7 @@ import ( var ( defaultV2MembersPrefix = "/v2/members" + defaultLeaderSuffix = "/leader" ) type Member struct { @@ -105,6 +106,9 @@ type MembersAPI interface { // Update instructs etcd to update an existing Member in the cluster. Update(ctx context.Context, mID string, peerURLs []string) error + + // Leader gets current leader of the cluster + Leader(ctx context.Context) (*Member, error) } type httpMembersAPI struct { @@ -199,6 +203,25 @@ func (m *httpMembersAPI) Remove(ctx context.Context, memberID string) error { return assertStatusCode(resp.StatusCode, http.StatusNoContent, http.StatusGone) } +func (m *httpMembersAPI) Leader(ctx context.Context) (*Member, error) { + req := &membersAPIActionLeader{} + resp, body, err := m.client.Do(ctx, req) + if err != nil { + return nil, err + } + + if err := assertStatusCode(resp.StatusCode, http.StatusOK); err != nil { + return nil, err + } + + var leader Member + if err := json.Unmarshal(body, &leader); err != nil { + return nil, err + } + + return &leader, nil +} + type membersAPIActionList struct{} func (l *membersAPIActionList) HTTPRequest(ep url.URL) *http.Request { @@ -255,6 +278,15 @@ func assertStatusCode(got int, want ...int) (err error) { return fmt.Errorf("unexpected status code %d", got) } +type membersAPIActionLeader struct{} + +func (l *membersAPIActionLeader) HTTPRequest(ep url.URL) *http.Request { + u := v2MembersURL(ep) + u.Path = path.Join(u.Path, defaultLeaderSuffix) + req, _ := http.NewRequest("GET", u.String(), nil) + return req +} + // v2MembersURL add the necessary path to the provided endpoint // to route requests to the default v2 members API. func v2MembersURL(ep url.URL) *url.URL { diff --git a/vendor/src/github.com/coreos/etcd/client/srv.go b/vendor/src/github.com/coreos/etcd/client/srv.go index f74c1220b4..06197967ca 100644 --- a/vendor/src/github.com/coreos/etcd/client/srv.go +++ b/vendor/src/github.com/coreos/etcd/client/srv.go @@ -27,7 +27,7 @@ var ( type srvDiscover struct{} -// NewSRVDiscover constructs a new Dicoverer that uses the stdlib to lookup SRV records. +// NewSRVDiscover constructs a new Discoverer that uses the stdlib to lookup SRV records. func NewSRVDiscover() Discoverer { return &srvDiscover{} } @@ -50,8 +50,8 @@ func (d *srvDiscover) Discover(domain string) ([]string, error) { return nil } - errHTTPS := updateURLs("etcd-server-ssl", "https") - errHTTP := updateURLs("etcd-server", "http") + errHTTPS := updateURLs("etcd-client-ssl", "https") + errHTTP := updateURLs("etcd-client", "http") if errHTTPS != nil && errHTTP != nil { return nil, fmt.Errorf("dns lookup errors: %s and %s", errHTTPS, errHTTP) diff --git a/vendor/src/github.com/coreos/etcd/client/util.go b/vendor/src/github.com/coreos/etcd/client/util.go new file mode 100644 index 0000000000..fc0800b3d2 --- /dev/null +++ b/vendor/src/github.com/coreos/etcd/client/util.go @@ -0,0 +1,23 @@ +// Copyright 2016 CoreOS, Inc. +// +// 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. + +package client + +// IsKeyNotFound returns true if the error code is ErrorCodeKeyNotFound. +func IsKeyNotFound(err error) bool { + if cErr, ok := err.(Error); ok { + return cErr.Code == ErrorCodeKeyNotFound + } + return false +} diff --git a/vendor/src/github.com/coreos/etcd/pkg/pathutil/path.go b/vendor/src/github.com/coreos/etcd/pkg/pathutil/path.go index 82fd1db397..f26254ba93 100644 --- a/vendor/src/github.com/coreos/etcd/pkg/pathutil/path.go +++ b/vendor/src/github.com/coreos/etcd/pkg/pathutil/path.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// Package pathutil implements utility functions for handling slash-separated +// paths. package pathutil import "path" diff --git a/vendor/src/github.com/coreos/etcd/pkg/types/doc.go b/vendor/src/github.com/coreos/etcd/pkg/types/doc.go new file mode 100644 index 0000000000..04b4c38d1c --- /dev/null +++ b/vendor/src/github.com/coreos/etcd/pkg/types/doc.go @@ -0,0 +1,17 @@ +// Copyright 2015 CoreOS, Inc. +// +// 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. + +// Package types declares various data types and implements type-checking +// functions. +package types diff --git a/vendor/src/github.com/coreos/etcd/pkg/types/urlsmap.go b/vendor/src/github.com/coreos/etcd/pkg/types/urlsmap.go index a2aa7fe660..4fe9218c74 100644 --- a/vendor/src/github.com/coreos/etcd/pkg/types/urlsmap.go +++ b/vendor/src/github.com/coreos/etcd/pkg/types/urlsmap.go @@ -16,26 +16,21 @@ package types import ( "fmt" - "net/url" "sort" "strings" ) +// URLsMap is a map from a name to its URLs. type URLsMap map[string]URLs // NewURLsMap returns a URLsMap instantiated from the given string, // which consists of discovery-formatted names-to-URLs, like: // mach0=http://1.1.1.1:2380,mach0=http://2.2.2.2::2380,mach1=http://3.3.3.3:2380,mach2=http://4.4.4.4:2380 func NewURLsMap(s string) (URLsMap, error) { + m := parse(s) + cl := URLsMap{} - v, err := url.ParseQuery(strings.Replace(s, ",", "&", -1)) - if err != nil { - return nil, err - } - for name, urls := range v { - if len(urls) == 0 || urls[0] == "" { - return nil, fmt.Errorf("empty URL given for %q", name) - } + for name, urls := range m { us, err := NewURLs(urls) if err != nil { return nil, err @@ -45,9 +40,9 @@ func NewURLsMap(s string) (URLsMap, error) { return cl, nil } -// String returns NameURLPairs into discovery-formatted name-to-URLs sorted by name. +// String turns URLsMap into discovery-formatted name-to-URLs sorted by name. func (c URLsMap) String() string { - pairs := make([]string, 0) + var pairs []string for name, urls := range c { for _, url := range urls { pairs = append(pairs, fmt.Sprintf("%s=%s", name, url.String())) @@ -60,7 +55,7 @@ func (c URLsMap) String() string { // URLs returns a list of all URLs. // The returned list is sorted in ascending lexicographical order. func (c URLsMap) URLs() []string { - urls := make([]string, 0) + var urls []string for _, us := range c { for _, u := range us { urls = append(urls, u.String()) @@ -70,6 +65,29 @@ func (c URLsMap) URLs() []string { return urls } +// Len returns the size of URLsMap. func (c URLsMap) Len() int { return len(c) } + +// parse parses the given string and returns a map listing the values specified for each key. +func parse(s string) map[string][]string { + m := make(map[string][]string) + for s != "" { + key := s + if i := strings.IndexAny(key, ","); i >= 0 { + key, s = key[:i], key[i+1:] + } else { + s = "" + } + if key == "" { + continue + } + value := "" + if i := strings.Index(key, "="); i >= 0 { + key, value = key[:i], key[i+1:] + } + m[key] = append(m[key], value) + } + return m +} diff --git a/vendor/src/github.com/ugorji/go/codec/0doc.go b/vendor/src/github.com/ugorji/go/codec/0doc.go index dd8b589de0..caa7e0a3b5 100644 --- a/vendor/src/github.com/ugorji/go/codec/0doc.go +++ b/vendor/src/github.com/ugorji/go/codec/0doc.go @@ -98,7 +98,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 +162,32 @@ 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: +// +// - (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(interface{}) -> call this interface for each entry in there. +// } +// - 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(...) +// - Handle recursive types during encoding/decoding? diff --git a/vendor/src/github.com/ugorji/go/codec/binc.go b/vendor/src/github.com/ugorji/go/codec/binc.go index 9dadb0a47b..c884d14dce 100644 --- a/vendor/src/github.com/ugorji/go/codec/binc.go +++ b/vendor/src/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,13 @@ 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 +} + +func (d *bincDecDriver) reset() { + d.r = d.d.r +} + var _ decDriver = (*bincDecDriver)(nil) var _ encDriver = (*bincEncDriver)(nil) diff --git a/vendor/src/github.com/ugorji/go/codec/cbor.go b/vendor/src/github.com/ugorji/go/codec/cbor.go index c3b88da202..0e5d32b2ea 100644 --- a/vendor/src/github.com/ugorji/go/codec/cbor.go +++ b/vendor/src/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() + n.v = valueTypeExt + n.u = d.decUint() + n.l = nil d.bdRead = false - re.Tag = ui - d.d.decode(&re.Value) - v = &re + // 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,13 @@ 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 +} + var _ decDriver = (*cborDecDriver)(nil) var _ encDriver = (*cborEncDriver)(nil) diff --git a/vendor/src/github.com/ugorji/go/codec/decode.go b/vendor/src/github.com/ugorji/go/codec/decode.go index a2e35d7a15..b3b99f0367 100644 --- a/vendor/src/github.com/ugorji/go/codec/decode.go +++ b/vendor/src/github.com/ugorji/go/codec/decode.go @@ -9,6 +9,7 @@ import ( "fmt" "io" "reflect" + "time" ) // Some tagging information for error messages. @@ -25,10 +26,6 @@ var ( // 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 @@ -38,6 +35,9 @@ type decReader interface { readb([]byte) readn1() uint8 readn1eof() (v uint8, eof bool) + numread() int // number of bytes read + track() + stopTrack() []byte } type decReaderByteScanner interface { @@ -49,16 +49,23 @@ 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 + // 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: 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) + + // 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) @@ -79,20 +86,15 @@ type decDriver interface { // decodeExt(verifyTag bool, tag byte) (xtag byte, xbs []byte) ReadMapStart() int ReadArrayStart() int - ReadMapEnd() - ReadArrayEnd() - ReadArrayEntrySeparator() - ReadMapEntrySeparator() - ReadMapKVSeparator() + + reset() + uncacheRead() } type decNoSeparator struct{} -func (_ decNoSeparator) ReadMapEnd() {} -func (_ decNoSeparator) ReadArrayEnd() {} -func (_ decNoSeparator) ReadArrayEntrySeparator() {} -func (_ decNoSeparator) ReadMapEntrySeparator() {} -func (_ decNoSeparator) ReadMapKVSeparator() {} +func (_ decNoSeparator) ReadEnd() {} +func (_ decNoSeparator) uncacheRead() {} type DecodeOptions struct { // MapType specifies type to use during schema-less decoding of a map in the stream. @@ -103,6 +105,14 @@ type DecodeOptions struct { // 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 @@ -114,6 +124,43 @@ type DecodeOptions struct { // 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 } // ------------------------------------ @@ -181,8 +228,15 @@ 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 + 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) { @@ -197,6 +251,10 @@ func (z *ioDecReader) readx(n int) (bs []byte) { 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 } @@ -204,9 +262,14 @@ func (z *ioDecReader) readb(bs []byte) { if len(bs) == 0 { return } - if _, err := io.ReadAtLeast(z.br, bs, len(bs)); err != nil { + 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) { @@ -214,12 +277,20 @@ func (z *ioDecReader) readn1() (b uint8) { 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 { @@ -229,9 +300,28 @@ func (z *ioDecReader) readn1eof() (b uint8, eof bool) { } func (z *ioDecReader) unreadn1() { - if err := z.br.UnreadByte(); err != nil { + 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 } // ------------------------------------ @@ -243,6 +333,18 @@ 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() { @@ -298,9 +400,17 @@ 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 decFnInfoX struct { +type decFnInfo struct { d *Decoder ti *typeInfo xfFn Ext @@ -308,40 +418,26 @@ type decFnInfoX struct { 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) + f func(*decFnInfo, reflect.Value) } -func (f decFnInfo) builtin(rv reflect.Value) { - f.dd.DecodeBuiltin(f.ti.rtid, rv.Addr().Interface()) +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.dd.DecodeExt(rv.Addr().Interface(), 0, nil) +func (f *decFnInfo) rawExt(rv reflect.Value) { + f.d.d.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) 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{}) { +func (f *decFnInfo) getValueForUnmarshalInterface(rv reflect.Value, indir int8) (v interface{}) { if indir == -1 { v = rv.Addr().Interface() } else if indir == 0 { @@ -358,95 +454,101 @@ func (f decFnInfo) getValueForUnmarshalInterface(rv reflect.Value, indir int8) ( return } -func (f decFnInfo) selferUnmarshal(rv reflect.Value) { +func (f *decFnInfo) selferUnmarshal(rv reflect.Value) { f.getValueForUnmarshalInterface(rv, f.ti.csIndir).(Selfer).CodecDecodeSelf(f.d) } -func (f decFnInfo) binaryUnmarshal(rv reflect.Value) { +func (f *decFnInfo) binaryUnmarshal(rv reflect.Value) { bm := f.getValueForUnmarshalInterface(rv, f.ti.bunmIndir).(encoding.BinaryUnmarshaler) - xbs := f.dd.DecodeBytes(nil, false, true) + xbs := f.d.d.DecodeBytes(nil, false, true) if fnerr := bm.UnmarshalBinary(xbs); fnerr != nil { panic(fnerr) } } -func (f decFnInfo) textUnmarshal(rv reflect.Value) { +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())) - // } + fnerr := tm.UnmarshalText(f.d.d.DecodeBytes(f.d.b[:], true, true)) if fnerr != nil { panic(fnerr) } } -func (f decFnInfo) kErr(rv reflect.Value) { +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.dd.DecodeString()) +func (f *decFnInfo) kString(rv reflect.Value) { + rv.SetString(f.d.d.DecodeString()) } -func (f decFnInfo) kBool(rv reflect.Value) { - rv.SetBool(f.dd.DecodeBool()) +func (f *decFnInfo) kBool(rv reflect.Value) { + rv.SetBool(f.d.d.DecodeBool()) } -func (f decFnInfo) kInt(rv reflect.Value) { - rv.SetInt(f.dd.DecodeInt(intBitsize)) +func (f *decFnInfo) kInt(rv reflect.Value) { + rv.SetInt(f.d.d.DecodeInt(intBitsize)) } -func (f decFnInfo) kInt64(rv reflect.Value) { - rv.SetInt(f.dd.DecodeInt(64)) +func (f *decFnInfo) kInt64(rv reflect.Value) { + rv.SetInt(f.d.d.DecodeInt(64)) } -func (f decFnInfo) kInt32(rv reflect.Value) { - rv.SetInt(f.dd.DecodeInt(32)) +func (f *decFnInfo) kInt32(rv reflect.Value) { + rv.SetInt(f.d.d.DecodeInt(32)) } -func (f decFnInfo) kInt8(rv reflect.Value) { - rv.SetInt(f.dd.DecodeInt(8)) +func (f *decFnInfo) kInt8(rv reflect.Value) { + rv.SetInt(f.d.d.DecodeInt(8)) } -func (f decFnInfo) kInt16(rv reflect.Value) { - rv.SetInt(f.dd.DecodeInt(16)) +func (f *decFnInfo) kInt16(rv reflect.Value) { + rv.SetInt(f.d.d.DecodeInt(16)) } -func (f decFnInfo) kFloat32(rv reflect.Value) { - rv.SetFloat(f.dd.DecodeFloat(true)) +func (f *decFnInfo) kFloat32(rv reflect.Value) { + rv.SetFloat(f.d.d.DecodeFloat(true)) } -func (f decFnInfo) kFloat64(rv reflect.Value) { - rv.SetFloat(f.dd.DecodeFloat(false)) +func (f *decFnInfo) kFloat64(rv reflect.Value) { + rv.SetFloat(f.d.d.DecodeFloat(false)) } -func (f decFnInfo) kUint8(rv reflect.Value) { - rv.SetUint(f.dd.DecodeUint(8)) +func (f *decFnInfo) kUint8(rv reflect.Value) { + rv.SetUint(f.d.d.DecodeUint(8)) } -func (f decFnInfo) kUint64(rv reflect.Value) { - rv.SetUint(f.dd.DecodeUint(64)) +func (f *decFnInfo) kUint64(rv reflect.Value) { + rv.SetUint(f.d.d.DecodeUint(64)) } -func (f decFnInfo) kUint(rv reflect.Value) { - rv.SetUint(f.dd.DecodeUint(uintBitsize)) +func (f *decFnInfo) kUint(rv reflect.Value) { + rv.SetUint(f.d.d.DecodeUint(uintBitsize)) } -func (f decFnInfo) kUint32(rv reflect.Value) { - rv.SetUint(f.dd.DecodeUint(32)) +func (f *decFnInfo) kUintptr(rv reflect.Value) { + rv.SetUint(f.d.d.DecodeUint(uintBitsize)) } -func (f decFnInfo) kUint16(rv reflect.Value) { - rv.SetUint(f.dd.DecodeUint(16)) +func (f *decFnInfo) kUint32(rv reflect.Value) { + rv.SetUint(f.d.d.DecodeUint(32)) } -// func (f decFnInfo) kPtr(rv reflect.Value) { +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())) @@ -456,72 +558,105 @@ func (f decFnInfo) kUint16(rv reflect.Value) { // var kIntfCtr uint64 -func (f decFnInfo) kInterfaceNaked() (rvn reflect.Value) { +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 { + 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 { - f.d.errorf("cannot decode non-nil codec value into nil %v (%v methods)", f.ti.rt, num) + // 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 vt { + // var useRvn bool + switch n.v { case valueTypeMap: - if f.d.h.MapType == nil { - var m2 map[interface{}]interface{} - v = &m2 + // 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) + d.decode(&n.ms[l]) + rvn = reflect.ValueOf(&n.ms[l]).Elem() + n.ms = n.ms[:l] + } else if d.mtid == mapStrIntfTypId { // for json performance + l := len(n.ns) + n.ns = append(n.ns, nil) + d.decode(&n.ns[l]) + rvn = reflect.ValueOf(&n.ns[l]).Elem() + n.ns = n.ns[:l] } else { - rvn = reflect.New(f.d.h.MapType).Elem() - useRvn = true + rvn = reflect.New(d.h.MapType).Elem() + d.decodeValue(rvn, nil) } case valueTypeArray: - if f.d.h.SliceType == nil { - var m2 []interface{} - v = &m2 + // 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) + d.decode(&n.ss[l]) + rvn = reflect.ValueOf(&n.ss[l]).Elem() + n.ss = n.ss[:l] } else { - rvn = reflect.New(f.d.h.SliceType).Elem() - useRvn = true + rvn = reflect.New(d.h.SliceType).Elem() + d.decodeValue(rvn, nil) } case valueTypeExt: - re := v.(*RawExt) - bfn := f.d.h.getExtForTag(re.Tag) + 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] + n.is = n.is[:l] + d.decode(v2) + v = *v2 + } + bfn := d.h.getExtForTag(tag) if bfn == nil { - re.Data = detachZeroCopyBytes(f.d.bytes, nil, re.Data) - rvn = reflect.ValueOf(*re) + 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 re.Data != nil { - bfn.ext.ReadExt(rvnA.Interface(), re.Data) + if bytes != nil { + bfn.ext.ReadExt(rvnA.Interface(), bytes) } else { - bfn.ext.UpdateExt(rvnA.Interface(), re.Value) + bfn.ext.UpdateExt(rvnA.Interface(), v) } } - 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) + 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) { +func (f *decFnInfo) kInterface(rv reflect.Value) { // debugf("\t===> kInterface") // Note: @@ -530,82 +665,108 @@ func (f decFnInfo) kInterface(rv reflect.Value) { // 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() + 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 { - rve := rv.Elem() + 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 rve.CanSet() { - f.d.decodeValue(rve, decFn{}) + if rvn.CanSet() { + f.d.decodeValue(rvn, nil) } else { - rve2 := reflect.New(rve.Type()).Elem() - rve2.Set(rve) - f.d.decodeValue(rve2, decFn{}) - rv.Set(rve2) + rvn2 := reflect.New(rvn.Type()).Elem() + rvn2.Set(rvn) + f.d.decodeValue(rvn2, nil) + rv.Set(rvn2) } } } -func (f decFnInfo) kStruct(rv reflect.Value) { +func (f *decFnInfo) kStruct(rv reflect.Value) { fti := f.ti d := f.d - if f.dd.IsContainerType(valueTypeMap) { - containerLen := f.dd.ReadMapStart() + dd := d.d + cr := d.cr + ctyp := dd.ContainerType() + if ctyp == valueTypeMap { + containerLen := dd.ReadMapStart() if containerLen == 0 { - f.dd.ReadMapEnd() + if cr != nil { + cr.sendContainerState(containerMapEnd) + } 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)) + // 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 f.dd.TryDecodeAsNil() { + if dd.TryDecodeAsNil() { si.setToZeroValue(rv) } else { - d.decodeValue(si.field(rv, true), decFn{}) + d.decodeValue(si.field(rv, true), nil) } } else { d.structFieldNotFound(-1, rvkencname) } } } else { - for j := 0; !f.dd.CheckBreak(); j++ { - if j > 0 { - f.dd.ReadMapEntrySeparator() + for j := 0; !dd.CheckBreak(); j++ { + // rvkencname := dd.DecodeString() + if cr != nil { + cr.sendContainerState(containerMapKey) } - // rvkencname := f.dd.DecodeString() - rvkencname := stringView(f.dd.DecodeBytes(f.d.b[:], true, true)) - f.dd.ReadMapKVSeparator() + 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 f.dd.TryDecodeAsNil() { + if dd.TryDecodeAsNil() { si.setToZeroValue(rv) } else { - d.decodeValue(si.field(rv, true), decFn{}) + d.decodeValue(si.field(rv, true), nil) } } else { d.structFieldNotFound(-1, rvkencname) } } - f.dd.ReadMapEnd() } - } else if f.dd.IsContainerType(valueTypeArray) { - containerLen := f.dd.ReadArrayStart() + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + } else if ctyp == valueTypeArray { + containerLen := dd.ReadArrayStart() if containerLen == 0 { - f.dd.ReadArrayEnd() + if cr != nil { + cr.sendContainerState(containerArrayEnd) + } return } // Not much gain from doing it two ways for array. @@ -616,137 +777,144 @@ func (f decFnInfo) kStruct(rv reflect.Value) { if j == containerLen { break } - } else if f.dd.CheckBreak() { + } else if dd.CheckBreak() { break } - if j > 0 { - f.dd.ReadArrayEntrySeparator() + if cr != nil { + cr.sendContainerState(containerArrayElem) } - if f.dd.TryDecodeAsNil() { + if dd.TryDecodeAsNil() { si.setToZeroValue(rv) } else { - d.decodeValue(si.field(rv, true), decFn{}) + d.decodeValue(si.field(rv, true), nil) } - // 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() + if cr != nil { + cr.sendContainerState(containerArrayElem) } d.structFieldNotFound(j, "") } } - f.dd.ReadArrayEnd() + if cr != nil { + cr.sendContainerState(containerArrayEnd) + } } else { f.d.error(onlyMapOrArrayCanDecodeIntoStructErr) return } } -func (f decFnInfo) kSlice(rv reflect.Value) { +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) - } + 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 } + return } // array := f.seq == seqTypeChan - slh, containerLenS := d.decSliceHelperStart() + 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 rv.IsNil() { - // either chan or slice + // // an array can never return a nil slice. so no need to check f.array here. + if containerLenS == 0 { if f.seq == seqTypeSlice { - if containerLenS <= 0 { + if rv.IsNil() { rv.Set(reflect.MakeSlice(ti.rt, 0, 0)) } else { - rv.Set(reflect.MakeSlice(ti.rt, containerLenS, containerLenS)) + rv.SetLen(0) } } else if f.seq == seqTypeChan { - if containerLenS <= 0 { + if rv.IsNil() { 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() + slh.End() return } - rtelem0 := ti.rt.Elem() rtelem := rtelem0 for rtelem.Kind() == reflect.Ptr { rtelem = rtelem.Elem() } fn := d.getDecFn(rtelem, true, true) - rv0 := rv + var rv0, rv9 reflect.Value + rv0 = rv rvChanged := false - rvcap := rv.Cap() - // for j := 0; j < containerLenS; j++ { - - hasLen := containerLenS >= 0 - if hasLen { + 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++ { - rv0 := reflect.New(rtelem0).Elem() - d.decodeValue(rv0, fn) - rv.Send(rv0) + rv9 = reflect.New(rtelem0).Elem() + slh.ElemContainerState(j) + d.decodeValue(rv9, fn) + rv.Send(rv9) } - } else { - numToRead := containerLenS + } 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(rv.Len(), containerLenS) - numToRead = rvlen + d.arrayCannotExpand(rvlen, containerLenS) } else { - rv = reflect.MakeSlice(ti.rt, containerLenS, containerLenS) - if rvlen > 0 && !isMutableKind(ti.rt.Kind()) { - rv1 := rv0 - rv1.SetLen(rvcap) - reflect.Copy(rv, rv1) + 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 } - rvChanged = true - rvlen = containerLenS + 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) @@ -754,73 +922,112 @@ func (f decFnInfo) kSlice(rv reflect.Value) { } } 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 { - 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 + 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 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) + } + 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() } + slh.End() if rvChanged { rv0.Set(rv) } } -func (f decFnInfo) kArray(rv reflect.Value) { +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() - +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 { - // f.dd.ReadMapEnd() + if cr != nil { + cr.sendContainerState(containerMapEnd) + } return } - d := f.d - ktype, vtype := ti.rt.Key(), ti.rt.Elem() ktypeId := reflect.ValueOf(ktype).Pointer() - var keyFn, valFn decFn + vtypeKind := vtype.Kind() + var keyFn, valFn *decFn var xtyp reflect.Type for xtyp = ktype; xtyp.Kind() == reflect.Ptr; xtyp = xtyp.Elem() { } @@ -828,90 +1035,276 @@ func (f decFnInfo) kMap(rv reflect.Value) { 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() + 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(string(rvk.Bytes())) + rvk = reflect.ValueOf(d.string(rvk.Bytes())) } } - rvv := rv.MapIndex(rvk) - // TODO: is !IsValid check required? - if !rvv.IsValid() { - rvv = reflect.New(vtype).Elem() + 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) - rv.SetMapIndex(rvk, rvv) + if mapSet { + rv.SetMapIndex(rvk, rvv) + } } } else { - for j := 0; !f.dd.CheckBreak(); j++ { - if j > 0 { - f.dd.ReadMapEntrySeparator() + for j := 0; !dd.CheckBreak(); j++ { + rvk = reflect.New(ktype).Elem() + if cr != nil { + cr.sendContainerState(containerMapKey) } - 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())) + rvk = reflect.ValueOf(d.string(rvk.Bytes())) } } - rvv := rv.MapIndex(rvk) - if !rvv.IsValid() { - rvv = reflect.New(vtype).Elem() + 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) } - f.dd.ReadMapKVSeparator() d.decodeValue(rvv, valFn) - rv.SetMapIndex(rvk, rvv) + if mapSet { + rv.SetMapIndex(rvk, rvv) + } } - f.dd.ReadMapEnd() + } + if cr != nil { + cr.sendContainerState(containerMapEnd) } } -type rtidDecFn struct { +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 [32]rtidDecFn - s []rtidDecFn - h *BasicHandle + // sa [initCollectionCap]decRtidFn + h *BasicHandle + hh Handle - rb bytesDecReader - hh Handle be bool // is binary encoding bytes bool // is bytes reader + js bool // is json handle + rb bytesDecReader ri ioDecReader - f map[uintptr]decFn - _ uintptr // for alignment purposes, so next one starts from a cache line + cr containerStateRecv - b [scratchByteArrayLen]byte + 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) (d *Decoder) { - d = &Decoder{hh: h, h: h.getBasicHandle(), be: h.isBinary()} - //d.s = d.sa[:0] +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) @@ -919,23 +1312,22 @@ func NewDecoder(r io.Reader, h Handle) (d *Decoder) { d.ri.br = &d.ri.bs } d.r = &d.ri - d.d = h.newDecDriver(d) - return + d.resetCommon() } -// 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) +func (d *Decoder) ResetBytes(in []byte) { + // d.s = d.sa[:0] + d.rb.reset(in) d.r = &d.rb - d.d = h.newDecDriver(d) - // d.d = h.newDecDriver(decReaderT{true, &d.rb, &d.ri}) - return + 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. @@ -995,15 +1387,18 @@ func (d *Decoder) Decode(v interface{}) (err error) { // 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{}) + d.decodeValue(reflect.ValueOf(&blank).Elem(), nil) } func (d *Decoder) swallow() { // smarter decode that just swallows the content dd := d.d - switch { - case dd.TryDecodeAsNil(): - case dd.IsContainerType(valueTypeMap): + if dd.TryDecodeAsNil() { + return + } + cr := d.cr + switch dd.ContainerType() { + case valueTypeMap: containerLen := dd.ReadMapStart() clenGtEqualZero := containerLen >= 0 for j := 0; ; j++ { @@ -1014,15 +1409,19 @@ func (d *Decoder) swallow() { } else if dd.CheckBreak() { break } - if j > 0 { - dd.ReadMapEntrySeparator() + if cr != nil { + cr.sendContainerState(containerMapKey) } d.swallow() - dd.ReadMapKVSeparator() + if cr != nil { + cr.sendContainerState(containerMapValue) + } d.swallow() } - dd.ReadMapEnd() - case dd.IsContainerType(valueTypeArray): + if cr != nil { + cr.sendContainerState(containerMapEnd) + } + case valueTypeArray: containerLenS := dd.ReadArrayStart() clenGtEqualZero := containerLenS >= 0 for j := 0; ; j++ { @@ -1033,20 +1432,30 @@ func (d *Decoder) swallow() { } else if dd.CheckBreak() { break } - if j > 0 { - dd.ReadArrayEntrySeparator() + if cr != nil { + cr.sendContainerState(containerArrayElem) } d.swallow() } - dd.ReadArrayEnd() - case dd.IsContainerType(valueTypeBytes): + if cr != nil { + cr.sendContainerState(containerArrayEnd) + } + case valueTypeBytes: dd.DecodeBytes(d.b[:], false, true) - case dd.IsContainerType(valueTypeString): + 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] + n.is = n.is[:l] + d.decode(v2) + } } } @@ -1096,14 +1505,20 @@ func (d *Decoder) decode(iv interface{}) { case *[]uint8: *v = nil case reflect.Value: - d.chkPtrValue(v) + 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) - d.chkPtrValue(rv) + 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())) @@ -1121,8 +1536,11 @@ func (d *Decoder) decode(iv interface{}) { v.CodecDecodeSelf(d) case reflect.Value: - d.chkPtrValue(v) - d.decodeValueNotNil(v.Elem(), decFn{}) + if v.Kind() != reflect.Ptr || v.IsNil() { + d.errNotValidPtrValue(v) + } + // d.chkPtrValue(v) + d.decodeValueNotNil(v.Elem(), nil) case *string: @@ -1157,7 +1575,7 @@ func (d *Decoder) decode(iv interface{}) { *v = d.d.DecodeBytes(*v, false, false) case *interface{}: - d.decodeValueNotNil(reflect.ValueOf(iv).Elem(), decFn{}) + d.decodeValueNotNil(reflect.ValueOf(iv).Elem(), nil) default: if !fastpathDecodeTypeSwitch(iv, d) { @@ -1191,34 +1609,37 @@ func (d *Decoder) preDecodeValue(rv reflect.Value, tryNil bool) (rv2 reflect.Val func (d *Decoder) decodeI(iv interface{}, checkPtr, tryNil, checkFastpath, checkCodecSelfer bool) { rv := reflect.ValueOf(iv) if checkPtr { - d.chkPtrValue(rv) + 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) + fn.f(&fn.i, rv) } } -func (d *Decoder) decodeValue(rv reflect.Value, fn decFn) { +func (d *Decoder) decodeValue(rv reflect.Value, fn *decFn) { if rv, proceed := d.preDecodeValue(rv, true); proceed { - if fn.f == nil { + if fn == nil { fn = d.getDecFn(rv.Type(), true, true) } - fn.f(fn.i, rv) + fn.f(&fn.i, rv) } } -func (d *Decoder) decodeValueNotNil(rv reflect.Value, fn decFn) { +func (d *Decoder) decodeValueNotNil(rv reflect.Value, fn *decFn) { if rv, proceed := d.preDecodeValue(rv, false); proceed { - if fn.f == nil { + if fn == nil { fn = d.getDecFn(rv.Type(), true, true) } - fn.f(fn.i, rv) + fn.f(&fn.i, rv) } } -func (d *Decoder) getDecFn(rt reflect.Type, checkFastpath, checkCodecSelfer bool) (fn decFn) { +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 @@ -1229,9 +1650,10 @@ func (d *Decoder) getDecFn(rt reflect.Type, checkFastpath, checkCodecSelfer bool if useMapForCodecCache { fn, ok = d.f[rtid] } else { - for _, v := range d.s { + for i := range d.s { + v := &(d.s[i]) if v.rtid == rtid { - fn, ok = v.fn, true + fn, ok = &(v.fn), true break } } @@ -1240,11 +1662,25 @@ func (d *Decoder) getDecFn(rt reflect.Type, checkFastpath, checkCodecSelfer bool 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 := getTypeInfo(rtid, rt) - var fi decFnInfo - fi.dd = d.d - // fi.decFnInfoX = new(decFnInfoX) + 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. @@ -1256,31 +1692,26 @@ func (d *Decoder) getDecFn(rt reflect.Type, checkFastpath, checkCodecSelfer bool // 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 + fn.f = (*decFnInfo).selferUnmarshal } else if rtid == rawExtTypId { - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti} - fn.f = (decFnInfo).rawExt + fn.f = (*decFnInfo).rawExt } else if d.d.IsBuiltinType(rtid) { - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti} - fn.f = (decFnInfo).builtin + 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 + fn.f = (*decFnInfo).ext } else if supportMarshalInterfaces && d.be && ti.bunm { - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti} - fn.f = (decFnInfo).binaryUnmarshal + 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 { - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti} - fn.f = (decFnInfo).textUnmarshal + 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 { @@ -1296,8 +1727,7 @@ func (d *Decoder) getDecFn(rt reflect.Type, checkFastpath, checkCodecSelfer bool 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) { + fn.f = func(xf *decFnInfo, xrv reflect.Value) { // xfnf(xf, xrv.Convert(xrt)) xfnf(xf, xrv.Addr().Convert(reflect.PtrTo(xrt)).Elem()) } @@ -1307,72 +1737,58 @@ func (d *Decoder) getDecFn(rt reflect.Type, checkFastpath, checkCodecSelfer bool if fn.f == nil { switch rk { case reflect.String: - fn.f = (decFnInfo).kString + fn.f = (*decFnInfo).kString case reflect.Bool: - fn.f = (decFnInfo).kBool + fn.f = (*decFnInfo).kBool case reflect.Int: - fn.f = (decFnInfo).kInt + fn.f = (*decFnInfo).kInt case reflect.Int64: - fn.f = (decFnInfo).kInt64 + fn.f = (*decFnInfo).kInt64 case reflect.Int32: - fn.f = (decFnInfo).kInt32 + fn.f = (*decFnInfo).kInt32 case reflect.Int8: - fn.f = (decFnInfo).kInt8 + fn.f = (*decFnInfo).kInt8 case reflect.Int16: - fn.f = (decFnInfo).kInt16 + fn.f = (*decFnInfo).kInt16 case reflect.Float32: - fn.f = (decFnInfo).kFloat32 + fn.f = (*decFnInfo).kFloat32 case reflect.Float64: - fn.f = (decFnInfo).kFloat64 + fn.f = (*decFnInfo).kFloat64 case reflect.Uint8: - fn.f = (decFnInfo).kUint8 + fn.f = (*decFnInfo).kUint8 case reflect.Uint64: - fn.f = (decFnInfo).kUint64 + fn.f = (*decFnInfo).kUint64 case reflect.Uint: - fn.f = (decFnInfo).kUint + fn.f = (*decFnInfo).kUint case reflect.Uint32: - fn.f = (decFnInfo).kUint32 + fn.f = (*decFnInfo).kUint32 case reflect.Uint16: - fn.f = (decFnInfo).kUint16 + fn.f = (*decFnInfo).kUint16 // case reflect.Ptr: - // fn.f = (decFnInfo).kPtr + // fn.f = (*decFnInfo).kPtr + case reflect.Uintptr: + fn.f = (*decFnInfo).kUintptr case reflect.Interface: - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti} - fn.f = (decFnInfo).kInterface + fn.f = (*decFnInfo).kInterface case reflect.Struct: - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti} - fn.f = (decFnInfo).kStruct + fn.f = (*decFnInfo).kStruct case reflect.Chan: - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti, seq: seqTypeChan} - fn.f = (decFnInfo).kSlice + fi.seq = seqTypeChan + fn.f = (*decFnInfo).kSlice case reflect.Slice: - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti, seq: seqTypeSlice} - fn.f = (decFnInfo).kSlice + fi.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 + fi.seq = seqTypeArray + fn.f = (*decFnInfo).kArray case reflect.Map: - fi.decFnInfoX = &decFnInfoX{d: d, ti: ti} - fn.f = (decFnInfo).kMap + fn.f = (*decFnInfo).kMap default: - fn.f = (decFnInfo).kErr + 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 } @@ -1400,6 +1816,10 @@ func (d *Decoder) chkPtrValue(rv reflect.Value) { 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 @@ -1417,57 +1837,92 @@ func (d *Decoder) error(err error) { } func (d *Decoder) errorf(format string, params ...interface{}) { - err := fmt.Errorf(format, params...) + 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 + } +} + +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 { - dd decDriver - ct valueType + d *Decoder + // ct valueType + array bool } 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 + 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.errorf("only encoded map or array can be decoded into a slice (%d)", ctyp) } + // x.ct = ctyp + x.d = d return } -func (x decSliceHelper) Sep(index int) { - if x.ct == valueTypeArray { - x.dd.ReadArrayEntrySeparator() +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 { - x.dd.ReadMapEntrySeparator() + cr.sendContainerState(containerMapKey) } else { - x.dd.ReadMapKVSeparator() + cr.sendContainerState(containerMapValue) } } } -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 @@ -1498,6 +1953,46 @@ func detachZeroCopyBytes(isBytesReader bool, dest []byte, in []byte) (out []byte 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 @@ -1516,37 +2011,5 @@ func detachZeroCopyBytes(isBytesReader bool, dest []byte, in []byte) (out []byte // 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{} // +// ... for other methods of decReader. +// Testing showed that performance improvement was negligible. diff --git a/vendor/src/github.com/ugorji/go/codec/encode.go b/vendor/src/github.com/ugorji/go/codec/encode.go index 38c55be4e8..99af6fa555 100644 --- a/vendor/src/github.com/ugorji/go/codec/encode.go +++ b/vendor/src/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,8 +97,17 @@ 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 // AsSymbols defines what should be encoded as symbols. @@ -166,6 +159,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 } @@ -249,10 +243,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 +258,7 @@ func (z *bytesEncWriter) grow(n int) (oldcursor int) { // --------------------------------------------- -type encFnInfoX struct { +type encFnInfo struct { e *Encoder ti *typeInfo xfFn Ext @@ -272,25 +266,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 +280,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 +318,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 +418,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 +433,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 +455,83 @@ 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 l%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 the occasional locking 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) + kv.r = si.field(rv, false) // if si.i != -1 { // rvals[newlen] = rv.Field(int(si.i)) // } else { // rvals[newlen] = rv.FieldByIndex(si.is) // } 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 +540,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 +587,37 @@ 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) { +func (f *encFnInfo) kInterface(rv reflect.Value) { if rv.IsNil() { - f.ee.EncodeNil() + f.e.e.EncodeNil() return } - f.e.encodeValue(rv.Elem(), encFn{}) + 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 +629,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 +656,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 +673,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 +859,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 +872,25 @@ 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 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 +898,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 +909,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 +985,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 +998,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 +1010,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 +1059,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,13 +1126,9 @@ 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) } } } @@ -1025,57 +1138,56 @@ func (e *Encoder) encodeI(iv interface{}, checkFastpath, checkCodecSelfer bool) rt := rv.Type() rtid := reflect.ValueOf(rt).Pointer() fn := e.getEncFn(rtid, rt, checkFastpath, checkCodecSelfer) - fn.f(fn.i, rv) + fn.f(&fn.i, rv) } } 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: + // use a goto statement instead of a recursive function for ptr/interface. +TOP: + switch rv.Kind() { + case reflect.Ptr, reflect.Interface: + if rv.IsNil() { e.e.EncodeNil() return } - break + 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 } 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 { + if fn == nil { rt := rv.Type() rtid := reflect.ValueOf(rt).Pointer() fn = e.getEncFn(rtid, rt, true, true) } - fn.f(fn.i, rv) + fn.f(&fn.i, rv) } } -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 +1195,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 idx := fastpathAV.index(rtid); idx != -1 { - fi.encFnInfoX = &encFnInfoX{e: e, ti: ti} fn.f = fastpathAV[idx].encfn } } else { @@ -1129,8 +1251,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 +1260,66 @@ 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 // case reflect.Ptr: - // fn.f = (encFnInfo).kPtr + // fn.f = (*encFnInfo).kPtr case reflect.Interface: - fi.encFnInfoX = &encFnInfoX{e: e, ti: ti} - fn.f = (encFnInfo).kInterface + 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 +1327,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 +1341,61 @@ 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 pool == nil { + // fkvs = make([]stringRv, newlen) + // } else { + // poolv = pool.Get() + // switch vv := poolv.(type) { + // case *[8]stringRv: + // fkvs = vv[:newlen] + // case *[16]stringRv: + // fkvs = vv[:newlen] + // case *[32]stringRv: + // fkvs = vv[:newlen] + // case *[64]stringRv: + // fkvs = vv[:newlen] + // case *[128]stringRv: + // fkvs = vv[:newlen] + // } + // } + + 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/vendor/src/github.com/ugorji/go/codec/fast-path.generated.go b/vendor/src/github.com/ugorji/go/codec/fast-path.generated.go index b0f7f8070f..d968a500fd 100644 --- a/vendor/src/github.com/ugorji/go/codec/fast-path.generated.go +++ b/vendor/src/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. @@ -48,15 +48,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 +65,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 @@ -85,7 +85,7 @@ func init() { 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 +93,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[:])) } @@ -341,6 +373,9 @@ func init() { // -- -- fast path type switch func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { + if !fastpathEnabled { + return false + } switch v := iv.(type) { case []interface{}: @@ -383,6 +418,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 +503,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 +588,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 +673,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 +758,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 +838,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 +923,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 +1008,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 +1093,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 +1138,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 +1263,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 +1348,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 +1433,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 +1518,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 +1603,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 +1688,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,12 +1734,16 @@ 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 } func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { + if !fastpathEnabled { + return false + } switch v := iv.(type) { case []interface{}: @@ -1587,6 +1786,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,12 +1822,16 @@ 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 } func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { + if !fastpathEnabled { + return false + } switch v := iv.(type) { case map[interface{}]interface{}: @@ -1661,6 +1869,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 +1949,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 +2029,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 +2109,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 +2189,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 +2269,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 +2349,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 +2429,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 +2509,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 +2554,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 +2669,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 +2749,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 +2829,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 +2909,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 +2989,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 +3069,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 +3115,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 +3123,12365 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { // -- -- fast path functions -func (f encFnInfo) fastpathEncSliceIntfR(rv reflect.Value) { +func (f *encFnInfo) fastpathEncSliceIntfR(rv reflect.Value) { 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) { +func (f *encFnInfo) fastpathEncSliceStringR(rv reflect.Value) { 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) { +func (f *encFnInfo) fastpathEncSliceFloat32R(rv reflect.Value) { 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) { +func (f *encFnInfo) fastpathEncSliceFloat64R(rv reflect.Value) { 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) { +func (f *encFnInfo) fastpathEncSliceUintR(rv reflect.Value) { 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) { +func (f *encFnInfo) fastpathEncSliceUint16R(rv reflect.Value) { 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) { +func (f *encFnInfo) fastpathEncSliceUint32R(rv reflect.Value) { 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) { +func (f *encFnInfo) fastpathEncSliceUint64R(rv reflect.Value) { 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) { +func (f *encFnInfo) fastpathEncSliceUintptrR(rv reflect.Value) { + 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 (f *encFnInfo) fastpathEncSliceIntR(rv reflect.Value) { 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) { +func (f *encFnInfo) fastpathEncSliceInt8R(rv reflect.Value) { 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) { +func (f *encFnInfo) fastpathEncSliceInt16R(rv reflect.Value) { 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) { +func (f *encFnInfo) fastpathEncSliceInt32R(rv reflect.Value) { 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) { +func (f *encFnInfo) fastpathEncSliceInt64R(rv reflect.Value) { 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) { +func (f *encFnInfo) fastpathEncSliceBoolR(rv reflect.Value) { 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 (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) } } @@ -10208,6 +15489,9 @@ func (_ fastpathT) EncMapBoolBoolV(v map[bool]bool, checkNil bool, e *Encoder) { // -- -- fast path type switch func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { + if !fastpathEnabled { + return false + } switch v := iv.(type) { case []interface{}: @@ -10274,6 +15558,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 +15694,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 +15830,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 +15966,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 +16102,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 +16230,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 +16366,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 +16502,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 +16638,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 +16710,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 +16910,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 +17046,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 +17182,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 +17318,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 +17454,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 +17590,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 +17663,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 +17671,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 +17691,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 +17702,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 } - return v, changed + slh.End() + return } - // 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 + } + 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 +17787,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 +17825,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 +17836,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 } - return v, changed + slh.End() + return } - // 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 + } + 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 +17921,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 +17958,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 +17969,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 } - return v, changed + slh.End() + return } - // 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 + } + 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 +18054,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 +18091,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 +18102,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 } - return v, changed + slh.End() + return } - // 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 + } + 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 +18187,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 +18224,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 +18235,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 } - return v, changed + slh.End() + return } - // 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 + } + 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 +18320,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 +18357,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 +18368,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 } - return v, changed + slh.End() + return } - // 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 + } + 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 +18453,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 +18490,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 +18501,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 } - return v, changed + slh.End() + return } - // 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 + } + 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 +18586,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 +18623,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 +18634,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 } - return v, changed + slh.End() + return } - // 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 + } + 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 +18719,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 + } + + 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 + } + 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 +18889,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 +18900,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 } - return v, changed + slh.End() + return } - // 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 + } + 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 +18985,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 +19022,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 +19033,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 } - return v, changed + slh.End() + return } - // 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 + } + 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 +19118,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 +19155,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 +19166,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 } - return v, changed + slh.End() + return } - // 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 + } + 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 +19251,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 +19288,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 +19299,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 } - return v, changed + slh.End() + return } - // 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 + } + 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 +19384,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 +19421,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 +19432,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 } - return v, changed + slh.End() + return } - // 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 + } + 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 +19517,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 +19554,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 +19565,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 } - return v, changed + slh.End() + return } - // 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 + } + 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 +19650,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 +19688,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 +19699,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 +19780,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 +19791,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 +19818,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 +19862,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 +19873,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 +19900,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 +19944,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 +19955,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 +19982,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 +20026,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 +20037,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 +20064,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 +20108,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 +20119,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 +20146,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 +20190,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 +20201,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 +20228,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 +20354,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 +20365,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 +20392,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 +20436,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 +20447,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 +20474,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 +20518,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 +20529,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 +20556,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 +20600,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 +20611,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 +20638,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 +20682,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 +20693,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 +20720,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 +20764,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 +20775,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 +20802,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 +20846,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 +20857,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 +20884,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 +20928,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 +20939,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 +20966,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 +21010,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 +21021,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 +21094,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 +21105,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 +21128,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 +21168,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 +21179,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 +21202,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 +21242,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 +21253,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 +21276,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 +21316,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 +21327,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 +21350,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 +21390,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 +21401,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 +21424,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 +21464,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 +21475,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 +21498,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 +21612,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 +21623,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 +21646,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 +21686,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 +21697,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 +21720,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 +21760,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 +21771,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 +21794,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 +21834,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 +21845,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 +21868,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 +21908,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 +21919,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 +21942,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 +21982,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 +21993,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 +22016,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 +22056,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 +22067,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 +22090,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 +22130,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 +22141,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 +22164,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 +22204,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 +22215,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 +22288,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 +22299,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 +22322,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 +22362,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 +22373,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 +22396,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 +22436,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 +22447,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 +22470,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 +22510,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 +22521,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 +22544,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 +22584,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 +22595,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 +22618,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 +22658,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 +22669,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 +22692,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 +22806,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 +22817,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 +22840,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 +22880,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 +22891,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 +22914,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 +22954,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 +22965,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 +22988,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 +23028,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 +23039,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 +23062,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 +23102,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 +23113,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 +23136,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 +23176,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 +23187,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 +23210,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 +23250,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 +23261,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 +23284,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 +23324,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 +23335,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 +23358,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 +23398,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 +23409,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 +23482,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 +23493,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 +23516,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 +23556,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 +23567,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 +23590,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 +23630,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 +23641,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 +23664,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 +23704,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 +23715,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 +23738,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 +23778,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 +23789,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 +23812,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 +23852,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 +23863,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 +23886,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 +24000,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 +24011,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 +24034,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 +24074,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 +24085,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 +24108,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 +24148,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 +24159,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 +24182,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 +24222,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 +24233,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 +24256,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 +24296,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 +24307,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 +24330,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 +24370,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 +24381,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 +24404,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 +24444,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 +24455,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 +24478,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 +24518,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 +24529,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 +24552,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 +24592,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 +24603,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 +24676,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 +24687,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 +24710,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 +24750,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 +24761,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 +24784,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 +24824,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 +24835,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 +24858,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 +24898,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 +24909,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 +24932,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 +24972,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 +24983,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 +25006,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 +25046,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 +25057,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 +25080,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 +25194,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 +25205,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 +25228,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 +25268,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 +25279,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 +25302,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 +25342,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 +25353,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 +25376,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 +25416,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 +25427,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 +25450,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 +25490,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 +25501,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 +25524,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 +25564,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 +25575,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 +25598,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 +25638,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 +25649,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 +25672,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 +25712,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 +25723,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 +25746,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 +25786,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 +25797,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 +25870,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 +25881,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 +25904,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 +25944,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 +25955,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 +25978,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 +26018,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 +26029,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 +26052,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 +26092,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 +26103,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 +26126,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 +26166,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 +26177,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 +26200,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 +26240,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 +26251,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 +26274,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 +26388,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 +26399,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 +26422,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 +26462,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 +26473,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 +26496,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 +26536,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 +26547,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 +26570,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 +26610,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 +26621,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 +26644,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 +26684,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 +26695,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 +26718,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 +26758,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 +26769,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 +26792,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 +26832,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 +26843,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 +26866,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 +26906,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 +26917,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 +26940,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 +26980,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 +26991,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 +27064,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 +27075,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 +27098,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 +27138,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 +27149,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 +27172,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 +27212,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 +27223,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 +27246,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 +27286,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 +27297,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 +27320,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 +27360,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 +27371,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 +27394,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 +27434,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 +27445,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 +27468,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 +27582,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 +27593,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 +27616,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 +27656,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 +27667,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 +27690,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 +27730,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 +27741,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 +27764,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 +27804,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 +27815,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 +27838,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 +27878,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 +27889,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 +27912,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 +27952,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 +27963,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 +27986,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 +28026,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 +28037,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 +28060,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 +28100,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 +28111,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 +28134,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 +28174,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 +28185,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 +28258,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 +28269,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 +28292,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 +28332,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 +28343,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 +28366,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 +28406,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 +28417,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 +28440,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 +28480,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 +28491,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 +28514,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 +28554,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 +28565,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 +28588,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 +28628,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 +28639,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 +28662,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 +28776,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 +28787,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 +28810,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 +28850,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 +28861,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 +28884,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 +28924,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 +28935,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 +28958,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 +28998,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 +29009,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 +29032,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 +29072,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 +29083,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 +29106,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 +29146,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 +29157,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 +29180,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 +29220,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 +29231,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 +29254,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 +29294,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 +29305,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 +29328,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 +29368,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 +29379,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 +29452,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 +29463,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 +29486,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 +29526,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 +29537,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 +29560,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 +29600,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 +29611,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 +29634,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 +29674,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 +29685,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 +29708,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 +29748,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 +29759,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 +29782,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 +29822,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 +29833,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 +29856,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 +29970,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 +29981,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 +30004,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 +30044,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 +30055,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 +30078,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 +30118,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 +30129,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 +30152,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 +30192,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 +30203,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 +30226,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 +30266,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 +30277,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 +30300,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 +30340,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 +30351,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 +30374,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 +30414,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 +30425,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 +30448,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 +30488,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 +30499,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 +30522,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 +31756,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 +31767,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 +31840,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 +31851,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 +31874,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 +31914,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 +31925,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 +31948,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 +31988,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 +31999,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 +32022,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 +32062,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 +32073,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 +32096,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 +32136,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 +32147,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 +32170,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 +32210,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 +32221,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 +32244,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 +32358,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 +32369,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 +32392,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 +32432,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 +32443,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 +32466,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 +32506,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 +32517,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 +32540,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 +32580,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 +32591,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 +32614,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 +32654,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 +32665,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 +32688,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 +32728,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 +32739,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 +32762,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 +32802,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 +32813,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 +32836,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 +32876,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 +32887,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 +32910,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 +32950,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 +32961,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 +33034,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 +33045,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 +33068,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 +33108,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 +33119,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 +33142,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 +33182,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 +33193,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 +33216,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 +33256,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 +33267,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 +33290,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 +33330,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 +33341,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 +33364,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 +33404,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 +33415,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 +33438,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 +33552,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 +33563,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 +33586,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 +33626,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 +33637,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 +33660,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 +33700,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 +33711,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 +33734,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 +33774,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 +33785,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 +33808,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 +33848,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 +33859,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 +33882,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 +33922,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 +33933,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 +33956,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 +33996,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 +34007,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 +34030,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 +34070,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 +34081,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 +34104,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 +34144,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 +34155,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 +34228,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 +34239,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 +34262,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 +34302,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 +34313,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 +34336,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 +34376,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 +34387,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 +34410,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 +34450,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 +34461,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 +34484,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 +34524,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 +34535,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 +34558,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 +34598,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 +34609,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 +34632,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 +34746,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 +34757,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 +34780,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 +34820,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 +34831,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 +34854,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 +34894,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 +34905,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 +34928,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 +34968,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 +34979,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 +35002,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 +35042,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 +35053,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 +35076,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 +35116,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 +35127,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 +35150,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 +35190,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 +35201,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 +35224,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 +35264,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 +35275,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 +35298,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 +35338,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 +35349,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 +35422,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 +35433,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 +35456,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 +35496,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 +35507,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 +35530,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 +35570,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 +35581,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 +35604,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 +35644,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 +35655,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 +35678,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 +35718,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 +35729,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 +35752,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 +35792,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 +35803,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 +35826,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 +35940,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 +35951,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 +35974,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 +36014,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 +36025,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 +36048,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 +36088,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 +36099,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 +36122,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 +36162,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 +36173,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 +36196,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 +36236,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 +36247,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 +36270,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 +36310,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 +36321,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 +36344,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 +36384,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 +36395,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 +36418,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 +36458,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 +36469,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 +36492,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 +36532,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 +36543,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 +36616,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 +36627,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 +36650,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 +36690,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 +36701,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 +36724,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 +36764,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 +36775,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 +36798,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 +36838,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 +36849,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 +36872,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 +36912,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 +36923,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 +36946,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 +36986,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 +36997,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 +37020,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 +37134,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 +37145,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 +37168,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 +37208,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 +37219,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 +37242,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 +37282,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 +37293,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 +37316,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 +37356,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 +37367,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 +37390,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 +37430,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 +37441,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 +37464,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 +37504,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 +37515,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 +37538,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 +37578,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 +37589,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 +37612,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 +37652,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 +37663,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 +37686,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 +37726,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 +37737,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 +37810,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 +37821,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 +37844,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 +37884,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 +37895,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 +37918,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 +37958,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 +37969,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 +37992,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 +38032,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 +38043,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 +38066,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 +38106,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 +38117,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 +38140,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 +38180,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 +38191,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 +38214,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 +38328,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 +38339,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 +38362,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 +38402,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 +38413,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 +38436,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 +38476,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 +38487,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 +38510,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 +38550,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 +38561,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 +38584,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 +38624,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 +38635,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 +38658,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 +38698,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 +38709,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 +38732,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 +38772,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 +38783,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 +38806,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 +38846,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 +38857,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 +38880,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/src/github.com/ugorji/go/codec/fast-path.go.tmpl b/vendor/src/github.com/ugorji/go/codec/fast-path.go.tmpl index 9f0adccf83..58cc6df4c5 100644 --- a/vendor/src/github.com/ugorji/go/codec/fast-path.go.tmpl +++ b/vendor/src/github.com/ugorji/go/codec/fast-path.go.tmpl @@ -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. @@ -48,8 +48,8 @@ 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 [{{ .FastpathLen }}]fastpathE @@ -85,7 +85,7 @@ func init() { 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,11 +93,11 @@ func init() { 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 .MapKey }} + 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}} + {{range .Values}}{{if not .Primitive}}{{if .MapKey }} + fn(map[{{ .MapKey }}]{{ .Elem }}(nil), (*encFnInfo).{{ .MethodNamePfx "fastpathEnc" false }}R, (*decFnInfo).{{ .MethodNamePfx "fastpathDec" false }}R){{end}}{{end}}{{end}} sort.Sort(fastpathAslice(fastpathAV[:])) } @@ -106,118 +106,149 @@ func init() { // -- -- fast path type switch func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { + if !fastpathEnabled { + return false + } switch v := iv.(type) { -{{range .Values}}{{if not .Primitive}}{{if .Slice }} +{{range .Values}}{{if not .Primitive}}{{if not .MapKey }} case []{{ .Elem }}:{{else}} case map[{{ .MapKey }}]{{ .Elem }}:{{end}} - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, fastpathCheckNilTrue, e){{if .Slice }} + fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, fastpathCheckNilTrue, e){{if not .MapKey }} case *[]{{ .Elem }}:{{else}} case *map[{{ .MapKey }}]{{ .Elem }}:{{end}} fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, fastpathCheckNilTrue, e) {{end}}{{end}} default: + _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) return false } return true } func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { + if !fastpathEnabled { + return false + } switch v := iv.(type) { -{{range .Values}}{{if not .Primitive}}{{if .Slice }} +{{range .Values}}{{if not .Primitive}}{{if not .MapKey }} case []{{ .Elem }}: fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, fastpathCheckNilTrue, e) case *[]{{ .Elem }}: fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, fastpathCheckNilTrue, e) {{end}}{{end}}{{end}} default: + _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) return false } return true } func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { + if !fastpathEnabled { + return false + } switch v := iv.(type) { -{{range .Values}}{{if not .Primitive}}{{if not .Slice }} +{{range .Values}}{{if not .Primitive}}{{if .MapKey }} 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: + _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) return false } return true } // -- -- fast path functions -{{range .Values}}{{if not .Primitive}}{{if .Slice }} +{{range .Values}}{{if not .Primitive}}{{if not .MapKey }} -func (f encFnInfo) {{ .MethodNamePfx "fastpathEnc" false }}R(rv reflect.Value) { +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 + ee := e.e + cr := e.cr 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() + for _, v2 := range v { + if cr != nil { cr.sendContainerState(containerArrayElem) } + {{ encmd .Elem "v2"}} } + if cr != nil { cr.sendContainerState(containerArrayEnd) }{{/* ee.EncodeEnd() */}} } {{end}}{{end}}{{end}} -{{range .Values}}{{if not .Primitive}}{{if not .Slice }} +{{range .Values}}{{if not .Primitive}}{{if .MapKey }} -func (f encFnInfo) {{ .MethodNamePfx "fastpathEnc" false }}R(rv reflect.Value) { +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 + cr := e.cr 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"}}asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 + {{end}}if e.h.Canonical { + {{if eq .MapKey "interface{}"}}{{/* out of band + */}}var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding + e2 := NewEncoderBytes(&mksv, e.hh) + v2 := make([]bytesI, len(v)) + var i, l int + var vp *bytesI {{/* put loop variables outside. seems currently needed for better perf */}} + 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}}{{ $x := sorttype .MapKey true}}v2 := make([]{{ $x }}, len(v)) + var i int + for k, _ := range v { + v2[i] = {{ $x }}(k) + i++ + } + sort.Sort({{ sorttype .MapKey false}}(v2)) + for _, k2 := range v2 { + if cr != nil { cr.sendContainerState(containerMapKey) } {{if eq .MapKey "string"}}if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) - }{{else}}{{ encmd .MapKey "k2"}}{{end}} - {{ encmd .Elem "v2"}} - } + }{{else}}{{ $y := printf "%s(k2)" .MapKey }}{{ encmd .MapKey $y }}{{end}} + if cr != nil { cr.sendContainerState(containerMapValue) } + {{ $y := printf "v[%s(k2)]" .MapKey }}{{ encmd .Elem $y }} + } {{end}} } else { - j := 0 for k2, v2 := range v { - if j > 0 { - ee.EncodeMapEntrySeparator() - } + if cr != nil { cr.sendContainerState(containerMapKey) } {{if eq .MapKey "string"}}if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) }{{else}}{{ encmd .MapKey "k2"}}{{end}} - ee.EncodeMapKVSeparator() + if cr != nil { cr.sendContainerState(containerMapValue) } {{ encmd .Elem "v2"}} - j++ } - ee.EncodeMapEnd() } + if cr != nil { cr.sendContainerState(containerMapEnd) }{{/* ee.EncodeEnd() */}} } {{end}}{{end}}{{end}} @@ -226,11 +257,14 @@ func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v map[{{ .MapKey }}]{{ .Ele // -- -- fast path type switch func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { + if !fastpathEnabled { + return false + } switch v := iv.(type) { -{{range .Values}}{{if not .Primitive}}{{if .Slice }} +{{range .Values}}{{if not .Primitive}}{{if not .MapKey }} case []{{ .Elem }}:{{else}} case map[{{ .MapKey }}]{{ .Elem }}:{{end}} - fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, fastpathCheckNilFalse, false, d){{if .Slice }} + fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, fastpathCheckNilFalse, false, d){{if not .MapKey }} case *[]{{ .Elem }}:{{else}} case *map[{{ .MapKey }}]{{ .Elem }}:{{end}} v2, changed2 := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*v, fastpathCheckNilFalse, true, d) @@ -239,22 +273,23 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { } {{end}}{{end}} default: + _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) return false } return true } // -- -- fast path functions -{{range .Values}}{{if not .Primitive}}{{if .Slice }} +{{range .Values}}{{if not .Primitive}}{{if not .MapKey }} {{/* 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) { +func (f *decFnInfo) {{ .MethodNamePfx "fastpathDec" false }}R(rv reflect.Value) { array := f.seq == seqTypeArray - if !array && rv.CanAddr() { // CanSet => CanAddr + Exported + 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 { @@ -272,10 +307,9 @@ func (f fastpathT) {{ .MethodNamePfx "Dec" false }}X(vp *[]{{ .Elem }}, checkNil *vp = v } } -func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v []{{ .Elem }}, checkNil bool, canChange bool, - d *Decoder) (_ []{{ .Elem }}, changed bool) { +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 dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() */}} if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -284,54 +318,87 @@ func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v []{{ .Elem }}, checkNil b } 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 + if canChange { + if v == nil { + v = []{{ .Elem }}{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return } - // for j := 0; j < containerLenS; j++ { if containerLenS > 0 { - decLen := containerLenS + x2read := containerLenS + var xtrunc bool if containerLenS > cap(v) { - if canChange { - s := make([]{{ .Elem }}, containerLenS, containerLenS) + if canChange { {{/* + // fast-path is for "basic" immutable types, so no need to copy them over + // s := make([]{{ .Elem }}, decInferLen(containerLenS, d.h.MaxInitLen)) // copy(s, v[:cap(v)]) - v = s + // v = s */}} + var xlen int + xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, {{ .Size }}) + if xtrunc { + if xlen <= cap(v) { + v = v[:xlen] + } else { + v = make([]{{ .Elem }}, xlen) + } + } else { + v = make([]{{ .Elem }}, 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 - } - // all checks done. cannot go past len. + 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) {{ if eq .Elem "interface{}" }}d.decode(&v[j]){{ else }}v[j] = {{ decmd .Elem }}{{ end }} } - if !canChange { - for ; j < containerLenS; j++ { + if xtrunc { {{/* // means canChange=true, changed=true already. */}} + for ; j < containerLenS; j++ { + v = append(v, {{ zerocmd .Elem }}) + slh.ElemContainerState(j) + {{ if eq .Elem "interface{}" }}d.decode(&v[j]){{ else }}v[j] = {{ decmd .Elem }}{{ end }} + } + } else if !canChange { + for ; j < containerLenS; j++ { + slh.ElemContainerState(j) d.swallow() } } } else { - j := 0 - for ; !dd.CheckBreak(); j++ { + breakFound := dd.CheckBreak() {{/* check break first, so we can initialize v with a capacity of 4 if necessary */}} + if breakFound { + if canChange { + if v == nil { + v = []{{ .Elem }}{} + } else if len(v) != 0 { + v = v[:0] + } + changed = true + } + slh.End() + return + } + if cap(v) == 0 { + v = make([]{{ .Elem }}, 1, 4) + changed = true + } + j := 0 + for ; !breakFound; j++ { if j >= len(v) { if canChange { v = append(v, {{ zerocmd .Elem }}) @@ -339,32 +406,35 @@ func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v []{{ .Elem }}, checkNil b } else { 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) { {{/* // all checks done. cannot go past len. */}} {{ if eq .Elem "interface{}" }}d.decode(&v[j]) {{ else }}v[j] = {{ decmd .Elem }}{{ end }} } else { d.swallow() } + breakFound = dd.CheckBreak() + } + if canChange && j < len(v) { + v = v[:j] + changed = true } - slh.End() } + slh.End() return v, changed } {{end}}{{end}}{{end}} -{{range .Values}}{{if not .Primitive}}{{if not .Slice }} +{{range .Values}}{{if not .Primitive}}{{if .MapKey }} {{/* Maps can change if they are - addressable (from a ptr) - settable (e.g. contained in an interface{}) */}} -func (f decFnInfo) {{ .MethodNamePfx "fastpathDec" false }}R(rv reflect.Value) { +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) @@ -385,7 +455,8 @@ func (f fastpathT) {{ .MethodNamePfx "Dec" false }}X(vp *map[{{ .MapKey }}]{{ .E 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() + cr := d.cr + {{/* // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() */}} if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true @@ -395,47 +466,45 @@ func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v map[{{ .MapKey }}]{{ .Ele 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 - } + xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, {{ .Size }}) + v = make(map[{{ .MapKey }}]{{ .Elem }}, xlen) changed = true } + {{ if eq .Elem "interface{}" }}mapGet := !d.h.MapValueReset && !d.h.InterfaceReset{{end}} + var mk {{ .MapKey }} + var mv {{ .Elem }} if containerLen > 0 { for j := 0; j < containerLen; j++ { - {{ if eq .MapKey "interface{}" }}var mk interface{} + if cr != nil { cr.sendContainerState(containerMapKey) } + {{ if eq .MapKey "interface{}" }}mk = nil 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 }} + mk = d.string(bv) {{/* // maps cannot have []byte as key. switch to string. */}} + }{{ else }}mk = {{ decmd .MapKey }}{{ end }} + if cr != nil { cr.sendContainerState(containerMapValue) } + {{ if eq .Elem "interface{}" }}if mapGet { mv = v[mk] } else { mv = nil } + d.decode(&mv){{ else }}mv = {{ decmd .Elem }}{{ end }} if v != nil { v[mk] = mv } } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { - if j > 0 { - dd.ReadMapEntrySeparator() - } - {{ if eq .MapKey "interface{}" }}var mk interface{} + if cr != nil { cr.sendContainerState(containerMapKey) } + {{ if eq .MapKey "interface{}" }}mk = nil 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 }} + mk = d.string(bv) {{/* // maps cannot have []byte as key. switch to string. */}} + }{{ else }}mk = {{ decmd .MapKey }}{{ end }} + if cr != nil { cr.sendContainerState(containerMapValue) } + {{ if eq .Elem "interface{}" }}if mapGet { mv = v[mk] } else { mv = nil } + d.decode(&mv){{ else }}mv = {{ decmd .Elem }}{{ end }} if v != nil { v[mk] = mv } } - dd.ReadMapEnd() } + if cr != nil { cr.sendContainerState(containerMapEnd) } return v, changed } diff --git a/vendor/src/github.com/ugorji/go/codec/fast-path.not.go b/vendor/src/github.com/ugorji/go/codec/fast-path.not.go new file mode 100644 index 0000000000..d6f5f0c911 --- /dev/null +++ b/vendor/src/github.com/ugorji/go/codec/fast-path.not.go @@ -0,0 +1,32 @@ +// +build notfastpath + +package codec + +import "reflect" + +// 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/vendor/src/github.com/ugorji/go/codec/gen-dec-array.go.tmpl b/vendor/src/github.com/ugorji/go/codec/gen-dec-array.go.tmpl index 0f4ea91d21..2caae5bfda 100644 --- a/vendor/src/github.com/ugorji/go/codec/gen-dec-array.go.tmpl +++ b/vendor/src/github.com/ugorji/go/codec/gen-dec-array.go.tmpl @@ -1,80 +1,101 @@ -{{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 }} +{{var "v"}} := {{if not isArray}}*{{end}}{{ .Varname }} +{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}} +var {{var "c"}} bool {{/* // changed */}} +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 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 "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 "v"}} <- {{var "t"}} } + {{ else }} var {{var "rr"}}, {{var "rl"}} int {{/* // num2read, length of slice/array/chan */}} + var {{var "rt"}} bool {{/* truncated */}} + 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 "n"}} ; {{var "j"}}++ { + 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"}}++ { + } + {{if isArray }}for ; {{var "j"}} < {{var "l"}} ; {{var "j"}}++ { + {{var "h"}}.ElemContainerState({{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 }} + } + {{ 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 }} } - if {{var "j"}} > 0 { - {{var "h"}}.Sep({{var "j"}}) - } - {{ if isChan}} + } {{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 }} + {{end}} } - {{var "h"}}.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}} } -{{ if not isArray }}if {{var "c"}} { +{{var "h"}}.End() +{{if not isArray }}if {{var "c"}} { *{{ .Varname }} = {{var "v"}} -}{{ end }} - +}{{end}} diff --git a/vendor/src/github.com/ugorji/go/codec/gen-dec-map.go.tmpl b/vendor/src/github.com/ugorji/go/codec/gen-dec-map.go.tmpl index 9f8dafa548..77400e0a11 100644 --- a/vendor/src/github.com/ugorji/go/codec/gen-dec-map.go.tmpl +++ b/vendor/src/github.com/ugorji/go/codec/gen-dec-map.go.tmpl @@ -1,46 +1,58 @@ {{var "v"}} := *{{ .Varname }} {{var "l"}} := r.ReadMapStart() +{{var "bh"}} := z.DecBasicHandle() 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 - } + {{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"}}++ { - var {{var "mk"}} {{ .KTyp }} + 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"}} { +{{ 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"}}] + }{{ 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 {{var "v"}} != nil { + 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"}}++ { - if {{var "j"}} > 0 { - r.ReadMapEntrySeparator() - } - var {{var "mk"}} {{ .KTyp }} + 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"}} { +{{ 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"}}] + }{{ 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 {{var "v"}} != nil { + if {{if decElemKindPtr}} {{var "ms"}} && {{end}} {{var "v"}} != nil { {{var "v"}}[{{var "mk"}}] = {{var "mv"}} } } -r.ReadMapEnd() } // else len==0: TODO: Should we clear map entries? +z.DecSendContainerState(codecSelfer_containerMapEnd{{ .Sfx }}) diff --git a/vendor/src/github.com/ugorji/go/codec/gen-helper.generated.go b/vendor/src/github.com/ugorji/go/codec/gen-helper.generated.go index ecf3ee54cf..22bce776bb 100644 --- a/vendor/src/github.com/ugorji/go/codec/gen-helper.generated.go +++ b/vendor/src/github.com/ugorji/go/codec/gen-helper.generated.go @@ -10,6 +10,11 @@ package codec +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. @@ -60,6 +65,65 @@ func (f genHelperEncoder) EncFallback(iv interface{}) { 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 @@ -100,3 +164,70 @@ func (f genHelperDecoder) DecStructFieldNotFound(index int, name string) { 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 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) + } +} diff --git a/vendor/src/github.com/ugorji/go/codec/gen-helper.go.tmpl b/vendor/src/github.com/ugorji/go/codec/gen-helper.go.tmpl index 89d75185a6..31958574ff 100644 --- a/vendor/src/github.com/ugorji/go/codec/gen-helper.go.tmpl +++ b/vendor/src/github.com/ugorji/go/codec/gen-helper.go.tmpl @@ -10,6 +10,11 @@ package codec +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. @@ -48,6 +53,7 @@ type genHelperDecoder struct { func (f genHelperEncoder) EncBasicHandle() *BasicHandle { return f.e.h } + // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* func (f genHelperEncoder) EncBinary() bool { return f.e.be // f.e.hh.isBinaryEncoding() @@ -57,6 +63,57 @@ 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 { @@ -91,7 +148,64 @@ func (f genHelperDecoder) DecStructFieldNotFound(index int, name string) { 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 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) + } +} {{/* diff --git a/vendor/src/github.com/ugorji/go/codec/gen.generated.go b/vendor/src/github.com/ugorji/go/codec/gen.generated.go index 8cc254ebff..fb6f4b8097 100644 --- a/vendor/src/github.com/ugorji/go/codec/gen.generated.go +++ b/vendor/src/github.com/ugorji/go/codec/gen.generated.go @@ -8,132 +8,165 @@ package codec const genDecMapTmpl = ` {{var "v"}} := *{{ .Varname }} {{var "l"}} := r.ReadMapStart() +{{var "bh"}} := z.DecBasicHandle() 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 - } + {{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"}}++ { - var {{var "mk"}} {{ .KTyp }} + 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"}} { +{{ 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"}}] + }{{ 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 {{var "v"}} != nil { + 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"}}++ { - if {{var "j"}} > 0 { - r.ReadMapEntrySeparator() - } - var {{var "mk"}} {{ .KTyp }} + 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"}} { +{{ 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"}}] + }{{ 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 {{var "v"}} != nil { + if {{if decElemKindPtr}} {{var "ms"}} && {{end}} {{var "v"}} != nil { {{var "v"}}[{{var "mk"}}] = {{var "mv"}} } } -r.ReadMapEnd() } // 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() - -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 }} +{{var "v"}} := {{if not isArray}}*{{end}}{{ .Varname }} +{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}} +var {{var "c"}} bool {{/* // changed */}} +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 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 "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 "v"}} <- {{var "t"}} } + {{ else }} var {{var "rr"}}, {{var "rl"}} int {{/* // num2read, length of slice/array/chan */}} + var {{var "rt"}} bool {{/* truncated */}} + 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 "n"}} ; {{var "j"}}++ { + 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"}}++ { + } + {{if isArray }}for ; {{var "j"}} < {{var "l"}} ; {{var "j"}}++ { + {{var "h"}}.ElemContainerState({{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 }} + } + {{ 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 }} } - if {{var "j"}} > 0 { - {{var "h"}}.Sep({{var "j"}}) - } - {{ if isChan}} + } {{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 }} + {{end}} } - {{var "h"}}.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}} } -{{ if not isArray }}if {{var "c"}} { +{{var "h"}}.End() +{{if not isArray }}if {{var "c"}} { *{{ .Varname }} = {{var "v"}} -}{{ end }} - +}{{end}} ` diff --git a/vendor/src/github.com/ugorji/go/codec/gen.go b/vendor/src/github.com/ugorji/go/codec/gen.go index b1eee33fe0..a075e7c0d6 100644 --- a/vendor/src/github.com/ugorji/go/codec/gen.go +++ b/vendor/src/github.com/ugorji/go/codec/gen.go @@ -12,8 +12,10 @@ import ( "io" "io/ioutil" "math/rand" + "os" "reflect" "regexp" + "sort" "strconv" "strings" "sync" @@ -22,14 +24,25 @@ import ( ) // --------------------------------------------------- -// 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 +79,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,6 +111,14 @@ 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") @@ -94,30 +129,39 @@ var ( // 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) { if len(typ) == 0 { return } @@ -128,17 +172,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 +217,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 +238,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())") @@ -205,13 +272,13 @@ func Gen(w io.Writer, buildTags, pkgName string, useUnsafe bool, typ ...reflect. 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,7 +306,7 @@ 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.linef("func (x %s) enc%s(v %s%s, e *%sEncoder) {", x.hn, x.genMethodNameT(t), x.arr2str(t, "*"), x.genTypeName(t), x.cpfx) @@ -273,6 +340,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 +367,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) + "_" + tpkg[idx+1:] + } + } } switch t.Kind() { case reflect.Array, reflect.Slice, reflect.Ptr, reflect.Chan: @@ -342,7 +423,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) { @@ -368,16 +507,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 +530,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 +553,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 +563,19 @@ 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{}{} + if _, ok := x.tm[t]; !ok { + x.tm[t] = struct{}{} + x.ts = append(x.ts, t) + } } // 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: @@ -470,46 +611,86 @@ 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) func (x *genRunner) enc(varname string, t reflect.Type) { - // varName here must be to a pointer to a struct, or to a value directly. + // varName here must be to a pointer to a struct/array, 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 + + tptr := reflect.PtrTo(t) + tk := t.Kind() + if x.checkForSelfer(t, varname) { + if t.Implements(selferTyp) || (tptr.Implements(selferTyp) && (tk == reflect.Array || tk == reflect.Struct)) { + x.line(varname + ".CodecEncodeSelf(e)") + 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 + mi := x.varsfx() + 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 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) + } + + 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 +715,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 +729,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 +754,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 +774,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 +824,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 +876,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 +892,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 +913,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 +968,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 { @@ -897,35 +1023,77 @@ func (x *genRunner) decVar(varname string, t reflect.Type, canBeNil bool) { 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 +1127,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 +1155,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 +1167,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) @@ -1037,10 +1203,10 @@ func (x *genRunner) decTryAssignPrimitive(varname string, t reflect.Type) (tryAs // 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))") + // case reflect.Uint32: x.line(varname + " = " + genTypeNamePrim(t, x.tc) + "(r.DecodeUint(32))") xfn := func(t reflect.Type) string { - return genTypeNamePrimitiveKind(t, x.tc) + return x.genTypeNamePrim(t) } switch t.Kind() { case reflect.Int: @@ -1064,6 +1230,8 @@ func (x *genRunner) decTryAssignPrimitive(varname string, t reflect.Type) (tryAs x.linef("%s = %s(r.DecodeUint(32))", varname, xfn(t)) case reflect.Uint64: x.linef("%s = %s(r.DecodeUint(64))", varname, xfn(t)) + case reflect.Uintptr: + x.linef("%s = %s(r.DecodeUint(codecSelferBitsize%s))", varname, xfn(t), x.xs) case reflect.Float32: x.linef("%s = %s(r.DecodeFloat(true))", varname, xfn(t)) @@ -1088,11 +1256,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 +1275,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 +1298,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 +1355,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 +1364,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 +1376,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 +1385,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 +1410,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 +1432,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 +1483,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 +1509,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 +1557,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 +1569,29 @@ func (x *genV) MethodNamePfx(prefix string, prim bool) string { } +var genCheckVendor = os.Getenv("GO15VENDOREXPERIMENT") == "1" + +// 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 +} + func genNonPtr(t reflect.Type) reflect.Type { for t.Kind() == reflect.Ptr { t = t.Elem() @@ -1393,59 +1608,17 @@ func genTitleCaseName(s string) string { } } -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 +1648,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 +1685,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 { @@ -1593,6 +1748,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 +1770,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 +1806,7 @@ func genInternalInit() { "uint16", "uint32", "uint64", + "uintptr", "int", "int8", "int16", @@ -1651,6 +1824,7 @@ func genInternalInit() { "uint16", "uint32", "uint64", + "uintptr", "int", "int8", "int16", @@ -1660,23 +1834,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 +1875,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/src/github.com/ugorji/go/codec/helper.go b/vendor/src/github.com/ugorji/go/codec/helper.go index 7848ea1359..560014ae39 100644 --- a/vendor/src/github.com/ugorji/go/codec/helper.go +++ b/vendor/src/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. @@ -147,6 +147,12 @@ const ( // 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} @@ -193,16 +199,43 @@ 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 +) + +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 +250,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 +261,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 +277,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 +304,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 +318,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 +351,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 +397,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 +499,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 +513,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. @@ -438,12 +538,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 +557,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 } @@ -471,6 +578,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 +627,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 +682,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 +702,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 @@ -623,33 +741,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 +798,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 } @@ -690,11 +830,11 @@ func getTypeInfo(rtid uintptr, rt reflect.Type) (pti *typeInfo) { if rt.Kind() == reflect.Struct { var siInfo *structFieldInfo if f, ok := rt.FieldByName(structInfoFieldName); ok { - siInfo = parseStructFieldInfo(structInfoFieldName, getStructTag(f.Tag)) + siInfo = parseStructFieldInfo(structInfoFieldName, x.structTag(f.Tag)) ti.toArray = siInfo.toArray } sfip := make([]*structFieldInfo, 0, rt.NumField()) - rgetTypeInfo(rt, nil, make(map[string]bool, 16), &sfip, siInfo) + x.rget(rt, nil, make(map[string]bool, 16), &sfip, siInfo) ti.sfip = make([]*structFieldInfo, len(sfip)) ti.sfi = make([]*structFieldInfo, len(sfip)) @@ -703,48 +843,78 @@ func getTypeInfo(rtid uintptr, rt reflect.Type) (pti *typeInfo) { copy(ti.sfi, sfip) } // 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, +func (x *TypeInfos) rget(rt reflect.Type, indexstack []int, fnameToHastag map[string]bool, sfi *[]*structFieldInfo, siInfo *structFieldInfo, ) { for j := 0; j < rt.NumField(); 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 == "-" + if fkind == reflect.Func { continue } - stag := getStructTag(f.Tag) + // if r1, _ := utf8.DecodeRuneInString(f.Name); r1 == utf8.RuneError || !unicode.IsUpper(r1) { + if f.PkgPath != "" && !f.Anonymous { // unexported, not embedded + continue + } + stag := x.structTag(f.Tag) if stag == "-" { continue } - if r1, _ := utf8.DecodeRuneInString(f.Name); r1 == utf8.RuneError || !unicode.IsUpper(r1) { + 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 doInline { + ft := f.Type + for ft.Kind() == reflect.Ptr { + ft = ft.Elem() + } + 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) + x.rget(ft, indexstack2, fnameToHastag, sfi, siInfo) + continue + } + } + } + + // after the anonymous dance: if an unexported field, skip + if f.PkgPath != "" { // unexported 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() - } - 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 - } - } + // 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 { continue } - si := parseStructFieldInfo(f.Name, stag) + if f.Name == "" { + panic(noFieldNameToStructFieldInfoErr) + } + if si == nil { + si = parseStructFieldInfo(f.Name, stag) + } else if si.encName == "" { + si.encName = f.Name + } // si.ikind = int(f.Type.Kind()) if len(indexstack) == 0 { si.i = int16(j) @@ -779,8 +949,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 +961,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 +1016,114 @@ 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] } diff --git a/vendor/src/github.com/ugorji/go/codec/helper_internal.go b/vendor/src/github.com/ugorji/go/codec/helper_internal.go index c865246f49..dea981fbb7 100644 --- a/vendor/src/github.com/ugorji/go/codec/helper_internal.go +++ b/vendor/src/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/vendor/src/github.com/ugorji/go/codec/helper_unsafe.go b/vendor/src/github.com/ugorji/go/codec/helper_unsafe.go index d7994961ea..373b2b1027 100644 --- a/vendor/src/github.com/ugorji/go/codec/helper_unsafe.go +++ b/vendor/src/github.com/ugorji/go/codec/helper_unsafe.go @@ -26,6 +26,9 @@ 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 { + if len(v) == 0 { + return "" + } x := unsafeString{uintptr(unsafe.Pointer(&v[0])), len(v)} return *(*string)(unsafe.Pointer(&x)) } @@ -34,6 +37,9 @@ func stringView(v []byte) string { // 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 { + if len(v) == 0 { + return zeroByteSlice + } x := unsafeBytes{uintptr(unsafe.Pointer(&v)), len(v), len(v)} return *(*[]byte)(unsafe.Pointer(&x)) } diff --git a/vendor/src/github.com/ugorji/go/codec/json.go b/vendor/src/github.com/ugorji/go/codec/json.go index cb370d48e7..a18a5f7063 100644 --- a/vendor/src/github.com/ugorji/go/codec/json.go +++ b/vendor/src/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" @@ -52,12 +57,13 @@ var jsonUint64Pow10 = [...]uint64{ } 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, @@ -87,9 +93,31 @@ type jsonEncDriver struct { h *JsonHandle b [64]byte // scratch bs []byte // scratch + se setExtWrapper + c containerState noBuiltInTypes } +func (e *jsonEncDriver) sendContainerState(c containerState) { + // determine whether to output separators + if c == containerMapKey { + if e.c != containerMapStart { + e.w.writen1(',') + } + } else if c == containerMapValue { + e.w.writen1(':') + } else if c == containerMapEnd { + e.w.writen1('}') + } else if c == containerArrayElem { + if e.c != containerArrayStart { + e.w.writen1(',') + } + } else if c == containerArrayEnd { + e.w.writen1(']') + } + e.c = c +} + func (e *jsonEncDriver) EncodeNil() { e.w.writeb(jsonLiterals[9:13]) // null } @@ -121,7 +149,7 @@ func (e *jsonEncDriver) EncodeUint(v uint64) { 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,7 +158,7 @@ func (e *jsonEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext, en *Enco func (e *jsonEncDriver) EncodeRawExt(re *RawExt, en *Encoder) { // only encodes re.Value (never re.Data) if re.Value == nil { - e.EncodeNil() + e.w.writeb(jsonLiterals[9:13]) // null // e.EncodeNil() } else { en.encode(re.Value) } @@ -138,30 +166,12 @@ func (e *jsonEncDriver) EncodeRawExt(re *RawExt, en *Encoder) { func (e *jsonEncDriver) EncodeArrayStart(length int) { 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) { 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 +185,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 +207,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 +282,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 +292,6 @@ type jsonNum struct { } func (x *jsonNum) reset() { - x.bytes = x.bytes[:0] x.manOverflow = false x.neg = false x.dot = false @@ -309,29 +324,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 +362,221 @@ 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 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 +843,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 +896,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 +929,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 +1015,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 +1028,40 @@ 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 +} + +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, w: e.w, h: h} + hd.bs = hd.b[:0] + hd.se.i = h.RawBytesExt + 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.bs = hd.b[:0] + hd.se.i = h.RawBytesExt return &hd } +func (e *jsonEncDriver) reset() { + e.w = e.e.w +} + +func (d *jsonDecDriver) reset() { + d.r = d.d.r +} + var jsonEncodeTerminate = []byte{' '} func (h *JsonHandle) rpcEncodeTerminate() []byte { diff --git a/vendor/src/github.com/ugorji/go/codec/msgpack.go b/vendor/src/github.com/ugorji/go/codec/msgpack.go index 5cfc2a2591..5eb4c96368 100644 --- a/vendor/src/github.com/ugorji/go/codec/msgpack.go +++ b/vendor/src/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.v) } 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,14 @@ 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 +} + //-------------------------------------------------- type msgpackSpecRpcCodec struct { diff --git a/vendor/src/github.com/ugorji/go/codec/noop.go b/vendor/src/github.com/ugorji/go/codec/noop.go index 25bef4fc3c..cfee3d084d 100644 --- a/vendor/src/github.com/ugorji/go/codec/noop.go +++ b/vendor/src/github.com/ugorji/go/codec/noop.go @@ -11,6 +11,7 @@ import ( // 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{} @@ -37,38 +38,57 @@ type noopHandle struct { } type noopDrv struct { + d *Decoder + e *Encoder 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. + 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(_ *Encoder) encDriver { return h } -func (h *noopDrv) newDecDriver(_ *Decoder) decDriver { return h } +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 -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() {} +// 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) {} @@ -90,28 +110,54 @@ func (h *noopDrv) DecodeString() (s string) { return h.S[h.m(8 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 } +func (h *noopDrv) ReadEnd() { h.end() } // 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) ReadMapStart() int { h.start(true); return h.m(10) } +func (h *noopDrv) ReadArrayStart() int { h.start(false); return h.m(10) } -func (h *noopDrv) IsContainerType(vt valueType) bool { +func (h *noopDrv) ContainerType() (vt valueType) { // 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 + // 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 { @@ -124,7 +170,7 @@ func (h *noopDrv) DecodeExt(rv interface{}, xtag uint64, ext Ext) uint64 { return 0 } -func (h *noopDrv) DecodeNaked() (v interface{}, vt valueType, decodeFurther bool) { +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 { @@ -133,32 +179,35 @@ func (h *noopDrv) DecodeNaked() (v interface{}, vt valueType, decodeFurther bool } else { sk = h.r(12) } + n := &h.d.n switch sk { case 0: - vt = valueTypeNil + n.v = valueTypeNil case 1: - vt, v = valueTypeBool, false + n.v, n.b = valueTypeBool, false case 2: - vt, v = valueTypeBool, true + n.v, n.b = valueTypeBool, true case 3: - vt, v = valueTypeInt, h.DecodeInt(64) + n.v, n.i = valueTypeInt, h.DecodeInt(64) case 4: - vt, v = valueTypeUint, h.DecodeUint(64) + n.v, n.u = valueTypeUint, h.DecodeUint(64) case 5: - vt, v = valueTypeFloat, h.DecodeFloat(true) + n.v, n.f = valueTypeFloat, h.DecodeFloat(true) case 6: - vt, v = valueTypeFloat, h.DecodeFloat(false) + n.v, n.f = valueTypeFloat, h.DecodeFloat(false) case 7: - vt, v = valueTypeString, h.DecodeString() + n.v, n.s = valueTypeString, h.DecodeString() case 8: - vt, v = valueTypeBytes, h.B[h.m(len(h.B))] + n.v, n.l = valueTypeBytes, h.B[h.m(len(h.B))] case 9: - vt, decodeFurther = valueTypeArray, true + n.v = valueTypeArray case 10: - vt, decodeFurther = valueTypeMap, true + n.v = valueTypeMap default: - vt, v = valueTypeExt, &RawExt{Tag: h.DecodeUint(64), Data: h.B[h.m(len(h.B))]} + n.v = valueTypeExt + n.u = h.DecodeUint(64) + n.l = h.B[h.m(len(h.B))] } - h.ct = vt + h.ct = n.v return } diff --git a/vendor/src/github.com/ugorji/go/codec/prebuild.sh b/vendor/src/github.com/ugorji/go/codec/prebuild.sh index c1916f3038..98f442487a 100755 --- a/vendor/src/github.com/ugorji/go/codec/prebuild.sh +++ b/vendor/src/github.com/ugorji/go/codec/prebuild.sh @@ -49,7 +49,8 @@ _build() { # [ -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 + 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 < fast-path.generated.go < gen-from-tmpl.codec.generated.go < gen-from-tmpl.generated.go <>>>>>> TAGS: $ztags" + + OPTIND=1 + while getopts "xurtcinsvgzmef" flag + do + case "x$flag" in + 'xt') printf ">>>>>>> REGULAR : "; go test "-tags=$ztags" $zargs ; sleep 2 ;; + 'xc') printf ">>>>>>> CANONICAL : "; go test "-tags=$ztags" $zargs -tc; sleep 2 ;; + 'xi') printf ">>>>>>> I/O : "; go test "-tags=$ztags" $zargs -ti; sleep 2 ;; + 'xn') printf ">>>>>>> NO_SYMBOLS : "; go test "-tags=$ztags" $zargs -tn; sleep 2 ;; + 'xs') printf ">>>>>>> TO_ARRAY : "; go test "-tags=$ztags" $zargs -ts; sleep 2 ;; + 'xe') printf ">>>>>>> INTERN : "; go test "-tags=$ztags" $zargs -te; sleep 2 ;; + *) ;; + esac + done + shift $((OPTIND-1)) + + OPTIND=1 +} + +# echo ">>>>>>> RUNNING VARIATIONS OF TESTS" +if [[ "x$@" = "x" ]]; then + # All: r, x, g, gu + _run "-rtcinsm" # regular + _run "-rtcinsmz" # regular with reset + _run "-rtcinsmf" # regular with no fastpath (notfastpath) + _run "-xtcinsm" # external + _run "-gxtcinsm" # codecgen: requires external + _run "-gxutcinsm" # codecgen + unsafe +elif [[ "x$@" = "x-Z" ]]; then + # Regular + _run "-rtcinsm" # regular + _run "-rtcinsmz" # regular with reset +elif [[ "x$@" = "x-F" ]]; then + # regular with notfastpath + _run "-rtcinsmf" # regular + _run "-rtcinsmzf" # regular with reset +else + _run "$@" +fi diff --git a/vendor/src/github.com/ugorji/go/codec/time.go b/vendor/src/github.com/ugorji/go/codec/time.go index 733fc3fb75..fc4c63e1de 100644 --- a/vendor/src/github.com/ugorji/go/codec/time.go +++ b/vendor/src/github.com/ugorji/go/codec/time.go @@ -4,6 +4,7 @@ package codec import ( + "fmt" "time" ) @@ -11,6 +12,34 @@ var ( timeDigits = [...]byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'} ) +type timeExt struct{} + +func (x timeExt) WriteExt(v interface{}) (bs []byte) { + switch v2 := v.(type) { + case time.Time: + bs = encodeTime(v2) + case *time.Time: + bs = encodeTime(*v2) + default: + panic(fmt.Errorf("unsupported format for time conversion: expecting time.Time; got %T", v2)) + } + return +} +func (x timeExt) ReadExt(v interface{}, bs []byte) { + tt, err := decodeTime(bs) + if err != nil { + panic(err) + } + *(v.(*time.Time)) = tt +} + +func (x timeExt) ConvertExt(v interface{}) interface{} { + return x.WriteExt(v) +} +func (x timeExt) UpdateExt(v interface{}, src interface{}) { + x.ReadExt(v, src.([]byte)) +} + // EncodeTime encodes a time.Time as a []byte, including // information on the instant in time and UTC offset. //