info = 3;
-// the protocol compiler produces a field in the generated struct that looks like:
-// Info *_proto_.MessageSet `protobuf:"bytes,3,opt,name=info"`
-// The package is automatically inserted so there is no need for that proto file to
-// import this package.
type _MessageSet_Item struct {
TypeId *int32 `protobuf:"varint,2,req,name=type_id"`
Message []byte `protobuf:"bytes,3,req,name=message"`
}
-type MessageSet struct {
+type messageSet struct {
Item []*_MessageSet_Item `protobuf:"group,1,rep"`
XXX_unrecognized []byte
// TODO: caching?
}
-// Make sure MessageSet is a Message.
-var _ Message = (*MessageSet)(nil)
+// Make sure messageSet is a Message.
+var _ Message = (*messageSet)(nil)
// messageTypeIder is an interface satisfied by a protocol buffer type
// that may be stored in a MessageSet.
@@ -86,7 +79,7 @@ type messageTypeIder interface {
MessageTypeId() int32
}
-func (ms *MessageSet) find(pb Message) *_MessageSet_Item {
+func (ms *messageSet) find(pb Message) *_MessageSet_Item {
mti, ok := pb.(messageTypeIder)
if !ok {
return nil
@@ -100,24 +93,24 @@ func (ms *MessageSet) find(pb Message) *_MessageSet_Item {
return nil
}
-func (ms *MessageSet) Has(pb Message) bool {
+func (ms *messageSet) Has(pb Message) bool {
if ms.find(pb) != nil {
return true
}
return false
}
-func (ms *MessageSet) Unmarshal(pb Message) error {
+func (ms *messageSet) Unmarshal(pb Message) error {
if item := ms.find(pb); item != nil {
return Unmarshal(item.Message, pb)
}
if _, ok := pb.(messageTypeIder); !ok {
- return ErrNoMessageTypeId
+ return errNoMessageTypeID
}
return nil // TODO: return error instead?
}
-func (ms *MessageSet) Marshal(pb Message) error {
+func (ms *messageSet) Marshal(pb Message) error {
msg, err := Marshal(pb)
if err != nil {
return err
@@ -130,7 +123,7 @@ func (ms *MessageSet) Marshal(pb Message) error {
mti, ok := pb.(messageTypeIder)
if !ok {
- return ErrNoMessageTypeId
+ return errNoMessageTypeID
}
mtid := mti.MessageTypeId()
@@ -141,9 +134,9 @@ func (ms *MessageSet) Marshal(pb Message) error {
return nil
}
-func (ms *MessageSet) Reset() { *ms = MessageSet{} }
-func (ms *MessageSet) String() string { return CompactTextString(ms) }
-func (*MessageSet) ProtoMessage() {}
+func (ms *messageSet) Reset() { *ms = messageSet{} }
+func (ms *messageSet) String() string { return CompactTextString(ms) }
+func (*messageSet) ProtoMessage() {}
// Support for the message_set_wire_format message option.
@@ -169,7 +162,7 @@ func MarshalMessageSet(m map[int32]Extension) ([]byte, error) {
}
sort.Ints(ids)
- ms := &MessageSet{Item: make([]*_MessageSet_Item, 0, len(m))}
+ ms := &messageSet{Item: make([]*_MessageSet_Item, 0, len(m))}
for _, id := range ids {
e := m[int32(id)]
// Remove the wire type and field number varint, as well as the length varint.
@@ -186,7 +179,7 @@ func MarshalMessageSet(m map[int32]Extension) ([]byte, error) {
// UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format.
// It is called by generated Unmarshal methods on protocol buffer messages with the message_set_wire_format option.
func UnmarshalMessageSet(buf []byte, m map[int32]Extension) error {
- ms := new(MessageSet)
+ ms := new(messageSet)
if err := Unmarshal(buf, ms); err != nil {
return err
}
diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_reflect.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_reflect.go
index c68b12525c..749919d250 100644
--- a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_reflect.go
+++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_reflect.go
@@ -144,8 +144,8 @@ func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension {
return structPointer_ifield(p, f).(*map[int32]Extension)
}
-// Map returns the reflect.Value for the address of a map field in the struct.
-func structPointer_Map(p structPointer, f field, typ reflect.Type) reflect.Value {
+// NewAt returns the reflect.Value for a pointer to a field in the struct.
+func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value {
return structPointer_field(p, f).Addr()
}
diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_unsafe.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_unsafe.go
index 48bc0fa482..e9be0fe92e 100644
--- a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_unsafe.go
+++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_unsafe.go
@@ -130,8 +130,8 @@ func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension {
return (*map[int32]Extension)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
-// Map returns the reflect.Value for the address of a map field in the struct.
-func structPointer_Map(p structPointer, f field, typ reflect.Type) reflect.Value {
+// NewAt returns the reflect.Value for a pointer to a field in the struct.
+func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value {
return reflect.NewAt(typ, unsafe.Pointer(uintptr(p)+uintptr(f)))
}
diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties.go
index 13245c00df..4711057e2b 100644
--- a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties.go
+++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties.go
@@ -42,6 +42,7 @@ package proto
import (
"fmt"
+ "log"
"os"
"reflect"
"sort"
@@ -89,6 +90,12 @@ type decoder func(p *Buffer, prop *Properties, base structPointer) error
// A valueDecoder decodes a single integer in a particular encoding.
type valueDecoder func(o *Buffer) (x uint64, err error)
+// A oneofMarshaler does the marshaling for all oneof fields in a message.
+type oneofMarshaler func(Message, *Buffer) error
+
+// A oneofUnmarshaler does the unmarshaling for a oneof field in a message.
+type oneofUnmarshaler func(Message, int, int, *Buffer) (bool, error)
+
// tagMap is an optimization over map[int]int for typical protocol buffer
// use-cases. Encoded protocol buffers are often in tag order with small tag
// numbers.
@@ -137,6 +144,21 @@ type StructProperties struct {
order []int // list of struct field numbers in tag order
unrecField field // field id of the XXX_unrecognized []byte field
extendable bool // is this an extendable proto
+
+ oneofMarshaler oneofMarshaler
+ oneofUnmarshaler oneofUnmarshaler
+ stype reflect.Type
+
+ // OneofTypes contains information about the oneof fields in this message.
+ // It is keyed by the original name of a field.
+ OneofTypes map[string]*OneofProperties
+}
+
+// OneofProperties represents information about a specific field in a oneof.
+type OneofProperties struct {
+ Type reflect.Type // pointer to generated struct type for this oneof field
+ Field int // struct field number of the containing oneof in the message
+ Prop *Properties
}
// Implement the sorting interface so we can sort the fields in tag order, as recommended by the spec.
@@ -161,6 +183,7 @@ type Properties struct {
Packed bool // relevant for repeated primitives only
Enum string // set for enum types only
proto3 bool // whether this is known to be a proto3 field; set for []byte only
+ oneof bool // whether this is a oneof field
Default string // default value
HasDefault bool // whether an explicit default was provided
@@ -216,6 +239,9 @@ func (p *Properties) String() string {
if p.proto3 {
s += ",proto3"
}
+ if p.oneof {
+ s += ",oneof"
+ }
if len(p.Enum) > 0 {
s += ",enum=" + p.Enum
}
@@ -292,6 +318,8 @@ func (p *Properties) Parse(s string) {
p.Enum = f[5:]
case f == "proto3":
p.proto3 = true
+ case f == "oneof":
+ p.oneof = true
case strings.HasPrefix(f, "def="):
p.HasDefault = true
p.Default = f[4:] // rest of string
@@ -713,6 +741,7 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
prop.Prop = make([]*Properties, t.NumField())
prop.order = make([]int, t.NumField())
+ isOneofMessage := false
for i := 0; i < t.NumField(); i++ {
f := t.Field(i)
p := new(Properties)
@@ -733,6 +762,10 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
if f.Name == "XXX_unrecognized" { // special case
prop.unrecField = toField(&f)
}
+ oneof := f.Tag.Get("protobuf_oneof") != "" // special case
+ if oneof {
+ isOneofMessage = true
+ }
prop.Prop[i] = p
prop.order[i] = i
if debug {
@@ -742,7 +775,7 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
}
print("\n")
}
- if p.enc == nil && !strings.HasPrefix(f.Name, "XXX_") {
+ if p.enc == nil && !strings.HasPrefix(f.Name, "XXX_") && !oneof {
fmt.Fprintln(os.Stderr, "proto: no encoder for", f.Name, f.Type.String(), "[GetProperties]")
}
}
@@ -750,6 +783,41 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
// Re-order prop.order.
sort.Sort(prop)
+ type oneofMessage interface {
+ XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), []interface{})
+ }
+ if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); isOneofMessage && ok {
+ var oots []interface{}
+ prop.oneofMarshaler, prop.oneofUnmarshaler, oots = om.XXX_OneofFuncs()
+ prop.stype = t
+
+ // Interpret oneof metadata.
+ prop.OneofTypes = make(map[string]*OneofProperties)
+ for _, oot := range oots {
+ oop := &OneofProperties{
+ Type: reflect.ValueOf(oot).Type(), // *T
+ Prop: new(Properties),
+ }
+ sft := oop.Type.Elem().Field(0)
+ oop.Prop.Name = sft.Name
+ oop.Prop.Parse(sft.Tag.Get("protobuf"))
+ // There will be exactly one interface field that
+ // this new value is assignable to.
+ for i := 0; i < t.NumField(); i++ {
+ f := t.Field(i)
+ if f.Type.Kind() != reflect.Interface {
+ continue
+ }
+ if !oop.Type.AssignableTo(f.Type) {
+ continue
+ }
+ oop.Field = i
+ break
+ }
+ prop.OneofTypes[oop.Prop.OrigName] = oop
+ }
+ }
+
// build required counts
// build tags
reqCount := 0
@@ -813,3 +881,35 @@ func RegisterEnum(typeName string, unusedNameMap map[int32]string, valueMap map[
}
enumStringMaps[typeName] = unusedNameMap
}
+
+// EnumValueMap returns the mapping from names to integers of the
+// enum type enumType, or a nil if not found.
+func EnumValueMap(enumType string) map[string]int32 {
+ return enumValueMaps[enumType]
+}
+
+// A registry of all linked message types.
+// The string is a fully-qualified proto name ("pkg.Message").
+var (
+ protoTypes = make(map[string]reflect.Type)
+ revProtoTypes = make(map[reflect.Type]string)
+)
+
+// RegisterType is called from generated code and maps from the fully qualified
+// proto name to the type (pointer to struct) of the protocol buffer.
+func RegisterType(x Message, name string) {
+ if _, ok := protoTypes[name]; ok {
+ // TODO: Some day, make this a panic.
+ log.Printf("proto: duplicate proto type registered: %s", name)
+ return
+ }
+ t := reflect.TypeOf(x)
+ protoTypes[name] = t
+ revProtoTypes[t] = name
+}
+
+// MessageName returns the fully-qualified proto name for the given message type.
+func MessageName(x Message) string { return revProtoTypes[reflect.TypeOf(x)] }
+
+// MessageType returns the message type (pointer to struct) for a named message.
+func MessageType(name string) reflect.Type { return protoTypes[name] }
diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/proto3_proto/proto3.pb.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/proto3_proto/proto3.pb.go
index 2f2da46044..0de701e889 100644
--- a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/proto3_proto/proto3.pb.go
+++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/proto3_proto/proto3.pb.go
@@ -16,10 +16,14 @@ It has these top-level messages:
package proto3_proto
import proto "github.com/gogo/protobuf/proto"
+import fmt "fmt"
+import math "math"
import testdata "github.com/gogo/protobuf/proto/testdata"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
type Message_Humour int32
@@ -118,5 +122,8 @@ func (m *MessageWithMap) GetByteMapping() map[bool][]byte {
}
func init() {
+ proto.RegisterType((*Message)(nil), "proto3_proto.Message")
+ proto.RegisterType((*Nested)(nil), "proto3_proto.Nested")
+ proto.RegisterType((*MessageWithMap)(nil), "proto3_proto.MessageWithMap")
proto.RegisterEnum("proto3_proto.Message_Humour", Message_Humour_name, Message_Humour_value)
}
diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text.go
index 1879c0d579..7c9ae90f95 100644
--- a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text.go
+++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text.go
@@ -42,6 +42,7 @@ import (
"bufio"
"bytes"
"encoding"
+ "errors"
"fmt"
"io"
"log"
@@ -174,20 +175,12 @@ func writeName(w *textWriter, props *Properties) error {
return nil
}
-var (
- messageSetType = reflect.TypeOf((*MessageSet)(nil)).Elem()
-)
-
// raw is the interface satisfied by RawMessage.
type raw interface {
Bytes() []byte
}
func writeStruct(w *textWriter, sv reflect.Value) error {
- if sv.Type() == messageSetType {
- return writeMessageSet(w, sv.Addr().Interface().(*MessageSet))
- }
-
st := sv.Type()
sprops := GetProperties(st)
for i := 0; i < sv.NumField(); i++ {
@@ -254,7 +247,7 @@ func writeStruct(w *textWriter, sv reflect.Value) error {
}
if fv.Kind() == reflect.Map {
// Map fields are rendered as a repeated struct with key/value fields.
- keys := fv.MapKeys() // TODO: should we sort these for deterministic output?
+ keys := fv.MapKeys()
sort.Sort(mapKeys(keys))
for _, key := range keys {
val := fv.MapIndex(key)
@@ -331,6 +324,32 @@ func writeStruct(w *textWriter, sv reflect.Value) error {
}
}
+ if fv.Kind() == reflect.Interface {
+ // Check if it is a oneof.
+ if st.Field(i).Tag.Get("protobuf_oneof") != "" {
+ // fv is nil, or holds a pointer to generated struct.
+ // That generated struct has exactly one field,
+ // which has a protobuf struct tag.
+ if fv.IsNil() {
+ continue
+ }
+ inner := fv.Elem().Elem() // interface -> *T -> T
+ tag := inner.Type().Field(0).Tag.Get("protobuf")
+ props.Parse(tag) // Overwrite the outer props.
+ // Write the value in the oneof, not the oneof itself.
+ fv = inner.Field(0)
+
+ // Special case to cope with malformed messages gracefully:
+ // If the value in the oneof is a nil pointer, don't panic
+ // in writeAny.
+ if fv.Kind() == reflect.Ptr && fv.IsNil() {
+ // Use errors.New so writeAny won't render quotes.
+ msg := errors.New("/* nil */")
+ fv = reflect.ValueOf(&msg).Elem()
+ }
+ }
+ }
+
if err := writeName(w, props); err != nil {
return err
}
@@ -360,7 +379,13 @@ func writeStruct(w *textWriter, sv reflect.Value) error {
}
// Extensions (the XXX_extensions field).
- pv := sv.Addr()
+ pv := sv
+ if pv.CanAddr() {
+ pv = sv.Addr()
+ } else {
+ pv = reflect.New(sv.Type())
+ pv.Elem().Set(sv)
+ }
if pv.Type().Implements(extendableProtoType) {
if err := writeExtensions(w, pv); err != nil {
return err
@@ -396,15 +421,17 @@ func writeAny(w *textWriter, v reflect.Value, props *Properties) error {
v = reflect.Indirect(v)
if props != nil && len(props.CustomType) > 0 {
- var custom Marshaler = v.Interface().(Marshaler)
- data, err := custom.Marshal()
- if err != nil {
- return err
+ custom, ok := v.Interface().(Marshaler)
+ if ok {
+ data, err := custom.Marshal()
+ if err != nil {
+ return err
+ }
+ if err := writeString(w, string(data)); err != nil {
+ return err
+ }
+ return nil
}
- if err := writeString(w, string(data)); err != nil {
- return err
- }
- return nil
}
// Floats have special cases.
@@ -521,44 +548,6 @@ func writeString(w *textWriter, s string) error {
return w.WriteByte('"')
}
-func writeMessageSet(w *textWriter, ms *MessageSet) error {
- for _, item := range ms.Item {
- id := *item.TypeId
- if msd, ok := messageSetMap[id]; ok {
- // Known message set type.
- if _, err := fmt.Fprintf(w, "[%s]: <\n", msd.name); err != nil {
- return err
- }
- w.indent()
-
- pb := reflect.New(msd.t.Elem())
- if err := Unmarshal(item.Message, pb.Interface().(Message)); err != nil {
- if _, err := fmt.Fprintf(w, "/* bad message: %v */\n", err); err != nil {
- return err
- }
- } else {
- if err := writeStruct(w, pb.Elem()); err != nil {
- return err
- }
- }
- } else {
- // Unknown type.
- if _, err := fmt.Fprintf(w, "[%d]: <\n", id); err != nil {
- return err
- }
- w.indent()
- if err := writeUnknownStruct(w, item.Message); err != nil {
- return err
- }
- }
- w.unindent()
- if _, err := w.Write(gtNewline); err != nil {
- return err
- }
- }
- return nil
-}
-
func writeUnknownStruct(w *textWriter, data []byte) (err error) {
if !w.compact {
if _, err := fmt.Fprintf(w, "/* %d unknown bytes */\n", len(data)); err != nil {
@@ -569,19 +558,19 @@ func writeUnknownStruct(w *textWriter, data []byte) (err error) {
for b.index < len(b.buf) {
x, err := b.DecodeVarint()
if err != nil {
- _, err := fmt.Fprintf(w, "/* %v */\n", err)
- return err
+ _, ferr := fmt.Fprintf(w, "/* %v */\n", err)
+ return ferr
}
wire, tag := x&7, x>>3
if wire == WireEndGroup {
w.unindent()
- if _, err := w.Write(endBraceNewline); err != nil {
- return err
+ if _, werr := w.Write(endBraceNewline); werr != nil {
+ return werr
}
continue
}
- if _, err := fmt.Fprint(w, tag); err != nil {
- return err
+ if _, ferr := fmt.Fprint(w, tag); ferr != nil {
+ return ferr
}
if wire != WireStartGroup {
if err := w.WriteByte(':'); err != nil {
@@ -619,7 +608,7 @@ func writeUnknownStruct(w *textWriter, data []byte) (err error) {
if err != nil {
return err
}
- if err = w.WriteByte('\n'); err != nil {
+ if err := w.WriteByte('\n'); err != nil {
return err
}
}
diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_parser.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_parser.go
index 9b2fab5935..f3909695ed 100644
--- a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_parser.go
+++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_parser.go
@@ -390,8 +390,7 @@ func (p *textParser) missingRequiredFieldError(sv reflect.Value) *RequiredNotSet
}
// Returns the index in the struct for the named field, as well as the parsed tag properties.
-func structFieldByName(st reflect.Type, name string) (int, *Properties, bool) {
- sprops := GetProperties(st)
+func structFieldByName(sprops *StructProperties, name string) (int, *Properties, bool) {
i, ok := sprops.decoderOrigNames[name]
if ok {
return i, sprops.Prop[i], true
@@ -443,7 +442,8 @@ func (p *textParser) checkForColon(props *Properties, typ reflect.Type) *ParseEr
func (p *textParser) readStruct(sv reflect.Value, terminator string) error {
st := sv.Type()
- reqCount := GetProperties(st).reqCount
+ sprops := GetProperties(st)
+ reqCount := sprops.reqCount
var reqFieldErr error
fieldSet := make(map[string]bool)
// A struct is a sequence of "name: value", terminated by one of
@@ -525,95 +525,107 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) error {
sl = reflect.Append(sl, ext)
SetExtension(ep, desc, sl.Interface())
}
- } else {
- // This is a normal, non-extension field.
- name := tok.value
- fi, props, ok := structFieldByName(st, name)
- if !ok {
- return p.errorf("unknown field name %q in %v", name, st)
+ if err := p.consumeOptionalSeparator(); err != nil {
+ return err
}
+ continue
+ }
- dst := sv.Field(fi)
+ // This is a normal, non-extension field.
+ name := tok.value
+ var dst reflect.Value
+ fi, props, ok := structFieldByName(sprops, name)
+ if ok {
+ dst = sv.Field(fi)
+ } else if oop, ok := sprops.OneofTypes[name]; ok {
+ // It is a oneof.
+ props = oop.Prop
+ nv := reflect.New(oop.Type.Elem())
+ dst = nv.Elem().Field(0)
+ sv.Field(oop.Field).Set(nv)
+ }
+ if !dst.IsValid() {
+ return p.errorf("unknown field name %q in %v", name, st)
+ }
- if dst.Kind() == reflect.Map {
- // Consume any colon.
- if err := p.checkForColon(props, dst.Type()); err != nil {
- return err
- }
-
- // Construct the map if it doesn't already exist.
- if dst.IsNil() {
- dst.Set(reflect.MakeMap(dst.Type()))
- }
- key := reflect.New(dst.Type().Key()).Elem()
- val := reflect.New(dst.Type().Elem()).Elem()
-
- // The map entry should be this sequence of tokens:
- // < key : KEY value : VALUE >
- // Technically the "key" and "value" could come in any order,
- // but in practice they won't.
-
- tok := p.next()
- var terminator string
- switch tok.value {
- case "<":
- terminator = ">"
- case "{":
- terminator = "}"
- default:
- return p.errorf("expected '{' or '<', found %q", tok.value)
- }
- if err := p.consumeToken("key"); err != nil {
- return err
- }
- if err := p.consumeToken(":"); err != nil {
- return err
- }
- if err := p.readAny(key, props.mkeyprop); err != nil {
- return err
- }
- if err := p.consumeOptionalSeparator(); err != nil {
- return err
- }
- if err := p.consumeToken("value"); err != nil {
- return err
- }
- if err := p.checkForColon(props.mvalprop, dst.Type().Elem()); err != nil {
- return err
- }
- if err := p.readAny(val, props.mvalprop); err != nil {
- return err
- }
- if err := p.consumeOptionalSeparator(); err != nil {
- return err
- }
- if err := p.consumeToken(terminator); err != nil {
- return err
- }
-
- dst.SetMapIndex(key, val)
- continue
- }
-
- // Check that it's not already set if it's not a repeated field.
- if !props.Repeated && fieldSet[name] {
- return p.errorf("non-repeated field %q was repeated", name)
- }
-
- if err := p.checkForColon(props, st.Field(fi).Type); err != nil {
+ if dst.Kind() == reflect.Map {
+ // Consume any colon.
+ if err := p.checkForColon(props, dst.Type()); err != nil {
return err
}
- // Parse into the field.
- fieldSet[name] = true
- if err := p.readAny(dst, props); err != nil {
- if _, ok := err.(*RequiredNotSetError); !ok {
- return err
- }
- reqFieldErr = err
- } else if props.Required {
- reqCount--
+ // Construct the map if it doesn't already exist.
+ if dst.IsNil() {
+ dst.Set(reflect.MakeMap(dst.Type()))
}
+ key := reflect.New(dst.Type().Key()).Elem()
+ val := reflect.New(dst.Type().Elem()).Elem()
+
+ // The map entry should be this sequence of tokens:
+ // < key : KEY value : VALUE >
+ // Technically the "key" and "value" could come in any order,
+ // but in practice they won't.
+
+ tok := p.next()
+ var terminator string
+ switch tok.value {
+ case "<":
+ terminator = ">"
+ case "{":
+ terminator = "}"
+ default:
+ return p.errorf("expected '{' or '<', found %q", tok.value)
+ }
+ if err := p.consumeToken("key"); err != nil {
+ return err
+ }
+ if err := p.consumeToken(":"); err != nil {
+ return err
+ }
+ if err := p.readAny(key, props.mkeyprop); err != nil {
+ return err
+ }
+ if err := p.consumeOptionalSeparator(); err != nil {
+ return err
+ }
+ if err := p.consumeToken("value"); err != nil {
+ return err
+ }
+ if err := p.checkForColon(props.mvalprop, dst.Type().Elem()); err != nil {
+ return err
+ }
+ if err := p.readAny(val, props.mvalprop); err != nil {
+ return err
+ }
+ if err := p.consumeOptionalSeparator(); err != nil {
+ return err
+ }
+ if err := p.consumeToken(terminator); err != nil {
+ return err
+ }
+
+ dst.SetMapIndex(key, val)
+ continue
+ }
+
+ // Check that it's not already set if it's not a repeated field.
+ if !props.Repeated && fieldSet[name] {
+ return p.errorf("non-repeated field %q was repeated", name)
+ }
+
+ if err := p.checkForColon(props, dst.Type()); err != nil {
+ return err
+ }
+
+ // Parse into the field.
+ fieldSet[name] = true
+ if err := p.readAny(dst, props); err != nil {
+ if _, ok := err.(*RequiredNotSetError); !ok {
+ return err
+ }
+ reqFieldErr = err
+ } else if props.Required {
+ reqCount--
}
if err := p.consumeOptionalSeparator(); err != nil {
@@ -703,18 +715,32 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) error {
fv.Set(reflect.ValueOf(bytes))
return nil
}
- // Repeated field. May already exist.
- flen := fv.Len()
- if flen == fv.Cap() {
- nav := reflect.MakeSlice(at, flen, 2*flen+1)
- reflect.Copy(nav, fv)
- fv.Set(nav)
+ // Repeated field.
+ if tok.value == "[" {
+ // Repeated field with list notation, like [1,2,3].
+ for {
+ fv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem()))
+ err := p.readAny(fv.Index(fv.Len()-1), props)
+ if err != nil {
+ return err
+ }
+ tok := p.next()
+ if tok.err != nil {
+ return tok.err
+ }
+ if tok.value == "]" {
+ break
+ }
+ if tok.value != "," {
+ return p.errorf("Expected ']' or ',' found %q", tok.value)
+ }
+ }
+ return nil
}
- fv.SetLen(flen + 1)
-
- // Read one.
+ // One value of the repeated field.
p.back()
- return p.readAny(fv.Index(flen), props)
+ fv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem()))
+ return p.readAny(fv.Index(fv.Len()-1), props)
case reflect.Bool:
// Either "true", "false", 1 or 0.
switch tok.value {
diff --git a/Godeps/_workspace/src/github.com/golang/glog/glog.go b/Godeps/_workspace/src/github.com/golang/glog/glog.go
index 3e63fffd5e..54bd7afdca 100644
--- a/Godeps/_workspace/src/github.com/golang/glog/glog.go
+++ b/Godeps/_workspace/src/github.com/golang/glog/glog.go
@@ -676,7 +676,10 @@ func (l *loggingT) output(s severity, buf *buffer, file string, line int, alsoTo
}
}
data := buf.Bytes()
- if l.toStderr {
+ if !flag.Parsed() {
+ os.Stderr.Write([]byte("ERROR: logging before flag.Parse: "))
+ os.Stderr.Write(data)
+ } else if l.toStderr {
os.Stderr.Write(data)
} else {
if alsoToStderr || l.alsoToStderr || s >= l.stderrThreshold.get() {
diff --git a/Godeps/_workspace/src/github.com/gorilla/context/.travis.yml b/Godeps/_workspace/src/github.com/gorilla/context/.travis.yml
index 6796581fbd..f983b60c62 100644
--- a/Godeps/_workspace/src/github.com/gorilla/context/.travis.yml
+++ b/Godeps/_workspace/src/github.com/gorilla/context/.travis.yml
@@ -1,9 +1,8 @@
language: go
+sudo: false
go:
- - 1.0
- - 1.1
- - 1.2
- 1.3
- 1.4
+ - 1.5
- tip
diff --git a/Godeps/_workspace/src/github.com/gorilla/mux/.travis.yml b/Godeps/_workspace/src/github.com/gorilla/mux/.travis.yml
index d87d465768..83ab8f59dd 100644
--- a/Godeps/_workspace/src/github.com/gorilla/mux/.travis.yml
+++ b/Godeps/_workspace/src/github.com/gorilla/mux/.travis.yml
@@ -1,7 +1,14 @@
language: go
-
+sudo: false
go:
- - 1.0
- - 1.1
- - 1.2
+ - 1.3
+ - 1.4
+ - 1.5
- tip
+install:
+ - go get golang.org/x/tools/cmd/vet
+script:
+ - go get -t -v ./...
+ - diff -u <(echo -n) <(gofmt -d -s .)
+ - go tool vet .
+ - go test -v -race ./...
diff --git a/Godeps/_workspace/src/github.com/gorilla/mux/README.md b/Godeps/_workspace/src/github.com/gorilla/mux/README.md
index e60301b033..b987c9e5d1 100644
--- a/Godeps/_workspace/src/github.com/gorilla/mux/README.md
+++ b/Godeps/_workspace/src/github.com/gorilla/mux/README.md
@@ -1,7 +1,240 @@
mux
===
-[](https://travis-ci.org/gorilla/mux)
+[](https://godoc.org/github.com/gorilla/mux)
+[](https://travis-ci.org/gorilla/mux)
-gorilla/mux is a powerful URL router and dispatcher.
+Package `gorilla/mux` implements a request router and dispatcher.
-Read the full documentation here: http://www.gorillatoolkit.org/pkg/mux
+The name mux stands for "HTTP request multiplexer". Like the standard `http.ServeMux`, `mux.Router` matches incoming requests against a list of registered routes and calls a handler for the route that matches the URL or other conditions. The main features are:
+
+* Requests can be matched based on URL host, path, path prefix, schemes, header and query values, HTTP methods or using custom matchers.
+* URL hosts and paths can have variables with an optional regular expression.
+* Registered URLs can be built, or "reversed", which helps maintaining references to resources.
+* Routes can be used as subrouters: nested routes are only tested if the parent route matches. This is useful to define groups of routes that share common conditions like a host, a path prefix or other repeated attributes. As a bonus, this optimizes request matching.
+* It implements the `http.Handler` interface so it is compatible with the standard `http.ServeMux`.
+
+Let's start registering a couple of URL paths and handlers:
+
+```go
+func main() {
+ r := mux.NewRouter()
+ r.HandleFunc("/", HomeHandler)
+ r.HandleFunc("/products", ProductsHandler)
+ r.HandleFunc("/articles", ArticlesHandler)
+ http.Handle("/", r)
+}
+```
+
+Here we register three routes mapping URL paths to handlers. This is equivalent to how `http.HandleFunc()` works: if an incoming request URL matches one of the paths, the corresponding handler is called passing (`http.ResponseWriter`, `*http.Request`) as parameters.
+
+Paths can have variables. They are defined using the format `{name}` or `{name:pattern}`. If a regular expression pattern is not defined, the matched variable will be anything until the next slash. For example:
+
+```go
+r := mux.NewRouter()
+r.HandleFunc("/products/{key}", ProductHandler)
+r.HandleFunc("/articles/{category}/", ArticlesCategoryHandler)
+r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler)
+```
+
+The names are used to create a map of route variables which can be retrieved calling `mux.Vars()`:
+
+```go
+vars := mux.Vars(request)
+category := vars["category"]
+```
+
+And this is all you need to know about the basic usage. More advanced options are explained below.
+
+Routes can also be restricted to a domain or subdomain. Just define a host pattern to be matched. They can also have variables:
+
+```go
+r := mux.NewRouter()
+// Only matches if domain is "www.example.com".
+r.Host("www.example.com")
+// Matches a dynamic subdomain.
+r.Host("{subdomain:[a-z]+}.domain.com")
+```
+
+There are several other matchers that can be added. To match path prefixes:
+
+```go
+r.PathPrefix("/products/")
+```
+
+...or HTTP methods:
+
+```go
+r.Methods("GET", "POST")
+```
+
+...or URL schemes:
+
+```go
+r.Schemes("https")
+```
+
+...or header values:
+
+```go
+r.Headers("X-Requested-With", "XMLHttpRequest")
+```
+
+...or query values:
+
+```go
+r.Queries("key", "value")
+```
+
+...or to use a custom matcher function:
+
+```go
+r.MatcherFunc(func(r *http.Request, rm *RouteMatch) bool {
+ return r.ProtoMajor == 0
+})
+```
+
+...and finally, it is possible to combine several matchers in a single route:
+
+```go
+r.HandleFunc("/products", ProductsHandler).
+ Host("www.example.com").
+ Methods("GET").
+ Schemes("http")
+```
+
+Setting the same matching conditions again and again can be boring, so we have a way to group several routes that share the same requirements. We call it "subrouting".
+
+For example, let's say we have several URLs that should only match when the host is `www.example.com`. Create a route for that host and get a "subrouter" from it:
+
+```go
+r := mux.NewRouter()
+s := r.Host("www.example.com").Subrouter()
+```
+
+Then register routes in the subrouter:
+
+```go
+s.HandleFunc("/products/", ProductsHandler)
+s.HandleFunc("/products/{key}", ProductHandler)
+s.HandleFunc("/articles/{category}/{id:[0-9]+}"), ArticleHandler)
+```
+
+The three URL paths we registered above will only be tested if the domain is `www.example.com`, because the subrouter is tested first. This is not only convenient, but also optimizes request matching. You can create subrouters combining any attribute matchers accepted by a route.
+
+Subrouters can be used to create domain or path "namespaces": you define subrouters in a central place and then parts of the app can register its paths relatively to a given subrouter.
+
+There's one more thing about subroutes. When a subrouter has a path prefix, the inner routes use it as base for their paths:
+
+```go
+r := mux.NewRouter()
+s := r.PathPrefix("/products").Subrouter()
+// "/products/"
+s.HandleFunc("/", ProductsHandler)
+// "/products/{key}/"
+s.HandleFunc("/{key}/", ProductHandler)
+// "/products/{key}/details"
+s.HandleFunc("/{key}/details", ProductDetailsHandler)
+```
+
+Now let's see how to build registered URLs.
+
+Routes can be named. All routes that define a name can have their URLs built, or "reversed". We define a name calling `Name()` on a route. For example:
+
+```go
+r := mux.NewRouter()
+r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler).
+ Name("article")
+```
+
+To build a URL, get the route and call the `URL()` method, passing a sequence of key/value pairs for the route variables. For the previous route, we would do:
+
+```go
+url, err := r.Get("article").URL("category", "technology", "id", "42")
+```
+
+...and the result will be a `url.URL` with the following path:
+
+```
+"/articles/technology/42"
+```
+
+This also works for host variables:
+
+```go
+r := mux.NewRouter()
+r.Host("{subdomain}.domain.com").
+ Path("/articles/{category}/{id:[0-9]+}").
+ HandlerFunc(ArticleHandler).
+ Name("article")
+
+// url.String() will be "http://news.domain.com/articles/technology/42"
+url, err := r.Get("article").URL("subdomain", "news",
+ "category", "technology",
+ "id", "42")
+```
+
+All variables defined in the route are required, and their values must conform to the corresponding patterns. These requirements guarantee that a generated URL will always match a registered route -- the only exception is for explicitly defined "build-only" routes which never match.
+
+Regex support also exists for matching Headers within a route. For example, we could do:
+
+```go
+r.HeadersRegexp("Content-Type", "application/(text|json)")
+```
+
+...and the route will match both requests with a Content-Type of `application/json` as well as `application/text`
+
+There's also a way to build only the URL host or path for a route: use the methods `URLHost()` or `URLPath()` instead. For the previous route, we would do:
+
+```go
+// "http://news.domain.com/"
+host, err := r.Get("article").URLHost("subdomain", "news")
+
+// "/articles/technology/42"
+path, err := r.Get("article").URLPath("category", "technology", "id", "42")
+```
+
+And if you use subrouters, host and path defined separately can be built as well:
+
+```go
+r := mux.NewRouter()
+s := r.Host("{subdomain}.domain.com").Subrouter()
+s.Path("/articles/{category}/{id:[0-9]+}").
+ HandlerFunc(ArticleHandler).
+ Name("article")
+
+// "http://news.domain.com/articles/technology/42"
+url, err := r.Get("article").URL("subdomain", "news",
+ "category", "technology",
+ "id", "42")
+```
+
+## Full Example
+
+Here's a complete, runnable example of a small `mux` based server:
+
+```go
+package main
+
+import (
+ "net/http"
+
+ "github.com/gorilla/mux"
+)
+
+func YourHandler(w http.ResponseWriter, r *http.Request) {
+ w.Write([]byte("Gorilla!\n"))
+}
+
+func main() {
+ r := mux.NewRouter()
+ // Routes consist of a path and a handler function.
+ r.HandleFunc("/", YourHandler)
+
+ // Bind to a port and pass our router in
+ http.ListenAndServe(":8000", r)
+}
+```
+
+## License
+
+BSD licensed. See the LICENSE file for details.
diff --git a/Godeps/_workspace/src/github.com/gorilla/mux/doc.go b/Godeps/_workspace/src/github.com/gorilla/mux/doc.go
index b2deed34c4..49798cb5cf 100644
--- a/Godeps/_workspace/src/github.com/gorilla/mux/doc.go
+++ b/Godeps/_workspace/src/github.com/gorilla/mux/doc.go
@@ -60,8 +60,8 @@ Routes can also be restricted to a domain or subdomain. Just define a host
pattern to be matched. They can also have variables:
r := mux.NewRouter()
- // Only matches if domain is "www.domain.com".
- r.Host("www.domain.com")
+ // Only matches if domain is "www.example.com".
+ r.Host("www.example.com")
// Matches a dynamic subdomain.
r.Host("{subdomain:[a-z]+}.domain.com")
@@ -89,12 +89,12 @@ There are several other matchers that can be added. To match path prefixes:
r.MatcherFunc(func(r *http.Request, rm *RouteMatch) bool {
return r.ProtoMajor == 0
- })
+ })
...and finally, it is possible to combine several matchers in a single route:
r.HandleFunc("/products", ProductsHandler).
- Host("www.domain.com").
+ Host("www.example.com").
Methods("GET").
Schemes("http")
@@ -103,11 +103,11 @@ a way to group several routes that share the same requirements.
We call it "subrouting".
For example, let's say we have several URLs that should only match when the
-host is "www.domain.com". Create a route for that host and get a "subrouter"
+host is "www.example.com". Create a route for that host and get a "subrouter"
from it:
r := mux.NewRouter()
- s := r.Host("www.domain.com").Subrouter()
+ s := r.Host("www.example.com").Subrouter()
Then register routes in the subrouter:
@@ -116,7 +116,7 @@ Then register routes in the subrouter:
s.HandleFunc("/articles/{category}/{id:[0-9]+}"), ArticleHandler)
The three URL paths we registered above will only be tested if the domain is
-"www.domain.com", because the subrouter is tested first. This is not
+"www.example.com", because the subrouter is tested first. This is not
only convenient, but also optimizes request matching. You can create
subrouters combining any attribute matchers accepted by a route.
@@ -164,14 +164,21 @@ This also works for host variables:
// url.String() will be "http://news.domain.com/articles/technology/42"
url, err := r.Get("article").URL("subdomain", "news",
- "category", "technology",
- "id", "42")
+ "category", "technology",
+ "id", "42")
All variables defined in the route are required, and their values must
conform to the corresponding patterns. These requirements guarantee that a
generated URL will always match a registered route -- the only exception is
for explicitly defined "build-only" routes which never match.
+Regex support also exists for matching Headers within a route. For example, we could do:
+
+ r.HeadersRegexp("Content-Type", "application/(text|json)")
+
+...and the route will match both requests with a Content-Type of `application/json` as well as
+`application/text`
+
There's also a way to build only the URL host or path for a route:
use the methods URLHost() or URLPath() instead. For the previous route,
we would do:
@@ -193,7 +200,7 @@ as well:
// "http://news.domain.com/articles/technology/42"
url, err := r.Get("article").URL("subdomain", "news",
- "category", "technology",
- "id", "42")
+ "category", "technology",
+ "id", "42")
*/
package mux
diff --git a/Godeps/_workspace/src/github.com/gorilla/mux/mux.go b/Godeps/_workspace/src/github.com/gorilla/mux/mux.go
index 5b5f8e7db5..aabe9958f2 100644
--- a/Godeps/_workspace/src/github.com/gorilla/mux/mux.go
+++ b/Godeps/_workspace/src/github.com/gorilla/mux/mux.go
@@ -5,9 +5,11 @@
package mux
import (
+ "errors"
"fmt"
"net/http"
"path"
+ "regexp"
"github.com/gorilla/context"
)
@@ -57,6 +59,12 @@ func (r *Router) Match(req *http.Request, match *RouteMatch) bool {
return true
}
}
+
+ // Closest match for a router (includes sub-routers)
+ if r.NotFoundHandler != nil {
+ match.Handler = r.NotFoundHandler
+ return true
+ }
return false
}
@@ -68,7 +76,7 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
// Clean path to canonical form and redirect.
if p := cleanPath(req.URL.Path); p != req.URL.Path {
- // Added 3 lines (Philip Schlump) - It was droping the query string and #whatever from query.
+ // Added 3 lines (Philip Schlump) - It was dropping the query string and #whatever from query.
// This matches with fix in go 1.2 r.c. 4 for same problem. Go Issue:
// http://code.google.com/p/go/issues/detail?id=5252
url := *req.URL
@@ -87,10 +95,7 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
setCurrentRoute(req, match.Route)
}
if handler == nil {
- handler = r.NotFoundHandler
- if handler == nil {
- handler = http.NotFoundHandler()
- }
+ handler = http.NotFoundHandler()
}
if !r.KeepContext {
defer context.Clear(req)
@@ -152,6 +157,13 @@ func (r *Router) getRegexpGroup() *routeRegexpGroup {
return nil
}
+func (r *Router) buildVars(m map[string]string) map[string]string {
+ if r.parent != nil {
+ m = r.parent.buildVars(m)
+ }
+ return m
+}
+
// ----------------------------------------------------------------------------
// Route factories
// ----------------------------------------------------------------------------
@@ -224,6 +236,58 @@ func (r *Router) Schemes(schemes ...string) *Route {
return r.NewRoute().Schemes(schemes...)
}
+// BuildVars registers a new route with a custom function for modifying
+// route variables before building a URL.
+func (r *Router) BuildVarsFunc(f BuildVarsFunc) *Route {
+ return r.NewRoute().BuildVarsFunc(f)
+}
+
+// Walk walks the router and all its sub-routers, calling walkFn for each route
+// in the tree. The routes are walked in the order they were added. Sub-routers
+// are explored depth-first.
+func (r *Router) Walk(walkFn WalkFunc) error {
+ return r.walk(walkFn, []*Route{})
+}
+
+// SkipRouter is used as a return value from WalkFuncs to indicate that the
+// router that walk is about to descend down to should be skipped.
+var SkipRouter = errors.New("skip this router")
+
+// WalkFunc is the type of the function called for each route visited by Walk.
+// At every invocation, it is given the current route, and the current router,
+// and a list of ancestor routes that lead to the current route.
+type WalkFunc func(route *Route, router *Router, ancestors []*Route) error
+
+func (r *Router) walk(walkFn WalkFunc, ancestors []*Route) error {
+ for _, t := range r.routes {
+ if t.regexp == nil || t.regexp.path == nil || t.regexp.path.template == "" {
+ continue
+ }
+
+ err := walkFn(t, r, ancestors)
+ if err == SkipRouter {
+ continue
+ }
+ for _, sr := range t.matchers {
+ if h, ok := sr.(*Router); ok {
+ err := h.walk(walkFn, ancestors)
+ if err != nil {
+ return err
+ }
+ }
+ }
+ if h, ok := t.handler.(*Router); ok {
+ ancestors = append(ancestors, t)
+ err := h.walk(walkFn, ancestors)
+ if err != nil {
+ return err
+ }
+ ancestors = ancestors[:len(ancestors)-1]
+ }
+ }
+ return nil
+}
+
// ----------------------------------------------------------------------------
// Context
// ----------------------------------------------------------------------------
@@ -251,6 +315,10 @@ func Vars(r *http.Request) map[string]string {
}
// CurrentRoute returns the matched route for the current request, if any.
+// This only works when called inside the handler of the matched route
+// because the matched route is stored in the request context which is cleared
+// after the handler returns, unless the KeepContext option is set on the
+// Router.
func CurrentRoute(r *http.Request) *Route {
if rv := context.Get(r, routeKey); rv != nil {
return rv.(*Route)
@@ -259,11 +327,15 @@ func CurrentRoute(r *http.Request) *Route {
}
func setVars(r *http.Request, val interface{}) {
- context.Set(r, varsKey, val)
+ if val != nil {
+ context.Set(r, varsKey, val)
+ }
}
func setCurrentRoute(r *http.Request, val interface{}) {
- context.Set(r, routeKey, val)
+ if val != nil {
+ context.Set(r, routeKey, val)
+ }
}
// ----------------------------------------------------------------------------
@@ -300,13 +372,24 @@ func uniqueVars(s1, s2 []string) error {
return nil
}
-// mapFromPairs converts variadic string parameters to a string map.
-func mapFromPairs(pairs ...string) (map[string]string, error) {
+// checkPairs returns the count of strings passed in, and an error if
+// the count is not an even number.
+func checkPairs(pairs ...string) (int, error) {
length := len(pairs)
if length%2 != 0 {
- return nil, fmt.Errorf(
+ return length, fmt.Errorf(
"mux: number of parameters must be multiple of 2, got %v", pairs)
}
+ return length, nil
+}
+
+// mapFromPairsToString converts variadic string parameters to a
+// string to string map.
+func mapFromPairsToString(pairs ...string) (map[string]string, error) {
+ length, err := checkPairs(pairs...)
+ if err != nil {
+ return nil, err
+ }
m := make(map[string]string, length/2)
for i := 0; i < length; i += 2 {
m[pairs[i]] = pairs[i+1]
@@ -314,6 +397,24 @@ func mapFromPairs(pairs ...string) (map[string]string, error) {
return m, nil
}
+// mapFromPairsToRegex converts variadic string paramers to a
+// string to regex map.
+func mapFromPairsToRegex(pairs ...string) (map[string]*regexp.Regexp, error) {
+ length, err := checkPairs(pairs...)
+ if err != nil {
+ return nil, err
+ }
+ m := make(map[string]*regexp.Regexp, length/2)
+ for i := 0; i < length; i += 2 {
+ regex, err := regexp.Compile(pairs[i+1])
+ if err != nil {
+ return nil, err
+ }
+ m[pairs[i]] = regex
+ }
+ return m, nil
+}
+
// matchInArray returns true if the given string value is in the array.
func matchInArray(arr []string, value string) bool {
for _, v := range arr {
@@ -324,9 +425,8 @@ func matchInArray(arr []string, value string) bool {
return false
}
-// matchMap returns true if the given key/value pairs exist in a given map.
-func matchMap(toCheck map[string]string, toMatch map[string][]string,
- canonicalKey bool) bool {
+// matchMapWithString returns true if the given key/value pairs exist in a given map.
+func matchMapWithString(toCheck map[string]string, toMatch map[string][]string, canonicalKey bool) bool {
for k, v := range toCheck {
// Check if key exists.
if canonicalKey {
@@ -351,3 +451,31 @@ func matchMap(toCheck map[string]string, toMatch map[string][]string,
}
return true
}
+
+// matchMapWithRegex returns true if the given key/value pairs exist in a given map compiled against
+// the given regex
+func matchMapWithRegex(toCheck map[string]*regexp.Regexp, toMatch map[string][]string, canonicalKey bool) bool {
+ for k, v := range toCheck {
+ // Check if key exists.
+ if canonicalKey {
+ k = http.CanonicalHeaderKey(k)
+ }
+ if values := toMatch[k]; values == nil {
+ return false
+ } else if v != nil {
+ // If value was defined as an empty string we only check that the
+ // key exists. Otherwise we also check for equality.
+ valueExists := false
+ for _, value := range values {
+ if v.MatchString(value) {
+ valueExists = true
+ break
+ }
+ }
+ if !valueExists {
+ return false
+ }
+ }
+ }
+ return true
+}
diff --git a/Godeps/_workspace/src/github.com/gorilla/mux/regexp.go b/Godeps/_workspace/src/github.com/gorilla/mux/regexp.go
index a6305483d5..06728dd545 100644
--- a/Godeps/_workspace/src/github.com/gorilla/mux/regexp.go
+++ b/Godeps/_workspace/src/github.com/gorilla/mux/regexp.go
@@ -10,6 +10,7 @@ import (
"net/http"
"net/url"
"regexp"
+ "strconv"
"strings"
)
@@ -34,8 +35,7 @@ func newRouteRegexp(tpl string, matchHost, matchPrefix, matchQuery, strictSlash
// Now let's parse it.
defaultPattern := "[^/]+"
if matchQuery {
- defaultPattern = "[^?&]+"
- matchPrefix = true
+ defaultPattern = "[^?&]*"
} else if matchHost {
defaultPattern = "[^.]+"
matchPrefix = false
@@ -53,9 +53,7 @@ func newRouteRegexp(tpl string, matchHost, matchPrefix, matchQuery, strictSlash
varsN := make([]string, len(idxs)/2)
varsR := make([]*regexp.Regexp, len(idxs)/2)
pattern := bytes.NewBufferString("")
- if !matchQuery {
- pattern.WriteByte('^')
- }
+ pattern.WriteByte('^')
reverse := bytes.NewBufferString("")
var end int
var err error
@@ -75,12 +73,14 @@ func newRouteRegexp(tpl string, matchHost, matchPrefix, matchQuery, strictSlash
tpl[idxs[i]:end])
}
// Build the regexp pattern.
- fmt.Fprintf(pattern, "%s(%s)", regexp.QuoteMeta(raw), patt)
+ varIdx := i / 2
+ fmt.Fprintf(pattern, "%s(?P<%s>%s)", regexp.QuoteMeta(raw), varGroupName(varIdx), patt)
// Build the reverse template.
fmt.Fprintf(reverse, "%s%%s", raw)
+
// Append variable name and compiled pattern.
- varsN[i/2] = name
- varsR[i/2], err = regexp.Compile(fmt.Sprintf("^%s$", patt))
+ varsN[varIdx] = name
+ varsR[varIdx], err = regexp.Compile(fmt.Sprintf("^%s$", patt))
if err != nil {
return nil, err
}
@@ -91,6 +91,12 @@ func newRouteRegexp(tpl string, matchHost, matchPrefix, matchQuery, strictSlash
if strictSlash {
pattern.WriteString("[/]?")
}
+ if matchQuery {
+ // Add the default pattern if the query value is empty
+ if queryVal := strings.SplitN(template, "=", 2)[1]; queryVal == "" {
+ pattern.WriteString(defaultPattern)
+ }
+ }
if !matchPrefix {
pattern.WriteByte('$')
}
@@ -141,7 +147,7 @@ type routeRegexp struct {
func (r *routeRegexp) Match(req *http.Request, match *RouteMatch) bool {
if !r.matchHost {
if r.matchQuery {
- return r.regexp.MatchString(req.URL.RawQuery)
+ return r.matchQueryString(req)
} else {
return r.regexp.MatchString(req.URL.Path)
}
@@ -150,11 +156,7 @@ func (r *routeRegexp) Match(req *http.Request, match *RouteMatch) bool {
}
// url builds a URL part using the given values.
-func (r *routeRegexp) url(pairs ...string) (string, error) {
- values, err := mapFromPairs(pairs...)
- if err != nil {
- return "", err
- }
+func (r *routeRegexp) url(values map[string]string) (string, error) {
urlValues := make([]interface{}, len(r.varsN))
for k, v := range r.varsN {
value, ok := values[v]
@@ -179,6 +181,26 @@ func (r *routeRegexp) url(pairs ...string) (string, error) {
return rv, nil
}
+// getUrlQuery returns a single query parameter from a request URL.
+// For a URL with foo=bar&baz=ding, we return only the relevant key
+// value pair for the routeRegexp.
+func (r *routeRegexp) getUrlQuery(req *http.Request) string {
+ if !r.matchQuery {
+ return ""
+ }
+ templateKey := strings.SplitN(r.template, "=", 2)[0]
+ for key, vals := range req.URL.Query() {
+ if key == templateKey && len(vals) > 0 {
+ return key + "=" + vals[0]
+ }
+ }
+ return ""
+}
+
+func (r *routeRegexp) matchQueryString(req *http.Request) bool {
+ return r.regexp.MatchString(r.getUrlQuery(req))
+}
+
// braceIndices returns the first level curly brace indices from a string.
// It returns an error in case of unbalanced braces.
func braceIndices(s string) ([]int, error) {
@@ -204,6 +226,11 @@ func braceIndices(s string) ([]int, error) {
return idxs, nil
}
+// varGroupName builds a capturing group name for the indexed variable.
+func varGroupName(idx int) string {
+ return "v" + strconv.Itoa(idx)
+}
+
// ----------------------------------------------------------------------------
// routeRegexpGroup
// ----------------------------------------------------------------------------
@@ -221,8 +248,13 @@ func (v *routeRegexpGroup) setMatch(req *http.Request, m *RouteMatch, r *Route)
if v.host != nil {
hostVars := v.host.regexp.FindStringSubmatch(getHost(req))
if hostVars != nil {
- for k, v := range v.host.varsN {
- m.Vars[v] = hostVars[k+1]
+ subexpNames := v.host.regexp.SubexpNames()
+ varName := 0
+ for i, name := range subexpNames[1:] {
+ if name != "" && name == varGroupName(varName) {
+ m.Vars[v.host.varsN[varName]] = hostVars[i+1]
+ varName++
+ }
}
}
}
@@ -230,8 +262,13 @@ func (v *routeRegexpGroup) setMatch(req *http.Request, m *RouteMatch, r *Route)
if v.path != nil {
pathVars := v.path.regexp.FindStringSubmatch(req.URL.Path)
if pathVars != nil {
- for k, v := range v.path.varsN {
- m.Vars[v] = pathVars[k+1]
+ subexpNames := v.path.regexp.SubexpNames()
+ varName := 0
+ for i, name := range subexpNames[1:] {
+ if name != "" && name == varGroupName(varName) {
+ m.Vars[v.path.varsN[varName]] = pathVars[i+1]
+ varName++
+ }
}
// Check if we should redirect.
if v.path.strictSlash {
@@ -250,12 +287,16 @@ func (v *routeRegexpGroup) setMatch(req *http.Request, m *RouteMatch, r *Route)
}
}
// Store query string variables.
- rawQuery := req.URL.RawQuery
for _, q := range v.queries {
- queryVars := q.regexp.FindStringSubmatch(rawQuery)
+ queryVars := q.regexp.FindStringSubmatch(q.getUrlQuery(req))
if queryVars != nil {
- for k, v := range q.varsN {
- m.Vars[v] = queryVars[k+1]
+ subexpNames := q.regexp.SubexpNames()
+ varName := 0
+ for i, name := range subexpNames[1:] {
+ if name != "" && name == varGroupName(varName) {
+ m.Vars[q.varsN[varName]] = queryVars[i+1]
+ varName++
+ }
}
}
}
diff --git a/Godeps/_workspace/src/github.com/gorilla/mux/route.go b/Godeps/_workspace/src/github.com/gorilla/mux/route.go
index c310e66bc7..913432c1c0 100644
--- a/Godeps/_workspace/src/github.com/gorilla/mux/route.go
+++ b/Godeps/_workspace/src/github.com/gorilla/mux/route.go
@@ -9,6 +9,7 @@ import (
"fmt"
"net/http"
"net/url"
+ "regexp"
"strings"
)
@@ -31,6 +32,8 @@ type Route struct {
name string
// Error resulted from building a route.
err error
+
+ buildVarsFunc BuildVarsFunc
}
// Match matches the route against the request.
@@ -186,7 +189,7 @@ func (r *Route) addRegexpMatcher(tpl string, matchHost, matchPrefix, matchQuery
type headerMatcher map[string]string
func (m headerMatcher) Match(r *http.Request, match *RouteMatch) bool {
- return matchMap(m, r.Header, true)
+ return matchMapWithString(m, r.Header, true)
}
// Headers adds a matcher for request header values.
@@ -197,22 +200,45 @@ func (m headerMatcher) Match(r *http.Request, match *RouteMatch) bool {
// "X-Requested-With", "XMLHttpRequest")
//
// The above route will only match if both request header values match.
-//
-// It the value is an empty string, it will match any value if the key is set.
+// If the value is an empty string, it will match any value if the key is set.
func (r *Route) Headers(pairs ...string) *Route {
if r.err == nil {
var headers map[string]string
- headers, r.err = mapFromPairs(pairs...)
+ headers, r.err = mapFromPairsToString(pairs...)
return r.addMatcher(headerMatcher(headers))
}
return r
}
+// headerRegexMatcher matches the request against the route given a regex for the header
+type headerRegexMatcher map[string]*regexp.Regexp
+
+func (m headerRegexMatcher) Match(r *http.Request, match *RouteMatch) bool {
+ return matchMapWithRegex(m, r.Header, true)
+}
+
+// Regular expressions can be used with headers as well.
+// It accepts a sequence of key/value pairs, where the value has regex support. For example
+// r := mux.NewRouter()
+// r.HeadersRegexp("Content-Type", "application/(text|json)",
+// "X-Requested-With", "XMLHttpRequest")
+//
+// The above route will only match if both the request header matches both regular expressions.
+// It the value is an empty string, it will match any value if the key is set.
+func (r *Route) HeadersRegexp(pairs ...string) *Route {
+ if r.err == nil {
+ var headers map[string]*regexp.Regexp
+ headers, r.err = mapFromPairsToRegex(pairs...)
+ return r.addMatcher(headerRegexMatcher(headers))
+ }
+ return r
+}
+
// Host -----------------------------------------------------------------------
// Host adds a matcher for the URL host.
// It accepts a template with zero or more URL variables enclosed by {}.
-// Variables can define an optional regexp pattern to me matched:
+// Variables can define an optional regexp pattern to be matched:
//
// - {name} matches anything until the next dot.
//
@@ -221,7 +247,7 @@ func (r *Route) Headers(pairs ...string) *Route {
// For example:
//
// r := mux.NewRouter()
-// r.Host("www.domain.com")
+// r.Host("www.example.com")
// r.Host("{subdomain}.domain.com")
// r.Host("{subdomain:[a-z]+}.domain.com")
//
@@ -270,7 +296,7 @@ func (r *Route) Methods(methods ...string) *Route {
// Path adds a matcher for the URL path.
// It accepts a template with zero or more URL variables enclosed by {}. The
// template must start with a "/".
-// Variables can define an optional regexp pattern to me matched:
+// Variables can define an optional regexp pattern to be matched:
//
// - {name} matches anything until the next slash.
//
@@ -321,7 +347,7 @@ func (r *Route) PathPrefix(tpl string) *Route {
//
// It the value is an empty string, it will match any value if the key is set.
//
-// Variables can define an optional regexp pattern to me matched:
+// Variables can define an optional regexp pattern to be matched:
//
// - {name} matches anything until the next slash.
//
@@ -334,7 +360,7 @@ func (r *Route) Queries(pairs ...string) *Route {
return nil
}
for i := 0; i < length; i += 2 {
- if r.err = r.addRegexpMatcher(pairs[i]+"="+pairs[i+1], false, true, true); r.err != nil {
+ if r.err = r.addRegexpMatcher(pairs[i]+"="+pairs[i+1], false, false, true); r.err != nil {
return r
}
}
@@ -360,6 +386,19 @@ func (r *Route) Schemes(schemes ...string) *Route {
return r.addMatcher(schemeMatcher(schemes))
}
+// BuildVarsFunc --------------------------------------------------------------
+
+// BuildVarsFunc is the function signature used by custom build variable
+// functions (which can modify route variables before a route's URL is built).
+type BuildVarsFunc func(map[string]string) map[string]string
+
+// BuildVarsFunc adds a custom function to be used to modify build variables
+// before a route's URL is built.
+func (r *Route) BuildVarsFunc(f BuildVarsFunc) *Route {
+ r.buildVarsFunc = f
+ return r
+}
+
// Subrouter ------------------------------------------------------------------
// Subrouter creates a subrouter for the route.
@@ -367,7 +406,7 @@ func (r *Route) Schemes(schemes ...string) *Route {
// It will test the inner routes only if the parent route matched. For example:
//
// r := mux.NewRouter()
-// s := r.Host("www.domain.com").Subrouter()
+// s := r.Host("www.example.com").Subrouter()
// s.HandleFunc("/products/", ProductsHandler)
// s.HandleFunc("/products/{key}", ProductHandler)
// s.HandleFunc("/articles/{category}/{id:[0-9]+}"), ArticleHandler)
@@ -422,17 +461,20 @@ func (r *Route) URL(pairs ...string) (*url.URL, error) {
if r.regexp == nil {
return nil, errors.New("mux: route doesn't have a host or path")
}
+ values, err := r.prepareVars(pairs...)
+ if err != nil {
+ return nil, err
+ }
var scheme, host, path string
- var err error
if r.regexp.host != nil {
// Set a default scheme.
scheme = "http"
- if host, err = r.regexp.host.url(pairs...); err != nil {
+ if host, err = r.regexp.host.url(values); err != nil {
return nil, err
}
}
if r.regexp.path != nil {
- if path, err = r.regexp.path.url(pairs...); err != nil {
+ if path, err = r.regexp.path.url(values); err != nil {
return nil, err
}
}
@@ -453,7 +495,11 @@ func (r *Route) URLHost(pairs ...string) (*url.URL, error) {
if r.regexp == nil || r.regexp.host == nil {
return nil, errors.New("mux: route doesn't have a host")
}
- host, err := r.regexp.host.url(pairs...)
+ values, err := r.prepareVars(pairs...)
+ if err != nil {
+ return nil, err
+ }
+ host, err := r.regexp.host.url(values)
if err != nil {
return nil, err
}
@@ -473,7 +519,11 @@ func (r *Route) URLPath(pairs ...string) (*url.URL, error) {
if r.regexp == nil || r.regexp.path == nil {
return nil, errors.New("mux: route doesn't have a path")
}
- path, err := r.regexp.path.url(pairs...)
+ values, err := r.prepareVars(pairs...)
+ if err != nil {
+ return nil, err
+ }
+ path, err := r.regexp.path.url(values)
if err != nil {
return nil, err
}
@@ -482,6 +532,26 @@ func (r *Route) URLPath(pairs ...string) (*url.URL, error) {
}, nil
}
+// prepareVars converts the route variable pairs into a map. If the route has a
+// BuildVarsFunc, it is invoked.
+func (r *Route) prepareVars(pairs ...string) (map[string]string, error) {
+ m, err := mapFromPairsToString(pairs...)
+ if err != nil {
+ return nil, err
+ }
+ return r.buildVars(m), nil
+}
+
+func (r *Route) buildVars(m map[string]string) map[string]string {
+ if r.parent != nil {
+ m = r.parent.buildVars(m)
+ }
+ if r.buildVarsFunc != nil {
+ m = r.buildVarsFunc(m)
+ }
+ return m
+}
+
// ----------------------------------------------------------------------------
// parentRoute
// ----------------------------------------------------------------------------
@@ -490,6 +560,7 @@ func (r *Route) URLPath(pairs ...string) (*url.URL, error) {
type parentRoute interface {
getNamedRoutes() map[string]*Route
getRegexpGroup() *routeRegexpGroup
+ buildVars(map[string]string) map[string]string
}
// getNamedRoutes returns the map where named routes are registered.
diff --git a/Godeps/_workspace/src/github.com/hashicorp/consul/api/README.md b/Godeps/_workspace/src/github.com/hashicorp/consul/api/README.md
index bce2ebb516..6fcdd2033d 100644
--- a/Godeps/_workspace/src/github.com/hashicorp/consul/api/README.md
+++ b/Godeps/_workspace/src/github.com/hashicorp/consul/api/README.md
@@ -4,7 +4,7 @@ Consul API client
This package provides the `api` package which attempts to
provide programmatic access to the full Consul API.
-Currently, all of the Consul APIs included in version 0.3 are supported.
+Currently, all of the Consul APIs included in version 0.6.0 are supported.
Documentation
=============
@@ -17,13 +17,18 @@ Usage
Below is an example of using the Consul client:
```go
-// Get a new client, with KV endpoints
-client, _ := api.NewClient(api.DefaultConfig())
+// Get a new client
+client, err := api.NewClient(api.DefaultConfig())
+if err != nil {
+ panic(err)
+}
+
+// Get a handle to the KV API
kv := client.KV()
// PUT a new KV pair
p := &api.KVPair{Key: "foo", Value: []byte("test")}
-_, err := kv.Put(p, nil)
+_, err = kv.Put(p, nil)
if err != nil {
panic(err)
}
diff --git a/Godeps/_workspace/src/github.com/hashicorp/consul/api/agent.go b/Godeps/_workspace/src/github.com/hashicorp/consul/api/agent.go
index 4b144fe181..e4466a6511 100644
--- a/Godeps/_workspace/src/github.com/hashicorp/consul/api/agent.go
+++ b/Godeps/_workspace/src/github.com/hashicorp/consul/api/agent.go
@@ -63,11 +63,15 @@ type AgentCheckRegistration struct {
// AgentServiceCheck is used to create an associated
// check for a service
type AgentServiceCheck struct {
- Script string `json:",omitempty"`
- Interval string `json:",omitempty"`
- Timeout string `json:",omitempty"`
- TTL string `json:",omitempty"`
- HTTP string `json:",omitempty"`
+ Script string `json:",omitempty"`
+ DockerContainerID string `json:",omitempty"`
+ Shell string `json:",omitempty"` // Only supported for Docker.
+ Interval string `json:",omitempty"`
+ Timeout string `json:",omitempty"`
+ TTL string `json:",omitempty"`
+ HTTP string `json:",omitempty"`
+ TCP string `json:",omitempty"`
+ Status string `json:",omitempty"`
}
type AgentServiceChecks []*AgentServiceCheck
diff --git a/Godeps/_workspace/src/github.com/hashicorp/consul/api/api.go b/Godeps/_workspace/src/github.com/hashicorp/consul/api/api.go
index aa0060816d..0a2a76e5dc 100644
--- a/Godeps/_workspace/src/github.com/hashicorp/consul/api/api.go
+++ b/Godeps/_workspace/src/github.com/hashicorp/consul/api/api.go
@@ -2,9 +2,11 @@ package api
import (
"bytes"
+ "crypto/tls"
"encoding/json"
"fmt"
"io"
+ "log"
"net"
"net/http"
"net/url"
@@ -12,6 +14,8 @@ import (
"strconv"
"strings"
"time"
+
+ "github.com/hashicorp/go-cleanhttp"
)
// QueryOptions are used to parameterize a query
@@ -34,12 +38,18 @@ type QueryOptions struct {
WaitIndex uint64
// WaitTime is used to bound the duration of a wait.
- // Defaults to that of the Config, but can be overriden.
+ // Defaults to that of the Config, but can be overridden.
WaitTime time.Duration
// Token is used to provide a per-request ACL token
// which overrides the agent's default token.
Token string
+
+ // Near is used to provide a node name that will sort the results
+ // in ascending order based on the estimated round trip time from
+ // that node. Setting this to "_agent" will use the agent's node
+ // for the sort.
+ Near string
}
// WriteOptions are used to parameterize a write
@@ -117,13 +127,59 @@ func DefaultConfig() *Config {
config := &Config{
Address: "127.0.0.1:8500",
Scheme: "http",
- HttpClient: http.DefaultClient,
+ HttpClient: cleanhttp.DefaultClient(),
}
if addr := os.Getenv("CONSUL_HTTP_ADDR"); addr != "" {
config.Address = addr
}
+ if token := os.Getenv("CONSUL_HTTP_TOKEN"); token != "" {
+ config.Token = token
+ }
+
+ if auth := os.Getenv("CONSUL_HTTP_AUTH"); auth != "" {
+ var username, password string
+ if strings.Contains(auth, ":") {
+ split := strings.SplitN(auth, ":", 2)
+ username = split[0]
+ password = split[1]
+ } else {
+ username = auth
+ }
+
+ config.HttpAuth = &HttpBasicAuth{
+ Username: username,
+ Password: password,
+ }
+ }
+
+ if ssl := os.Getenv("CONSUL_HTTP_SSL"); ssl != "" {
+ enabled, err := strconv.ParseBool(ssl)
+ if err != nil {
+ log.Printf("[WARN] client: could not parse CONSUL_HTTP_SSL: %s", err)
+ }
+
+ if enabled {
+ config.Scheme = "https"
+ }
+ }
+
+ if verify := os.Getenv("CONSUL_HTTP_SSL_VERIFY"); verify != "" {
+ doVerify, err := strconv.ParseBool(verify)
+ if err != nil {
+ log.Printf("[WARN] client: could not parse CONSUL_HTTP_SSL_VERIFY: %s", err)
+ }
+
+ if !doVerify {
+ transport := cleanhttp.DefaultTransport()
+ transport.TLSClientConfig = &tls.Config{
+ InsecureSkipVerify: true,
+ }
+ config.HttpClient.Transport = transport
+ }
+ }
+
return config
}
@@ -150,12 +206,12 @@ func NewClient(config *Config) (*Client, error) {
}
if parts := strings.SplitN(config.Address, "unix://", 2); len(parts) == 2 {
+ trans := cleanhttp.DefaultTransport()
+ trans.Dial = func(_, _ string) (net.Conn, error) {
+ return net.Dial("unix", parts[1])
+ }
config.HttpClient = &http.Client{
- Transport: &http.Transport{
- Dial: func(_, _ string) (net.Conn, error) {
- return net.Dial("unix", parts[1])
- },
- },
+ Transport: trans,
}
config.Address = parts[1]
}
@@ -200,11 +256,36 @@ func (r *request) setQueryOptions(q *QueryOptions) {
if q.Token != "" {
r.params.Set("token", q.Token)
}
+ if q.Near != "" {
+ r.params.Set("near", q.Near)
+ }
}
-// durToMsec converts a duration to a millisecond specified string
+// durToMsec converts a duration to a millisecond specified string. If the
+// user selected a positive value that rounds to 0 ms, then we will use 1 ms
+// so they get a short delay, otherwise Consul will translate the 0 ms into
+// a huge default delay.
func durToMsec(dur time.Duration) string {
- return fmt.Sprintf("%dms", dur/time.Millisecond)
+ ms := dur / time.Millisecond
+ if dur > 0 && ms == 0 {
+ ms = 1
+ }
+ return fmt.Sprintf("%dms", ms)
+}
+
+// serverError is a string we look for to detect 500 errors.
+const serverError = "Unexpected response code: 500"
+
+// IsServerError returns true for 500 errors from the Consul servers, these are
+// usually retryable at a later time.
+func IsServerError(err error) bool {
+ if err == nil {
+ return false
+ }
+
+ // TODO (slackpad) - Make a real error type here instead of using
+ // a string check.
+ return strings.Contains(err.Error(), serverError)
}
// setWriteOptions is used to annotate the request with
@@ -289,6 +370,49 @@ func (c *Client) doRequest(r *request) (time.Duration, *http.Response, error) {
return diff, resp, err
}
+// Query is used to do a GET request against an endpoint
+// and deserialize the response into an interface using
+// standard Consul conventions.
+func (c *Client) query(endpoint string, out interface{}, q *QueryOptions) (*QueryMeta, error) {
+ r := c.newRequest("GET", endpoint)
+ r.setQueryOptions(q)
+ rtt, resp, err := requireOK(c.doRequest(r))
+ if err != nil {
+ return nil, err
+ }
+ defer resp.Body.Close()
+
+ qm := &QueryMeta{}
+ parseQueryMeta(resp, qm)
+ qm.RequestTime = rtt
+
+ if err := decodeBody(resp, out); err != nil {
+ return nil, err
+ }
+ return qm, nil
+}
+
+// write is used to do a PUT request against an endpoint
+// and serialize/deserialized using the standard Consul conventions.
+func (c *Client) write(endpoint string, in, out interface{}, q *WriteOptions) (*WriteMeta, error) {
+ r := c.newRequest("PUT", endpoint)
+ r.setWriteOptions(q)
+ r.obj = in
+ rtt, resp, err := requireOK(c.doRequest(r))
+ if err != nil {
+ return nil, err
+ }
+ defer resp.Body.Close()
+
+ wm := &WriteMeta{RequestTime: rtt}
+ if out != nil {
+ if err := decodeBody(resp, &out); err != nil {
+ return nil, err
+ }
+ }
+ return wm, nil
+}
+
// parseQueryMeta is used to help parse query meta-data
func parseQueryMeta(resp *http.Response, q *QueryMeta) error {
header := resp.Header
diff --git a/Godeps/_workspace/src/github.com/hashicorp/consul/api/catalog.go b/Godeps/_workspace/src/github.com/hashicorp/consul/api/catalog.go
index fee1695677..cf64bd9091 100644
--- a/Godeps/_workspace/src/github.com/hashicorp/consul/api/catalog.go
+++ b/Godeps/_workspace/src/github.com/hashicorp/consul/api/catalog.go
@@ -6,12 +6,13 @@ type Node struct {
}
type CatalogService struct {
- Node string
- Address string
- ServiceID string
- ServiceName string
- ServiceTags []string
- ServicePort int
+ Node string
+ Address string
+ ServiceID string
+ ServiceName string
+ ServiceAddress string
+ ServiceTags []string
+ ServicePort int
}
type CatalogNode struct {
diff --git a/Godeps/_workspace/src/github.com/hashicorp/consul/api/coordinate.go b/Godeps/_workspace/src/github.com/hashicorp/consul/api/coordinate.go
new file mode 100644
index 0000000000..fdff2075cd
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/hashicorp/consul/api/coordinate.go
@@ -0,0 +1,66 @@
+package api
+
+import (
+ "github.com/hashicorp/serf/coordinate"
+)
+
+// CoordinateEntry represents a node and its associated network coordinate.
+type CoordinateEntry struct {
+ Node string
+ Coord *coordinate.Coordinate
+}
+
+// CoordinateDatacenterMap represents a datacenter and its associated WAN
+// nodes and their associates coordinates.
+type CoordinateDatacenterMap struct {
+ Datacenter string
+ Coordinates []CoordinateEntry
+}
+
+// Coordinate can be used to query the coordinate endpoints
+type Coordinate struct {
+ c *Client
+}
+
+// Coordinate returns a handle to the coordinate endpoints
+func (c *Client) Coordinate() *Coordinate {
+ return &Coordinate{c}
+}
+
+// Datacenters is used to return the coordinates of all the servers in the WAN
+// pool.
+func (c *Coordinate) Datacenters() ([]*CoordinateDatacenterMap, error) {
+ r := c.c.newRequest("GET", "/v1/coordinate/datacenters")
+ _, resp, err := requireOK(c.c.doRequest(r))
+ if err != nil {
+ return nil, err
+ }
+ defer resp.Body.Close()
+
+ var out []*CoordinateDatacenterMap
+ if err := decodeBody(resp, &out); err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+// Nodes is used to return the coordinates of all the nodes in the LAN pool.
+func (c *Coordinate) Nodes(q *QueryOptions) ([]*CoordinateEntry, *QueryMeta, error) {
+ r := c.c.newRequest("GET", "/v1/coordinate/nodes")
+ r.setQueryOptions(q)
+ rtt, resp, err := requireOK(c.c.doRequest(r))
+ if err != nil {
+ return nil, nil, err
+ }
+ defer resp.Body.Close()
+
+ qm := &QueryMeta{}
+ parseQueryMeta(resp, qm)
+ qm.RequestTime = rtt
+
+ var out []*CoordinateEntry
+ if err := decodeBody(resp, &out); err != nil {
+ return nil, nil, err
+ }
+ return out, qm, nil
+}
diff --git a/Godeps/_workspace/src/github.com/hashicorp/consul/api/health.go b/Godeps/_workspace/src/github.com/hashicorp/consul/api/health.go
index 02b161e28e..1a273e087c 100644
--- a/Godeps/_workspace/src/github.com/hashicorp/consul/api/health.go
+++ b/Godeps/_workspace/src/github.com/hashicorp/consul/api/health.go
@@ -104,7 +104,7 @@ func (h *Health) Service(service, tag string, passingOnly bool, q *QueryOptions)
return out, qm, nil
}
-// State is used to retreive all the checks in a given state.
+// State is used to retrieve all the checks in a given state.
// The wildcard "any" state can also be used for all checks.
func (h *Health) State(state string, q *QueryOptions) ([]*HealthCheck, *QueryMeta, error) {
switch state {
diff --git a/Godeps/_workspace/src/github.com/hashicorp/consul/api/kv.go b/Godeps/_workspace/src/github.com/hashicorp/consul/api/kv.go
index ba74057fcc..688b3a09d2 100644
--- a/Godeps/_workspace/src/github.com/hashicorp/consul/api/kv.go
+++ b/Godeps/_workspace/src/github.com/hashicorp/consul/api/kv.go
@@ -143,7 +143,7 @@ func (k *KV) CAS(p *KVPair, q *WriteOptions) (bool, *WriteMeta, error) {
return k.put(p.Key, params, p.Value, q)
}
-// Acquire is used for a lock acquisiiton operation. The Key,
+// Acquire is used for a lock acquisition operation. The Key,
// Flags, Value and Session are respected. Returns true
// on success or false on failures.
func (k *KV) Acquire(p *KVPair, q *WriteOptions) (bool, *WriteMeta, error) {
@@ -168,6 +168,10 @@ func (k *KV) Release(p *KVPair, q *WriteOptions) (bool, *WriteMeta, error) {
}
func (k *KV) put(key string, params map[string]string, body []byte, q *WriteOptions) (bool, *WriteMeta, error) {
+ if len(key) > 0 && key[0] == '/' {
+ return false, nil, fmt.Errorf("Invalid key. Key must not begin with a '/': %s", key)
+ }
+
r := k.c.newRequest("PUT", "/v1/kv/"+key)
r.setWriteOptions(q)
for param, val := range params {
diff --git a/Godeps/_workspace/src/github.com/hashicorp/consul/api/lock.go b/Godeps/_workspace/src/github.com/hashicorp/consul/api/lock.go
index f6fdbbb166..11cfdedbc8 100644
--- a/Godeps/_workspace/src/github.com/hashicorp/consul/api/lock.go
+++ b/Godeps/_workspace/src/github.com/hashicorp/consul/api/lock.go
@@ -22,9 +22,16 @@ const (
// DefaultLockRetryTime is how long we wait after a failed lock acquisition
// before attempting to do the lock again. This is so that once a lock-delay
- // is in affect, we do not hot loop retrying the acquisition.
+ // is in effect, we do not hot loop retrying the acquisition.
DefaultLockRetryTime = 5 * time.Second
+ // DefaultMonitorRetryTime is how long we wait after a failed monitor check
+ // of a lock (500 response code). This allows the monitor to ride out brief
+ // periods of unavailability, subject to the MonitorRetries setting in the
+ // lock options which is by default set to 0, disabling this feature. This
+ // affects locks and semaphores.
+ DefaultMonitorRetryTime = 2 * time.Second
+
// LockFlagValue is a magic flag we set to indicate a key
// is being used for a lock. It is used to detect a potential
// conflict with a semaphore.
@@ -62,11 +69,15 @@ type Lock struct {
// LockOptions is used to parameterize the Lock behavior.
type LockOptions struct {
- Key string // Must be set and have write permissions
- Value []byte // Optional, value to associate with the lock
- Session string // Optional, created if not specified
- SessionName string // Optional, defaults to DefaultLockSessionName
- SessionTTL string // Optional, defaults to DefaultLockSessionTTL
+ Key string // Must be set and have write permissions
+ Value []byte // Optional, value to associate with the lock
+ Session string // Optional, created if not specified
+ SessionName string // Optional, defaults to DefaultLockSessionName
+ SessionTTL string // Optional, defaults to DefaultLockSessionTTL
+ MonitorRetries int // Optional, defaults to 0 which means no retries
+ MonitorRetryTime time.Duration // Optional, defaults to DefaultMonitorRetryTime
+ LockWaitTime time.Duration // Optional, defaults to DefaultLockWaitTime
+ LockTryOnce bool // Optional, defaults to false which means try forever
}
// LockKey returns a handle to a lock struct which can be used
@@ -96,6 +107,12 @@ func (c *Client) LockOpts(opts *LockOptions) (*Lock, error) {
return nil, fmt.Errorf("invalid SessionTTL: %v", err)
}
}
+ if opts.MonitorRetryTime == 0 {
+ opts.MonitorRetryTime = DefaultMonitorRetryTime
+ }
+ if opts.LockWaitTime == 0 {
+ opts.LockWaitTime = DefaultLockWaitTime
+ }
l := &Lock{
c: c,
opts: opts,
@@ -146,9 +163,11 @@ func (l *Lock) Lock(stopCh <-chan struct{}) (<-chan struct{}, error) {
// Setup the query options
kv := l.c.KV()
qOpts := &QueryOptions{
- WaitTime: DefaultLockWaitTime,
+ WaitTime: l.opts.LockWaitTime,
}
+ start := time.Now()
+ attempts := 0
WAIT:
// Check if we should quit
select {
@@ -157,6 +176,17 @@ WAIT:
default:
}
+ // Handle the one-shot mode.
+ if l.opts.LockTryOnce && attempts > 0 {
+ elapsed := time.Now().Sub(start)
+ if elapsed > qOpts.WaitTime {
+ return nil, nil
+ }
+
+ qOpts.WaitTime -= elapsed
+ }
+ attempts++
+
// Look for an existing lock, blocking until not taken
pair, meta, err := kv.Get(l.opts.Key, qOpts)
if err != nil {
@@ -165,28 +195,45 @@ WAIT:
if pair != nil && pair.Flags != LockFlagValue {
return nil, ErrLockConflict
}
+ locked := false
+ if pair != nil && pair.Session == l.lockSession {
+ goto HELD
+ }
if pair != nil && pair.Session != "" {
qOpts.WaitIndex = meta.LastIndex
goto WAIT
}
// Try to acquire the lock
- lockEnt := l.lockEntry(l.lockSession)
- locked, _, err := kv.Acquire(lockEnt, nil)
+ pair = l.lockEntry(l.lockSession)
+ locked, _, err = kv.Acquire(pair, nil)
if err != nil {
return nil, fmt.Errorf("failed to acquire lock: %v", err)
}
// Handle the case of not getting the lock
if !locked {
- select {
- case <-time.After(DefaultLockRetryTime):
+ // Determine why the lock failed
+ qOpts.WaitIndex = 0
+ pair, meta, err = kv.Get(l.opts.Key, qOpts)
+ if pair != nil && pair.Session != "" {
+ //If the session is not null, this means that a wait can safely happen
+ //using a long poll
+ qOpts.WaitIndex = meta.LastIndex
goto WAIT
- case <-stopCh:
- return nil, nil
+ } else {
+ // If the session is empty and the lock failed to acquire, then it means
+ // a lock-delay is in effect and a timed wait must be used
+ select {
+ case <-time.After(DefaultLockRetryTime):
+ goto WAIT
+ case <-stopCh:
+ return nil, nil
+ }
}
}
+HELD:
// Watch to ensure we maintain leadership
leaderCh := make(chan struct{})
go l.monitorLock(l.lockSession, leaderCh)
@@ -310,8 +357,20 @@ func (l *Lock) monitorLock(session string, stopCh chan struct{}) {
kv := l.c.KV()
opts := &QueryOptions{RequireConsistent: true}
WAIT:
+ retries := l.opts.MonitorRetries
+RETRY:
pair, meta, err := kv.Get(l.opts.Key, opts)
if err != nil {
+ // If configured we can try to ride out a brief Consul unavailability
+ // by doing retries. Note that we have to attempt the retry in a non-
+ // blocking fashion so that we have a clean place to reset the retry
+ // counter if service is restored.
+ if retries > 0 && IsServerError(err) {
+ time.Sleep(l.opts.MonitorRetryTime)
+ retries--
+ opts.WaitIndex = 0
+ goto RETRY
+ }
return
}
if pair != nil && pair.Session == session {
diff --git a/Godeps/_workspace/src/github.com/hashicorp/consul/api/prepared_query.go b/Godeps/_workspace/src/github.com/hashicorp/consul/api/prepared_query.go
new file mode 100644
index 0000000000..c8141887c4
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/hashicorp/consul/api/prepared_query.go
@@ -0,0 +1,173 @@
+package api
+
+// QueryDatacenterOptions sets options about how we fail over if there are no
+// healthy nodes in the local datacenter.
+type QueryDatacenterOptions struct {
+ // NearestN is set to the number of remote datacenters to try, based on
+ // network coordinates.
+ NearestN int
+
+ // Datacenters is a fixed list of datacenters to try after NearestN. We
+ // never try a datacenter multiple times, so those are subtracted from
+ // this list before proceeding.
+ Datacenters []string
+}
+
+// QueryDNSOptions controls settings when query results are served over DNS.
+type QueryDNSOptions struct {
+ // TTL is the time to live for the served DNS results.
+ TTL string
+}
+
+// ServiceQuery is used to query for a set of healthy nodes offering a specific
+// service.
+type ServiceQuery struct {
+ // Service is the service to query.
+ Service string
+
+ // Failover controls what we do if there are no healthy nodes in the
+ // local datacenter.
+ Failover QueryDatacenterOptions
+
+ // If OnlyPassing is true then we will only include nodes with passing
+ // health checks (critical AND warning checks will cause a node to be
+ // discarded)
+ OnlyPassing bool
+
+ // Tags are a set of required and/or disallowed tags. If a tag is in
+ // this list it must be present. If the tag is preceded with "!" then
+ // it is disallowed.
+ Tags []string
+}
+
+// PrepatedQueryDefinition defines a complete prepared query.
+type PreparedQueryDefinition struct {
+ // ID is this UUID-based ID for the query, always generated by Consul.
+ ID string
+
+ // Name is an optional friendly name for the query supplied by the
+ // user. NOTE - if this feature is used then it will reduce the security
+ // of any read ACL associated with this query/service since this name
+ // can be used to locate nodes with supplying any ACL.
+ Name string
+
+ // Session is an optional session to tie this query's lifetime to. If
+ // this is omitted then the query will not expire.
+ Session string
+
+ // Token is the ACL token used when the query was created, and it is
+ // used when a query is subsequently executed. This token, or a token
+ // with management privileges, must be used to change the query later.
+ Token string
+
+ // Service defines a service query (leaving things open for other types
+ // later).
+ Service ServiceQuery
+
+ // DNS has options that control how the results of this query are
+ // served over DNS.
+ DNS QueryDNSOptions
+}
+
+// PreparedQueryExecuteResponse has the results of executing a query.
+type PreparedQueryExecuteResponse struct {
+ // Service is the service that was queried.
+ Service string
+
+ // Nodes has the nodes that were output by the query.
+ Nodes []ServiceEntry
+
+ // DNS has the options for serving these results over DNS.
+ DNS QueryDNSOptions
+
+ // Datacenter is the datacenter that these results came from.
+ Datacenter string
+
+ // Failovers is a count of how many times we had to query a remote
+ // datacenter.
+ Failovers int
+}
+
+// PreparedQuery can be used to query the prepared query endpoints.
+type PreparedQuery struct {
+ c *Client
+}
+
+// PreparedQuery returns a handle to the prepared query endpoints.
+func (c *Client) PreparedQuery() *PreparedQuery {
+ return &PreparedQuery{c}
+}
+
+// Create makes a new prepared query. The ID of the new query is returned.
+func (c *PreparedQuery) Create(query *PreparedQueryDefinition, q *WriteOptions) (string, *WriteMeta, error) {
+ r := c.c.newRequest("POST", "/v1/query")
+ r.setWriteOptions(q)
+ r.obj = query
+ rtt, resp, err := requireOK(c.c.doRequest(r))
+ if err != nil {
+ return "", nil, err
+ }
+ defer resp.Body.Close()
+
+ wm := &WriteMeta{}
+ wm.RequestTime = rtt
+
+ var out struct{ ID string }
+ if err := decodeBody(resp, &out); err != nil {
+ return "", nil, err
+ }
+ return out.ID, wm, nil
+}
+
+// Update makes updates to an existing prepared query.
+func (c *PreparedQuery) Update(query *PreparedQueryDefinition, q *WriteOptions) (*WriteMeta, error) {
+ return c.c.write("/v1/query/"+query.ID, query, nil, q)
+}
+
+// List is used to fetch all the prepared queries (always requires a management
+// token).
+func (c *PreparedQuery) List(q *QueryOptions) ([]*PreparedQueryDefinition, *QueryMeta, error) {
+ var out []*PreparedQueryDefinition
+ qm, err := c.c.query("/v1/query", &out, q)
+ if err != nil {
+ return nil, nil, err
+ }
+ return out, qm, nil
+}
+
+// Get is used to fetch a specific prepared query.
+func (c *PreparedQuery) Get(queryID string, q *QueryOptions) ([]*PreparedQueryDefinition, *QueryMeta, error) {
+ var out []*PreparedQueryDefinition
+ qm, err := c.c.query("/v1/query/"+queryID, &out, q)
+ if err != nil {
+ return nil, nil, err
+ }
+ return out, qm, nil
+}
+
+// Delete is used to delete a specific prepared query.
+func (c *PreparedQuery) Delete(queryID string, q *QueryOptions) (*QueryMeta, error) {
+ r := c.c.newRequest("DELETE", "/v1/query/"+queryID)
+ r.setQueryOptions(q)
+ rtt, resp, err := requireOK(c.c.doRequest(r))
+ if err != nil {
+ return nil, err
+ }
+ defer resp.Body.Close()
+
+ qm := &QueryMeta{}
+ parseQueryMeta(resp, qm)
+ qm.RequestTime = rtt
+ return qm, nil
+}
+
+// Execute is used to execute a specific prepared query. You can execute using
+// a query ID or name.
+func (c *PreparedQuery) Execute(queryIDOrName string, q *QueryOptions) (*PreparedQueryExecuteResponse, *QueryMeta, error) {
+ var out *PreparedQueryExecuteResponse
+ qm, err := c.c.query("/v1/query/"+queryIDOrName+"/execute", &out, q)
+ if err != nil {
+ return nil, nil, err
+ }
+ return out, qm, nil
+}
diff --git a/Godeps/_workspace/src/github.com/hashicorp/consul/api/raw.go b/Godeps/_workspace/src/github.com/hashicorp/consul/api/raw.go
new file mode 100644
index 0000000000..745a208c99
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/hashicorp/consul/api/raw.go
@@ -0,0 +1,24 @@
+package api
+
+// Raw can be used to do raw queries against custom endpoints
+type Raw struct {
+ c *Client
+}
+
+// Raw returns a handle to query endpoints
+func (c *Client) Raw() *Raw {
+ return &Raw{c}
+}
+
+// Query is used to do a GET request against an endpoint
+// and deserialize the response into an interface using
+// standard Consul conventions.
+func (raw *Raw) Query(endpoint string, out interface{}, q *QueryOptions) (*QueryMeta, error) {
+ return raw.c.query(endpoint, out, q)
+}
+
+// Write is used to do a PUT request against an endpoint
+// and serialize/deserialized using the standard Consul conventions.
+func (raw *Raw) Write(endpoint string, in, out interface{}, q *WriteOptions) (*WriteMeta, error) {
+ return raw.c.write(endpoint, in, out, q)
+}
diff --git a/Godeps/_workspace/src/github.com/hashicorp/consul/api/semaphore.go b/Godeps/_workspace/src/github.com/hashicorp/consul/api/semaphore.go
index 957f884a4d..e6645ac1d3 100644
--- a/Godeps/_workspace/src/github.com/hashicorp/consul/api/semaphore.go
+++ b/Godeps/_workspace/src/github.com/hashicorp/consul/api/semaphore.go
@@ -22,11 +22,6 @@ const (
// a Semaphore acquisition.
DefaultSemaphoreWaitTime = 15 * time.Second
- // DefaultSemaphoreRetryTime is how long we wait after a failed lock acquisition
- // before attempting to do the lock again. This is so that once a lock-delay
- // is in affect, we do not hot loop retrying the acquisition.
- DefaultSemaphoreRetryTime = 5 * time.Second
-
// DefaultSemaphoreKey is the key used within the prefix to
// use for coordination between all the contenders.
DefaultSemaphoreKey = ".lock"
@@ -68,12 +63,16 @@ type Semaphore struct {
// SemaphoreOptions is used to parameterize the Semaphore
type SemaphoreOptions struct {
- Prefix string // Must be set and have write permissions
- Limit int // Must be set, and be positive
- Value []byte // Optional, value to associate with the contender entry
- Session string // OPtional, created if not specified
- SessionName string // Optional, defaults to DefaultLockSessionName
- SessionTTL string // Optional, defaults to DefaultLockSessionTTL
+ Prefix string // Must be set and have write permissions
+ Limit int // Must be set, and be positive
+ Value []byte // Optional, value to associate with the contender entry
+ Session string // Optional, created if not specified
+ SessionName string // Optional, defaults to DefaultLockSessionName
+ SessionTTL string // Optional, defaults to DefaultLockSessionTTL
+ MonitorRetries int // Optional, defaults to 0 which means no retries
+ MonitorRetryTime time.Duration // Optional, defaults to DefaultMonitorRetryTime
+ SemaphoreWaitTime time.Duration // Optional, defaults to DefaultSemaphoreWaitTime
+ SemaphoreTryOnce bool // Optional, defaults to false which means try forever
}
// semaphoreLock is written under the DefaultSemaphoreKey and
@@ -120,6 +119,12 @@ func (c *Client) SemaphoreOpts(opts *SemaphoreOptions) (*Semaphore, error) {
return nil, fmt.Errorf("invalid SessionTTL: %v", err)
}
}
+ if opts.MonitorRetryTime == 0 {
+ opts.MonitorRetryTime = DefaultMonitorRetryTime
+ }
+ if opts.SemaphoreWaitTime == 0 {
+ opts.SemaphoreWaitTime = DefaultSemaphoreWaitTime
+ }
s := &Semaphore{
c: c,
opts: opts,
@@ -128,7 +133,7 @@ func (c *Client) SemaphoreOpts(opts *SemaphoreOptions) (*Semaphore, error) {
}
// Acquire attempts to reserve a slot in the semaphore, blocking until
-// success, interrupted via the stopCh or an error is encounted.
+// success, interrupted via the stopCh or an error is encountered.
// Providing a non-nil stopCh can be used to abort the attempt.
// On success, a channel is returned that represents our slot.
// This channel could be closed at any time due to session invalidation,
@@ -177,9 +182,11 @@ func (s *Semaphore) Acquire(stopCh <-chan struct{}) (<-chan struct{}, error) {
// Setup the query options
qOpts := &QueryOptions{
- WaitTime: DefaultSemaphoreWaitTime,
+ WaitTime: s.opts.SemaphoreWaitTime,
}
+ start := time.Now()
+ attempts := 0
WAIT:
// Check if we should quit
select {
@@ -188,6 +195,17 @@ WAIT:
default:
}
+ // Handle the one-shot mode.
+ if s.opts.SemaphoreTryOnce && attempts > 0 {
+ elapsed := time.Now().Sub(start)
+ if elapsed > qOpts.WaitTime {
+ return nil, nil
+ }
+
+ qOpts.WaitTime -= elapsed
+ }
+ attempts++
+
// Read the prefix
pairs, meta, err := kv.List(s.opts.Prefix, qOpts)
if err != nil {
@@ -465,8 +483,20 @@ func (s *Semaphore) monitorLock(session string, stopCh chan struct{}) {
kv := s.c.KV()
opts := &QueryOptions{RequireConsistent: true}
WAIT:
+ retries := s.opts.MonitorRetries
+RETRY:
pairs, meta, err := kv.List(s.opts.Prefix, opts)
if err != nil {
+ // If configured we can try to ride out a brief Consul unavailability
+ // by doing retries. Note that we have to attempt the retry in a non-
+ // blocking fashion so that we have a clean place to reset the retry
+ // counter if service is restored.
+ if retries > 0 && IsServerError(err) {
+ time.Sleep(s.opts.MonitorRetryTime)
+ retries--
+ opts.WaitIndex = 0
+ goto RETRY
+ }
return
}
lockPair := s.findLock(pairs)
diff --git a/Godeps/_workspace/src/github.com/hashicorp/consul/api/session.go b/Godeps/_workspace/src/github.com/hashicorp/consul/api/session.go
index bb84644fd9..36e99a389e 100644
--- a/Godeps/_workspace/src/github.com/hashicorp/consul/api/session.go
+++ b/Godeps/_workspace/src/github.com/hashicorp/consul/api/session.go
@@ -1,6 +1,8 @@
package api
import (
+ "errors"
+ "fmt"
"time"
)
@@ -15,6 +17,8 @@ const (
SessionBehaviorDelete = "delete"
)
+var ErrSessionExpired = errors.New("session expired")
+
// SessionEntry represents a session in consul
type SessionEntry struct {
CreateIndex uint64
@@ -93,34 +97,20 @@ func (s *Session) Create(se *SessionEntry, q *WriteOptions) (string, *WriteMeta,
}
func (s *Session) create(obj interface{}, q *WriteOptions) (string, *WriteMeta, error) {
- r := s.c.newRequest("PUT", "/v1/session/create")
- r.setWriteOptions(q)
- r.obj = obj
- rtt, resp, err := requireOK(s.c.doRequest(r))
- if err != nil {
- return "", nil, err
- }
- defer resp.Body.Close()
-
- wm := &WriteMeta{RequestTime: rtt}
var out struct{ ID string }
- if err := decodeBody(resp, &out); err != nil {
+ wm, err := s.c.write("/v1/session/create", obj, &out, q)
+ if err != nil {
return "", nil, err
}
return out.ID, wm, nil
}
-// Destroy invalides a given session
+// Destroy invalidates a given session
func (s *Session) Destroy(id string, q *WriteOptions) (*WriteMeta, error) {
- r := s.c.newRequest("PUT", "/v1/session/destroy/"+id)
- r.setWriteOptions(q)
- rtt, resp, err := requireOK(s.c.doRequest(r))
+ wm, err := s.c.write("/v1/session/destroy/"+id, nil, nil, q)
if err != nil {
return nil, err
}
- resp.Body.Close()
-
- wm := &WriteMeta{RequestTime: rtt}
return wm, nil
}
@@ -128,7 +118,7 @@ func (s *Session) Destroy(id string, q *WriteOptions) (*WriteMeta, error) {
func (s *Session) Renew(id string, q *WriteOptions) (*SessionEntry, *WriteMeta, error) {
r := s.c.newRequest("PUT", "/v1/session/renew/"+id)
r.setWriteOptions(q)
- rtt, resp, err := requireOK(s.c.doRequest(r))
+ rtt, resp, err := s.c.doRequest(r)
if err != nil {
return nil, nil, err
}
@@ -136,11 +126,16 @@ func (s *Session) Renew(id string, q *WriteOptions) (*SessionEntry, *WriteMeta,
wm := &WriteMeta{RequestTime: rtt}
- var entries []*SessionEntry
- if err := decodeBody(resp, &entries); err != nil {
- return nil, wm, err
+ if resp.StatusCode == 404 {
+ return nil, wm, nil
+ } else if resp.StatusCode != 200 {
+ return nil, nil, fmt.Errorf("Unexpected response code: %d", resp.StatusCode)
}
+ var entries []*SessionEntry
+ if err := decodeBody(resp, &entries); err != nil {
+ return nil, nil, fmt.Errorf("Failed to read response: %v", err)
+ }
if len(entries) > 0 {
return entries[0], wm, nil
}
@@ -155,19 +150,30 @@ func (s *Session) RenewPeriodic(initialTTL string, id string, q *WriteOptions, d
if err != nil {
return err
}
+
+ waitDur := ttl / 2
+ lastRenewTime := time.Now()
+ var lastErr error
for {
+ if time.Since(lastRenewTime) > ttl {
+ return lastErr
+ }
select {
- case <-time.After(ttl / 2):
+ case <-time.After(waitDur):
entry, _, err := s.Renew(id, q)
if err != nil {
- return err
+ waitDur = time.Second
+ lastErr = err
+ continue
}
if entry == nil {
- return nil
+ return ErrSessionExpired
}
// Handle the server updating the TTL
ttl, _ = time.ParseDuration(entry.TTL)
+ waitDur = ttl / 2
+ lastRenewTime = time.Now()
case <-doneCh:
// Attempt a session destroy
@@ -179,23 +185,11 @@ func (s *Session) RenewPeriodic(initialTTL string, id string, q *WriteOptions, d
// Info looks up a single session
func (s *Session) Info(id string, q *QueryOptions) (*SessionEntry, *QueryMeta, error) {
- r := s.c.newRequest("GET", "/v1/session/info/"+id)
- r.setQueryOptions(q)
- rtt, resp, err := requireOK(s.c.doRequest(r))
+ var entries []*SessionEntry
+ qm, err := s.c.query("/v1/session/info/"+id, &entries, q)
if err != nil {
return nil, nil, err
}
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- var entries []*SessionEntry
- if err := decodeBody(resp, &entries); err != nil {
- return nil, nil, err
- }
-
if len(entries) > 0 {
return entries[0], qm, nil
}
@@ -204,20 +198,9 @@ func (s *Session) Info(id string, q *QueryOptions) (*SessionEntry, *QueryMeta, e
// List gets sessions for a node
func (s *Session) Node(node string, q *QueryOptions) ([]*SessionEntry, *QueryMeta, error) {
- r := s.c.newRequest("GET", "/v1/session/node/"+node)
- r.setQueryOptions(q)
- rtt, resp, err := requireOK(s.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
var entries []*SessionEntry
- if err := decodeBody(resp, &entries); err != nil {
+ qm, err := s.c.query("/v1/session/node/"+node, &entries, q)
+ if err != nil {
return nil, nil, err
}
return entries, qm, nil
@@ -225,20 +208,9 @@ func (s *Session) Node(node string, q *QueryOptions) ([]*SessionEntry, *QueryMet
// List gets all active sessions
func (s *Session) List(q *QueryOptions) ([]*SessionEntry, *QueryMeta, error) {
- r := s.c.newRequest("GET", "/v1/session/list")
- r.setQueryOptions(q)
- rtt, resp, err := requireOK(s.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
var entries []*SessionEntry
- if err := decodeBody(resp, &entries); err != nil {
+ qm, err := s.c.query("/v1/session/list", &entries, q)
+ if err != nil {
return nil, nil, err
}
return entries, qm, nil
diff --git a/Godeps/_workspace/src/github.com/hashicorp/go-cleanhttp/LICENSE b/Godeps/_workspace/src/github.com/hashicorp/go-cleanhttp/LICENSE
new file mode 100644
index 0000000000..e87a115e46
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/hashicorp/go-cleanhttp/LICENSE
@@ -0,0 +1,363 @@
+Mozilla Public License, version 2.0
+
+1. Definitions
+
+1.1. "Contributor"
+
+ means each individual or legal entity that creates, contributes to the
+ creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+
+ means the combination of the Contributions of others (if any) used by a
+ Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+
+ means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+
+ means Source Code Form to which the initial Contributor has attached the
+ notice in Exhibit A, the Executable Form of such Source Code Form, and
+ Modifications of such Source Code Form, in each case including portions
+ thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+ means
+
+ a. that the initial Contributor has attached the notice described in
+ Exhibit B to the Covered Software; or
+
+ b. that the Covered Software was made available under the terms of
+ version 1.1 or earlier of the License, but not also under the terms of
+ a Secondary License.
+
+1.6. "Executable Form"
+
+ means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+
+ means a work that combines Covered Software with other material, in a
+ separate file or files, that is not Covered Software.
+
+1.8. "License"
+
+ means this document.
+
+1.9. "Licensable"
+
+ means having the right to grant, to the maximum extent possible, whether
+ at the time of the initial grant or subsequently, any and all of the
+ rights conveyed by this License.
+
+1.10. "Modifications"
+
+ means any of the following:
+
+ a. any file in Source Code Form that results from an addition to,
+ deletion from, or modification of the contents of Covered Software; or
+
+ b. any new file in Source Code Form that contains any Covered Software.
+
+1.11. "Patent Claims" of a Contributor
+
+ means any patent claim(s), including without limitation, method,
+ process, and apparatus claims, in any patent Licensable by such
+ Contributor that would be infringed, but for the grant of the License,
+ by the making, using, selling, offering for sale, having made, import,
+ or transfer of either its Contributions or its Contributor Version.
+
+1.12. "Secondary License"
+
+ means either the GNU General Public License, Version 2.0, the GNU Lesser
+ General Public License, Version 2.1, the GNU Affero General Public
+ License, Version 3.0, or any later versions of those licenses.
+
+1.13. "Source Code Form"
+
+ means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+
+ means an individual or a legal entity exercising rights under this
+ License. For legal entities, "You" includes any entity that controls, is
+ controlled by, or is under common control with You. For purposes of this
+ definition, "control" means (a) the power, direct or indirect, to cause
+ the direction or management of such entity, whether by contract or
+ otherwise, or (b) ownership of more than fifty percent (50%) of the
+ outstanding shares or beneficial ownership of such entity.
+
+
+2. License Grants and Conditions
+
+2.1. Grants
+
+ Each Contributor hereby grants You a world-wide, royalty-free,
+ non-exclusive license:
+
+ a. under intellectual property rights (other than patent or trademark)
+ Licensable by such Contributor to use, reproduce, make available,
+ modify, display, perform, distribute, and otherwise exploit its
+ Contributions, either on an unmodified basis, with Modifications, or
+ as part of a Larger Work; and
+
+ b. under Patent Claims of such Contributor to make, use, sell, offer for
+ sale, have made, import, and otherwise transfer either its
+ Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+ The licenses granted in Section 2.1 with respect to any Contribution
+ become effective for each Contribution on the date the Contributor first
+ distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+ The licenses granted in this Section 2 are the only rights granted under
+ this License. No additional rights or licenses will be implied from the
+ distribution or licensing of Covered Software under this License.
+ Notwithstanding Section 2.1(b) above, no patent license is granted by a
+ Contributor:
+
+ a. for any code that a Contributor has removed from Covered Software; or
+
+ b. for infringements caused by: (i) Your and any other third party's
+ modifications of Covered Software, or (ii) the combination of its
+ Contributions with other software (except as part of its Contributor
+ Version); or
+
+ c. under Patent Claims infringed by Covered Software in the absence of
+ its Contributions.
+
+ This License does not grant any rights in the trademarks, service marks,
+ or logos of any Contributor (except as may be necessary to comply with
+ the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+ No Contributor makes additional grants as a result of Your choice to
+ distribute the Covered Software under a subsequent version of this
+ License (see Section 10.2) or under the terms of a Secondary License (if
+ permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+ Each Contributor represents that the Contributor believes its
+ Contributions are its original creation(s) or it has sufficient rights to
+ grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+ This License is not intended to limit any rights You have under
+ applicable copyright doctrines of fair use, fair dealing, or other
+ equivalents.
+
+2.7. Conditions
+
+ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
+ Section 2.1.
+
+
+3. Responsibilities
+
+3.1. Distribution of Source Form
+
+ All distribution of Covered Software in Source Code Form, including any
+ Modifications that You create or to which You contribute, must be under
+ the terms of this License. You must inform recipients that the Source
+ Code Form of the Covered Software is governed by the terms of this
+ License, and how they can obtain a copy of this License. You may not
+ attempt to alter or restrict the recipients' rights in the Source Code
+ Form.
+
+3.2. Distribution of Executable Form
+
+ If You distribute Covered Software in Executable Form then:
+
+ a. such Covered Software must also be made available in Source Code Form,
+ as described in Section 3.1, and You must inform recipients of the
+ Executable Form how they can obtain a copy of such Source Code Form by
+ reasonable means in a timely manner, at a charge no more than the cost
+ of distribution to the recipient; and
+
+ b. You may distribute such Executable Form under the terms of this
+ License, or sublicense it under different terms, provided that the
+ license for the Executable Form does not attempt to limit or alter the
+ recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+ You may create and distribute a Larger Work under terms of Your choice,
+ provided that You also comply with the requirements of this License for
+ the Covered Software. If the Larger Work is a combination of Covered
+ Software with a work governed by one or more Secondary Licenses, and the
+ Covered Software is not Incompatible With Secondary Licenses, this
+ License permits You to additionally distribute such Covered Software
+ under the terms of such Secondary License(s), so that the recipient of
+ the Larger Work may, at their option, further distribute the Covered
+ Software under the terms of either this License or such Secondary
+ License(s).
+
+3.4. Notices
+
+ You may not remove or alter the substance of any license notices
+ (including copyright notices, patent notices, disclaimers of warranty, or
+ limitations of liability) contained within the Source Code Form of the
+ Covered Software, except that You may alter any license notices to the
+ extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+ You may choose to offer, and to charge a fee for, warranty, support,
+ indemnity or liability obligations to one or more recipients of Covered
+ Software. However, You may do so only on Your own behalf, and not on
+ behalf of any Contributor. You must make it absolutely clear that any
+ such warranty, support, indemnity, or liability obligation is offered by
+ You alone, and You hereby agree to indemnify every Contributor for any
+ liability incurred by such Contributor as a result of warranty, support,
+ indemnity or liability terms You offer. You may include additional
+ disclaimers of warranty and limitations of liability specific to any
+ jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+
+ If it is impossible for You to comply with any of the terms of this License
+ with respect to some or all of the Covered Software due to statute,
+ judicial order, or regulation then You must: (a) comply with the terms of
+ this License to the maximum extent possible; and (b) describe the
+ limitations and the code they affect. Such description must be placed in a
+ text file included with all distributions of the Covered Software under
+ this License. Except to the extent prohibited by statute or regulation,
+ such description must be sufficiently detailed for a recipient of ordinary
+ skill to be able to understand it.
+
+5. Termination
+
+5.1. The rights granted under this License will terminate automatically if You
+ fail to comply with any of its terms. However, if You become compliant,
+ then the rights granted under this License from a particular Contributor
+ are reinstated (a) provisionally, unless and until such Contributor
+ explicitly and finally terminates Your grants, and (b) on an ongoing
+ basis, if such Contributor fails to notify You of the non-compliance by
+ some reasonable means prior to 60 days after You have come back into
+ compliance. Moreover, Your grants from a particular Contributor are
+ reinstated on an ongoing basis if such Contributor notifies You of the
+ non-compliance by some reasonable means, this is the first time You have
+ received notice of non-compliance with this License from such
+ Contributor, and You become compliant prior to 30 days after Your receipt
+ of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+ infringement claim (excluding declaratory judgment actions,
+ counter-claims, and cross-claims) alleging that a Contributor Version
+ directly or indirectly infringes any patent, then the rights granted to
+ You by any and all Contributors for the Covered Software under Section
+ 2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
+ license agreements (excluding distributors and resellers) which have been
+ validly granted by You or Your distributors under this License prior to
+ termination shall survive termination.
+
+6. Disclaimer of Warranty
+
+ Covered Software is provided under this License on an "as is" basis,
+ without warranty of any kind, either expressed, implied, or statutory,
+ including, without limitation, warranties that the Covered Software is free
+ of defects, merchantable, fit for a particular purpose or non-infringing.
+ The entire risk as to the quality and performance of the Covered Software
+ is with You. Should any Covered Software prove defective in any respect,
+ You (not any Contributor) assume the cost of any necessary servicing,
+ repair, or correction. This disclaimer of warranty constitutes an essential
+ part of this License. No use of any Covered Software is authorized under
+ this License except under this disclaimer.
+
+7. Limitation of Liability
+
+ Under no circumstances and under no legal theory, whether tort (including
+ negligence), contract, or otherwise, shall any Contributor, or anyone who
+ distributes Covered Software as permitted above, be liable to You for any
+ direct, indirect, special, incidental, or consequential damages of any
+ character including, without limitation, damages for lost profits, loss of
+ goodwill, work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses, even if such party shall have been
+ informed of the possibility of such damages. This limitation of liability
+ shall not apply to liability for death or personal injury resulting from
+ such party's negligence to the extent applicable law prohibits such
+ limitation. Some jurisdictions do not allow the exclusion or limitation of
+ incidental or consequential damages, so this exclusion and limitation may
+ not apply to You.
+
+8. Litigation
+
+ Any litigation relating to this License may be brought only in the courts
+ of a jurisdiction where the defendant maintains its principal place of
+ business and such litigation shall be governed by laws of that
+ jurisdiction, without reference to its conflict-of-law provisions. Nothing
+ in this Section shall prevent a party's ability to bring cross-claims or
+ counter-claims.
+
+9. Miscellaneous
+
+ This License represents the complete agreement concerning the subject
+ matter hereof. If any provision of this License is held to be
+ unenforceable, such provision shall be reformed only to the extent
+ necessary to make it enforceable. Any law or regulation which provides that
+ the language of a contract shall be construed against the drafter shall not
+ be used to construe this License against a Contributor.
+
+
+10. Versions of the License
+
+10.1. New Versions
+
+ Mozilla Foundation is the license steward. Except as provided in Section
+ 10.3, no one other than the license steward has the right to modify or
+ publish new versions of this License. Each version will be given a
+ distinguishing version number.
+
+10.2. Effect of New Versions
+
+ You may distribute the Covered Software under the terms of the version
+ of the License under which You originally received the Covered Software,
+ or under the terms of any subsequent version published by the license
+ steward.
+
+10.3. Modified Versions
+
+ If you create software not governed by this License, and you want to
+ create a new license for such software, you may create and use a
+ modified version of this License if you rename the license and remove
+ any references to the name of the license steward (except to note that
+ such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+ Licenses If You choose to distribute Source Code Form that is
+ Incompatible With Secondary Licenses under the terms of this version of
+ the License, the notice described in Exhibit B of this License must be
+ attached.
+
+Exhibit A - Source Code Form License Notice
+
+ This Source Code Form is subject to the
+ terms of the Mozilla Public License, v.
+ 2.0. If a copy of the MPL was not
+ distributed with this file, You can
+ obtain one at
+ http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular file,
+then You may include the notice in a location (such as a LICENSE file in a
+relevant directory) where a recipient would be likely to look for such a
+notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+
+ This Source Code Form is "Incompatible
+ With Secondary Licenses", as defined by
+ the Mozilla Public License, v. 2.0.
+
diff --git a/Godeps/_workspace/src/github.com/hashicorp/go-cleanhttp/README.md b/Godeps/_workspace/src/github.com/hashicorp/go-cleanhttp/README.md
new file mode 100644
index 0000000000..036e5313fc
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/hashicorp/go-cleanhttp/README.md
@@ -0,0 +1,30 @@
+# cleanhttp
+
+Functions for accessing "clean" Go http.Client values
+
+-------------
+
+The Go standard library contains a default `http.Client` called
+`http.DefaultClient`. It is a common idiom in Go code to start with
+`http.DefaultClient` and tweak it as necessary, and in fact, this is
+encouraged; from the `http` package documentation:
+
+> The Client's Transport typically has internal state (cached TCP connections),
+so Clients should be reused instead of created as needed. Clients are safe for
+concurrent use by multiple goroutines.
+
+Unfortunately, this is a shared value, and it is not uncommon for libraries to
+assume that they are free to modify it at will. With enough dependencies, it
+can be very easy to encounter strange problems and race conditions due to
+manipulation of this shared value across libraries and goroutines (clients are
+safe for concurrent use, but writing values to the client struct itself is not
+protected).
+
+Making things worse is the fact that a bare `http.Client` will use a default
+`http.Transport` called `http.DefaultTransport`, which is another global value
+that behaves the same way. So it is not simply enough to replace
+`http.DefaultClient` with `&http.Client{}`.
+
+This repository provides some simple functions to get a "clean" `http.Client`
+-- one that uses the same default values as the Go standard library, but
+returns a client that does not share any state with other clients.
diff --git a/Godeps/_workspace/src/github.com/hashicorp/go-cleanhttp/cleanhttp.go b/Godeps/_workspace/src/github.com/hashicorp/go-cleanhttp/cleanhttp.go
new file mode 100644
index 0000000000..c692e23f46
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/hashicorp/go-cleanhttp/cleanhttp.go
@@ -0,0 +1,40 @@
+package cleanhttp
+
+import (
+ "net"
+ "net/http"
+ "runtime"
+ "time"
+)
+
+// DefaultTransport returns a new http.Transport with the same default values
+// as http.DefaultTransport
+func DefaultTransport() *http.Transport {
+ transport := &http.Transport{
+ Proxy: http.ProxyFromEnvironment,
+ Dial: (&net.Dialer{
+ Timeout: 30 * time.Second,
+ KeepAlive: 30 * time.Second,
+ }).Dial,
+ TLSHandshakeTimeout: 10 * time.Second,
+ }
+ SetTransportFinalizer(transport)
+ return transport
+}
+
+// DefaultClient returns a new http.Client with the same default values as
+// http.Client, but with a non-shared Transport
+func DefaultClient() *http.Client {
+ return &http.Client{
+ Transport: DefaultTransport(),
+ }
+}
+
+// SetTransportFinalizer sets a finalizer on the transport to ensure that
+// idle connections are closed prior to garbage collection; otherwise
+// these may leak
+func SetTransportFinalizer(transport *http.Transport) {
+ runtime.SetFinalizer(&transport, func(t **http.Transport) {
+ (*t).CloseIdleConnections()
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/hashicorp/serf/LICENSE b/Godeps/_workspace/src/github.com/hashicorp/serf/LICENSE
new file mode 100644
index 0000000000..c33dcc7c92
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/hashicorp/serf/LICENSE
@@ -0,0 +1,354 @@
+Mozilla Public License, version 2.0
+
+1. Definitions
+
+1.1. “Contributor”
+
+ means each individual or legal entity that creates, contributes to the
+ creation of, or owns Covered Software.
+
+1.2. “Contributor Version”
+
+ means the combination of the Contributions of others (if any) used by a
+ Contributor and that particular Contributor’s Contribution.
+
+1.3. “Contribution”
+
+ means Covered Software of a particular Contributor.
+
+1.4. “Covered Software”
+
+ means Source Code Form to which the initial Contributor has attached the
+ notice in Exhibit A, the Executable Form of such Source Code Form, and
+ Modifications of such Source Code Form, in each case including portions
+ thereof.
+
+1.5. “Incompatible With Secondary Licenses”
+ means
+
+ a. that the initial Contributor has attached the notice described in
+ Exhibit B to the Covered Software; or
+
+ b. that the Covered Software was made available under the terms of version
+ 1.1 or earlier of the License, but not also under the terms of a
+ Secondary License.
+
+1.6. “Executable Form”
+
+ means any form of the work other than Source Code Form.
+
+1.7. “Larger Work”
+
+ means a work that combines Covered Software with other material, in a separate
+ file or files, that is not Covered Software.
+
+1.8. “License”
+
+ means this document.
+
+1.9. “Licensable”
+
+ means having the right to grant, to the maximum extent possible, whether at the
+ time of the initial grant or subsequently, any and all of the rights conveyed by
+ this License.
+
+1.10. “Modifications”
+
+ means any of the following:
+
+ a. any file in Source Code Form that results from an addition to, deletion
+ from, or modification of the contents of Covered Software; or
+
+ b. any new file in Source Code Form that contains any Covered Software.
+
+1.11. “Patent Claims” of a Contributor
+
+ means any patent claim(s), including without limitation, method, process,
+ and apparatus claims, in any patent Licensable by such Contributor that
+ would be infringed, but for the grant of the License, by the making,
+ using, selling, offering for sale, having made, import, or transfer of
+ either its Contributions or its Contributor Version.
+
+1.12. “Secondary License”
+
+ means either the GNU General Public License, Version 2.0, the GNU Lesser
+ General Public License, Version 2.1, the GNU Affero General Public
+ License, Version 3.0, or any later versions of those licenses.
+
+1.13. “Source Code Form”
+
+ means the form of the work preferred for making modifications.
+
+1.14. “You” (or “Your”)
+
+ means an individual or a legal entity exercising rights under this
+ License. For legal entities, “You” includes any entity that controls, is
+ controlled by, or is under common control with You. For purposes of this
+ definition, “control” means (a) the power, direct or indirect, to cause
+ the direction or management of such entity, whether by contract or
+ otherwise, or (b) ownership of more than fifty percent (50%) of the
+ outstanding shares or beneficial ownership of such entity.
+
+
+2. License Grants and Conditions
+
+2.1. Grants
+
+ Each Contributor hereby grants You a world-wide, royalty-free,
+ non-exclusive license:
+
+ a. under intellectual property rights (other than patent or trademark)
+ Licensable by such Contributor to use, reproduce, make available,
+ modify, display, perform, distribute, and otherwise exploit its
+ Contributions, either on an unmodified basis, with Modifications, or as
+ part of a Larger Work; and
+
+ b. under Patent Claims of such Contributor to make, use, sell, offer for
+ sale, have made, import, and otherwise transfer either its Contributions
+ or its Contributor Version.
+
+2.2. Effective Date
+
+ The licenses granted in Section 2.1 with respect to any Contribution become
+ effective for each Contribution on the date the Contributor first distributes
+ such Contribution.
+
+2.3. Limitations on Grant Scope
+
+ The licenses granted in this Section 2 are the only rights granted under this
+ License. No additional rights or licenses will be implied from the distribution
+ or licensing of Covered Software under this License. Notwithstanding Section
+ 2.1(b) above, no patent license is granted by a Contributor:
+
+ a. for any code that a Contributor has removed from Covered Software; or
+
+ b. for infringements caused by: (i) Your and any other third party’s
+ modifications of Covered Software, or (ii) the combination of its
+ Contributions with other software (except as part of its Contributor
+ Version); or
+
+ c. under Patent Claims infringed by Covered Software in the absence of its
+ Contributions.
+
+ This License does not grant any rights in the trademarks, service marks, or
+ logos of any Contributor (except as may be necessary to comply with the
+ notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+ No Contributor makes additional grants as a result of Your choice to
+ distribute the Covered Software under a subsequent version of this License
+ (see Section 10.2) or under the terms of a Secondary License (if permitted
+ under the terms of Section 3.3).
+
+2.5. Representation
+
+ Each Contributor represents that the Contributor believes its Contributions
+ are its original creation(s) or it has sufficient rights to grant the
+ rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+ This License is not intended to limit any rights You have under applicable
+ copyright doctrines of fair use, fair dealing, or other equivalents.
+
+2.7. Conditions
+
+ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
+ Section 2.1.
+
+
+3. Responsibilities
+
+3.1. Distribution of Source Form
+
+ All distribution of Covered Software in Source Code Form, including any
+ Modifications that You create or to which You contribute, must be under the
+ terms of this License. You must inform recipients that the Source Code Form
+ of the Covered Software is governed by the terms of this License, and how
+ they can obtain a copy of this License. You may not attempt to alter or
+ restrict the recipients’ rights in the Source Code Form.
+
+3.2. Distribution of Executable Form
+
+ If You distribute Covered Software in Executable Form then:
+
+ a. such Covered Software must also be made available in Source Code Form,
+ as described in Section 3.1, and You must inform recipients of the
+ Executable Form how they can obtain a copy of such Source Code Form by
+ reasonable means in a timely manner, at a charge no more than the cost
+ of distribution to the recipient; and
+
+ b. You may distribute such Executable Form under the terms of this License,
+ or sublicense it under different terms, provided that the license for
+ the Executable Form does not attempt to limit or alter the recipients’
+ rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+ You may create and distribute a Larger Work under terms of Your choice,
+ provided that You also comply with the requirements of this License for the
+ Covered Software. If the Larger Work is a combination of Covered Software
+ with a work governed by one or more Secondary Licenses, and the Covered
+ Software is not Incompatible With Secondary Licenses, this License permits
+ You to additionally distribute such Covered Software under the terms of
+ such Secondary License(s), so that the recipient of the Larger Work may, at
+ their option, further distribute the Covered Software under the terms of
+ either this License or such Secondary License(s).
+
+3.4. Notices
+
+ You may not remove or alter the substance of any license notices (including
+ copyright notices, patent notices, disclaimers of warranty, or limitations
+ of liability) contained within the Source Code Form of the Covered
+ Software, except that You may alter any license notices to the extent
+ required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+ You may choose to offer, and to charge a fee for, warranty, support,
+ indemnity or liability obligations to one or more recipients of Covered
+ Software. However, You may do so only on Your own behalf, and not on behalf
+ of any Contributor. You must make it absolutely clear that any such
+ warranty, support, indemnity, or liability obligation is offered by You
+ alone, and You hereby agree to indemnify every Contributor for any
+ liability incurred by such Contributor as a result of warranty, support,
+ indemnity or liability terms You offer. You may include additional
+ disclaimers of warranty and limitations of liability specific to any
+ jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+
+ If it is impossible for You to comply with any of the terms of this License
+ with respect to some or all of the Covered Software due to statute, judicial
+ order, or regulation then You must: (a) comply with the terms of this License
+ to the maximum extent possible; and (b) describe the limitations and the code
+ they affect. Such description must be placed in a text file included with all
+ distributions of the Covered Software under this License. Except to the
+ extent prohibited by statute or regulation, such description must be
+ sufficiently detailed for a recipient of ordinary skill to be able to
+ understand it.
+
+5. Termination
+
+5.1. The rights granted under this License will terminate automatically if You
+ fail to comply with any of its terms. However, if You become compliant,
+ then the rights granted under this License from a particular Contributor
+ are reinstated (a) provisionally, unless and until such Contributor
+ explicitly and finally terminates Your grants, and (b) on an ongoing basis,
+ if such Contributor fails to notify You of the non-compliance by some
+ reasonable means prior to 60 days after You have come back into compliance.
+ Moreover, Your grants from a particular Contributor are reinstated on an
+ ongoing basis if such Contributor notifies You of the non-compliance by
+ some reasonable means, this is the first time You have received notice of
+ non-compliance with this License from such Contributor, and You become
+ compliant prior to 30 days after Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+ infringement claim (excluding declaratory judgment actions, counter-claims,
+ and cross-claims) alleging that a Contributor Version directly or
+ indirectly infringes any patent, then the rights granted to You by any and
+ all Contributors for the Covered Software under Section 2.1 of this License
+ shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
+ license agreements (excluding distributors and resellers) which have been
+ validly granted by You or Your distributors under this License prior to
+ termination shall survive termination.
+
+6. Disclaimer of Warranty
+
+ Covered Software is provided under this License on an “as is” basis, without
+ warranty of any kind, either expressed, implied, or statutory, including,
+ without limitation, warranties that the Covered Software is free of defects,
+ merchantable, fit for a particular purpose or non-infringing. The entire
+ risk as to the quality and performance of the Covered Software is with You.
+ Should any Covered Software prove defective in any respect, You (not any
+ Contributor) assume the cost of any necessary servicing, repair, or
+ correction. This disclaimer of warranty constitutes an essential part of this
+ License. No use of any Covered Software is authorized under this License
+ except under this disclaimer.
+
+7. Limitation of Liability
+
+ Under no circumstances and under no legal theory, whether tort (including
+ negligence), contract, or otherwise, shall any Contributor, or anyone who
+ distributes Covered Software as permitted above, be liable to You for any
+ direct, indirect, special, incidental, or consequential damages of any
+ character including, without limitation, damages for lost profits, loss of
+ goodwill, work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses, even if such party shall have been
+ informed of the possibility of such damages. This limitation of liability
+ shall not apply to liability for death or personal injury resulting from such
+ party’s negligence to the extent applicable law prohibits such limitation.
+ Some jurisdictions do not allow the exclusion or limitation of incidental or
+ consequential damages, so this exclusion and limitation may not apply to You.
+
+8. Litigation
+
+ Any litigation relating to this License may be brought only in the courts of
+ a jurisdiction where the defendant maintains its principal place of business
+ and such litigation shall be governed by laws of that jurisdiction, without
+ reference to its conflict-of-law provisions. Nothing in this Section shall
+ prevent a party’s ability to bring cross-claims or counter-claims.
+
+9. Miscellaneous
+
+ This License represents the complete agreement concerning the subject matter
+ hereof. If any provision of this License is held to be unenforceable, such
+ provision shall be reformed only to the extent necessary to make it
+ enforceable. Any law or regulation which provides that the language of a
+ contract shall be construed against the drafter shall not be used to construe
+ this License against a Contributor.
+
+
+10. Versions of the License
+
+10.1. New Versions
+
+ Mozilla Foundation is the license steward. Except as provided in Section
+ 10.3, no one other than the license steward has the right to modify or
+ publish new versions of this License. Each version will be given a
+ distinguishing version number.
+
+10.2. Effect of New Versions
+
+ You may distribute the Covered Software under the terms of the version of
+ the License under which You originally received the Covered Software, or
+ under the terms of any subsequent version published by the license
+ steward.
+
+10.3. Modified Versions
+
+ If you create software not governed by this License, and you want to
+ create a new license for such software, you may create and use a modified
+ version of this License if you rename the license and remove any
+ references to the name of the license steward (except to note that such
+ modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
+ If You choose to distribute Source Code Form that is Incompatible With
+ Secondary Licenses under the terms of this version of the License, the
+ notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+
+ This Source Code Form is subject to the
+ terms of the Mozilla Public License, v.
+ 2.0. If a copy of the MPL was not
+ distributed with this file, You can
+ obtain one at
+ http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular file, then
+You may include the notice in a location (such as a LICENSE file in a relevant
+directory) where a recipient would be likely to look for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - “Incompatible With Secondary Licenses” Notice
+
+ This Source Code Form is “Incompatible
+ With Secondary Licenses”, as defined by
+ the Mozilla Public License, v. 2.0.
+
diff --git a/Godeps/_workspace/src/github.com/hashicorp/serf/coordinate/README.md b/Godeps/_workspace/src/github.com/hashicorp/serf/coordinate/README.md
new file mode 100644
index 0000000000..0a96fd3eba
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/hashicorp/serf/coordinate/README.md
@@ -0,0 +1 @@
+# TODO - I'll beef this up as I implement each of the enhancements.
\ No newline at end of file
diff --git a/Godeps/_workspace/src/github.com/hashicorp/serf/coordinate/client.go b/Godeps/_workspace/src/github.com/hashicorp/serf/coordinate/client.go
new file mode 100644
index 0000000000..613bfff89e
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/hashicorp/serf/coordinate/client.go
@@ -0,0 +1,180 @@
+package coordinate
+
+import (
+ "fmt"
+ "math"
+ "sort"
+ "sync"
+ "time"
+)
+
+// Client manages the estimated network coordinate for a given node, and adjusts
+// it as the node observes round trip times and estimated coordinates from other
+// nodes. The core algorithm is based on Vivaldi, see the documentation for Config
+// for more details.
+type Client struct {
+ // coord is the current estimate of the client's network coordinate.
+ coord *Coordinate
+
+ // origin is a coordinate sitting at the origin.
+ origin *Coordinate
+
+ // config contains the tuning parameters that govern the performance of
+ // the algorithm.
+ config *Config
+
+ // adjustmentIndex is the current index into the adjustmentSamples slice.
+ adjustmentIndex uint
+
+ // adjustment is used to store samples for the adjustment calculation.
+ adjustmentSamples []float64
+
+ // latencyFilterSamples is used to store the last several RTT samples,
+ // keyed by node name. We will use the config's LatencyFilterSamples
+ // value to determine how many samples we keep, per node.
+ latencyFilterSamples map[string][]float64
+
+ // mutex enables safe concurrent access to the client.
+ mutex sync.RWMutex
+}
+
+// NewClient creates a new Client and verifies the configuration is valid.
+func NewClient(config *Config) (*Client, error) {
+ if !(config.Dimensionality > 0) {
+ return nil, fmt.Errorf("dimensionality must be >0")
+ }
+
+ return &Client{
+ coord: NewCoordinate(config),
+ origin: NewCoordinate(config),
+ config: config,
+ adjustmentIndex: 0,
+ adjustmentSamples: make([]float64, config.AdjustmentWindowSize),
+ latencyFilterSamples: make(map[string][]float64),
+ }, nil
+}
+
+// GetCoordinate returns a copy of the coordinate for this client.
+func (c *Client) GetCoordinate() *Coordinate {
+ c.mutex.RLock()
+ defer c.mutex.RUnlock()
+
+ return c.coord.Clone()
+}
+
+// SetCoordinate forces the client's coordinate to a known state.
+func (c *Client) SetCoordinate(coord *Coordinate) {
+ c.mutex.Lock()
+ defer c.mutex.Unlock()
+
+ c.coord = coord.Clone()
+}
+
+// ForgetNode removes any client state for the given node.
+func (c *Client) ForgetNode(node string) {
+ c.mutex.Lock()
+ defer c.mutex.Unlock()
+
+ delete(c.latencyFilterSamples, node)
+}
+
+// latencyFilter applies a simple moving median filter with a new sample for
+// a node. This assumes that the mutex has been locked already.
+func (c *Client) latencyFilter(node string, rttSeconds float64) float64 {
+ samples, ok := c.latencyFilterSamples[node]
+ if !ok {
+ samples = make([]float64, 0, c.config.LatencyFilterSize)
+ }
+
+ // Add the new sample and trim the list, if needed.
+ samples = append(samples, rttSeconds)
+ if len(samples) > int(c.config.LatencyFilterSize) {
+ samples = samples[1:]
+ }
+ c.latencyFilterSamples[node] = samples
+
+ // Sort a copy of the samples and return the median.
+ sorted := make([]float64, len(samples))
+ copy(sorted, samples)
+ sort.Float64s(sorted)
+ return sorted[len(sorted)/2]
+}
+
+// updateVivialdi updates the Vivaldi portion of the client's coordinate. This
+// assumes that the mutex has been locked already.
+func (c *Client) updateVivaldi(other *Coordinate, rttSeconds float64) {
+ const zeroThreshold = 1.0e-6
+
+ dist := c.coord.DistanceTo(other).Seconds()
+ if rttSeconds < zeroThreshold {
+ rttSeconds = zeroThreshold
+ }
+ wrongness := math.Abs(dist-rttSeconds) / rttSeconds
+
+ totalError := c.coord.Error + other.Error
+ if totalError < zeroThreshold {
+ totalError = zeroThreshold
+ }
+ weight := c.coord.Error / totalError
+
+ c.coord.Error = c.config.VivaldiCE*weight*wrongness + c.coord.Error*(1.0-c.config.VivaldiCE*weight)
+ if c.coord.Error > c.config.VivaldiErrorMax {
+ c.coord.Error = c.config.VivaldiErrorMax
+ }
+
+ delta := c.config.VivaldiCC * weight
+ force := delta * (rttSeconds - dist)
+ c.coord = c.coord.ApplyForce(c.config, force, other)
+}
+
+// updateAdjustment updates the adjustment portion of the client's coordinate, if
+// the feature is enabled. This assumes that the mutex has been locked already.
+func (c *Client) updateAdjustment(other *Coordinate, rttSeconds float64) {
+ if c.config.AdjustmentWindowSize == 0 {
+ return
+ }
+
+ // Note that the existing adjustment factors don't figure in to this
+ // calculation so we use the raw distance here.
+ dist := c.coord.rawDistanceTo(other)
+ c.adjustmentSamples[c.adjustmentIndex] = rttSeconds - dist
+ c.adjustmentIndex = (c.adjustmentIndex + 1) % c.config.AdjustmentWindowSize
+
+ sum := 0.0
+ for _, sample := range c.adjustmentSamples {
+ sum += sample
+ }
+ c.coord.Adjustment = sum / (2.0 * float64(c.config.AdjustmentWindowSize))
+}
+
+// updateGravity applies a small amount of gravity to pull coordinates towards
+// the center of the coordinate system to combat drift. This assumes that the
+// mutex is locked already.
+func (c *Client) updateGravity() {
+ dist := c.origin.DistanceTo(c.coord).Seconds()
+ force := -1.0 * math.Pow(dist/c.config.GravityRho, 2.0)
+ c.coord = c.coord.ApplyForce(c.config, force, c.origin)
+}
+
+// Update takes other, a coordinate for another node, and rtt, a round trip
+// time observation for a ping to that node, and updates the estimated position of
+// the client's coordinate. Returns the updated coordinate.
+func (c *Client) Update(node string, other *Coordinate, rtt time.Duration) *Coordinate {
+ c.mutex.Lock()
+ defer c.mutex.Unlock()
+
+ rttSeconds := c.latencyFilter(node, rtt.Seconds())
+ c.updateVivaldi(other, rttSeconds)
+ c.updateAdjustment(other, rttSeconds)
+ c.updateGravity()
+ return c.coord.Clone()
+}
+
+// DistanceTo returns the estimated RTT from the client's coordinate to other, the
+// coordinate for another node.
+func (c *Client) DistanceTo(other *Coordinate) time.Duration {
+ c.mutex.RLock()
+ defer c.mutex.RUnlock()
+
+ return c.coord.DistanceTo(other)
+}
diff --git a/Godeps/_workspace/src/github.com/hashicorp/serf/coordinate/config.go b/Godeps/_workspace/src/github.com/hashicorp/serf/coordinate/config.go
new file mode 100644
index 0000000000..a5b3aadfe4
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/hashicorp/serf/coordinate/config.go
@@ -0,0 +1,70 @@
+package coordinate
+
+// Config is used to set the parameters of the Vivaldi-based coordinate mapping
+// algorithm.
+//
+// The following references are called out at various points in the documentation
+// here:
+//
+// [1] Dabek, Frank, et al. "Vivaldi: A decentralized network coordinate system."
+// ACM SIGCOMM Computer Communication Review. Vol. 34. No. 4. ACM, 2004.
+// [2] Ledlie, Jonathan, Paul Gardner, and Margo I. Seltzer. "Network Coordinates
+// in the Wild." NSDI. Vol. 7. 2007.
+// [3] Lee, Sanghwan, et al. "On suitability of Euclidean embedding for
+// host-based network coordinate systems." Networking, IEEE/ACM Transactions
+// on 18.1 (2010): 27-40.
+type Config struct {
+ // The dimensionality of the coordinate system. As discussed in [2], more
+ // dimensions improves the accuracy of the estimates up to a point. Per [2]
+ // we chose 4 dimensions plus a non-Euclidean height.
+ Dimensionality uint
+
+ // VivaldiErrorMax is the default error value when a node hasn't yet made
+ // any observations. It also serves as an upper limit on the error value in
+ // case observations cause the error value to increase without bound.
+ VivaldiErrorMax float64
+
+ // VivaldiCE is a tuning factor that controls the maximum impact an
+ // observation can have on a node's confidence. See [1] for more details.
+ VivaldiCE float64
+
+ // VivaldiCC is a tuning factor that controls the maximum impact an
+ // observation can have on a node's coordinate. See [1] for more details.
+ VivaldiCC float64
+
+ // AdjustmentWindowSize is a tuning factor that determines how many samples
+ // we retain to calculate the adjustment factor as discussed in [3]. Setting
+ // this to zero disables this feature.
+ AdjustmentWindowSize uint
+
+ // HeightMin is the minimum value of the height parameter. Since this
+ // always must be positive, it will introduce a small amount error, so
+ // the chosen value should be relatively small compared to "normal"
+ // coordinates.
+ HeightMin float64
+
+ // LatencyFilterSamples is the maximum number of samples that are retained
+ // per node, in order to compute a median. The intent is to ride out blips
+ // but still keep the delay low, since our time to probe any given node is
+ // pretty infrequent. See [2] for more details.
+ LatencyFilterSize uint
+
+ // GravityRho is a tuning factor that sets how much gravity has an effect
+ // to try to re-center coordinates. See [2] for more details.
+ GravityRho float64
+}
+
+// DefaultConfig returns a Config that has some default values suitable for
+// basic testing of the algorithm, but not tuned to any particular type of cluster.
+func DefaultConfig() *Config {
+ return &Config{
+ Dimensionality: 8,
+ VivaldiErrorMax: 1.5,
+ VivaldiCE: 0.25,
+ VivaldiCC: 0.25,
+ AdjustmentWindowSize: 20,
+ HeightMin: 10.0e-6,
+ LatencyFilterSize: 3,
+ GravityRho: 150.0,
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/hashicorp/serf/coordinate/coordinate.go b/Godeps/_workspace/src/github.com/hashicorp/serf/coordinate/coordinate.go
new file mode 100644
index 0000000000..c9194e048b
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/hashicorp/serf/coordinate/coordinate.go
@@ -0,0 +1,183 @@
+package coordinate
+
+import (
+ "math"
+ "math/rand"
+ "time"
+)
+
+// Coordinate is a specialized structure for holding network coordinates for the
+// Vivaldi-based coordinate mapping algorithm. All of the fields should be public
+// to enable this to be serialized. All values in here are in units of seconds.
+type Coordinate struct {
+ // Vec is the Euclidean portion of the coordinate. This is used along
+ // with the other fields to provide an overall distance estimate. The
+ // units here are seconds.
+ Vec []float64
+
+ // Err reflects the confidence in the given coordinate and is updated
+ // dynamically by the Vivaldi Client. This is dimensionless.
+ Error float64
+
+ // Adjustment is a distance offset computed based on a calculation over
+ // observations from all other nodes over a fixed window and is updated
+ // dynamically by the Vivaldi Client. The units here are seconds.
+ Adjustment float64
+
+ // Height is a distance offset that accounts for non-Euclidean effects
+ // which model the access links from nodes to the core Internet. The access
+ // links are usually set by bandwidth and congestion, and the core links
+ // usually follow distance based on geography.
+ Height float64
+}
+
+const (
+ // secondsToNanoseconds is used to convert float seconds to nanoseconds.
+ secondsToNanoseconds = 1.0e9
+
+ // zeroThreshold is used to decide if two coordinates are on top of each
+ // other.
+ zeroThreshold = 1.0e-6
+)
+
+// ErrDimensionalityConflict will be panic-d if you try to perform operations
+// with incompatible dimensions.
+type DimensionalityConflictError struct{}
+
+// Adds the error interface.
+func (e DimensionalityConflictError) Error() string {
+ return "coordinate dimensionality does not match"
+}
+
+// NewCoordinate creates a new coordinate at the origin, using the given config
+// to supply key initial values.
+func NewCoordinate(config *Config) *Coordinate {
+ return &Coordinate{
+ Vec: make([]float64, config.Dimensionality),
+ Error: config.VivaldiErrorMax,
+ Adjustment: 0.0,
+ Height: config.HeightMin,
+ }
+}
+
+// Clone creates an independent copy of this coordinate.
+func (c *Coordinate) Clone() *Coordinate {
+ vec := make([]float64, len(c.Vec))
+ copy(vec, c.Vec)
+ return &Coordinate{
+ Vec: vec,
+ Error: c.Error,
+ Adjustment: c.Adjustment,
+ Height: c.Height,
+ }
+}
+
+// IsCompatibleWith checks to see if the two coordinates are compatible
+// dimensionally. If this returns true then you are guaranteed to not get
+// any runtime errors operating on them.
+func (c *Coordinate) IsCompatibleWith(other *Coordinate) bool {
+ return len(c.Vec) == len(other.Vec)
+}
+
+// ApplyForce returns the result of applying the force from the direction of the
+// other coordinate.
+func (c *Coordinate) ApplyForce(config *Config, force float64, other *Coordinate) *Coordinate {
+ if !c.IsCompatibleWith(other) {
+ panic(DimensionalityConflictError{})
+ }
+
+ ret := c.Clone()
+ unit, mag := unitVectorAt(c.Vec, other.Vec)
+ ret.Vec = add(ret.Vec, mul(unit, force))
+ if mag > zeroThreshold {
+ ret.Height = (ret.Height+other.Height)*force/mag + ret.Height
+ ret.Height = math.Max(ret.Height, config.HeightMin)
+ }
+ return ret
+}
+
+// DistanceTo returns the distance between this coordinate and the other
+// coordinate, including adjustments.
+func (c *Coordinate) DistanceTo(other *Coordinate) time.Duration {
+ if !c.IsCompatibleWith(other) {
+ panic(DimensionalityConflictError{})
+ }
+
+ dist := c.rawDistanceTo(other)
+ adjustedDist := dist + c.Adjustment + other.Adjustment
+ if adjustedDist > 0.0 {
+ dist = adjustedDist
+ }
+ return time.Duration(dist * secondsToNanoseconds)
+}
+
+// rawDistanceTo returns the Vivaldi distance between this coordinate and the
+// other coordinate in seconds, not including adjustments. This assumes the
+// dimensions have already been checked to be compatible.
+func (c *Coordinate) rawDistanceTo(other *Coordinate) float64 {
+ return magnitude(diff(c.Vec, other.Vec)) + c.Height + other.Height
+}
+
+// add returns the sum of vec1 and vec2. This assumes the dimensions have
+// already been checked to be compatible.
+func add(vec1 []float64, vec2 []float64) []float64 {
+ ret := make([]float64, len(vec1))
+ for i, _ := range ret {
+ ret[i] = vec1[i] + vec2[i]
+ }
+ return ret
+}
+
+// diff returns the difference between the vec1 and vec2. This assumes the
+// dimensions have already been checked to be compatible.
+func diff(vec1 []float64, vec2 []float64) []float64 {
+ ret := make([]float64, len(vec1))
+ for i, _ := range ret {
+ ret[i] = vec1[i] - vec2[i]
+ }
+ return ret
+}
+
+// mul returns vec multiplied by a scalar factor.
+func mul(vec []float64, factor float64) []float64 {
+ ret := make([]float64, len(vec))
+ for i, _ := range vec {
+ ret[i] = vec[i] * factor
+ }
+ return ret
+}
+
+// magnitude computes the magnitude of the vec.
+func magnitude(vec []float64) float64 {
+ sum := 0.0
+ for i, _ := range vec {
+ sum += vec[i] * vec[i]
+ }
+ return math.Sqrt(sum)
+}
+
+// unitVectorAt returns a unit vector pointing at vec1 from vec2. If the two
+// positions are the same then a random unit vector is returned. We also return
+// the distance between the points for use in the later height calculation.
+func unitVectorAt(vec1 []float64, vec2 []float64) ([]float64, float64) {
+ ret := diff(vec1, vec2)
+
+ // If the coordinates aren't on top of each other we can normalize.
+ if mag := magnitude(ret); mag > zeroThreshold {
+ return mul(ret, 1.0/mag), mag
+ }
+
+ // Otherwise, just return a random unit vector.
+ for i, _ := range ret {
+ ret[i] = rand.Float64() - 0.5
+ }
+ if mag := magnitude(ret); mag > zeroThreshold {
+ return mul(ret, 1.0/mag), 0.0
+ }
+
+ // And finally just give up and make a unit vector along the first
+ // dimension. This should be exceedingly rare.
+ ret = make([]float64, len(ret))
+ ret[0] = 1.0
+ return ret, 0.0
+}
diff --git a/Godeps/_workspace/src/github.com/hashicorp/serf/coordinate/phantom.go b/Godeps/_workspace/src/github.com/hashicorp/serf/coordinate/phantom.go
new file mode 100644
index 0000000000..6fb033c0cd
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/hashicorp/serf/coordinate/phantom.go
@@ -0,0 +1,187 @@
+package coordinate
+
+import (
+ "fmt"
+ "math"
+ "math/rand"
+ "time"
+)
+
+// GenerateClients returns a slice with nodes number of clients, all with the
+// given config.
+func GenerateClients(nodes int, config *Config) ([]*Client, error) {
+ clients := make([]*Client, nodes)
+ for i, _ := range clients {
+ client, err := NewClient(config)
+ if err != nil {
+ return nil, err
+ }
+
+ clients[i] = client
+ }
+ return clients, nil
+}
+
+// GenerateLine returns a truth matrix as if all the nodes are in a straight linke
+// with the given spacing between them.
+func GenerateLine(nodes int, spacing time.Duration) [][]time.Duration {
+ truth := make([][]time.Duration, nodes)
+ for i := range truth {
+ truth[i] = make([]time.Duration, nodes)
+ }
+
+ for i := 0; i < nodes; i++ {
+ for j := i + 1; j < nodes; j++ {
+ rtt := time.Duration(j-i) * spacing
+ truth[i][j], truth[j][i] = rtt, rtt
+ }
+ }
+ return truth
+}
+
+// GenerateGrid returns a truth matrix as if all the nodes are in a two dimensional
+// grid with the given spacing between them.
+func GenerateGrid(nodes int, spacing time.Duration) [][]time.Duration {
+ truth := make([][]time.Duration, nodes)
+ for i := range truth {
+ truth[i] = make([]time.Duration, nodes)
+ }
+
+ n := int(math.Sqrt(float64(nodes)))
+ for i := 0; i < nodes; i++ {
+ for j := i + 1; j < nodes; j++ {
+ x1, y1 := float64(i%n), float64(i/n)
+ x2, y2 := float64(j%n), float64(j/n)
+ dx, dy := x2-x1, y2-y1
+ dist := math.Sqrt(dx*dx + dy*dy)
+ rtt := time.Duration(dist * float64(spacing))
+ truth[i][j], truth[j][i] = rtt, rtt
+ }
+ }
+ return truth
+}
+
+// GenerateSplit returns a truth matrix as if half the nodes are close together in
+// one location and half the nodes are close together in another. The lan factor
+// is used to separate the nodes locally and the wan factor represents the split
+// between the two sides.
+func GenerateSplit(nodes int, lan time.Duration, wan time.Duration) [][]time.Duration {
+ truth := make([][]time.Duration, nodes)
+ for i := range truth {
+ truth[i] = make([]time.Duration, nodes)
+ }
+
+ split := nodes / 2
+ for i := 0; i < nodes; i++ {
+ for j := i + 1; j < nodes; j++ {
+ rtt := lan
+ if (i <= split && j > split) || (i > split && j <= split) {
+ rtt += wan
+ }
+ truth[i][j], truth[j][i] = rtt, rtt
+ }
+ }
+ return truth
+}
+
+// GenerateCircle returns a truth matrix for a set of nodes, evenly distributed
+// around a circle with the given radius. The first node is at the "center" of the
+// circle because it's equidistant from all the other nodes, but we place it at
+// double the radius, so it should show up above all the other nodes in height.
+func GenerateCircle(nodes int, radius time.Duration) [][]time.Duration {
+ truth := make([][]time.Duration, nodes)
+ for i := range truth {
+ truth[i] = make([]time.Duration, nodes)
+ }
+
+ for i := 0; i < nodes; i++ {
+ for j := i + 1; j < nodes; j++ {
+ var rtt time.Duration
+ if i == 0 {
+ rtt = 2 * radius
+ } else {
+ t1 := 2.0 * math.Pi * float64(i) / float64(nodes)
+ x1, y1 := math.Cos(t1), math.Sin(t1)
+ t2 := 2.0 * math.Pi * float64(j) / float64(nodes)
+ x2, y2 := math.Cos(t2), math.Sin(t2)
+ dx, dy := x2-x1, y2-y1
+ dist := math.Sqrt(dx*dx + dy*dy)
+ rtt = time.Duration(dist * float64(radius))
+ }
+ truth[i][j], truth[j][i] = rtt, rtt
+ }
+ }
+ return truth
+}
+
+// GenerateRandom returns a truth matrix for a set of nodes with normally
+// distributed delays, with the given mean and deviation. The RNG is re-seeded
+// so you always get the same matrix for a given size.
+func GenerateRandom(nodes int, mean time.Duration, deviation time.Duration) [][]time.Duration {
+ rand.Seed(1)
+
+ truth := make([][]time.Duration, nodes)
+ for i := range truth {
+ truth[i] = make([]time.Duration, nodes)
+ }
+
+ for i := 0; i < nodes; i++ {
+ for j := i + 1; j < nodes; j++ {
+ rttSeconds := rand.NormFloat64()*deviation.Seconds() + mean.Seconds()
+ rtt := time.Duration(rttSeconds * secondsToNanoseconds)
+ truth[i][j], truth[j][i] = rtt, rtt
+ }
+ }
+ return truth
+}
+
+// Simulate runs the given number of cycles using the given list of clients and
+// truth matrix. On each cycle, each client will pick a random node and observe
+// the truth RTT, updating its coordinate estimate. The RNG is re-seeded for
+// each simulation run to get deterministic results (for this algorithm and the
+// underlying algorithm which will use random numbers for position vectors when
+// starting out with everything at the origin).
+func Simulate(clients []*Client, truth [][]time.Duration, cycles int) {
+ rand.Seed(1)
+
+ nodes := len(clients)
+ for cycle := 0; cycle < cycles; cycle++ {
+ for i, _ := range clients {
+ if j := rand.Intn(nodes); j != i {
+ c := clients[j].GetCoordinate()
+ rtt := truth[i][j]
+ node := fmt.Sprintf("node_%d", j)
+ clients[i].Update(node, c, rtt)
+ }
+ }
+ }
+}
+
+// Stats is returned from the Evaluate function with a summary of the algorithm
+// performance.
+type Stats struct {
+ ErrorMax float64
+ ErrorAvg float64
+}
+
+// Evaluate uses the coordinates of the given clients to calculate estimated
+// distances and compares them with the given truth matrix, returning summary
+// stats.
+func Evaluate(clients []*Client, truth [][]time.Duration) (stats Stats) {
+ nodes := len(clients)
+ count := 0
+ for i := 0; i < nodes; i++ {
+ for j := i + 1; j < nodes; j++ {
+ est := clients[i].DistanceTo(clients[j].GetCoordinate()).Seconds()
+ actual := truth[i][j].Seconds()
+ error := math.Abs(est-actual) / actual
+ stats.ErrorMax = math.Max(stats.ErrorMax, error)
+ stats.ErrorAvg += error
+ count += 1
+ }
+ }
+
+ stats.ErrorAvg /= float64(count)
+ fmt.Printf("Error avg=%9.6f max=%9.6f\n", stats.ErrorAvg, stats.ErrorMax)
+ return
+}
diff --git a/Godeps/_workspace/src/github.com/hashicorp/serf/coordinate/test_util.go b/Godeps/_workspace/src/github.com/hashicorp/serf/coordinate/test_util.go
new file mode 100644
index 0000000000..116e949337
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/hashicorp/serf/coordinate/test_util.go
@@ -0,0 +1,27 @@
+package coordinate
+
+import (
+ "math"
+ "testing"
+)
+
+// verifyEqualFloats will compare f1 and f2 and fail if they are not
+// "equal" within a threshold.
+func verifyEqualFloats(t *testing.T, f1 float64, f2 float64) {
+ const zeroThreshold = 1.0e-6
+ if math.Abs(f1-f2) > zeroThreshold {
+ t.Fatalf("equal assertion fail, %9.6f != %9.6f", f1, f2)
+ }
+}
+
+// verifyEqualVectors will compare vec1 and vec2 and fail if they are not
+// "equal" within a threshold.
+func verifyEqualVectors(t *testing.T, vec1 []float64, vec2 []float64) {
+ if len(vec1) != len(vec2) {
+ t.Fatalf("vector length mismatch, %d != %d", len(vec1), len(vec2))
+ }
+
+ for i, _ := range vec1 {
+ verifyEqualFloats(t, vec1[i], vec2[i])
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/hashicorp/serf/ops-misc/debian/copyright b/Godeps/_workspace/src/github.com/hashicorp/serf/ops-misc/debian/copyright
new file mode 100644
index 0000000000..21a1a1b532
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/hashicorp/serf/ops-misc/debian/copyright
@@ -0,0 +1,2 @@
+Name: serf
+Copyright: Hashicorp 2013
diff --git a/Godeps/_workspace/src/github.com/hashicorp/serf/website/LICENSE.md b/Godeps/_workspace/src/github.com/hashicorp/serf/website/LICENSE.md
new file mode 100644
index 0000000000..36c29d7f7b
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/hashicorp/serf/website/LICENSE.md
@@ -0,0 +1,10 @@
+# Proprietary License
+
+This license is temporary while a more official one is drafted. However,
+this should make it clear:
+
+* The text contents of this website are MPL 2.0 licensed.
+
+* The design contents of this website are proprietary and may not be reproduced
+ or reused in any way other than to run the Serf website locally. The license
+ for the design is owned solely by HashiCorp, Inc.
diff --git a/Godeps/_workspace/src/github.com/pborman/uuid/sql.go b/Godeps/_workspace/src/github.com/pborman/uuid/sql.go
new file mode 100644
index 0000000000..98b23aa15b
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/pborman/uuid/sql.go
@@ -0,0 +1,48 @@
+// Copyright 2015 Google Inc. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package uuid
+
+import (
+ "errors"
+ "fmt"
+)
+
+// Scan implements sql.Scanner so UUIDs can be read from databases transparently
+// Currently, database types that map to string and []byte are supported. Please
+// consult database-specific driver documentation for matching types.
+func (uuid *UUID) Scan(src interface{}) error {
+ switch src.(type) {
+ case string:
+ // see uuid.Parse for required string format
+ parsed := Parse(src.(string))
+
+ if parsed == nil {
+ return errors.New("Scan: invalid UUID format")
+ }
+
+ *uuid = parsed
+ case []byte:
+ b := src.([]byte)
+
+ // assumes a simple slice of bytes if 16 bytes
+ // otherwise attempts to parse
+ if len(b) == 16 {
+ *uuid = UUID(b)
+ } else {
+ u := Parse(string(b))
+
+ if u == nil {
+ return errors.New("Scan: invalid UUID format")
+ }
+
+ *uuid = u
+ }
+
+ default:
+ return fmt.Errorf("Scan: unable to scan type %T into UUID", src)
+ }
+
+ return nil
+}
diff --git a/Godeps/_workspace/src/github.com/pmezard/go-difflib/LICENSE b/Godeps/_workspace/src/github.com/pmezard/go-difflib/LICENSE
new file mode 100644
index 0000000000..c67dad612a
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/pmezard/go-difflib/LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 2013, Patrick Mezard
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+ The names of its contributors may not be used to endorse or promote
+products derived from this software without specific prior written
+permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Godeps/_workspace/src/github.com/pmezard/go-difflib/difflib/difflib.go b/Godeps/_workspace/src/github.com/pmezard/go-difflib/difflib/difflib.go
new file mode 100644
index 0000000000..e5005daaa3
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/pmezard/go-difflib/difflib/difflib.go
@@ -0,0 +1,768 @@
+// Package difflib is a partial port of Python difflib module.
+//
+// It provides tools to compare sequences of strings and generate textual diffs.
+//
+// The following class and functions have been ported:
+//
+// - SequenceMatcher
+//
+// - unified_diff
+//
+// - context_diff
+//
+// Getting unified diffs was the main goal of the port. Keep in mind this code
+// is mostly suitable to output text differences in a human friendly way, there
+// are no guarantees generated diffs are consumable by patch(1).
+package difflib
+
+import (
+ "bufio"
+ "bytes"
+ "fmt"
+ "io"
+ "strings"
+)
+
+func min(a, b int) int {
+ if a < b {
+ return a
+ }
+ return b
+}
+
+func max(a, b int) int {
+ if a > b {
+ return a
+ }
+ return b
+}
+
+func calculateRatio(matches, length int) float64 {
+ if length > 0 {
+ return 2.0 * float64(matches) / float64(length)
+ }
+ return 1.0
+}
+
+type Match struct {
+ A int
+ B int
+ Size int
+}
+
+type OpCode struct {
+ Tag byte
+ I1 int
+ I2 int
+ J1 int
+ J2 int
+}
+
+// SequenceMatcher compares sequence of strings. The basic
+// algorithm predates, and is a little fancier than, an algorithm
+// published in the late 1980's by Ratcliff and Obershelp under the
+// hyperbolic name "gestalt pattern matching". The basic idea is to find
+// the longest contiguous matching subsequence that contains no "junk"
+// elements (R-O doesn't address junk). The same idea is then applied
+// recursively to the pieces of the sequences to the left and to the right
+// of the matching subsequence. This does not yield minimal edit
+// sequences, but does tend to yield matches that "look right" to people.
+//
+// SequenceMatcher tries to compute a "human-friendly diff" between two
+// sequences. Unlike e.g. UNIX(tm) diff, the fundamental notion is the
+// longest *contiguous* & junk-free matching subsequence. That's what
+// catches peoples' eyes. The Windows(tm) windiff has another interesting
+// notion, pairing up elements that appear uniquely in each sequence.
+// That, and the method here, appear to yield more intuitive difference
+// reports than does diff. This method appears to be the least vulnerable
+// to synching up on blocks of "junk lines", though (like blank lines in
+// ordinary text files, or maybe "" lines in HTML files). That may be
+// because this is the only method of the 3 that has a *concept* of
+// "junk" .
+//
+// Timing: Basic R-O is cubic time worst case and quadratic time expected
+// case. SequenceMatcher is quadratic time for the worst case and has
+// expected-case behavior dependent in a complicated way on how many
+// elements the sequences have in common; best case time is linear.
+type SequenceMatcher struct {
+ a []string
+ b []string
+ b2j map[string][]int
+ IsJunk func(string) bool
+ autoJunk bool
+ bJunk map[string]struct{}
+ matchingBlocks []Match
+ fullBCount map[string]int
+ bPopular map[string]struct{}
+ opCodes []OpCode
+}
+
+func NewMatcher(a, b []string) *SequenceMatcher {
+ m := SequenceMatcher{autoJunk: true}
+ m.SetSeqs(a, b)
+ return &m
+}
+
+func NewMatcherWithJunk(a, b []string, autoJunk bool,
+ isJunk func(string) bool) *SequenceMatcher {
+
+ m := SequenceMatcher{IsJunk: isJunk, autoJunk: autoJunk}
+ m.SetSeqs(a, b)
+ return &m
+}
+
+// Set two sequences to be compared.
+func (m *SequenceMatcher) SetSeqs(a, b []string) {
+ m.SetSeq1(a)
+ m.SetSeq2(b)
+}
+
+// Set the first sequence to be compared. The second sequence to be compared is
+// not changed.
+//
+// SequenceMatcher computes and caches detailed information about the second
+// sequence, so if you want to compare one sequence S against many sequences,
+// use .SetSeq2(s) once and call .SetSeq1(x) repeatedly for each of the other
+// sequences.
+//
+// See also SetSeqs() and SetSeq2().
+func (m *SequenceMatcher) SetSeq1(a []string) {
+ if &a == &m.a {
+ return
+ }
+ m.a = a
+ m.matchingBlocks = nil
+ m.opCodes = nil
+}
+
+// Set the second sequence to be compared. The first sequence to be compared is
+// not changed.
+func (m *SequenceMatcher) SetSeq2(b []string) {
+ if &b == &m.b {
+ return
+ }
+ m.b = b
+ m.matchingBlocks = nil
+ m.opCodes = nil
+ m.fullBCount = nil
+ m.chainB()
+}
+
+func (m *SequenceMatcher) chainB() {
+ // Populate line -> index mapping
+ b2j := map[string][]int{}
+ for i, s := range m.b {
+ indices := b2j[s]
+ indices = append(indices, i)
+ b2j[s] = indices
+ }
+
+ // Purge junk elements
+ m.bJunk = map[string]struct{}{}
+ if m.IsJunk != nil {
+ junk := m.bJunk
+ for s, _ := range b2j {
+ if m.IsJunk(s) {
+ junk[s] = struct{}{}
+ }
+ }
+ for s, _ := range junk {
+ delete(b2j, s)
+ }
+ }
+
+ // Purge remaining popular elements
+ popular := map[string]struct{}{}
+ n := len(m.b)
+ if m.autoJunk && n >= 200 {
+ ntest := n/100 + 1
+ for s, indices := range b2j {
+ if len(indices) > ntest {
+ popular[s] = struct{}{}
+ }
+ }
+ for s, _ := range popular {
+ delete(b2j, s)
+ }
+ }
+ m.bPopular = popular
+ m.b2j = b2j
+}
+
+func (m *SequenceMatcher) isBJunk(s string) bool {
+ _, ok := m.bJunk[s]
+ return ok
+}
+
+// Find longest matching block in a[alo:ahi] and b[blo:bhi].
+//
+// If IsJunk is not defined:
+//
+// Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where
+// alo <= i <= i+k <= ahi
+// blo <= j <= j+k <= bhi
+// and for all (i',j',k') meeting those conditions,
+// k >= k'
+// i <= i'
+// and if i == i', j <= j'
+//
+// In other words, of all maximal matching blocks, return one that
+// starts earliest in a, and of all those maximal matching blocks that
+// start earliest in a, return the one that starts earliest in b.
+//
+// If IsJunk is defined, first the longest matching block is
+// determined as above, but with the additional restriction that no
+// junk element appears in the block. Then that block is extended as
+// far as possible by matching (only) junk elements on both sides. So
+// the resulting block never matches on junk except as identical junk
+// happens to be adjacent to an "interesting" match.
+//
+// If no blocks match, return (alo, blo, 0).
+func (m *SequenceMatcher) findLongestMatch(alo, ahi, blo, bhi int) Match {
+ // CAUTION: stripping common prefix or suffix would be incorrect.
+ // E.g.,
+ // ab
+ // acab
+ // Longest matching block is "ab", but if common prefix is
+ // stripped, it's "a" (tied with "b"). UNIX(tm) diff does so
+ // strip, so ends up claiming that ab is changed to acab by
+ // inserting "ca" in the middle. That's minimal but unintuitive:
+ // "it's obvious" that someone inserted "ac" at the front.
+ // Windiff ends up at the same place as diff, but by pairing up
+ // the unique 'b's and then matching the first two 'a's.
+ besti, bestj, bestsize := alo, blo, 0
+
+ // find longest junk-free match
+ // during an iteration of the loop, j2len[j] = length of longest
+ // junk-free match ending with a[i-1] and b[j]
+ j2len := map[int]int{}
+ for i := alo; i != ahi; i++ {
+ // look at all instances of a[i] in b; note that because
+ // b2j has no junk keys, the loop is skipped if a[i] is junk
+ newj2len := map[int]int{}
+ for _, j := range m.b2j[m.a[i]] {
+ // a[i] matches b[j]
+ if j < blo {
+ continue
+ }
+ if j >= bhi {
+ break
+ }
+ k := j2len[j-1] + 1
+ newj2len[j] = k
+ if k > bestsize {
+ besti, bestj, bestsize = i-k+1, j-k+1, k
+ }
+ }
+ j2len = newj2len
+ }
+
+ // Extend the best by non-junk elements on each end. In particular,
+ // "popular" non-junk elements aren't in b2j, which greatly speeds
+ // the inner loop above, but also means "the best" match so far
+ // doesn't contain any junk *or* popular non-junk elements.
+ for besti > alo && bestj > blo && !m.isBJunk(m.b[bestj-1]) &&
+ m.a[besti-1] == m.b[bestj-1] {
+ besti, bestj, bestsize = besti-1, bestj-1, bestsize+1
+ }
+ for besti+bestsize < ahi && bestj+bestsize < bhi &&
+ !m.isBJunk(m.b[bestj+bestsize]) &&
+ m.a[besti+bestsize] == m.b[bestj+bestsize] {
+ bestsize += 1
+ }
+
+ // Now that we have a wholly interesting match (albeit possibly
+ // empty!), we may as well suck up the matching junk on each
+ // side of it too. Can't think of a good reason not to, and it
+ // saves post-processing the (possibly considerable) expense of
+ // figuring out what to do with it. In the case of an empty
+ // interesting match, this is clearly the right thing to do,
+ // because no other kind of match is possible in the regions.
+ for besti > alo && bestj > blo && m.isBJunk(m.b[bestj-1]) &&
+ m.a[besti-1] == m.b[bestj-1] {
+ besti, bestj, bestsize = besti-1, bestj-1, bestsize+1
+ }
+ for besti+bestsize < ahi && bestj+bestsize < bhi &&
+ m.isBJunk(m.b[bestj+bestsize]) &&
+ m.a[besti+bestsize] == m.b[bestj+bestsize] {
+ bestsize += 1
+ }
+
+ return Match{A: besti, B: bestj, Size: bestsize}
+}
+
+// Return list of triples describing matching subsequences.
+//
+// Each triple is of the form (i, j, n), and means that
+// a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in
+// i and in j. It's also guaranteed that if (i, j, n) and (i', j', n') are
+// adjacent triples in the list, and the second is not the last triple in the
+// list, then i+n != i' or j+n != j'. IOW, adjacent triples never describe
+// adjacent equal blocks.
+//
+// The last triple is a dummy, (len(a), len(b), 0), and is the only
+// triple with n==0.
+func (m *SequenceMatcher) GetMatchingBlocks() []Match {
+ if m.matchingBlocks != nil {
+ return m.matchingBlocks
+ }
+
+ var matchBlocks func(alo, ahi, blo, bhi int, matched []Match) []Match
+ matchBlocks = func(alo, ahi, blo, bhi int, matched []Match) []Match {
+ match := m.findLongestMatch(alo, ahi, blo, bhi)
+ i, j, k := match.A, match.B, match.Size
+ if match.Size > 0 {
+ if alo < i && blo < j {
+ matched = matchBlocks(alo, i, blo, j, matched)
+ }
+ matched = append(matched, match)
+ if i+k < ahi && j+k < bhi {
+ matched = matchBlocks(i+k, ahi, j+k, bhi, matched)
+ }
+ }
+ return matched
+ }
+ matched := matchBlocks(0, len(m.a), 0, len(m.b), nil)
+
+ // It's possible that we have adjacent equal blocks in the
+ // matching_blocks list now.
+ nonAdjacent := []Match{}
+ i1, j1, k1 := 0, 0, 0
+ for _, b := range matched {
+ // Is this block adjacent to i1, j1, k1?
+ i2, j2, k2 := b.A, b.B, b.Size
+ if i1+k1 == i2 && j1+k1 == j2 {
+ // Yes, so collapse them -- this just increases the length of
+ // the first block by the length of the second, and the first
+ // block so lengthened remains the block to compare against.
+ k1 += k2
+ } else {
+ // Not adjacent. Remember the first block (k1==0 means it's
+ // the dummy we started with), and make the second block the
+ // new block to compare against.
+ if k1 > 0 {
+ nonAdjacent = append(nonAdjacent, Match{i1, j1, k1})
+ }
+ i1, j1, k1 = i2, j2, k2
+ }
+ }
+ if k1 > 0 {
+ nonAdjacent = append(nonAdjacent, Match{i1, j1, k1})
+ }
+
+ nonAdjacent = append(nonAdjacent, Match{len(m.a), len(m.b), 0})
+ m.matchingBlocks = nonAdjacent
+ return m.matchingBlocks
+}
+
+// Return list of 5-tuples describing how to turn a into b.
+//
+// Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple
+// has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the
+// tuple preceding it, and likewise for j1 == the previous j2.
+//
+// The tags are characters, with these meanings:
+//
+// 'r' (replace): a[i1:i2] should be replaced by b[j1:j2]
+//
+// 'd' (delete): a[i1:i2] should be deleted, j1==j2 in this case.
+//
+// 'i' (insert): b[j1:j2] should be inserted at a[i1:i1], i1==i2 in this case.
+//
+// 'e' (equal): a[i1:i2] == b[j1:j2]
+func (m *SequenceMatcher) GetOpCodes() []OpCode {
+ if m.opCodes != nil {
+ return m.opCodes
+ }
+ i, j := 0, 0
+ matching := m.GetMatchingBlocks()
+ opCodes := make([]OpCode, 0, len(matching))
+ for _, m := range matching {
+ // invariant: we've pumped out correct diffs to change
+ // a[:i] into b[:j], and the next matching block is
+ // a[ai:ai+size] == b[bj:bj+size]. So we need to pump
+ // out a diff to change a[i:ai] into b[j:bj], pump out
+ // the matching block, and move (i,j) beyond the match
+ ai, bj, size := m.A, m.B, m.Size
+ tag := byte(0)
+ if i < ai && j < bj {
+ tag = 'r'
+ } else if i < ai {
+ tag = 'd'
+ } else if j < bj {
+ tag = 'i'
+ }
+ if tag > 0 {
+ opCodes = append(opCodes, OpCode{tag, i, ai, j, bj})
+ }
+ i, j = ai+size, bj+size
+ // the list of matching blocks is terminated by a
+ // sentinel with size 0
+ if size > 0 {
+ opCodes = append(opCodes, OpCode{'e', ai, i, bj, j})
+ }
+ }
+ m.opCodes = opCodes
+ return m.opCodes
+}
+
+// Isolate change clusters by eliminating ranges with no changes.
+//
+// Return a generator of groups with up to n lines of context.
+// Each group is in the same format as returned by GetOpCodes().
+func (m *SequenceMatcher) GetGroupedOpCodes(n int) [][]OpCode {
+ if n < 0 {
+ n = 3
+ }
+ codes := m.GetOpCodes()
+ if len(codes) == 0 {
+ codes = []OpCode{OpCode{'e', 0, 1, 0, 1}}
+ }
+ // Fixup leading and trailing groups if they show no changes.
+ if codes[0].Tag == 'e' {
+ c := codes[0]
+ i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2
+ codes[0] = OpCode{c.Tag, max(i1, i2-n), i2, max(j1, j2-n), j2}
+ }
+ if codes[len(codes)-1].Tag == 'e' {
+ c := codes[len(codes)-1]
+ i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2
+ codes[len(codes)-1] = OpCode{c.Tag, i1, min(i2, i1+n), j1, min(j2, j1+n)}
+ }
+ nn := n + n
+ groups := [][]OpCode{}
+ group := []OpCode{}
+ for _, c := range codes {
+ i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2
+ // End the current group and start a new one whenever
+ // there is a large range with no changes.
+ if c.Tag == 'e' && i2-i1 > nn {
+ group = append(group, OpCode{c.Tag, i1, min(i2, i1+n),
+ j1, min(j2, j1+n)})
+ groups = append(groups, group)
+ group = []OpCode{}
+ i1, j1 = max(i1, i2-n), max(j1, j2-n)
+ }
+ group = append(group, OpCode{c.Tag, i1, i2, j1, j2})
+ }
+ if len(group) > 0 && !(len(group) == 1 && group[0].Tag == 'e') {
+ groups = append(groups, group)
+ }
+ return groups
+}
+
+// Return a measure of the sequences' similarity (float in [0,1]).
+//
+// Where T is the total number of elements in both sequences, and
+// M is the number of matches, this is 2.0*M / T.
+// Note that this is 1 if the sequences are identical, and 0 if
+// they have nothing in common.
+//
+// .Ratio() is expensive to compute if you haven't already computed
+// .GetMatchingBlocks() or .GetOpCodes(), in which case you may
+// want to try .QuickRatio() or .RealQuickRation() first to get an
+// upper bound.
+func (m *SequenceMatcher) Ratio() float64 {
+ matches := 0
+ for _, m := range m.GetMatchingBlocks() {
+ matches += m.Size
+ }
+ return calculateRatio(matches, len(m.a)+len(m.b))
+}
+
+// Return an upper bound on ratio() relatively quickly.
+//
+// This isn't defined beyond that it is an upper bound on .Ratio(), and
+// is faster to compute.
+func (m *SequenceMatcher) QuickRatio() float64 {
+ // viewing a and b as multisets, set matches to the cardinality
+ // of their intersection; this counts the number of matches
+ // without regard to order, so is clearly an upper bound
+ if m.fullBCount == nil {
+ m.fullBCount = map[string]int{}
+ for _, s := range m.b {
+ m.fullBCount[s] = m.fullBCount[s] + 1
+ }
+ }
+
+ // avail[x] is the number of times x appears in 'b' less the
+ // number of times we've seen it in 'a' so far ... kinda
+ avail := map[string]int{}
+ matches := 0
+ for _, s := range m.a {
+ n, ok := avail[s]
+ if !ok {
+ n = m.fullBCount[s]
+ }
+ avail[s] = n - 1
+ if n > 0 {
+ matches += 1
+ }
+ }
+ return calculateRatio(matches, len(m.a)+len(m.b))
+}
+
+// Return an upper bound on ratio() very quickly.
+//
+// This isn't defined beyond that it is an upper bound on .Ratio(), and
+// is faster to compute than either .Ratio() or .QuickRatio().
+func (m *SequenceMatcher) RealQuickRatio() float64 {
+ la, lb := len(m.a), len(m.b)
+ return calculateRatio(min(la, lb), la+lb)
+}
+
+// Convert range to the "ed" format
+func formatRangeUnified(start, stop int) string {
+ // Per the diff spec at http://www.unix.org/single_unix_specification/
+ beginning := start + 1 // lines start numbering with one
+ length := stop - start
+ if length == 1 {
+ return fmt.Sprintf("%d", beginning)
+ }
+ if length == 0 {
+ beginning -= 1 // empty ranges begin at line just before the range
+ }
+ return fmt.Sprintf("%d,%d", beginning, length)
+}
+
+// Unified diff parameters
+type UnifiedDiff struct {
+ A []string // First sequence lines
+ FromFile string // First file name
+ FromDate string // First file time
+ B []string // Second sequence lines
+ ToFile string // Second file name
+ ToDate string // Second file time
+ Eol string // Headers end of line, defaults to LF
+ Context int // Number of context lines
+}
+
+// Compare two sequences of lines; generate the delta as a unified diff.
+//
+// Unified diffs are a compact way of showing line changes and a few
+// lines of context. The number of context lines is set by 'n' which
+// defaults to three.
+//
+// By default, the diff control lines (those with ---, +++, or @@) are
+// created with a trailing newline. This is helpful so that inputs
+// created from file.readlines() result in diffs that are suitable for
+// file.writelines() since both the inputs and outputs have trailing
+// newlines.
+//
+// For inputs that do not have trailing newlines, set the lineterm
+// argument to "" so that the output will be uniformly newline free.
+//
+// The unidiff format normally has a header for filenames and modification
+// times. Any or all of these may be specified using strings for
+// 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'.
+// The modification times are normally expressed in the ISO 8601 format.
+func WriteUnifiedDiff(writer io.Writer, diff UnifiedDiff) error {
+ buf := bufio.NewWriter(writer)
+ defer buf.Flush()
+ wf := func(format string, args ...interface{}) error {
+ _, err := buf.WriteString(fmt.Sprintf(format, args...))
+ return err
+ }
+ ws := func(s string) error {
+ _, err := buf.WriteString(s)
+ return err
+ }
+
+ if len(diff.Eol) == 0 {
+ diff.Eol = "\n"
+ }
+
+ started := false
+ m := NewMatcher(diff.A, diff.B)
+ for _, g := range m.GetGroupedOpCodes(diff.Context) {
+ if !started {
+ started = true
+ fromDate := ""
+ if len(diff.FromDate) > 0 {
+ fromDate = "\t" + diff.FromDate
+ }
+ toDate := ""
+ if len(diff.ToDate) > 0 {
+ toDate = "\t" + diff.ToDate
+ }
+ err := wf("--- %s%s%s", diff.FromFile, fromDate, diff.Eol)
+ if err != nil {
+ return err
+ }
+ err = wf("+++ %s%s%s", diff.ToFile, toDate, diff.Eol)
+ if err != nil {
+ return err
+ }
+ }
+ first, last := g[0], g[len(g)-1]
+ range1 := formatRangeUnified(first.I1, last.I2)
+ range2 := formatRangeUnified(first.J1, last.J2)
+ if err := wf("@@ -%s +%s @@%s", range1, range2, diff.Eol); err != nil {
+ return err
+ }
+ for _, c := range g {
+ i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2
+ if c.Tag == 'e' {
+ for _, line := range diff.A[i1:i2] {
+ if err := ws(" " + line); err != nil {
+ return err
+ }
+ }
+ continue
+ }
+ if c.Tag == 'r' || c.Tag == 'd' {
+ for _, line := range diff.A[i1:i2] {
+ if err := ws("-" + line); err != nil {
+ return err
+ }
+ }
+ }
+ if c.Tag == 'r' || c.Tag == 'i' {
+ for _, line := range diff.B[j1:j2] {
+ if err := ws("+" + line); err != nil {
+ return err
+ }
+ }
+ }
+ }
+ }
+ return nil
+}
+
+// Like WriteUnifiedDiff but returns the diff a string.
+func GetUnifiedDiffString(diff UnifiedDiff) (string, error) {
+ w := &bytes.Buffer{}
+ err := WriteUnifiedDiff(w, diff)
+ return string(w.Bytes()), err
+}
+
+// Convert range to the "ed" format.
+func formatRangeContext(start, stop int) string {
+ // Per the diff spec at http://www.unix.org/single_unix_specification/
+ beginning := start + 1 // lines start numbering with one
+ length := stop - start
+ if length == 0 {
+ beginning -= 1 // empty ranges begin at line just before the range
+ }
+ if length <= 1 {
+ return fmt.Sprintf("%d", beginning)
+ }
+ return fmt.Sprintf("%d,%d", beginning, beginning+length-1)
+}
+
+type ContextDiff UnifiedDiff
+
+// Compare two sequences of lines; generate the delta as a context diff.
+//
+// Context diffs are a compact way of showing line changes and a few
+// lines of context. The number of context lines is set by diff.Context
+// which defaults to three.
+//
+// By default, the diff control lines (those with *** or ---) are
+// created with a trailing newline.
+//
+// For inputs that do not have trailing newlines, set the diff.Eol
+// argument to "" so that the output will be uniformly newline free.
+//
+// The context diff format normally has a header for filenames and
+// modification times. Any or all of these may be specified using
+// strings for diff.FromFile, diff.ToFile, diff.FromDate, diff.ToDate.
+// The modification times are normally expressed in the ISO 8601 format.
+// If not specified, the strings default to blanks.
+func WriteContextDiff(writer io.Writer, diff ContextDiff) error {
+ buf := bufio.NewWriter(writer)
+ defer buf.Flush()
+ var diffErr error
+ wf := func(format string, args ...interface{}) {
+ _, err := buf.WriteString(fmt.Sprintf(format, args...))
+ if diffErr == nil && err != nil {
+ diffErr = err
+ }
+ }
+ ws := func(s string) {
+ _, err := buf.WriteString(s)
+ if diffErr == nil && err != nil {
+ diffErr = err
+ }
+ }
+
+ if len(diff.Eol) == 0 {
+ diff.Eol = "\n"
+ }
+
+ prefix := map[byte]string{
+ 'i': "+ ",
+ 'd': "- ",
+ 'r': "! ",
+ 'e': " ",
+ }
+
+ started := false
+ m := NewMatcher(diff.A, diff.B)
+ for _, g := range m.GetGroupedOpCodes(diff.Context) {
+ if !started {
+ started = true
+ fromDate := ""
+ if len(diff.FromDate) > 0 {
+ fromDate = "\t" + diff.FromDate
+ }
+ toDate := ""
+ if len(diff.ToDate) > 0 {
+ toDate = "\t" + diff.ToDate
+ }
+ wf("*** %s%s%s", diff.FromFile, fromDate, diff.Eol)
+ wf("--- %s%s%s", diff.ToFile, toDate, diff.Eol)
+ }
+
+ first, last := g[0], g[len(g)-1]
+ ws("***************" + diff.Eol)
+
+ range1 := formatRangeContext(first.I1, last.I2)
+ wf("*** %s ****%s", range1, diff.Eol)
+ for _, c := range g {
+ if c.Tag == 'r' || c.Tag == 'd' {
+ for _, cc := range g {
+ if cc.Tag == 'i' {
+ continue
+ }
+ for _, line := range diff.A[cc.I1:cc.I2] {
+ ws(prefix[cc.Tag] + line)
+ }
+ }
+ break
+ }
+ }
+
+ range2 := formatRangeContext(first.J1, last.J2)
+ wf("--- %s ----%s", range2, diff.Eol)
+ for _, c := range g {
+ if c.Tag == 'r' || c.Tag == 'i' {
+ for _, cc := range g {
+ if cc.Tag == 'd' {
+ continue
+ }
+ for _, line := range diff.B[cc.J1:cc.J2] {
+ ws(prefix[cc.Tag] + line)
+ }
+ }
+ break
+ }
+ }
+ }
+ return diffErr
+}
+
+// Like WriteContextDiff but returns the diff a string.
+func GetContextDiffString(diff ContextDiff) (string, error) {
+ w := &bytes.Buffer{}
+ err := WriteContextDiff(w, diff)
+ return string(w.Bytes()), err
+}
+
+// Split a string on "\n" while preserving them. The output can be used
+// as input for UnifiedDiff and ContextDiff structures.
+func SplitLines(s string) []string {
+ lines := strings.SplitAfter(s, "\n")
+ lines[len(lines)-1] += "\n"
+ return lines
+}
diff --git a/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/conn.go b/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/conn.go
index 0a3f9b774c..0df5e87556 100644
--- a/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/conn.go
+++ b/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/conn.go
@@ -1,3 +1,4 @@
+// Package zk is a native Go client library for the ZooKeeper orchestration service.
package zk
/*
@@ -14,7 +15,6 @@ import (
"errors"
"fmt"
"io"
- "log"
"net"
"strconv"
"strings"
@@ -23,8 +23,17 @@ import (
"time"
)
+// ErrNoServer indicates that an operation cannot be completed
+// because attempts to connect to all servers in the list failed.
var ErrNoServer = errors.New("zk: could not connect to a server")
+// ErrInvalidPath indicates that an operation was being attempted on
+// an invalid path. (e.g. empty path)
+var ErrInvalidPath = errors.New("zk: invalid path")
+
+// DefaultLogger uses the stdlib log package for logging.
+var DefaultLogger Logger = defaultLogger{}
+
const (
bufferSize = 1536 * 1024
eventChanSize = 6
@@ -47,20 +56,26 @@ type watchPathType struct {
type Dialer func(network, address string, timeout time.Duration) (net.Conn, error)
+// Logger is an interface that can be implemented to provide custom log output.
+type Logger interface {
+ Printf(string, ...interface{})
+}
+
type Conn struct {
- lastZxid int64
- sessionID int64
- state State // must be 32-bit aligned
- xid int32
- timeout int32 // session timeout in milliseconds
- passwd []byte
+ lastZxid int64
+ sessionID int64
+ state State // must be 32-bit aligned
+ xid uint32
+ sessionTimeoutMs int32 // session timeout in milliseconds
+ passwd []byte
dialer Dialer
- servers []string
- serverIndex int
+ hostProvider HostProvider
+ serverMu sync.Mutex // protects server
+ server string // remember the address/port of the current server
conn net.Conn
eventChan chan Event
- shouldQuit chan bool
+ shouldQuit chan struct{}
pingInterval time.Duration
recvTimeout time.Duration
connectTimeout time.Duration
@@ -73,8 +88,13 @@ type Conn struct {
// Debug (used by unit tests)
reconnectDelay time.Duration
+
+ logger Logger
}
+// connOption represents a connection option.
+type connOption func(c *Conn)
+
type request struct {
xid int32
opcode int32
@@ -98,67 +118,110 @@ type response struct {
}
type Event struct {
- Type EventType
- State State
- Path string // For non-session events, the path of the watched node.
- Err error
+ Type EventType
+ State State
+ Path string // For non-session events, the path of the watched node.
+ Err error
+ Server string // For connection events
}
-// Connect establishes a new connection to a pool of zookeeper servers
-// using the default net.Dialer. See ConnectWithDialer for further
-// information about session timeout.
-func Connect(servers []string, sessionTimeout time.Duration) (*Conn, <-chan Event, error) {
- return ConnectWithDialer(servers, sessionTimeout, nil)
+// HostProvider is used to represent a set of hosts a ZooKeeper client should connect to.
+// It is an analog of the Java equivalent:
+// http://svn.apache.org/viewvc/zookeeper/trunk/src/java/main/org/apache/zookeeper/client/HostProvider.java?view=markup
+type HostProvider interface {
+ // Init is called first, with the servers specified in the connection string.
+ Init(servers []string) error
+ // Len returns the number of servers.
+ Len() int
+ // Next returns the next server to connect to. retryStart will be true if we've looped through
+ // all known servers without Connected() being called.
+ Next() (server string, retryStart bool)
+ // Notify the HostProvider of a successful connection.
+ Connected()
}
-// ConnectWithDialer establishes a new connection to a pool of zookeeper
+// ConnectWithDialer establishes a new connection to a pool of zookeeper servers
+// using a custom Dialer. See Connect for further information about session timeout.
+// This method is deprecated and provided for compatibility: use the WithDialer option instead.
+func ConnectWithDialer(servers []string, sessionTimeout time.Duration, dialer Dialer) (*Conn, <-chan Event, error) {
+ return Connect(servers, sessionTimeout, WithDialer(dialer))
+}
+
+// Connect establishes a new connection to a pool of zookeeper
// servers. The provided session timeout sets the amount of time for which
// a session is considered valid after losing connection to a server. Within
// the session timeout it's possible to reestablish a connection to a different
// server and keep the same session. This is means any ephemeral nodes and
// watches are maintained.
-func ConnectWithDialer(servers []string, sessionTimeout time.Duration, dialer Dialer) (*Conn, <-chan Event, error) {
- // Randomize the order of the servers to avoid creating hotspots
- stringShuffle(servers)
+func Connect(servers []string, sessionTimeout time.Duration, options ...connOption) (*Conn, <-chan Event, error) {
+ if len(servers) == 0 {
+ return nil, nil, errors.New("zk: server list must not be empty")
+ }
- recvTimeout := sessionTimeout * 2 / 3
+ srvs := make([]string, len(servers))
for i, addr := range servers {
- if !strings.Contains(addr, ":") {
- servers[i] = addr + ":" + strconv.Itoa(DefaultPort)
+ if strings.Contains(addr, ":") {
+ srvs[i] = addr
+ } else {
+ srvs[i] = addr + ":" + strconv.Itoa(DefaultPort)
}
}
+
+ // Randomize the order of the servers to avoid creating hotspots
+ stringShuffle(srvs)
+
ec := make(chan Event, eventChanSize)
- if dialer == nil {
- dialer = net.DialTimeout
- }
- conn := Conn{
- dialer: dialer,
- servers: servers,
- serverIndex: 0,
+ conn := &Conn{
+ dialer: net.DialTimeout,
+ hostProvider: &DNSHostProvider{},
conn: nil,
state: StateDisconnected,
eventChan: ec,
- shouldQuit: make(chan bool),
- recvTimeout: recvTimeout,
- pingInterval: recvTimeout / 2,
+ shouldQuit: make(chan struct{}),
connectTimeout: 1 * time.Second,
sendChan: make(chan *request, sendChanSize),
requests: make(map[int32]*request),
watchers: make(map[watchPathType][]chan Event),
passwd: emptyPassword,
- timeout: int32(sessionTimeout.Nanoseconds() / 1e6),
+ logger: DefaultLogger,
// Debug
reconnectDelay: 0,
}
+
+ // Set provided options.
+ for _, option := range options {
+ option(conn)
+ }
+
+ if err := conn.hostProvider.Init(srvs); err != nil {
+ return nil, nil, err
+ }
+
+ conn.setTimeouts(int32(sessionTimeout / time.Millisecond))
+
go func() {
conn.loop()
conn.flushRequests(ErrClosing)
conn.invalidateWatches(ErrClosing)
close(conn.eventChan)
}()
- return &conn, ec, nil
+ return conn, ec, nil
+}
+
+// WithDialer returns a connection option specifying a non-default Dialer.
+func WithDialer(dialer Dialer) connOption {
+ return func(c *Conn) {
+ c.dialer = dialer
+ }
+}
+
+// WithHostProvider returns a connection option specifying a non-default HostProvider.
+func WithHostProvider(hostProvider HostProvider) connOption {
+ return func(c *Conn) {
+ c.hostProvider = hostProvider
+ }
}
func (c *Conn) Close() {
@@ -170,64 +233,97 @@ func (c *Conn) Close() {
}
}
+// States returns the current state of the connection.
func (c *Conn) State() State {
return State(atomic.LoadInt32((*int32)(&c.state)))
}
+// SetLogger sets the logger to be used for printing errors.
+// Logger is an interface provided by this package.
+func (c *Conn) SetLogger(l Logger) {
+ c.logger = l
+}
+
+func (c *Conn) setTimeouts(sessionTimeoutMs int32) {
+ c.sessionTimeoutMs = sessionTimeoutMs
+ sessionTimeout := time.Duration(sessionTimeoutMs) * time.Millisecond
+ c.recvTimeout = sessionTimeout * 2 / 3
+ c.pingInterval = c.recvTimeout / 2
+}
+
func (c *Conn) setState(state State) {
atomic.StoreInt32((*int32)(&c.state), int32(state))
select {
- case c.eventChan <- Event{Type: EventSession, State: state}:
+ case c.eventChan <- Event{Type: EventSession, State: state, Server: c.Server()}:
default:
// panic("zk: event channel full - it must be monitored and never allowed to be full")
}
}
-func (c *Conn) connect() {
- c.serverIndex = (c.serverIndex + 1) % len(c.servers)
- startIndex := c.serverIndex
- c.setState(StateConnecting)
+func (c *Conn) connect() error {
+ var retryStart bool
for {
- zkConn, err := c.dialer("tcp", c.servers[c.serverIndex], c.connectTimeout)
+ c.serverMu.Lock()
+ c.server, retryStart = c.hostProvider.Next()
+ c.serverMu.Unlock()
+ c.setState(StateConnecting)
+ if retryStart {
+ c.flushUnsentRequests(ErrNoServer)
+ select {
+ case <-time.After(time.Second):
+ // pass
+ case <-c.shouldQuit:
+ c.setState(StateDisconnected)
+ c.flushUnsentRequests(ErrClosing)
+ return ErrClosing
+ }
+ }
+
+ zkConn, err := c.dialer("tcp", c.Server(), c.connectTimeout)
if err == nil {
c.conn = zkConn
c.setState(StateConnected)
- return
+ c.logger.Printf("Connected to %s", c.Server())
+ return nil
}
- log.Printf("Failed to connect to %s: %+v", c.servers[c.serverIndex], err)
-
- c.serverIndex = (c.serverIndex + 1) % len(c.servers)
- if c.serverIndex == startIndex {
- c.flushUnsentRequests(ErrNoServer)
- time.Sleep(time.Second)
- }
+ c.logger.Printf("Failed to connect to %s: %+v", c.Server(), err)
}
}
func (c *Conn) loop() {
for {
- c.connect()
+ if err := c.connect(); err != nil {
+ // c.Close() was called
+ return
+ }
+
err := c.authenticate()
switch {
case err == ErrSessionExpired:
+ c.logger.Printf("Authentication failed: %s", err)
c.invalidateWatches(err)
case err != nil && c.conn != nil:
+ c.logger.Printf("Authentication failed: %s", err)
c.conn.Close()
case err == nil:
- closeChan := make(chan bool) // channel to tell send loop stop
+ c.logger.Printf("Authenticated: id=%d, timeout=%d", c.sessionID, c.sessionTimeoutMs)
+ c.hostProvider.Connected() // mark success
+ closeChan := make(chan struct{}) // channel to tell send loop stop
var wg sync.WaitGroup
wg.Add(1)
go func() {
- c.sendLoop(c.conn, closeChan)
+ err := c.sendLoop(c.conn, closeChan)
+ c.logger.Printf("Send loop terminated: err=%v", err)
c.conn.Close() // causes recv loop to EOF/exit
wg.Done()
}()
wg.Add(1)
go func() {
- err = c.recvLoop(c.conn)
+ err := c.recvLoop(c.conn)
+ c.logger.Printf("Recv loop terminated: err=%v", err)
if err == nil {
panic("zk: recvLoop should never return nil error")
}
@@ -235,16 +331,12 @@ func (c *Conn) loop() {
wg.Done()
}()
+ c.sendSetWatches()
wg.Wait()
}
c.setState(StateDisconnected)
- // Yeesh
- if err != io.EOF && err != ErrSessionExpired && !strings.Contains(err.Error(), "use of closed network connection") {
- log.Println(err)
- }
-
select {
case <-c.shouldQuit:
c.flushRequests(ErrClosing)
@@ -342,7 +434,7 @@ func (c *Conn) sendSetWatches() {
res := &setWatchesResponse{}
_, err := c.request(opSetWatches, req, res, nil)
if err != nil {
- log.Printf("Failed to set previous watches: %s", err.Error())
+ c.logger.Printf("Failed to set previous watches: %s", err.Error())
}
}()
}
@@ -350,12 +442,11 @@ func (c *Conn) sendSetWatches() {
func (c *Conn) authenticate() error {
buf := make([]byte, 256)
- // connect request
-
+ // Encode and send a connect request.
n, err := encodePacket(buf[4:], &connectRequest{
ProtocolVersion: protocolVersion,
LastZxidSeen: c.lastZxid,
- TimeOut: c.timeout,
+ TimeOut: c.sessionTimeoutMs,
SessionID: c.sessionID,
Passwd: c.passwd,
})
@@ -372,11 +463,7 @@ func (c *Conn) authenticate() error {
return err
}
- c.sendSetWatches()
-
- // connect response
-
- // package length
+ // Receive and decode a connect response.
c.conn.SetReadDeadline(time.Now().Add(c.recvTimeout * 10))
_, err = io.ReadFull(c.conn, buf[:4])
c.conn.SetReadDeadline(time.Time{})
@@ -407,10 +494,7 @@ func (c *Conn) authenticate() error {
return ErrSessionExpired
}
- if c.sessionID != r.SessionID {
- atomic.StoreInt32(&c.xid, 0)
- }
- c.timeout = r.TimeOut
+ c.setTimeouts(r.TimeOut)
c.sessionID = r.SessionID
c.passwd = r.Passwd
c.setState(StateHasSession)
@@ -418,7 +502,7 @@ func (c *Conn) authenticate() error {
return nil
}
-func (c *Conn) sendLoop(conn net.Conn, closeChan <-chan bool) error {
+func (c *Conn) sendLoop(conn net.Conn, closeChan <-chan struct{}) error {
pingTicker := time.NewTicker(c.pingInterval)
defer pingTicker.Stop()
@@ -550,7 +634,7 @@ func (c *Conn) recvLoop(conn net.Conn) error {
} else if res.Xid == -2 {
// Ping response. Ignore.
} else if res.Xid < 0 {
- log.Printf("Xid < 0 (%d) but not ping or watcher event", res.Xid)
+ c.logger.Printf("Xid < 0 (%d) but not ping or watcher event", res.Xid)
} else {
if res.Zxid > 0 {
c.lastZxid = res.Zxid
@@ -564,7 +648,7 @@ func (c *Conn) recvLoop(conn net.Conn) error {
c.requestsLock.Unlock()
if !ok {
- log.Printf("Response for unknown request with xid %d", res.Xid)
+ c.logger.Printf("Response for unknown request with xid %d", res.Xid)
} else {
if res.Err != 0 {
err = res.Err.toError()
@@ -584,7 +668,7 @@ func (c *Conn) recvLoop(conn net.Conn) error {
}
func (c *Conn) nextXid() int32 {
- return atomic.AddInt32(&c.xid, 1)
+ return int32(atomic.AddUint32(&c.xid, 1) & 0x7fffffff)
}
func (c *Conn) addWatcher(path string, watchType watchType) <-chan Event {
@@ -662,6 +746,9 @@ func (c *Conn) GetW(path string) ([]byte, *Stat, <-chan Event, error) {
}
func (c *Conn) Set(path string, data []byte, version int32) (*Stat, error) {
+ if path == "" {
+ return nil, ErrInvalidPath
+ }
res := &setDataResponse{}
_, err := c.request(opSetData, &SetDataRequest{path, data, version}, res, nil)
return &res.Stat, err
@@ -760,7 +847,6 @@ func (c *Conn) GetACL(path string) ([]ACL, *Stat, error) {
_, err := c.request(opGetAcl, &getAclRequest{Path: path}, res, nil)
return res.Acl, &res.Stat, err
}
-
func (c *Conn) SetACL(path string, acl []ACL, version int32) (*Stat, error) {
res := &setAclResponse{}
_, err := c.request(opSetAcl, &setAclRequest{Path: path, Acl: acl, Version: version}, res, nil)
@@ -798,7 +884,7 @@ func (c *Conn) Multi(ops ...interface{}) ([]MultiResponse, error) {
case *CheckVersionRequest:
opCode = opCheck
default:
- return nil, fmt.Errorf("uknown operation type %T", op)
+ return nil, fmt.Errorf("unknown operation type %T", op)
}
req.Ops = append(req.Ops, multiRequestOp{multiHeader{opCode, false, -1}, op})
}
@@ -810,3 +896,10 @@ func (c *Conn) Multi(ops ...interface{}) ([]MultiResponse, error) {
}
return mr, err
}
+
+// Server returns the current or last-connected server name.
+func (c *Conn) Server() string {
+ c.serverMu.Lock()
+ defer c.serverMu.Unlock()
+ return c.server
+}
diff --git a/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/constants.go b/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/constants.go
index ee8772437b..f9b39b904f 100644
--- a/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/constants.go
+++ b/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/constants.go
@@ -57,7 +57,6 @@ const (
StateUnknown = State(-1)
StateDisconnected = State(0)
StateConnecting = State(1)
- StateSyncConnected = State(3)
StateAuthFailed = State(4)
StateConnectedReadOnly = State(5)
StateSaslAuthenticated = State(6)
@@ -77,7 +76,6 @@ var (
stateNames = map[State]string{
StateUnknown: "StateUnknown",
StateDisconnected: "StateDisconnected",
- StateSyncConnected: "StateSyncConnected",
StateConnectedReadOnly: "StateConnectedReadOnly",
StateSaslAuthenticated: "StateSaslAuthenticated",
StateExpired: "StateExpired",
@@ -215,3 +213,28 @@ func (t EventType) String() string {
}
return "Unknown"
}
+
+// Mode is used to build custom server modes (leader|follower|standalone).
+type Mode uint8
+
+func (m Mode) String() string {
+ if name := modeNames[m]; name != "" {
+ return name
+ }
+ return "unknown"
+}
+
+const (
+ ModeUnknown Mode = iota
+ ModeLeader Mode = iota
+ ModeFollower Mode = iota
+ ModeStandalone Mode = iota
+)
+
+var (
+ modeNames = map[Mode]string{
+ ModeLeader: "leader",
+ ModeFollower: "follower",
+ ModeStandalone: "standalone",
+ }
+)
diff --git a/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/dnshostprovider.go b/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/dnshostprovider.go
new file mode 100644
index 0000000000..c021fe93f0
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/dnshostprovider.go
@@ -0,0 +1,87 @@
+package zk
+
+import (
+ "fmt"
+ "net"
+ "sync"
+)
+
+// DNSHostProvider is the default HostProvider. It currently matches
+// the Java StaticHostProvider, resolving hosts from DNS once during
+// the call to Init. It could be easily extended to re-query DNS
+// periodically or if there is trouble connecting.
+type DNSHostProvider struct {
+ mu sync.Mutex // Protects everything, so we can add asynchronous updates later.
+ servers []string
+ curr int
+ last int
+ lookupHost func(string) ([]string, error) // Override of net.LookupHost, for testing.
+}
+
+// Init is called first, with the servers specified in the connection
+// string. It uses DNS to look up addresses for each server, then
+// shuffles them all together.
+func (hp *DNSHostProvider) Init(servers []string) error {
+ hp.mu.Lock()
+ defer hp.mu.Unlock()
+
+ lookupHost := hp.lookupHost
+ if lookupHost == nil {
+ lookupHost = net.LookupHost
+ }
+
+ found := []string{}
+ for _, server := range servers {
+ host, port, err := net.SplitHostPort(server)
+ if err != nil {
+ return err
+ }
+ addrs, err := lookupHost(host)
+ if err != nil {
+ return err
+ }
+ for _, addr := range addrs {
+ found = append(found, net.JoinHostPort(addr, port))
+ }
+ }
+
+ if len(found) == 0 {
+ return fmt.Errorf("No hosts found for addresses %q", servers)
+ }
+
+ // Randomize the order of the servers to avoid creating hotspots
+ stringShuffle(found)
+
+ hp.servers = found
+ hp.curr = -1
+ hp.last = -1
+
+ return nil
+}
+
+func (hp *DNSHostProvider) Len() int {
+ hp.mu.Lock()
+ defer hp.mu.Unlock()
+ return len(hp.servers)
+}
+
+// Next returns the next server to connect to. retryStart will be true
+// if we've looped through all known servers without Connected() being
+// called.
+func (hp *DNSHostProvider) Next() (server string, retryStart bool) {
+ hp.mu.Lock()
+ defer hp.mu.Unlock()
+ hp.curr = (hp.curr + 1) % len(hp.servers)
+ retryStart = hp.curr == hp.last
+ if hp.last == -1 {
+ hp.last = 0
+ }
+ return hp.servers[hp.curr], retryStart
+}
+
+// Notify the HostProvider of a successful connection.
+func (hp *DNSHostProvider) Connected() {
+ hp.mu.Lock()
+ defer hp.mu.Unlock()
+ hp.last = hp.curr
+}
diff --git a/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/flw.go b/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/flw.go
new file mode 100644
index 0000000000..1045c98cfd
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/flw.go
@@ -0,0 +1,290 @@
+package zk
+
+import (
+ "bufio"
+ "bytes"
+ "fmt"
+ "io/ioutil"
+ "math/big"
+ "net"
+ "regexp"
+ "strconv"
+ "time"
+)
+
+// FLWSrvr is a FourLetterWord helper function. In particular, this function pulls the srvr output
+// from the zookeeper instances and parses the output. A slice of *ServerStats structs are returned
+// as well as a boolean value to indicate whether this function processed successfully.
+//
+// If the boolean value is false there was a problem. If the *ServerStats slice is empty or nil,
+// then the error happened before we started to obtain 'srvr' values. Otherwise, one of the
+// servers had an issue and the "Error" value in the struct should be inspected to determine
+// which server had the issue.
+func FLWSrvr(servers []string, timeout time.Duration) ([]*ServerStats, bool) {
+ // different parts of the regular expression that are required to parse the srvr output
+ var (
+ zrVer = `^Zookeeper version: ([A-Za-z0-9\.\-]+), built on (\d\d/\d\d/\d\d\d\d \d\d:\d\d [A-Za-z0-9:\+\-]+)`
+ zrLat = `^Latency min/avg/max: (\d+)/(\d+)/(\d+)`
+ zrNet = `^Received: (\d+).*\n^Sent: (\d+).*\n^Connections: (\d+).*\n^Outstanding: (\d+)`
+ zrState = `^Zxid: (0x[A-Za-z0-9]+).*\n^Mode: (\w+).*\n^Node count: (\d+)`
+ )
+
+ // build the regex from the pieces above
+ re, err := regexp.Compile(fmt.Sprintf(`(?m:\A%v.*\n%v.*\n%v.*\n%v)`, zrVer, zrLat, zrNet, zrState))
+
+ if err != nil {
+ return nil, false
+ }
+
+ imOk := true
+ servers = FormatServers(servers)
+ ss := make([]*ServerStats, len(servers))
+
+ for i := range ss {
+ response, err := fourLetterWord(servers[i], "srvr", timeout)
+
+ if err != nil {
+ ss[i] = &ServerStats{Error: err}
+ imOk = false
+ continue
+ }
+
+ matches := re.FindAllStringSubmatch(string(response), -1)
+
+ if matches == nil {
+ err := fmt.Errorf("unable to parse fields from zookeeper response (no regex matches)")
+ ss[i] = &ServerStats{Error: err}
+ imOk = false
+ continue
+ }
+
+ match := matches[0][1:]
+
+ // determine current server
+ var srvrMode Mode
+ switch match[10] {
+ case "leader":
+ srvrMode = ModeLeader
+ case "follower":
+ srvrMode = ModeFollower
+ case "standalone":
+ srvrMode = ModeStandalone
+ default:
+ srvrMode = ModeUnknown
+ }
+
+ buildTime, err := time.Parse("01/02/2006 15:04 MST", match[1])
+
+ if err != nil {
+ ss[i] = &ServerStats{Error: err}
+ imOk = false
+ continue
+ }
+
+ parsedInt, err := strconv.ParseInt(match[9], 0, 64)
+
+ if err != nil {
+ ss[i] = &ServerStats{Error: err}
+ imOk = false
+ continue
+ }
+
+ // the ZxID value is an int64 with two int32s packed inside
+ // the high int32 is the epoch (i.e., number of leader elections)
+ // the low int32 is the counter
+ epoch := int32(parsedInt >> 32)
+ counter := int32(parsedInt & 0xFFFFFFFF)
+
+ // within the regex above, these values must be numerical
+ // so we can avoid useless checking of the error return value
+ minLatency, _ := strconv.ParseInt(match[2], 0, 64)
+ avgLatency, _ := strconv.ParseInt(match[3], 0, 64)
+ maxLatency, _ := strconv.ParseInt(match[4], 0, 64)
+ recv, _ := strconv.ParseInt(match[5], 0, 64)
+ sent, _ := strconv.ParseInt(match[6], 0, 64)
+ cons, _ := strconv.ParseInt(match[7], 0, 64)
+ outs, _ := strconv.ParseInt(match[8], 0, 64)
+ ncnt, _ := strconv.ParseInt(match[11], 0, 64)
+
+ ss[i] = &ServerStats{
+ Sent: sent,
+ Received: recv,
+ NodeCount: ncnt,
+ MinLatency: minLatency,
+ AvgLatency: avgLatency,
+ MaxLatency: maxLatency,
+ Connections: cons,
+ Outstanding: outs,
+ Epoch: epoch,
+ Counter: counter,
+ BuildTime: buildTime,
+ Mode: srvrMode,
+ Version: match[0],
+ }
+ }
+
+ return ss, imOk
+}
+
+// FLWRuok is a FourLetterWord helper function. In particular, this function
+// pulls the ruok output from each server.
+func FLWRuok(servers []string, timeout time.Duration) []bool {
+ servers = FormatServers(servers)
+ oks := make([]bool, len(servers))
+
+ for i := range oks {
+ response, err := fourLetterWord(servers[i], "ruok", timeout)
+
+ if err != nil {
+ continue
+ }
+
+ if bytes.Equal(response[:4], []byte("imok")) {
+ oks[i] = true
+ }
+ }
+ return oks
+}
+
+// FLWCons is a FourLetterWord helper function. In particular, this function
+// pulls the ruok output from each server.
+//
+// As with FLWSrvr, the boolean value indicates whether one of the requests had
+// an issue. The Clients struct has an Error value that can be checked.
+func FLWCons(servers []string, timeout time.Duration) ([]*ServerClients, bool) {
+ var (
+ zrAddr = `^ /((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):(?:\d+))\[\d+\]`
+ zrPac = `\(queued=(\d+),recved=(\d+),sent=(\d+),sid=(0x[A-Za-z0-9]+),lop=(\w+),est=(\d+),to=(\d+),`
+ zrSesh = `lcxid=(0x[A-Za-z0-9]+),lzxid=(0x[A-Za-z0-9]+),lresp=(\d+),llat=(\d+),minlat=(\d+),avglat=(\d+),maxlat=(\d+)\)`
+ )
+
+ re, err := regexp.Compile(fmt.Sprintf("%v%v%v", zrAddr, zrPac, zrSesh))
+
+ if err != nil {
+ return nil, false
+ }
+
+ servers = FormatServers(servers)
+ sc := make([]*ServerClients, len(servers))
+ imOk := true
+
+ for i := range sc {
+ response, err := fourLetterWord(servers[i], "cons", timeout)
+
+ if err != nil {
+ sc[i] = &ServerClients{Error: err}
+ imOk = false
+ continue
+ }
+
+ scan := bufio.NewScanner(bytes.NewReader(response))
+
+ var clients []*ServerClient
+
+ for scan.Scan() {
+ line := scan.Bytes()
+
+ if len(line) == 0 {
+ continue
+ }
+
+ m := re.FindAllStringSubmatch(string(line), -1)
+
+ if m == nil {
+ err := fmt.Errorf("unable to parse fields from zookeeper response (no regex matches)")
+ sc[i] = &ServerClients{Error: err}
+ imOk = false
+ continue
+ }
+
+ match := m[0][1:]
+
+ queued, _ := strconv.ParseInt(match[1], 0, 64)
+ recvd, _ := strconv.ParseInt(match[2], 0, 64)
+ sent, _ := strconv.ParseInt(match[3], 0, 64)
+ sid, _ := strconv.ParseInt(match[4], 0, 64)
+ est, _ := strconv.ParseInt(match[6], 0, 64)
+ timeout, _ := strconv.ParseInt(match[7], 0, 32)
+ lresp, _ := strconv.ParseInt(match[10], 0, 64)
+ llat, _ := strconv.ParseInt(match[11], 0, 32)
+ minlat, _ := strconv.ParseInt(match[12], 0, 32)
+ avglat, _ := strconv.ParseInt(match[13], 0, 32)
+ maxlat, _ := strconv.ParseInt(match[14], 0, 32)
+
+ // zookeeper returns a value, '0xffffffffffffffff', as the
+ // Lzxid for PING requests in the 'cons' output.
+ // unfortunately, in Go that is an invalid int64 and is not represented
+ // as -1.
+ // However, converting the string value to a big.Int and then back to
+ // and int64 properly sets the value to -1
+ lzxid, ok := new(big.Int).SetString(match[9], 0)
+
+ var errVal error
+
+ if !ok {
+ errVal = fmt.Errorf("failed to convert lzxid value to big.Int")
+ imOk = false
+ }
+
+ lcxid, ok := new(big.Int).SetString(match[8], 0)
+
+ if !ok && errVal == nil {
+ errVal = fmt.Errorf("failed to convert lcxid value to big.Int")
+ imOk = false
+ }
+
+ clients = append(clients, &ServerClient{
+ Queued: queued,
+ Received: recvd,
+ Sent: sent,
+ SessionID: sid,
+ Lcxid: lcxid.Int64(),
+ Lzxid: lzxid.Int64(),
+ Timeout: int32(timeout),
+ LastLatency: int32(llat),
+ MinLatency: int32(minlat),
+ AvgLatency: int32(avglat),
+ MaxLatency: int32(maxlat),
+ Established: time.Unix(est, 0),
+ LastResponse: time.Unix(lresp, 0),
+ Addr: match[0],
+ LastOperation: match[5],
+ Error: errVal,
+ })
+ }
+
+ sc[i] = &ServerClients{Clients: clients}
+ }
+
+ return sc, imOk
+}
+
+func fourLetterWord(server, command string, timeout time.Duration) ([]byte, error) {
+ conn, err := net.DialTimeout("tcp", server, timeout)
+
+ if err != nil {
+ return nil, err
+ }
+
+ // the zookeeper server should automatically close this socket
+ // once the command has been processed, but better safe than sorry
+ defer conn.Close()
+
+ conn.SetWriteDeadline(time.Now().Add(timeout))
+
+ _, err = conn.Write([]byte(command))
+
+ if err != nil {
+ return nil, err
+ }
+
+ conn.SetReadDeadline(time.Now().Add(timeout))
+
+ resp, err := ioutil.ReadAll(conn)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return resp, nil
+}
diff --git a/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/lock.go b/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/lock.go
index fb77e4a538..f13a8b0ba6 100644
--- a/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/lock.go
+++ b/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/lock.go
@@ -8,10 +8,13 @@ import (
)
var (
- ErrDeadlock = errors.New("zk: trying to acquire a lock twice")
+ // ErrDeadlock is returned by Lock when trying to lock twice without unlocking first
+ ErrDeadlock = errors.New("zk: trying to acquire a lock twice")
+ // ErrNotLocked is returned by Unlock when trying to release a lock that has not first be acquired.
ErrNotLocked = errors.New("zk: not locked")
)
+// Lock is a mutual exclusion lock.
type Lock struct {
c *Conn
path string
@@ -20,6 +23,9 @@ type Lock struct {
seq int
}
+// NewLock creates a new lock instance using the provided connection, path, and acl.
+// The path must be a node that is only used by this lock. A lock instances starts
+// unlocked until Lock() is called.
func NewLock(c *Conn, path string, acl []ACL) *Lock {
return &Lock{
c: c,
@@ -33,6 +39,9 @@ func parseSeq(path string) (int, error) {
return strconv.Atoi(parts[len(parts)-1])
}
+// Lock attempts to acquire the lock. It will wait to return until the lock
+// is acquired or an error occurs. If this instance already has the lock
+// then ErrDeadlock is returned.
func (l *Lock) Lock() error {
if l.lockPath != "" {
return ErrDeadlock
@@ -118,6 +127,8 @@ func (l *Lock) Lock() error {
return nil
}
+// Unlock releases an acquired lock. If the lock is not currently acquired by
+// this Lock instance than ErrNotLocked is returned.
func (l *Lock) Unlock() error {
if l.lockPath == "" {
return ErrNotLocked
diff --git a/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/server_help.go b/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/server_help.go
index 7f561b2904..a0e12cf433 100644
--- a/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/server_help.go
+++ b/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/server_help.go
@@ -7,6 +7,7 @@ import (
"math/rand"
"os"
"path/filepath"
+ "strings"
"time"
)
@@ -88,7 +89,7 @@ func StartTestCluster(size int, stdout, stderr io.Writer) (*TestCluster, error)
})
}
success = true
- time.Sleep(time.Second) // Give the server time to become active. Should probably actually attempt to connect to verify.
+ time.Sleep(3 * time.Second) // Give the server time to become active. Should probably actually attempt to connect to verify.
return cluster, nil
}
@@ -97,13 +98,17 @@ func (ts *TestCluster) Connect(idx int) (*Conn, error) {
return zk, err
}
-func (ts *TestCluster) ConnectAll() (*Conn, error) {
+func (ts *TestCluster) ConnectAll() (*Conn, <-chan Event, error) {
+ return ts.ConnectAllTimeout(time.Second * 15)
+}
+
+func (ts *TestCluster) ConnectAllTimeout(sessionTimeout time.Duration) (*Conn, <-chan Event, error) {
hosts := make([]string, len(ts.Servers))
for i, srv := range ts.Servers {
hosts[i] = fmt.Sprintf("127.0.0.1:%d", srv.Port)
}
- zk, _, err := Connect(hosts, time.Second*15)
- return zk, err
+ zk, ch, err := Connect(hosts, sessionTimeout)
+ return zk, ch, err
}
func (ts *TestCluster) Stop() error {
@@ -113,3 +118,23 @@ func (ts *TestCluster) Stop() error {
defer os.RemoveAll(ts.Path)
return nil
}
+
+func (tc *TestCluster) StartServer(server string) {
+ for _, s := range tc.Servers {
+ if strings.HasSuffix(server, fmt.Sprintf(":%d", s.Port)) {
+ s.Srv.Start()
+ return
+ }
+ }
+ panic(fmt.Sprintf("Unknown server: %s", server))
+}
+
+func (tc *TestCluster) StopServer(server string) {
+ for _, s := range tc.Servers {
+ if strings.HasSuffix(server, fmt.Sprintf(":%d", s.Port)) {
+ s.Srv.Stop()
+ return
+ }
+ }
+ panic(fmt.Sprintf("Unknown server: %s", server))
+}
diff --git a/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/structs.go b/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/structs.go
index fd1285e46a..8fbc069ee1 100644
--- a/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/structs.go
+++ b/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/structs.go
@@ -3,8 +3,10 @@ package zk
import (
"encoding/binary"
"errors"
+ "log"
"reflect"
"runtime"
+ "time"
)
var (
@@ -13,6 +15,12 @@ var (
ErrShortBuffer = errors.New("zk: buffer too small")
)
+type defaultLogger struct{}
+
+func (defaultLogger) Printf(format string, a ...interface{}) {
+ log.Printf(format, a...)
+}
+
type ACL struct {
Perms int32
Scheme string
@@ -33,6 +41,54 @@ type Stat struct {
Pzxid int64 // last modified children
}
+// ServerClient is the information for a single Zookeeper client and its session.
+// This is used to parse/extract the output fo the `cons` command.
+type ServerClient struct {
+ Queued int64
+ Received int64
+ Sent int64
+ SessionID int64
+ Lcxid int64
+ Lzxid int64
+ Timeout int32
+ LastLatency int32
+ MinLatency int32
+ AvgLatency int32
+ MaxLatency int32
+ Established time.Time
+ LastResponse time.Time
+ Addr string
+ LastOperation string // maybe?
+ Error error
+}
+
+// ServerClients is a struct for the FLWCons() function. It's used to provide
+// the list of Clients.
+//
+// This is needed because FLWCons() takes multiple servers.
+type ServerClients struct {
+ Clients []*ServerClient
+ Error error
+}
+
+// ServerStats is the information pulled from the Zookeeper `stat` command.
+type ServerStats struct {
+ Sent int64
+ Received int64
+ NodeCount int64
+ MinLatency int64
+ AvgLatency int64
+ MaxLatency int64
+ Connections int64
+ Outstanding int64
+ Epoch int32
+ Counter int32
+ BuildTime time.Time
+ Mode Mode
+ Version string
+ Error error
+}
+
type requestHeader struct {
Xid int32
Opcode int32
diff --git a/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/util.go b/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/util.go
index 741095b427..769bbe878b 100644
--- a/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/util.go
+++ b/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/util.go
@@ -5,6 +5,8 @@ import (
"encoding/base64"
"fmt"
"math/rand"
+ "strconv"
+ "strings"
)
// AuthACL produces an ACL list containing a single ACL which uses the
@@ -31,6 +33,18 @@ func DigestACL(perms int32, user, password string) []ACL {
return []ACL{{perms, "digest", fmt.Sprintf("%s:%s", user, digest)}}
}
+// FormatServers takes a slice of addresses, and makes sure they are in a format
+// that resembles :. If the server has no port provided, the
+// DefaultPort constant is added to the end.
+func FormatServers(servers []string) []string {
+ for i := range servers {
+ if !strings.Contains(servers[i], ":") {
+ servers[i] = servers[i] + ":" + strconv.Itoa(DefaultPort)
+ }
+ }
+ return servers
+}
+
// stringShuffle performs a Fisher-Yates shuffle on a slice of strings
func stringShuffle(s []string) {
for i := len(s) - 1; i > 0; i-- {
diff --git a/Godeps/_workspace/src/github.com/stretchr/objx/value.go b/Godeps/_workspace/src/github.com/stretchr/objx/value.go
index 7aaef06b1c..956a2211d4 100644
--- a/Godeps/_workspace/src/github.com/stretchr/objx/value.go
+++ b/Godeps/_workspace/src/github.com/stretchr/objx/value.go
@@ -1,5 +1,10 @@
package objx
+import (
+ "fmt"
+ "strconv"
+)
+
// Value provides methods for extracting interface{} data in various
// types.
type Value struct {
@@ -11,3 +16,41 @@ type Value struct {
func (v *Value) Data() interface{} {
return v.data
}
+
+// String returns the value always as a string
+func (v *Value) String() string {
+ switch {
+ case v.IsStr():
+ return v.Str()
+ case v.IsBool():
+ return strconv.FormatBool(v.Bool())
+ case v.IsFloat32():
+ return strconv.FormatFloat(float64(v.Float32()), 'f', -1, 32)
+ case v.IsFloat64():
+ return strconv.FormatFloat(v.Float64(), 'f', -1, 64)
+ case v.IsInt():
+ return strconv.FormatInt(int64(v.Int()), 10)
+ case v.IsInt():
+ return strconv.FormatInt(int64(v.Int()), 10)
+ case v.IsInt8():
+ return strconv.FormatInt(int64(v.Int8()), 10)
+ case v.IsInt16():
+ return strconv.FormatInt(int64(v.Int16()), 10)
+ case v.IsInt32():
+ return strconv.FormatInt(int64(v.Int32()), 10)
+ case v.IsInt64():
+ return strconv.FormatInt(v.Int64(), 10)
+ case v.IsUint():
+ return strconv.FormatUint(uint64(v.Uint()), 10)
+ case v.IsUint8():
+ return strconv.FormatUint(uint64(v.Uint8()), 10)
+ case v.IsUint16():
+ return strconv.FormatUint(uint64(v.Uint16()), 10)
+ case v.IsUint32():
+ return strconv.FormatUint(uint64(v.Uint32()), 10)
+ case v.IsUint64():
+ return strconv.FormatUint(v.Uint64(), 10)
+ }
+
+ return fmt.Sprintf("%#v", v.Data())
+}
diff --git a/Godeps/_workspace/src/github.com/stretchr/testify/LICENSE b/Godeps/_workspace/src/github.com/stretchr/testify/LICENSE
new file mode 100644
index 0000000000..473b670a7c
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/stretchr/testify/LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell
+
+Please consider promoting this project if you find it useful.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of the Software,
+and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/Godeps/_workspace/src/github.com/stretchr/testify/assert/assertions.go b/Godeps/_workspace/src/github.com/stretchr/testify/assert/assertions.go
index 818cd7b0e4..e95357d29c 100644
--- a/Godeps/_workspace/src/github.com/stretchr/testify/assert/assertions.go
+++ b/Godeps/_workspace/src/github.com/stretchr/testify/assert/assertions.go
@@ -3,6 +3,7 @@ package assert
import (
"bufio"
"bytes"
+ "encoding/json"
"fmt"
"math"
"reflect"
@@ -10,6 +11,11 @@ import (
"runtime"
"strings"
"time"
+ "unicode"
+ "unicode/utf8"
+
+ "github.com/davecgh/go-spew/spew"
+ "github.com/pmezard/go-difflib/difflib"
)
// TestingT is an interface wrapper around *testing.T
@@ -33,11 +39,7 @@ func ObjectsAreEqual(expected, actual interface{}) bool {
return expected == actual
}
- if reflect.DeepEqual(expected, actual) {
- return true
- }
-
- return false
+ return reflect.DeepEqual(expected, actual)
}
@@ -49,12 +51,13 @@ func ObjectsAreEqualValues(expected, actual interface{}) bool {
}
actualType := reflect.TypeOf(actual)
+ if actualType == nil {
+ return false
+ }
expectedValue := reflect.ValueOf(expected)
- if expectedValue.Type().ConvertibleTo(actualType) {
+ if expectedValue.IsValid() && expectedValue.Type().ConvertibleTo(actualType) {
// Attempt comparison after type conversion
- if reflect.DeepEqual(actual, expectedValue.Convert(actualType).Interface()) {
- return true
- }
+ return reflect.DeepEqual(expectedValue.Convert(actualType).Interface(), actual)
}
return false
@@ -64,28 +67,67 @@ func ObjectsAreEqualValues(expected, actual interface{}) bool {
internally, causing it to print the file:line of the assert method, rather than where
the problem actually occured in calling code.*/
-// CallerInfo returns a string containing the file and line number of the assert call
-// that failed.
-func CallerInfo() string {
+// CallerInfo returns an array of strings containing the file and line number
+// of each stack frame leading from the current test to the assert call that
+// failed.
+func CallerInfo() []string {
+ pc := uintptr(0)
file := ""
line := 0
ok := false
+ name := ""
+ callers := []string{}
for i := 0; ; i++ {
- _, file, line, ok = runtime.Caller(i)
+ pc, file, line, ok = runtime.Caller(i)
if !ok {
- return ""
+ return nil
}
+
+ // This is a huge edge case, but it will panic if this is the case, see #180
+ if file == "" {
+ break
+ }
+
parts := strings.Split(file, "/")
dir := parts[len(parts)-2]
file = parts[len(parts)-1]
if (dir != "assert" && dir != "mock" && dir != "require") || file == "mock_test.go" {
+ callers = append(callers, fmt.Sprintf("%s:%d", file, line))
+ }
+
+ f := runtime.FuncForPC(pc)
+ if f == nil {
+ break
+ }
+ name = f.Name()
+ // Drop the package
+ segments := strings.Split(name, ".")
+ name = segments[len(segments)-1]
+ if isTest(name, "Test") ||
+ isTest(name, "Benchmark") ||
+ isTest(name, "Example") {
break
}
}
- return fmt.Sprintf("%s:%d", file, line)
+ return callers
+}
+
+// Stolen from the `go test` tool.
+// isTest tells whether name looks like a test (or benchmark, according to prefix).
+// It is a Test (say) if there is a character after Test that is not a lower-case letter.
+// We don't want TesticularCancer.
+func isTest(name, prefix string) bool {
+ if !strings.HasPrefix(name, prefix) {
+ return false
+ }
+ if len(name) == len(prefix) { // "Test" is ok
+ return true
+ }
+ rune, _ := utf8.DecodeRuneInString(name[len(prefix):])
+ return !unicode.IsLower(rune)
}
// getWhitespaceString returns a string that is long enough to overwrite the default
@@ -144,19 +186,20 @@ func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool {
message := messageFromMsgAndArgs(msgAndArgs...)
+ errorTrace := strings.Join(CallerInfo(), "\n\r\t\t\t")
if len(message) > 0 {
- t.Errorf("\r%s\r\tLocation:\t%s\n"+
+ t.Errorf("\r%s\r\tError Trace:\t%s\n"+
"\r\tError:%s\n"+
"\r\tMessages:\t%s\n\r",
getWhitespaceString(),
- CallerInfo(),
+ errorTrace,
indentMessageLines(failureMessage, 2),
message)
} else {
- t.Errorf("\r%s\r\tLocation:\t%s\n"+
+ t.Errorf("\r%s\r\tError Trace:\t%s\n"+
"\r\tError:%s\n\r",
getWhitespaceString(),
- CallerInfo(),
+ errorTrace,
indentMessageLines(failureMessage, 2))
}
@@ -171,7 +214,7 @@ func Implements(t TestingT, interfaceObject interface{}, object interface{}, msg
interfaceType := reflect.TypeOf(interfaceObject).Elem()
if !reflect.TypeOf(object).Implements(interfaceType) {
- return Fail(t, fmt.Sprintf("Object must implement %v", interfaceType), msgAndArgs...)
+ return Fail(t, fmt.Sprintf("%T must implement %v", object, interfaceType), msgAndArgs...)
}
return true
@@ -196,8 +239,9 @@ func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs
func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
if !ObjectsAreEqual(expected, actual) {
+ diff := diff(expected, actual)
return Fail(t, fmt.Sprintf("Not equal: %#v (expected)\n"+
- " != %#v (actual)", expected, actual), msgAndArgs...)
+ " != %#v (actual)%s", expected, actual, diff), msgAndArgs...)
}
return true
@@ -232,7 +276,7 @@ func Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}
bType := reflect.TypeOf(actual)
if aType != bType {
- return Fail(t, "Types expected to match exactly", "%v != %v", aType, bType)
+ return Fail(t, fmt.Sprintf("Types expected to match exactly\n\r\t%v != %v", aType, bType), msgAndArgs...)
}
return Equal(t, expected, actual, msgAndArgs...)
@@ -245,24 +289,10 @@ func Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}
//
// Returns whether the assertion was successful (true) or not (false).
func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
-
- success := true
-
- if object == nil {
- success = false
- } else {
- value := reflect.ValueOf(object)
- kind := value.Kind()
- if kind >= reflect.Chan && kind <= reflect.Slice && value.IsNil() {
- success = false
- }
+ if !isNil(object) {
+ return true
}
-
- if !success {
- Fail(t, "Expected not to be nil.", msgAndArgs...)
- }
-
- return success
+ return Fail(t, "Expected value not to be nil.", msgAndArgs...)
}
// isNil checks if a specified object is nil or not, without Failing.
@@ -292,7 +322,7 @@ func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
return Fail(t, fmt.Sprintf("Expected nil, but got: %#v", object), msgAndArgs...)
}
-var zeros = []interface{}{
+var numericZeros = []interface{}{
int(0),
int8(0),
int16(0),
@@ -318,7 +348,7 @@ func isEmpty(object interface{}) bool {
return true
}
- for _, v := range zeros {
+ for _, v := range numericZeros {
if object == v {
return true
}
@@ -335,6 +365,9 @@ func isEmpty(object interface{}) bool {
}
case reflect.Ptr:
{
+ if objValue.IsNil() {
+ return true
+ }
switch object.(type) {
case *time.Time:
return object.(*time.Time).IsZero()
@@ -349,7 +382,7 @@ func isEmpty(object interface{}) bool {
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
// a slice or a channel with len == 0.
//
-// assert.Empty(t, obj)
+// assert.Empty(t, obj)
//
// Returns whether the assertion was successful (true) or not (false).
func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
@@ -366,9 +399,9 @@ func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
// a slice or a channel with len == 0.
//
-// if assert.NotEmpty(t, obj) {
-// assert.Equal(t, "two", obj[1])
-// }
+// if assert.NotEmpty(t, obj) {
+// assert.Equal(t, "two", obj[1])
+// }
//
// Returns whether the assertion was successful (true) or not (false).
func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
@@ -427,7 +460,7 @@ func True(t TestingT, value bool, msgAndArgs ...interface{}) bool {
}
-// False asserts that the specified value is true.
+// False asserts that the specified value is false.
//
// assert.False(t, myBool, "myBool should be false")
//
@@ -450,7 +483,7 @@ func False(t TestingT, value bool, msgAndArgs ...interface{}) bool {
func NotEqual(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
if ObjectsAreEqual(expected, actual) {
- return Fail(t, "Should not be equal", msgAndArgs...)
+ return Fail(t, fmt.Sprintf("Should not be: %#v\n", actual), msgAndArgs...)
}
return true
@@ -476,6 +509,16 @@ func includeElement(list interface{}, element interface{}) (ok, found bool) {
return true, strings.Contains(listValue.String(), elementValue.String())
}
+ if reflect.TypeOf(list).Kind() == reflect.Map {
+ mapKeys := listValue.MapKeys()
+ for i := 0; i < len(mapKeys); i++ {
+ if ObjectsAreEqual(mapKeys[i].Interface(), element) {
+ return true, true
+ }
+ }
+ return true, false
+ }
+
for i := 0; i < listValue.Len(); i++ {
if ObjectsAreEqual(listValue.Index(i).Interface(), element) {
return true, true
@@ -485,11 +528,12 @@ func includeElement(list interface{}, element interface{}) (ok, found bool) {
}
-// Contains asserts that the specified string or list(array, slice...) contains the
+// Contains asserts that the specified string, list(array, slice...) or map contains the
// specified substring or element.
//
// assert.Contains(t, "Hello World", "World", "But 'Hello World' does contain 'World'")
// assert.Contains(t, ["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'")
+// assert.Contains(t, {"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'")
//
// Returns whether the assertion was successful (true) or not (false).
func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool {
@@ -506,11 +550,12 @@ func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bo
}
-// NotContains asserts that the specified string or list(array, slice...) does NOT contain the
+// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
// specified substring or element.
//
// assert.NotContains(t, "Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
// assert.NotContains(t, ["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'")
+// assert.NotContains(t, {"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'")
//
// Returns whether the assertion was successful (true) or not (false).
func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool {
@@ -766,7 +811,7 @@ func NoError(t TestingT, err error, msgAndArgs ...interface{}) bool {
return true
}
- return Fail(t, fmt.Sprintf("No error is expected but got %v", err), msgAndArgs...)
+ return Fail(t, fmt.Sprintf("Received unexpected error %q", err), msgAndArgs...)
}
// Error asserts that a function returned an error (i.e. not `nil`).
@@ -800,7 +845,7 @@ func EqualError(t TestingT, theError error, errString string, msgAndArgs ...inte
return false
}
s := "An error with value \"%s\" is expected but got \"%s\". %s"
- return Equal(t, theError.Error(), errString,
+ return Equal(t, errString, theError.Error(),
s, errString, theError.Error(), message)
}
@@ -851,3 +896,84 @@ func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interf
return !match
}
+
+// Zero asserts that i is the zero value for its type and returns the truth.
+func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) bool {
+ if i != nil && !reflect.DeepEqual(i, reflect.Zero(reflect.TypeOf(i)).Interface()) {
+ return Fail(t, fmt.Sprintf("Should be zero, but was %v", i), msgAndArgs...)
+ }
+ return true
+}
+
+// NotZero asserts that i is not the zero value for its type and returns the truth.
+func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) bool {
+ if i == nil || reflect.DeepEqual(i, reflect.Zero(reflect.TypeOf(i)).Interface()) {
+ return Fail(t, fmt.Sprintf("Should not be zero, but was %v", i), msgAndArgs...)
+ }
+ return true
+}
+
+// JSONEq asserts that two JSON strings are equivalent.
+//
+// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
+//
+// Returns whether the assertion was successful (true) or not (false).
+func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) bool {
+ var expectedJSONAsInterface, actualJSONAsInterface interface{}
+
+ if err := json.Unmarshal([]byte(expected), &expectedJSONAsInterface); err != nil {
+ return Fail(t, fmt.Sprintf("Expected value ('%s') is not valid json.\nJSON parsing error: '%s'", expected, err.Error()), msgAndArgs...)
+ }
+
+ if err := json.Unmarshal([]byte(actual), &actualJSONAsInterface); err != nil {
+ return Fail(t, fmt.Sprintf("Input ('%s') needs to be valid json.\nJSON parsing error: '%s'", actual, err.Error()), msgAndArgs...)
+ }
+
+ return Equal(t, expectedJSONAsInterface, actualJSONAsInterface, msgAndArgs...)
+}
+
+func typeAndKind(v interface{}) (reflect.Type, reflect.Kind) {
+ t := reflect.TypeOf(v)
+ k := t.Kind()
+
+ if k == reflect.Ptr {
+ t = t.Elem()
+ k = t.Kind()
+ }
+ return t, k
+}
+
+// diff returns a diff of both values as long as both are of the same type and
+// are a struct, map, slice or array. Otherwise it returns an empty string.
+func diff(expected interface{}, actual interface{}) string {
+ if expected == nil || actual == nil {
+ return ""
+ }
+
+ et, ek := typeAndKind(expected)
+ at, _ := typeAndKind(actual)
+
+ if et != at {
+ return ""
+ }
+
+ if ek != reflect.Struct && ek != reflect.Map && ek != reflect.Slice && ek != reflect.Array {
+ return ""
+ }
+
+ spew.Config.SortKeys = true
+ e := spew.Sdump(expected)
+ a := spew.Sdump(actual)
+
+ diff, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{
+ A: difflib.SplitLines(e),
+ B: difflib.SplitLines(a),
+ FromFile: "Expected",
+ FromDate: "",
+ ToFile: "Actual",
+ ToDate: "",
+ Context: 1,
+ })
+
+ return "\n\nDiff:\n" + diff
+}
diff --git a/Godeps/_workspace/src/github.com/stretchr/testify/assert/doc.go b/Godeps/_workspace/src/github.com/stretchr/testify/assert/doc.go
index f678106287..c9dccc4d6c 100644
--- a/Godeps/_workspace/src/github.com/stretchr/testify/assert/doc.go
+++ b/Godeps/_workspace/src/github.com/stretchr/testify/assert/doc.go
@@ -17,7 +17,7 @@
//
// }
//
-// if you assert many times, use the below:
+// if you assert many times, use the format below:
//
// import (
// "testing"
@@ -42,113 +42,4 @@
//
// Every assertion function also takes an optional string message as the final argument,
// allowing custom error messages to be appended to the message the assertion method outputs.
-//
-// Here is an overview of the assert functions:
-//
-// assert.Equal(t, expected, actual [, message [, format-args]])
-//
-// assert.EqualValues(t, expected, actual [, message [, format-args]])
-//
-// assert.NotEqual(t, notExpected, actual [, message [, format-args]])
-//
-// assert.True(t, actualBool [, message [, format-args]])
-//
-// assert.False(t, actualBool [, message [, format-args]])
-//
-// assert.Nil(t, actualObject [, message [, format-args]])
-//
-// assert.NotNil(t, actualObject [, message [, format-args]])
-//
-// assert.Empty(t, actualObject [, message [, format-args]])
-//
-// assert.NotEmpty(t, actualObject [, message [, format-args]])
-//
-// assert.Len(t, actualObject, expectedLength, [, message [, format-args]])
-//
-// assert.Error(t, errorObject [, message [, format-args]])
-//
-// assert.NoError(t, errorObject [, message [, format-args]])
-//
-// assert.EqualError(t, theError, errString [, message [, format-args]])
-//
-// assert.Implements(t, (*MyInterface)(nil), new(MyObject) [,message [, format-args]])
-//
-// assert.IsType(t, expectedObject, actualObject [, message [, format-args]])
-//
-// assert.Contains(t, stringOrSlice, substringOrElement [, message [, format-args]])
-//
-// assert.NotContains(t, stringOrSlice, substringOrElement [, message [, format-args]])
-//
-// assert.Panics(t, func(){
-//
-// // call code that should panic
-//
-// } [, message [, format-args]])
-//
-// assert.NotPanics(t, func(){
-//
-// // call code that should not panic
-//
-// } [, message [, format-args]])
-//
-// assert.WithinDuration(t, timeA, timeB, deltaTime, [, message [, format-args]])
-//
-// assert.InDelta(t, numA, numB, delta, [, message [, format-args]])
-//
-// assert.InEpsilon(t, numA, numB, epsilon, [, message [, format-args]])
-//
-// assert package contains Assertions object. it has assertion methods.
-//
-// Here is an overview of the assert functions:
-// assert.Equal(expected, actual [, message [, format-args]])
-//
-// assert.EqualValues(expected, actual [, message [, format-args]])
-//
-// assert.NotEqual(notExpected, actual [, message [, format-args]])
-//
-// assert.True(actualBool [, message [, format-args]])
-//
-// assert.False(actualBool [, message [, format-args]])
-//
-// assert.Nil(actualObject [, message [, format-args]])
-//
-// assert.NotNil(actualObject [, message [, format-args]])
-//
-// assert.Empty(actualObject [, message [, format-args]])
-//
-// assert.NotEmpty(actualObject [, message [, format-args]])
-//
-// assert.Len(actualObject, expectedLength, [, message [, format-args]])
-//
-// assert.Error(errorObject [, message [, format-args]])
-//
-// assert.NoError(errorObject [, message [, format-args]])
-//
-// assert.EqualError(theError, errString [, message [, format-args]])
-//
-// assert.Implements((*MyInterface)(nil), new(MyObject) [,message [, format-args]])
-//
-// assert.IsType(expectedObject, actualObject [, message [, format-args]])
-//
-// assert.Contains(stringOrSlice, substringOrElement [, message [, format-args]])
-//
-// assert.NotContains(stringOrSlice, substringOrElement [, message [, format-args]])
-//
-// assert.Panics(func(){
-//
-// // call code that should panic
-//
-// } [, message [, format-args]])
-//
-// assert.NotPanics(func(){
-//
-// // call code that should not panic
-//
-// } [, message [, format-args]])
-//
-// assert.WithinDuration(timeA, timeB, deltaTime, [, message [, format-args]])
-//
-// assert.InDelta(numA, numB, delta, [, message [, format-args]])
-//
-// assert.InEpsilon(numA, numB, epsilon, [, message [, format-args]])
package assert
diff --git a/Godeps/_workspace/src/github.com/stretchr/testify/assert/forward_assertions.go b/Godeps/_workspace/src/github.com/stretchr/testify/assert/forward_assertions.go
index d8d3f531ea..fe6b664e07 100644
--- a/Godeps/_workspace/src/github.com/stretchr/testify/assert/forward_assertions.go
+++ b/Godeps/_workspace/src/github.com/stretchr/testify/assert/forward_assertions.go
@@ -81,7 +81,7 @@ func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool {
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or a
// slice with len == 0.
//
-// assert.Empty(obj)
+// assert.Empty(obj)
//
// Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool {
@@ -91,9 +91,9 @@ func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool {
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or a
// slice with len == 0.
//
-// if assert.NotEmpty(obj) {
-// assert.Equal("two", obj[1])
-// }
+// if assert.NotEmpty(obj) {
+// assert.Equal("two", obj[1])
+// }
//
// Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool {
@@ -119,7 +119,7 @@ func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool {
return True(a.t, value, msgAndArgs...)
}
-// False asserts that the specified value is true.
+// False asserts that the specified value is false.
//
// assert.False(myBool, "myBool should be false")
//
@@ -263,3 +263,22 @@ func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...inter
func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
return NotRegexp(a.t, rx, str, msgAndArgs...)
}
+
+// Zero asserts that i is the zero value for its type and returns the truth.
+func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool {
+ return Zero(a.t, i, msgAndArgs...)
+}
+
+// NotZero asserts that i is not the zero value for its type and returns the truth.
+func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool {
+ return NotZero(a.t, i, msgAndArgs...)
+}
+
+// JSONEq asserts that two JSON strings are equivalent.
+//
+// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
+//
+// Returns whether the assertion was successful (true) or not (false).
+func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool {
+ return JSONEq(a.t, expected, actual, msgAndArgs...)
+}
diff --git a/Godeps/_workspace/src/github.com/stretchr/testify/assert/http_assertions.go b/Godeps/_workspace/src/github.com/stretchr/testify/assert/http_assertions.go
index 1246e58e0e..437a86ce47 100644
--- a/Godeps/_workspace/src/github.com/stretchr/testify/assert/http_assertions.go
+++ b/Godeps/_workspace/src/github.com/stretchr/testify/assert/http_assertions.go
@@ -10,9 +10,9 @@ import (
// httpCode is a helper that returns HTTP code of the response. It returns -1
// if building a new request fails.
-func httpCode(handler http.HandlerFunc, mode, url string, values url.Values) int {
+func httpCode(handler http.HandlerFunc, method, url string, values url.Values) int {
w := httptest.NewRecorder()
- req, err := http.NewRequest(mode, url+"?"+values.Encode(), nil)
+ req, err := http.NewRequest(method, url+"?"+values.Encode(), nil)
if err != nil {
return -1
}
@@ -25,8 +25,8 @@ func httpCode(handler http.HandlerFunc, mode, url string, values url.Values) int
// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)
//
// Returns whether the assertion was successful (true) or not (false).
-func HTTPSuccess(t TestingT, handler http.HandlerFunc, mode, url string, values url.Values) bool {
- code := httpCode(handler, mode, url, values)
+func HTTPSuccess(t TestingT, handler http.HandlerFunc, method, url string, values url.Values) bool {
+ code := httpCode(handler, method, url, values)
if code == -1 {
return false
}
@@ -38,8 +38,8 @@ func HTTPSuccess(t TestingT, handler http.HandlerFunc, mode, url string, values
// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
//
// Returns whether the assertion was successful (true) or not (false).
-func HTTPRedirect(t TestingT, handler http.HandlerFunc, mode, url string, values url.Values) bool {
- code := httpCode(handler, mode, url, values)
+func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url string, values url.Values) bool {
+ code := httpCode(handler, method, url, values)
if code == -1 {
return false
}
@@ -51,8 +51,8 @@ func HTTPRedirect(t TestingT, handler http.HandlerFunc, mode, url string, values
// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
//
// Returns whether the assertion was successful (true) or not (false).
-func HTTPError(t TestingT, handler http.HandlerFunc, mode, url string, values url.Values) bool {
- code := httpCode(handler, mode, url, values)
+func HTTPError(t TestingT, handler http.HandlerFunc, method, url string, values url.Values) bool {
+ code := httpCode(handler, method, url, values)
if code == -1 {
return false
}
@@ -61,9 +61,9 @@ func HTTPError(t TestingT, handler http.HandlerFunc, mode, url string, values ur
// HTTPBody is a helper that returns HTTP body of the response. It returns
// empty string if building a new request fails.
-func HTTPBody(handler http.HandlerFunc, mode, url string, values url.Values) string {
+func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values) string {
w := httptest.NewRecorder()
- req, err := http.NewRequest(mode, url+"?"+values.Encode(), nil)
+ req, err := http.NewRequest(method, url+"?"+values.Encode(), nil)
if err != nil {
return ""
}
@@ -77,8 +77,8 @@ func HTTPBody(handler http.HandlerFunc, mode, url string, values url.Values) str
// assert.HTTPBodyContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky")
//
// Returns whether the assertion was successful (true) or not (false).
-func HTTPBodyContains(t TestingT, handler http.HandlerFunc, mode, url string, values url.Values, str interface{}) bool {
- body := HTTPBody(handler, mode, url, values)
+func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}) bool {
+ body := HTTPBody(handler, method, url, values)
contains := strings.Contains(body, fmt.Sprint(str))
if !contains {
@@ -94,8 +94,8 @@ func HTTPBodyContains(t TestingT, handler http.HandlerFunc, mode, url string, va
// assert.HTTPBodyNotContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky")
//
// Returns whether the assertion was successful (true) or not (false).
-func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, mode, url string, values url.Values, str interface{}) bool {
- body := HTTPBody(handler, mode, url, values)
+func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}) bool {
+ body := HTTPBody(handler, method, url, values)
contains := strings.Contains(body, fmt.Sprint(str))
if contains {
@@ -114,8 +114,8 @@ func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, mode, url string,
// assert.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
//
// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, mode, url string, values url.Values) bool {
- return HTTPSuccess(a.t, handler, mode, url, values)
+func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method, url string, values url.Values) bool {
+ return HTTPSuccess(a.t, handler, method, url, values)
}
// HTTPRedirect asserts that a specified handler returns a redirect status code.
@@ -123,8 +123,8 @@ func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, mode, url string, val
// assert.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
//
// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, mode, url string, values url.Values) bool {
- return HTTPRedirect(a.t, handler, mode, url, values)
+func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method, url string, values url.Values) bool {
+ return HTTPRedirect(a.t, handler, method, url, values)
}
// HTTPError asserts that a specified handler returns an error status code.
@@ -132,8 +132,8 @@ func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, mode, url string, va
// assert.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
//
// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPError(handler http.HandlerFunc, mode, url string, values url.Values) bool {
- return HTTPError(a.t, handler, mode, url, values)
+func (a *Assertions) HTTPError(handler http.HandlerFunc, method, url string, values url.Values) bool {
+ return HTTPError(a.t, handler, method, url, values)
}
// HTTPBodyContains asserts that a specified handler returns a
@@ -142,8 +142,8 @@ func (a *Assertions) HTTPError(handler http.HandlerFunc, mode, url string, value
// assert.HTTPBodyContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky")
//
// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, mode, url string, values url.Values, str interface{}) bool {
- return HTTPBodyContains(a.t, handler, mode, url, values, str)
+func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method, url string, values url.Values, str interface{}) bool {
+ return HTTPBodyContains(a.t, handler, method, url, values, str)
}
// HTTPBodyNotContains asserts that a specified handler returns a
@@ -152,6 +152,6 @@ func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, mode, url string
// assert.HTTPBodyNotContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky")
//
// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, mode, url string, values url.Values, str interface{}) bool {
- return HTTPBodyNotContains(a.t, handler, mode, url, values, str)
+func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method, url string, values url.Values, str interface{}) bool {
+ return HTTPBodyNotContains(a.t, handler, method, url, values, str)
}
diff --git a/Godeps/_workspace/src/github.com/stretchr/testify/mock/mock.go b/Godeps/_workspace/src/github.com/stretchr/testify/mock/mock.go
index fa8747e29f..bc6c86bc50 100644
--- a/Godeps/_workspace/src/github.com/stretchr/testify/mock/mock.go
+++ b/Godeps/_workspace/src/github.com/stretchr/testify/mock/mock.go
@@ -2,13 +2,15 @@ package mock
import (
"fmt"
- "github.com/stretchr/objx"
- "github.com/stretchr/testify/assert"
"reflect"
+ "regexp"
"runtime"
"strings"
"sync"
"time"
+
+ "github.com/stretchr/objx"
+ "github.com/stretchr/testify/assert"
)
// TestingT is an interface wrapper around *testing.T
@@ -24,6 +26,7 @@ type TestingT interface {
// Call represents a method call and is used for setting expectations,
// as well as recording activity.
type Call struct {
+ Parent *Mock
// The name of the method that was or will be called.
Method string
@@ -46,24 +49,113 @@ type Call struct {
// Holds a handler used to manipulate arguments content that are passed by
// reference. It's useful when mocking methods such as unmarshalers or
// decoders.
- Run func(Arguments)
+ RunFn func(Arguments)
+}
+
+func newCall(parent *Mock, methodName string, methodArguments ...interface{}) *Call {
+ return &Call{
+ Parent: parent,
+ Method: methodName,
+ Arguments: methodArguments,
+ ReturnArguments: make([]interface{}, 0),
+ Repeatability: 0,
+ WaitFor: nil,
+ RunFn: nil,
+ }
+}
+
+func (self *Call) lock() {
+ self.Parent.mutex.Lock()
+}
+
+func (self *Call) unlock() {
+ self.Parent.mutex.Unlock()
+}
+
+func (self *Call) Return(returnArguments ...interface{}) *Call {
+ self.lock()
+ defer self.unlock()
+
+ self.ReturnArguments = returnArguments
+
+ return self
+}
+
+// Once indicates that that the mock should only return the value once.
+//
+// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Once()
+func (self *Call) Once() *Call {
+ return self.Times(1)
+}
+
+// Twice indicates that that the mock should only return the value twice.
+//
+// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Twice()
+func (self *Call) Twice() *Call {
+ return self.Times(2)
+}
+
+// Times indicates that that the mock should only return the indicated number
+// of times.
+//
+// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Times(5)
+func (self *Call) Times(i int) *Call {
+ self.lock()
+ defer self.unlock()
+ self.Repeatability = i
+ return self
+}
+
+// WaitUntil sets the channel that will block the mock's return until its closed
+// or a message is received.
+//
+// Mock.On("MyMethod", arg1, arg2).WaitUntil(time.After(time.Second))
+func (self *Call) WaitUntil(w <-chan time.Time) *Call {
+ self.lock()
+ defer self.unlock()
+ self.WaitFor = w
+ return self
+}
+
+// After sets how long to block until the call returns
+//
+// Mock.On("MyMethod", arg1, arg2).After(time.Second)
+func (self *Call) After(d time.Duration) *Call {
+ return self.WaitUntil(time.After(d))
+}
+
+// Run sets a handler to be called before returning. It can be used when
+// mocking a method such as unmarshalers that takes a pointer to a struct and
+// sets properties in such struct
+//
+// Mock.On("Unmarshal", AnythingOfType("*map[string]interface{}").Return().Run(function(args Arguments) {
+// arg := args.Get(0).(*map[string]interface{})
+// arg["foo"] = "bar"
+// })
+func (self *Call) Run(fn func(Arguments)) *Call {
+ self.lock()
+ defer self.unlock()
+ self.RunFn = fn
+ return self
+}
+
+// On chains a new expectation description onto the mocked interface. This
+// allows syntax like.
+//
+// Mock.
+// On("MyMethod", 1).Return(nil).
+// On("MyOtherMethod", 'a', 'b', 'c').Return(errors.New("Some Error"))
+func (self *Call) On(methodName string, arguments ...interface{}) *Call {
+ return self.Parent.On(methodName, arguments...)
}
// Mock is the workhorse used to track activity on another object.
-// For an example of its usage, refer to the "Example Usage" section at the top of this document.
+// For an example of its usage, refer to the "Example Usage" section at the top
+// of this document.
type Mock struct {
-
- // The method name that is currently
- // being referred to by the On method.
- onMethodName string
-
- // An array of the arguments that are
- // currently being referred to by the On method.
- onMethodArguments Arguments
-
// Represents the calls that are expected of
// an object.
- ExpectedCalls []Call
+ ExpectedCalls []*Call
// Holds the calls that were made to this mocked object.
Calls []Call
@@ -94,90 +186,33 @@ func (m *Mock) TestData() objx.Map {
// being called.
//
// Mock.On("MyMethod", arg1, arg2)
-func (m *Mock) On(methodName string, arguments ...interface{}) *Mock {
- m.onMethodName = methodName
- m.onMethodArguments = arguments
-
+func (self *Mock) On(methodName string, arguments ...interface{}) *Call {
for _, arg := range arguments {
if v := reflect.ValueOf(arg); v.Kind() == reflect.Func {
panic(fmt.Sprintf("cannot use Func in expectations. Use mock.AnythingOfType(\"%T\")", arg))
}
}
- return m
+ self.mutex.Lock()
+ defer self.mutex.Unlock()
+ c := newCall(self, methodName, arguments...)
+ self.ExpectedCalls = append(self.ExpectedCalls, c)
+ return c
}
-// Return finishes a description of an expectation of the method (and arguments)
-// specified in the most recent On method call.
-//
-// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2)
-func (m *Mock) Return(returnArguments ...interface{}) *Mock {
- m.ExpectedCalls = append(m.ExpectedCalls, Call{m.onMethodName, m.onMethodArguments, returnArguments, 0, nil, nil})
- return m
-}
-
-// Once indicates that that the mock should only return the value once.
-//
-// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Once()
-func (m *Mock) Once() {
- m.ExpectedCalls[len(m.ExpectedCalls)-1].Repeatability = 1
-}
-
-// Twice indicates that that the mock should only return the value twice.
-//
-// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Twice()
-func (m *Mock) Twice() {
- m.ExpectedCalls[len(m.ExpectedCalls)-1].Repeatability = 2
-}
-
-// Times indicates that that the mock should only return the indicated number
-// of times.
-//
-// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Times(5)
-func (m *Mock) Times(i int) {
- m.ExpectedCalls[len(m.ExpectedCalls)-1].Repeatability = i
-}
-
-// WaitUntil sets the channel that will block the mock's return until its closed
-// or a message is received.
-//
-// Mock.On("MyMethod", arg1, arg2).WaitUntil(time.After(time.Second))
-func (m *Mock) WaitUntil(w <-chan time.Time) *Mock {
- m.ExpectedCalls[len(m.ExpectedCalls)-1].WaitFor = w
- return m
-}
-
-// After sets how long to block until the call returns
-//
-// Mock.On("MyMethod", arg1, arg2).After(time.Second)
-func (m *Mock) After(d time.Duration) *Mock {
- return m.WaitUntil(time.After(d))
-}
-
-// Run sets a handler to be called before returning. It can be used when
-// mocking a method such as unmarshalers that takes a pointer to a struct and
-// sets properties in such struct
-//
-// Mock.On("Unmarshal", AnythingOfType("*map[string]interface{}").Return().Run(function(args Arguments) {
-// arg := args.Get(0).(*map[string]interface{})
-// arg["foo"] = "bar"
-// })
-func (m *Mock) Run(fn func(Arguments)) *Mock {
- m.ExpectedCalls[len(m.ExpectedCalls)-1].Run = fn
- return m
-}
-
-/*
- Recording and responding to activity
-*/
+// /*
+// Recording and responding to activity
+// */
func (m *Mock) findExpectedCall(method string, arguments ...interface{}) (int, *Call) {
+ m.mutex.Lock()
+ defer m.mutex.Unlock()
for i, call := range m.ExpectedCalls {
if call.Method == method && call.Repeatability > -1 {
_, diffCount := call.Arguments.Diff(arguments)
if diffCount == 0 {
- return i, &call
+ return i, call
}
}
@@ -186,17 +221,16 @@ func (m *Mock) findExpectedCall(method string, arguments ...interface{}) (int, *
}
func (m *Mock) findClosestCall(method string, arguments ...interface{}) (bool, *Call) {
-
diffCount := 0
var closestCall *Call = nil
- for _, call := range m.ExpectedCalls {
+ for _, call := range m.expectedCalls() {
if call.Method == method {
_, tempDiffCount := call.Arguments.Diff(arguments)
if tempDiffCount < diffCount || diffCount == 0 {
diffCount = tempDiffCount
- closestCall = &call
+ closestCall = call
}
}
@@ -215,7 +249,7 @@ func callString(method string, arguments Arguments, includeArgumentValues bool)
if includeArgumentValues {
var argVals []string
for argIndex, arg := range arguments {
- argVals = append(argVals, fmt.Sprintf("%d: %v", argIndex, arg))
+ argVals = append(argVals, fmt.Sprintf("%d: %#v", argIndex, arg))
}
argValsString = fmt.Sprintf("\n\t\t%s", strings.Join(argVals, "\n\t\t"))
}
@@ -228,22 +262,26 @@ func callString(method string, arguments Arguments, includeArgumentValues bool)
// appropriate .On .Return() calls)
// If Call.WaitFor is set, blocks until the channel is closed or receives a message.
func (m *Mock) Called(arguments ...interface{}) Arguments {
- defer m.mutex.Unlock()
- m.mutex.Lock()
-
// get the calling function's name
pc, _, _, ok := runtime.Caller(1)
if !ok {
panic("Couldn't get the caller information")
}
functionPath := runtime.FuncForPC(pc).Name()
+ //Next four lines are required to use GCCGO function naming conventions.
+ //For Ex: github_com_docker_libkv_store_mock.WatchTree.pN39_github_com_docker_libkv_store_mock.Mock
+ //uses inteface information unlike golang github.com/docker/libkv/store/mock.(*Mock).WatchTree
+ //With GCCGO we need to remove interface information starting from pN.
+ re := regexp.MustCompile("\\.pN\\d+_")
+ if re.MatchString(functionPath) {
+ functionPath = re.Split(functionPath, -1)[0]
+ }
parts := strings.Split(functionPath, ".")
functionName := parts[len(parts)-1]
found, call := m.findExpectedCall(functionName, arguments...)
- switch {
- case found < 0:
+ if found < 0 {
// we have to fail here - because we don't know what to do
// as the return arguments. This is because:
//
@@ -258,28 +296,33 @@ func (m *Mock) Called(arguments ...interface{}) Arguments {
} else {
panic(fmt.Sprintf("\nassert: mock: I don't know what to return because the method call was unexpected.\n\tEither do Mock.On(\"%s\").Return(...) first, or remove the %s() call.\n\tThis method was unexpected:\n\t\t%s\n\tat: %s", functionName, functionName, callString(functionName, arguments, true), assert.CallerInfo()))
}
- case call.Repeatability == 1:
- call.Repeatability = -1
- m.ExpectedCalls[found] = *call
- case call.Repeatability > 1:
- call.Repeatability -= 1
- m.ExpectedCalls[found] = *call
+ } else {
+ m.mutex.Lock()
+ switch {
+ case call.Repeatability == 1:
+ call.Repeatability = -1
+
+ case call.Repeatability > 1:
+ call.Repeatability -= 1
+ }
+ m.mutex.Unlock()
}
// add the call
- m.Calls = append(m.Calls, Call{functionName, arguments, make([]interface{}, 0), 0, nil, nil})
+ m.mutex.Lock()
+ m.Calls = append(m.Calls, *newCall(m, functionName, arguments...))
+ m.mutex.Unlock()
// block if specified
if call.WaitFor != nil {
<-call.WaitFor
}
- if call.Run != nil {
- call.Run(arguments)
+ if call.RunFn != nil {
+ call.RunFn(arguments)
}
return call.ReturnArguments
-
}
/*
@@ -302,27 +345,30 @@ func AssertExpectationsForObjects(t TestingT, testObjects ...interface{}) bool {
// AssertExpectations asserts that everything specified with On and Return was
// in fact called as expected. Calls may have occurred in any order.
func (m *Mock) AssertExpectations(t TestingT) bool {
-
var somethingMissing bool = false
var failedExpectations int = 0
// iterate through each expectation
- for _, expectedCall := range m.ExpectedCalls {
- switch {
- case !m.methodWasCalled(expectedCall.Method, expectedCall.Arguments):
+ expectedCalls := m.expectedCalls()
+ for _, expectedCall := range expectedCalls {
+ if !m.methodWasCalled(expectedCall.Method, expectedCall.Arguments) {
somethingMissing = true
failedExpectations++
t.Logf("\u274C\t%s(%s)", expectedCall.Method, expectedCall.Arguments.String())
- case expectedCall.Repeatability > 0:
- somethingMissing = true
- failedExpectations++
- default:
- t.Logf("\u2705\t%s(%s)", expectedCall.Method, expectedCall.Arguments.String())
+ } else {
+ m.mutex.Lock()
+ if expectedCall.Repeatability > 0 {
+ somethingMissing = true
+ failedExpectations++
+ } else {
+ t.Logf("\u2705\t%s(%s)", expectedCall.Method, expectedCall.Arguments.String())
+ }
+ m.mutex.Unlock()
}
}
if somethingMissing {
- t.Errorf("FAIL: %d out of %d expectation(s) were met.\n\tThe code you are testing needs to make %d more call(s).\n\tat: %s", len(m.ExpectedCalls)-failedExpectations, len(m.ExpectedCalls), failedExpectations, assert.CallerInfo())
+ t.Errorf("FAIL: %d out of %d expectation(s) were met.\n\tThe code you are testing needs to make %d more call(s).\n\tat: %s", len(expectedCalls)-failedExpectations, len(expectedCalls), failedExpectations, assert.CallerInfo())
}
return !somethingMissing
@@ -331,18 +377,18 @@ func (m *Mock) AssertExpectations(t TestingT) bool {
// AssertNumberOfCalls asserts that the method was called expectedCalls times.
func (m *Mock) AssertNumberOfCalls(t TestingT, methodName string, expectedCalls int) bool {
var actualCalls int = 0
- for _, call := range m.Calls {
+ for _, call := range m.calls() {
if call.Method == methodName {
actualCalls++
}
}
- return assert.Equal(t, actualCalls, expectedCalls, fmt.Sprintf("Expected number of calls (%d) does not match the actual number of calls (%d).", expectedCalls, actualCalls))
+ return assert.Equal(t, expectedCalls, actualCalls, fmt.Sprintf("Expected number of calls (%d) does not match the actual number of calls (%d).", expectedCalls, actualCalls))
}
// AssertCalled asserts that the method was called.
func (m *Mock) AssertCalled(t TestingT, methodName string, arguments ...interface{}) bool {
if !assert.True(t, m.methodWasCalled(methodName, arguments), fmt.Sprintf("The \"%s\" method should have been called with %d argument(s), but was not.", methodName, len(arguments))) {
- t.Logf("%v", m.ExpectedCalls)
+ t.Logf("%v", m.expectedCalls())
return false
}
return true
@@ -351,14 +397,14 @@ func (m *Mock) AssertCalled(t TestingT, methodName string, arguments ...interfac
// AssertNotCalled asserts that the method was not called.
func (m *Mock) AssertNotCalled(t TestingT, methodName string, arguments ...interface{}) bool {
if !assert.False(t, m.methodWasCalled(methodName, arguments), fmt.Sprintf("The \"%s\" method was called with %d argument(s), but should NOT have been.", methodName, len(arguments))) {
- t.Logf("%v", m.ExpectedCalls)
+ t.Logf("%v", m.expectedCalls())
return false
}
return true
}
func (m *Mock) methodWasCalled(methodName string, expected []interface{}) bool {
- for _, call := range m.Calls {
+ for _, call := range m.calls() {
if call.Method == methodName {
_, differences := Arguments(expected).Diff(call.Arguments)
@@ -374,6 +420,18 @@ func (m *Mock) methodWasCalled(methodName string, expected []interface{}) bool {
return false
}
+func (m *Mock) expectedCalls() []*Call {
+ m.mutex.Lock()
+ defer m.mutex.Unlock()
+ return append([]*Call{}, m.ExpectedCalls...)
+}
+
+func (m *Mock) calls() []Call {
+ m.mutex.Lock()
+ defer m.mutex.Unlock()
+ return append([]Call{}, m.Calls...)
+}
+
/*
Arguments
*/
@@ -400,6 +458,55 @@ func AnythingOfType(t string) AnythingOfTypeArgument {
return AnythingOfTypeArgument(t)
}
+// argumentMatcher performs custom argument matching, returning whether or
+// not the argument is matched by the expectation fixture function.
+type argumentMatcher struct {
+ // fn is a function which accepts one argument, and returns a bool.
+ fn reflect.Value
+}
+
+func (f argumentMatcher) Matches(argument interface{}) bool {
+ expectType := f.fn.Type().In(0)
+
+ if reflect.TypeOf(argument).AssignableTo(expectType) {
+ result := f.fn.Call([]reflect.Value{reflect.ValueOf(argument)})
+ return result[0].Bool()
+ } else {
+ return false
+ }
+}
+
+func (f argumentMatcher) String() string {
+ return fmt.Sprintf("func(%s) bool", f.fn.Type().In(0).Name())
+}
+
+// MatchedBy can be used to match a mock call based on only certain properties
+// from a complex struct or some calculation. It takes a function that will be
+// evaluated with the called argument and will return true when there's a match
+// and false otherwise.
+//
+// Example:
+// m.On("Do", func(req *http.Request) bool { return req.Host == "example.com" })
+//
+// |fn|, must be a function accepting a single argument (of the expected type)
+// which returns a bool. If |fn| doesn't match the required signature,
+// MathedBy() panics.
+func MatchedBy(fn interface{}) argumentMatcher {
+ fnType := reflect.TypeOf(fn)
+
+ if fnType.Kind() != reflect.Func {
+ panic(fmt.Sprintf("assert: arguments: %s is not a func", fn))
+ }
+ if fnType.NumIn() != 1 {
+ panic(fmt.Sprintf("assert: arguments: %s does not take exactly one argument", fn))
+ }
+ if fnType.NumOut() != 1 || fnType.Out(0).Kind() != reflect.Bool {
+ panic(fmt.Sprintf("assert: arguments: %s does not return a bool", fn))
+ }
+
+ return argumentMatcher{fn: reflect.ValueOf(fn)}
+}
+
// Get Returns the argument at the specified index.
func (args Arguments) Get(index int) interface{} {
if index+1 > len(args) {
@@ -447,7 +554,14 @@ func (args Arguments) Diff(objects []interface{}) (string, int) {
expected = args[i]
}
- if reflect.TypeOf(expected) == reflect.TypeOf((*AnythingOfTypeArgument)(nil)).Elem() {
+ if matcher, ok := expected.(argumentMatcher); ok {
+ if matcher.Matches(actual) {
+ output = fmt.Sprintf("%s\t%d: \u2705 %s matched by %s\n", output, i, actual, matcher)
+ } else {
+ differences++
+ output = fmt.Sprintf("%s\t%d: \u2705 %s not matched by %s\n", output, i, actual, matcher)
+ }
+ } else if reflect.TypeOf(expected) == reflect.TypeOf((*AnythingOfTypeArgument)(nil)).Elem() {
// type checking
if reflect.TypeOf(actual).Name() != string(expected.(AnythingOfTypeArgument)) && reflect.TypeOf(actual).String() != string(expected.(AnythingOfTypeArgument)) {
diff --git a/Godeps/_workspace/src/github.com/ugorji/go/codec/0doc.go b/Godeps/_workspace/src/github.com/ugorji/go/codec/0doc.go
index dd8b589de0..bd7361c879 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/0doc.go
+++ b/Godeps/_workspace/src/github.com/ugorji/go/codec/0doc.go
@@ -64,6 +64,7 @@ Rich Feature Set includes:
- Never silently skip data when decoding.
User decides whether to return an error or silently skip data when keys or indexes
in the data stream do not map to fields in the struct.
+ - Detect and error when encoding a cyclic reference (instead of stack overflow shutdown)
- Encode/Decode from/to chan types (for iterative streaming support)
- Drop-in replacement for encoding/json. `json:` key in struct tag supported.
- Provides a RPC Server and Client Codec for net/rpc communication protocol.
@@ -98,7 +99,21 @@ with the standard net/rpc package.
Usage
-Typical usage model:
+The Handle is SAFE for concurrent READ, but NOT SAFE for concurrent modification.
+
+The Encoder and Decoder are NOT safe for concurrent use.
+
+Consequently, the usage model is basically:
+
+ - Create and initialize the Handle before any use.
+ Once created, DO NOT modify it.
+ - Multiple Encoders or Decoders can now use the Handle concurrently.
+ They only read information off the Handle (never write).
+ - However, each Encoder or Decoder MUST not be used concurrently
+ - To re-use an Encoder/Decoder, call Reset(...) on it first.
+ This allows you use state maintained on the Encoder/Decoder.
+
+Sample usage model:
// create and configure Handle
var (
@@ -148,3 +163,37 @@ Typical usage model:
*/
package codec
+// Benefits of go-codec:
+//
+// - encoding/json always reads whole file into memory first.
+// This makes it unsuitable for parsing very large files.
+// - encoding/xml cannot parse into a map[string]interface{}
+// I found this out on reading https://github.com/clbanning/mxj
+
+// TODO:
+//
+// - optimization for codecgen:
+// if len of entity is <= 3 words, then support a value receiver for encode.
+// - (En|De)coder should store an error when it occurs.
+// Until reset, subsequent calls return that error that was stored.
+// This means that free panics must go away.
+// All errors must be raised through errorf method.
+// - Decoding using a chan is good, but incurs concurrency costs.
+// This is because there's no fast way to use a channel without it
+// having to switch goroutines constantly.
+// Callback pattern is still the best. Maybe cnsider supporting something like:
+// type X struct {
+// Name string
+// Ys []Y
+// Ys chan <- Y
+// Ys func(Y) -> call this function for each entry
+// }
+// - Consider adding a isZeroer interface { isZero() bool }
+// It is used within isEmpty, for omitEmpty support.
+// - Consider making Handle used AS-IS within the encoding/decoding session.
+// This means that we don't cache Handle information within the (En|De)coder,
+// except we really need it at Reset(...)
+// - Consider adding math/big support
+// - Consider reducing the size of the generated functions:
+// Maybe use one loop, and put the conditionals in the loop.
+// for ... { if cLen > 0 { if j == cLen { break } } else if dd.CheckBreak() { break } }
diff --git a/Godeps/_workspace/src/github.com/ugorji/go/codec/binc.go b/Godeps/_workspace/src/github.com/ugorji/go/codec/binc.go
index 9dadb0a47b..766d26cf6d 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/binc.go
+++ b/Godeps/_workspace/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,17 @@ func (h *BincHandle) newDecDriver(d *Decoder) decDriver {
return &bincDecDriver{d: d, r: d.r, h: h, br: d.bytes}
}
+func (e *bincEncDriver) reset() {
+ e.w = e.e.w
+ e.s = 0
+ e.m = nil
+}
+
+func (d *bincDecDriver) reset() {
+ d.r = d.d.r
+ d.s = nil
+ d.bd, d.bdRead, d.vd, d.vs = 0, false, 0, 0
+}
+
var _ decDriver = (*bincDecDriver)(nil)
var _ encDriver = (*bincEncDriver)(nil)
diff --git a/Godeps/_workspace/src/github.com/ugorji/go/codec/cbor.go b/Godeps/_workspace/src/github.com/ugorji/go/codec/cbor.go
index c3b88da202..a224cd3a72 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/cbor.go
+++ b/Godeps/_workspace/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()
- d.bdRead = false
- re.Tag = ui
- d.d.decode(&re.Value)
- v = &re
+ n.v = valueTypeExt
+ n.u = d.decUint()
+ n.l = nil
+ // d.bdRead = false
+ // d.d.decode(&re.Value) // handled by decode itself.
// decodeFurther = true
default:
d.d.errorf("decodeNaked: Unrecognized d.bd: 0x%x", d.bd)
@@ -550,8 +556,12 @@ func (d *cborDecDriver) DecodeNaked() (v interface{}, vt valueType, decodeFurthe
// // Now, vv contains the same string "one-byte"
//
type CborHandle struct {
- BasicHandle
binaryEncodingType
+ BasicHandle
+}
+
+func (h *CborHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) {
+ return h.SetExt(rt, tag, &setExtWrapper{i: ext})
}
func (h *CborHandle) newEncDriver(e *Encoder) encDriver {
@@ -562,5 +572,14 @@ func (h *CborHandle) newDecDriver(d *Decoder) decDriver {
return &cborDecDriver{d: d, r: d.r, h: h, br: d.bytes}
}
+func (e *cborEncDriver) reset() {
+ e.w = e.e.w
+}
+
+func (d *cborDecDriver) reset() {
+ d.r = d.d.r
+ d.bd, d.bdRead = 0, false
+}
+
var _ decDriver = (*cborDecDriver)(nil)
var _ encDriver = (*cborEncDriver)(nil)
diff --git a/Godeps/_workspace/src/github.com/ugorji/go/codec/codecgen/gen.go b/Godeps/_workspace/src/github.com/ugorji/go/codec/codecgen/gen.go
index 892df598f8..f370b4c796 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/codecgen/gen.go
+++ b/Godeps/_workspace/src/github.com/ugorji/go/codec/codecgen/gen.go
@@ -14,6 +14,7 @@ import (
"go/build"
"go/parser"
"go/token"
+ "math/rand"
"os"
"os/exec"
"path/filepath"
@@ -23,6 +24,8 @@ import (
"time"
)
+const genCodecPkg = "codec1978" // keep this in sync with codec.genCodecPkg
+
const genFrunMainTmpl = `//+build ignore
package main
@@ -38,24 +41,13 @@ package {{ $.PackageName }}
import (
{{ if not .CodecPkgFiles }}{{ .CodecPkgName }} "{{ .CodecImportPath }}"{{ end }}
-{{/*
- {{ if .Types }}"{{ .ImportPath }}"{{ end }}
- "io"
-*/}}
"os"
"reflect"
"bytes"
+ "strings"
"go/format"
)
-{{/* This is not used anymore. Remove it.
-func write(w io.Writer, s string) {
- if _, err := io.WriteString(w, s); err != nil {
- panic(err)
- }
-}
-*/}}
-
func CodecGenTempWrite{{ .RandString }}() {
fout, err := os.Create("{{ .OutFile }}")
if err != nil {
@@ -69,7 +61,7 @@ func CodecGenTempWrite{{ .RandString }}() {
var t{{ $index }} {{ . }}
typs = append(typs, reflect.TypeOf(t{{ $index }}))
{{ end }}
- {{ if not .CodecPkgFiles }}{{ .CodecPkgName }}.{{ end }}Gen(&out, "{{ .BuildTag }}", "{{ .PackageName }}", {{ .UseUnsafe }}, typs...)
+ {{ if not .CodecPkgFiles }}{{ .CodecPkgName }}.{{ end }}Gen(&out, "{{ .BuildTag }}", "{{ .PackageName }}", "{{ .RandString }}", {{ .UseUnsafe }}, {{ if not .CodecPkgFiles }}{{ .CodecPkgName }}.{{ end }}NewTypeInfos(strings.Split("{{ .StructTags }}", ",")), typs...)
bout, err := format.Source(out.Bytes())
if err != nil {
fout.Write(out.Bytes())
@@ -89,8 +81,8 @@ func CodecGenTempWrite{{ .RandString }}() {
// Tool then executes: "go run __frun__" which creates fout.
// fout contains Codec(En|De)codeSelf implementations for every type T.
//
-func Generate(outfile, buildTag, codecPkgPath string, useUnsafe bool, goRunTag string,
- regexName *regexp.Regexp, deleteTempFile bool, infiles ...string) (err error) {
+func Generate(outfile, buildTag, codecPkgPath string, uid int64, useUnsafe bool, goRunTag string,
+ st string, regexName *regexp.Regexp, deleteTempFile bool, infiles ...string) (err error) {
// For each file, grab AST, find each type, and write a call to it.
if len(infiles) == 0 {
return
@@ -99,6 +91,13 @@ func Generate(outfile, buildTag, codecPkgPath string, useUnsafe bool, goRunTag s
err = errors.New("outfile and codec package path cannot be blank")
return
}
+ if uid < 0 {
+ uid = -uid
+ }
+ if uid == 0 {
+ rr := rand.New(rand.NewSource(time.Now().UnixNano()))
+ uid = 101 + rr.Int63n(9777)
+ }
// We have to parse dir for package, before opening the temp file for writing (else ImportDir fails).
// Also, ImportDir(...) must take an absolute path.
lastdir := filepath.Dir(outfile)
@@ -118,17 +117,19 @@ func Generate(outfile, buildTag, codecPkgPath string, useUnsafe bool, goRunTag s
PackageName string
RandString string
BuildTag string
+ StructTags string
Types []string
CodecPkgFiles bool
UseUnsafe bool
}
tv := tmplT{
- CodecPkgName: "codec1978",
+ CodecPkgName: genCodecPkg,
OutFile: outfile,
CodecImportPath: codecPkgPath,
BuildTag: buildTag,
UseUnsafe: useUnsafe,
- RandString: strconv.FormatInt(time.Now().UnixNano(), 10),
+ RandString: strconv.FormatInt(uid, 10),
+ StructTags: st,
}
tv.ImportPath = pkg.ImportPath
if tv.ImportPath == tv.CodecImportPath {
@@ -259,11 +260,12 @@ func main() {
t := flag.String("t", "", "build tag to put in file")
r := flag.String("r", ".*", "regex for type name to match")
rt := flag.String("rt", "", "tags for go run")
+ st := flag.String("st", "codec,json", "struct tag keys to introspect")
x := flag.Bool("x", false, "keep temp file")
u := flag.Bool("u", false, "Use unsafe, e.g. to avoid unnecessary allocation on []byte->string")
-
+ d := flag.Int64("d", 0, "random identifier for use in generated code")
flag.Parse()
- if err := Generate(*o, *t, *c, *u, *rt,
+ if err := Generate(*o, *t, *c, *d, *u, *rt, *st,
regexp.MustCompile(*r), !*x, flag.Args()...); err != nil {
fmt.Fprintf(os.Stderr, "codecgen error: %v\n", err)
os.Exit(1)
diff --git a/Godeps/_workspace/src/github.com/ugorji/go/codec/decode.go b/Godeps/_workspace/src/github.com/ugorji/go/codec/decode.go
index a2e35d7a15..7e56f1eca5 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/decode.go
+++ b/Godeps/_workspace/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,108 @@ 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)
+ var v2 interface{} = &n.ms[l]
+ d.decode(v2)
+ rvn = reflect.ValueOf(v2).Elem()
+ n.ms = n.ms[:l]
+ } else if d.mtid == mapStrIntfTypId { // for json performance
+ l := len(n.ns)
+ n.ns = append(n.ns, nil)
+ var v2 interface{} = &n.ns[l]
+ d.decode(v2)
+ rvn = reflect.ValueOf(v2).Elem()
+ n.ns = n.ns[:l]
} else {
- rvn = reflect.New(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)
+ var v2 interface{} = &n.ss[l]
+ d.decode(v2)
+ rvn = reflect.ValueOf(v2).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]
+ d.decode(v2)
+ v = *v2
+ n.is = n.is[:l]
+ }
+ 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 +668,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 +780,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 +925,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 +1038,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 +1315,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 +1390,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 +1412,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 +1435,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]
+ d.decode(v2)
+ n.is = n.is[:l]
+ }
}
}
@@ -1096,14 +1508,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 +1539,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 +1578,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 +1612,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 +1653,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 +1665,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 +1695,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 +1730,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 +1740,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 +1819,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 +1840,93 @@ 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
+ }
+}
+
+// nextValueBytes returns the next value in the stream as a set of bytes.
+func (d *Decoder) nextValueBytes() []byte {
+ d.d.uncacheRead()
+ d.r.track()
+ d.swallow()
+ return d.r.stopTrack()
+}
+
// --------------------------------------------------
// decSliceHelper assists when decoding into a slice, from a map or an array in the stream.
// A slice can be set from a map or array in stream. This supports the MapBySlice interface.
type decSliceHelper struct {
- 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 +1957,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 +2015,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/Godeps/_workspace/src/github.com/ugorji/go/codec/encode.go b/Godeps/_workspace/src/github.com/ugorji/go/codec/encode.go
index 38c55be4e8..a874c744b8 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/encode.go
+++ b/Godeps/_workspace/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,10 +97,28 @@ type EncodeOptions struct {
// Canonical representation means that encoding a value will always result in the same
// sequence of bytes.
//
- // This mostly will apply to maps. In this case, codec will do more work to encode the
- // map keys out of band, and then sort them, before writing out the map to the stream.
+ // This only affects maps, as the iteration order for maps is random.
+ //
+ // The implementation MAY use the natural sort order for the map keys if possible:
+ //
+ // - If there is a natural sort order (ie for number, bool, string or []byte keys),
+ // then the map keys are first sorted in natural order and then written
+ // with corresponding map values to the strema.
+ // - If there is no natural sort order, then the map keys will first be
+ // encoded into []byte, and then sorted,
+ // before writing the sorted keys and the corresponding map values to the stream.
+ //
Canonical bool
+ // CheckCircularRef controls whether we check for circular references
+ // and error fast during an encode.
+ //
+ // If enabled, an error is received if a pointer to a struct
+ // references itself either directly or through one of its fields (iteratively).
+ //
+ // This is opt-in, as there may be a performance hit to checking circular references.
+ CheckCircularRef bool
+
// AsSymbols defines what should be encoded as symbols.
//
// Encoding as symbols can reduce the encoded size significantly.
@@ -166,6 +168,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 +252,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 +267,7 @@ func (z *bytesEncWriter) grow(n int) (oldcursor int) {
// ---------------------------------------------
-type encFnInfoX struct {
+type encFnInfo struct {
e *Encoder
ti *typeInfo
xfFn Ext
@@ -272,25 +275,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 +289,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 +327,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 +427,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 +442,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 +464,78 @@ func (f encFnInfo) kSlice(rv reflect.Value) {
// if kind is reflect.Interface, do not pre-determine the
// encoding type, because preEncodeValue may break it down to
// a concrete type and kInterface will bomb.
- var fn encFn
+ var fn *encFn
if rtelem.Kind() != reflect.Interface {
rtelemid := reflect.ValueOf(rtelem).Pointer()
fn = e.getEncFn(rtelemid, rtelem, true, true)
}
// TODO: Consider perf implication of encoding odd index values as symbols if type is string
- if sep {
- for j := 0; j < l; j++ {
- if j > 0 {
- if ti.mbs {
- if j%2 == 0 {
- f.ee.EncodeMapEntrySeparator()
- } else {
- f.ee.EncodeMapKVSeparator()
- }
+ for j := 0; j < l; j++ {
+ if cr != nil {
+ if ti.mbs {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
} else {
- f.ee.EncodeArrayEntrySeparator()
- }
- }
- if f.seq == seqTypeChan {
- if rv2, ok2 := rv.Recv(); ok2 {
- e.encodeValue(rv2, fn)
+ cr.sendContainerState(containerMapValue)
}
} else {
- e.encodeValue(rv.Index(j), fn)
+ cr.sendContainerState(containerArrayElem)
}
}
- } else {
- for j := 0; j < l; j++ {
- if f.seq == seqTypeChan {
- if rv2, ok2 := rv.Recv(); ok2 {
- e.encodeValue(rv2, fn)
- }
+ if f.seq == seqTypeChan {
+ if rv2, ok2 := rv.Recv(); ok2 {
+ e.encodeValue(rv2, fn)
} else {
- e.encodeValue(rv.Index(j), fn)
+ e.encode(nil) // WE HAVE TO DO SOMETHING, so nil if nothing received.
}
+ } else {
+ e.encodeValue(rv.Index(j), fn)
}
}
}
- if sep {
+ if cr != nil {
if ti.mbs {
- f.ee.EncodeMapEnd()
+ cr.sendContainerState(containerMapEnd)
} else {
- f.ee.EncodeArrayEnd()
+ cr.sendContainerState(containerArrayEnd)
}
}
}
-func (f encFnInfo) kStruct(rv reflect.Value) {
+func (f *encFnInfo) kStruct(rv reflect.Value) {
fti := f.ti
e := f.e
+ cr := e.cr
tisfi := fti.sfip
toMap := !(fti.toArray || e.h.StructToArray)
newlen := len(fti.sfi)
- // Use sync.Pool to reduce allocating slices unnecessarily.
- // The cost of the occasional locking is less than the cost of locking.
- var fkvs []encStructFieldKV
- var pool *sync.Pool
- var poolv interface{}
- idxpool := newlen / 8
- if encStructPoolLen != 4 {
- panic(errors.New("encStructPoolLen must be equal to 4")) // defensive, in case it is changed
- }
- if idxpool < encStructPoolLen {
- pool = &encStructPool[idxpool]
- poolv = pool.Get()
- switch vv := poolv.(type) {
- case *[8]encStructFieldKV:
- fkvs = vv[:newlen]
- case *[16]encStructFieldKV:
- fkvs = vv[:newlen]
- case *[32]encStructFieldKV:
- fkvs = vv[:newlen]
- case *[64]encStructFieldKV:
- fkvs = vv[:newlen]
- }
- }
- if fkvs == nil {
- fkvs = make([]encStructFieldKV, newlen)
- }
+ // Use sync.Pool to reduce allocating slices unnecessarily.
+ // The cost of sync.Pool is less than the cost of new allocation.
+ pool, poolv, fkvs := encStructPoolGet(newlen)
+
// if toMap, use the sorted array. If toArray, use unsorted array (to match sequence in struct)
if toMap {
tisfi = fti.sfi
}
newlen = 0
- var kv encStructFieldKV
+ var kv stringRv
for _, si := range tisfi {
- kv.v = si.field(rv, false)
- // if si.i != -1 {
- // rvals[newlen] = rv.Field(int(si.i))
- // } else {
- // rvals[newlen] = rv.FieldByIndex(si.is)
- // }
+ kv.r = si.field(rv, false)
if toMap {
- if si.omitEmpty && isEmptyValue(kv.v) {
+ if si.omitEmpty && isEmptyValue(kv.r) {
continue
}
- kv.k = si.encName
+ kv.v = si.encName
} else {
// use the zero value.
// if a reference or struct, set to nil (so you do not output too much)
- if si.omitEmpty && isEmptyValue(kv.v) {
- switch kv.v.Kind() {
+ if si.omitEmpty && isEmptyValue(kv.r) {
+ switch kv.r.Kind() {
case reflect.Struct, reflect.Interface, reflect.Ptr, reflect.Array,
reflect.Map, reflect.Slice:
- kv.v = reflect.Value{} //encode as nil
+ kv.r = reflect.Value{} //encode as nil
}
}
}
@@ -587,58 +544,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 +591,39 @@ func (f encFnInfo) kStruct(rv reflect.Value) {
}
}
-// func (f encFnInfo) kPtr(rv reflect.Value) {
+// func (f *encFnInfo) kPtr(rv reflect.Value) {
// debugf(">>>>>>> ??? encode kPtr called - shouldn't get called")
// if rv.IsNil() {
-// f.ee.encodeNil()
+// f.e.e.encodeNil()
// return
// }
// f.e.encodeValue(rv.Elem())
// }
-func (f encFnInfo) kInterface(rv reflect.Value) {
- if rv.IsNil() {
- f.ee.EncodeNil()
- return
- }
- f.e.encodeValue(rv.Elem(), encFn{})
-}
+// func (f *encFnInfo) kInterface(rv reflect.Value) {
+// println("kInterface called")
+// debug.PrintStack()
+// if rv.IsNil() {
+// f.e.e.EncodeNil()
+// return
+// }
+// f.e.encodeValue(rv.Elem(), nil)
+// }
-func (f encFnInfo) kMap(rv reflect.Value) {
+func (f *encFnInfo) kMap(rv reflect.Value) {
+ ee := f.e.e
if rv.IsNil() {
- f.ee.EncodeNil()
+ ee.EncodeNil()
return
}
l := rv.Len()
- f.ee.EncodeMapStart(l)
+ ee.EncodeMapStart(l)
e := f.e
- sep := !e.be
+ cr := e.cr
if l == 0 {
- if sep {
- f.ee.EncodeMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
return
}
@@ -691,7 +635,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 +662,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 +679,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 +865,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 +878,26 @@ type rtidEncFn struct {
// An Encoder writes an object to an output stream in the codec format.
type Encoder struct {
// hopefully, reduce derefencing cost by laying the encWriter inside the Encoder
- e encDriver
+ e encDriver
+ // NOTE: Encoder shouldn't call it's write methods,
+ // as the handler MAY need to do some coordination.
w encWriter
- s []rtidEncFn
+ s []encRtidFn
+ ci set
be bool // is binary encoding
+ js bool // is json handle
wi ioEncWriter
wb bytesEncWriter
- h *BasicHandle
+ h *BasicHandle
hh Handle
- f map[uintptr]encFn
- b [scratchByteArrayLen]byte
+
+ cr containerStateRecv
+ as encDriverAsis
+
+ f map[uintptr]*encFn
+ b [scratchByteArrayLen]byte
}
// NewEncoder returns an Encoder for encoding into an io.Writer.
@@ -815,18 +905,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 +916,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 +992,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 +1005,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 +1017,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 +1066,7 @@ func (e *Encoder) encode(iv interface{}) {
v.CodecEncodeSelf(e)
case reflect.Value:
- e.encodeValue(v, encFn{})
+ e.encodeValue(v, nil)
case string:
e.e.EncodeString(c_UTF8, v)
@@ -1009,73 +1133,93 @@ func (e *Encoder) encode(iv interface{}) {
e.e.EncodeStringBytes(c_RAW, *v)
default:
- // canonical mode is not supported for fastpath of maps (but is fine for slices)
- if e.h.Canonical {
- if !fastpathEncodeTypeSwitchSlice(iv, e) {
- e.encodeI(iv, false, false)
- }
- } else if !fastpathEncodeTypeSwitch(iv, e) {
- e.encodeI(iv, false, false)
+ const checkCodecSelfer1 = true // in case T is passed, where *T is a Selfer, still checkCodecSelfer
+ if !fastpathEncodeTypeSwitch(iv, e) {
+ e.encodeI(iv, false, checkCodecSelfer1)
}
}
}
+func (e *Encoder) preEncodeValue(rv reflect.Value) (rv2 reflect.Value, sptr uintptr, proceed bool) {
+ // use a goto statement instead of a recursive function for ptr/interface.
+TOP:
+ switch rv.Kind() {
+ case reflect.Ptr:
+ if rv.IsNil() {
+ e.e.EncodeNil()
+ return
+ }
+ rv = rv.Elem()
+ if e.h.CheckCircularRef && rv.Kind() == reflect.Struct {
+ // TODO: Movable pointers will be an issue here. Future problem.
+ sptr = rv.UnsafeAddr()
+ break TOP
+ }
+ goto TOP
+ case reflect.Interface:
+ if rv.IsNil() {
+ e.e.EncodeNil()
+ return
+ }
+ rv = rv.Elem()
+ goto TOP
+ case reflect.Slice, reflect.Map:
+ if rv.IsNil() {
+ e.e.EncodeNil()
+ return
+ }
+ case reflect.Invalid, reflect.Func:
+ e.e.EncodeNil()
+ return
+ }
+
+ proceed = true
+ rv2 = rv
+ return
+}
+
+func (e *Encoder) doEncodeValue(rv reflect.Value, fn *encFn, sptr uintptr,
+ checkFastpath, checkCodecSelfer bool) {
+ if sptr != 0 {
+ if (&e.ci).add(sptr) {
+ e.errorf("circular reference found: # %d", sptr)
+ }
+ }
+ if fn == nil {
+ rt := rv.Type()
+ rtid := reflect.ValueOf(rt).Pointer()
+ // fn = e.getEncFn(rtid, rt, true, true)
+ fn = e.getEncFn(rtid, rt, checkFastpath, checkCodecSelfer)
+ }
+ fn.f(&fn.i, rv)
+ if sptr != 0 {
+ (&e.ci).remove(sptr)
+ }
+}
+
func (e *Encoder) encodeI(iv interface{}, checkFastpath, checkCodecSelfer bool) {
- if rv, proceed := e.preEncodeValue(reflect.ValueOf(iv)); proceed {
- rt := rv.Type()
- rtid := reflect.ValueOf(rt).Pointer()
- fn := e.getEncFn(rtid, rt, checkFastpath, checkCodecSelfer)
- fn.f(fn.i, rv)
+ if rv, sptr, proceed := e.preEncodeValue(reflect.ValueOf(iv)); proceed {
+ e.doEncodeValue(rv, nil, sptr, checkFastpath, checkCodecSelfer)
}
}
-func (e *Encoder) preEncodeValue(rv reflect.Value) (rv2 reflect.Value, proceed bool) {
-LOOP:
- for {
- switch rv.Kind() {
- case reflect.Ptr, reflect.Interface:
- if rv.IsNil() {
- e.e.EncodeNil()
- return
- }
- rv = rv.Elem()
- continue LOOP
- case reflect.Slice, reflect.Map:
- if rv.IsNil() {
- e.e.EncodeNil()
- return
- }
- case reflect.Invalid, reflect.Func:
- e.e.EncodeNil()
- return
- }
- break
- }
-
- return rv, true
-}
-
-func (e *Encoder) encodeValue(rv reflect.Value, fn encFn) {
+func (e *Encoder) encodeValue(rv reflect.Value, fn *encFn) {
// if a valid fn is passed, it MUST BE for the dereferenced type of rv
- if rv, proceed := e.preEncodeValue(rv); proceed {
- if fn.f == nil {
- rt := rv.Type()
- rtid := reflect.ValueOf(rt).Pointer()
- fn = e.getEncFn(rtid, rt, true, true)
- }
- fn.f(fn.i, rv)
+ if rv, sptr, proceed := e.preEncodeValue(rv); proceed {
+ e.doEncodeValue(rv, fn, sptr, true, true)
}
}
-func (e *Encoder) getEncFn(rtid uintptr, rt reflect.Type, checkFastpath, checkCodecSelfer bool) (fn encFn) {
+func (e *Encoder) getEncFn(rtid uintptr, rt reflect.Type, checkFastpath, checkCodecSelfer bool) (fn *encFn) {
// rtid := reflect.ValueOf(rt).Pointer()
var ok bool
if useMapForCodecCache {
fn, ok = e.f[rtid]
} else {
- for _, v := range e.s {
+ for i := range e.s {
+ v := &(e.s[i])
if v.rtid == rtid {
- fn, ok = v.fn, true
+ fn, ok = &(v.fn), true
break
}
}
@@ -1083,37 +1227,47 @@ func (e *Encoder) getEncFn(rtid uintptr, rt reflect.Type, checkFastpath, checkCo
if ok {
return
}
- // fi.encFnInfoX = new(encFnInfoX)
- ti := getTypeInfo(rtid, rt)
- var fi encFnInfo
- fi.ee = e.e
+
+ if useMapForCodecCache {
+ if e.f == nil {
+ e.f = make(map[uintptr]*encFn, initCollectionCap)
+ }
+ fn = new(encFn)
+ e.f[rtid] = fn
+ } else {
+ if e.s == nil {
+ e.s = make([]encRtidFn, 0, initCollectionCap)
+ }
+ e.s = append(e.s, encRtidFn{rtid: rtid})
+ fn = &(e.s[len(e.s)-1]).fn
+ }
+
+ ti := e.h.getTypeInfo(rtid, rt)
+ fi := &(fn.i)
+ fi.e = e
+ fi.ti = ti
if checkCodecSelfer && ti.cs {
- fi.encFnInfoX = &encFnInfoX{e: e, ti: ti}
- fn.f = (encFnInfo).selferMarshal
+ fn.f = (*encFnInfo).selferMarshal
} else if rtid == rawExtTypId {
- fi.encFnInfoX = &encFnInfoX{e: e, ti: ti}
- fn.f = (encFnInfo).rawExt
+ fn.f = (*encFnInfo).rawExt
} else if e.e.IsBuiltinType(rtid) {
- fi.encFnInfoX = &encFnInfoX{e: e, ti: ti}
- fn.f = (encFnInfo).builtin
+ fn.f = (*encFnInfo).builtin
} else if xfFn := e.h.getExt(rtid); xfFn != nil {
- // fi.encFnInfoX = new(encFnInfoX)
- fi.encFnInfoX = &encFnInfoX{e: e, ti: ti}
fi.xfTag, fi.xfFn = xfFn.tag, xfFn.ext
- fn.f = (encFnInfo).ext
+ fn.f = (*encFnInfo).ext
} else if supportMarshalInterfaces && e.be && ti.bm {
- fi.encFnInfoX = &encFnInfoX{e: e, ti: ti}
- fn.f = (encFnInfo).binaryMarshal
+ fn.f = (*encFnInfo).binaryMarshal
+ } else if supportMarshalInterfaces && !e.be && e.js && ti.jm {
+ //If JSON, we should check JSONMarshal before textMarshal
+ fn.f = (*encFnInfo).jsonMarshal
} else if supportMarshalInterfaces && !e.be && ti.tm {
- fi.encFnInfoX = &encFnInfoX{e: e, ti: ti}
- fn.f = (encFnInfo).textMarshal
+ fn.f = (*encFnInfo).textMarshal
} else {
rk := rt.Kind()
if fastpathEnabled && checkFastpath && (rk == reflect.Map || rk == reflect.Slice) {
- if rt.PkgPath() == "" {
+ if rt.PkgPath() == "" { // un-named slice or map
if idx := fastpathAV.index(rtid); idx != -1 {
- fi.encFnInfoX = &encFnInfoX{e: e, ti: ti}
fn.f = fastpathAV[idx].encfn
}
} else {
@@ -1129,8 +1283,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 +1292,67 @@ func (e *Encoder) getEncFn(rtid uintptr, rt reflect.Type, checkFastpath, checkCo
if fn.f == nil {
switch rk {
case reflect.Bool:
- fn.f = (encFnInfo).kBool
+ fn.f = (*encFnInfo).kBool
case reflect.String:
- fn.f = (encFnInfo).kString
+ fn.f = (*encFnInfo).kString
case reflect.Float64:
- fn.f = (encFnInfo).kFloat64
+ fn.f = (*encFnInfo).kFloat64
case reflect.Float32:
- fn.f = (encFnInfo).kFloat32
+ fn.f = (*encFnInfo).kFloat32
case reflect.Int, reflect.Int8, reflect.Int64, reflect.Int32, reflect.Int16:
- fn.f = (encFnInfo).kInt
- case reflect.Uint8, reflect.Uint64, reflect.Uint, reflect.Uint32, reflect.Uint16:
- fn.f = (encFnInfo).kUint
+ fn.f = (*encFnInfo).kInt
+ case reflect.Uint8, reflect.Uint64, reflect.Uint, reflect.Uint32, reflect.Uint16, reflect.Uintptr:
+ fn.f = (*encFnInfo).kUint
case reflect.Invalid:
- fn.f = (encFnInfo).kInvalid
+ fn.f = (*encFnInfo).kInvalid
case reflect.Chan:
- fi.encFnInfoX = &encFnInfoX{e: e, ti: ti, seq: seqTypeChan}
- fn.f = (encFnInfo).kSlice
+ fi.seq = seqTypeChan
+ fn.f = (*encFnInfo).kSlice
case reflect.Slice:
- fi.encFnInfoX = &encFnInfoX{e: e, ti: ti, seq: seqTypeSlice}
- fn.f = (encFnInfo).kSlice
+ fi.seq = seqTypeSlice
+ fn.f = (*encFnInfo).kSlice
case reflect.Array:
- fi.encFnInfoX = &encFnInfoX{e: e, ti: ti, seq: seqTypeArray}
- fn.f = (encFnInfo).kSlice
+ fi.seq = seqTypeArray
+ fn.f = (*encFnInfo).kSlice
case reflect.Struct:
- fi.encFnInfoX = &encFnInfoX{e: e, ti: ti}
- fn.f = (encFnInfo).kStruct
+ fn.f = (*encFnInfo).kStruct
+ // reflect.Ptr and reflect.Interface are handled already by preEncodeValue
// case reflect.Ptr:
- // fn.f = (encFnInfo).kPtr
- case reflect.Interface:
- fi.encFnInfoX = &encFnInfoX{e: e, ti: ti}
- fn.f = (encFnInfo).kInterface
+ // fn.f = (*encFnInfo).kPtr
+ // case reflect.Interface:
+ // fn.f = (*encFnInfo).kInterface
case reflect.Map:
- fi.encFnInfoX = &encFnInfoX{e: e, ti: ti}
- fn.f = (encFnInfo).kMap
+ fn.f = (*encFnInfo).kMap
default:
- fn.f = (encFnInfo).kErr
+ fn.f = (*encFnInfo).kErr
}
}
}
- fn.i = fi
- if useMapForCodecCache {
- if e.f == nil {
- e.f = make(map[uintptr]encFn, 32)
- }
- e.f[rtid] = fn
- } else {
- if e.s == nil {
- e.s = make([]rtidEncFn, 0, 32)
- }
- e.s = append(e.s, rtidEncFn{rtid, fn})
- }
return
}
+func (e *Encoder) marshal(bs []byte, fnerr error, asis bool, c charEncoding) {
+ if fnerr != nil {
+ panic(fnerr)
+ }
+ if bs == nil {
+ e.e.EncodeNil()
+ } else if asis {
+ e.asis(bs)
+ } else {
+ e.e.EncodeStringBytes(c, bs)
+ }
+}
+
+func (e *Encoder) asis(v []byte) {
+ if e.as == nil {
+ e.w.writeb(v)
+ } else {
+ e.as.EncodeAsis(v)
+ }
+}
+
func (e *Encoder) errorf(format string, params ...interface{}) {
err := fmt.Errorf(format, params...)
panic(err)
@@ -1200,12 +1360,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 +1374,42 @@ const encStructPoolLen = 4
var encStructPool [encStructPoolLen]sync.Pool
func init() {
- encStructPool[0].New = func() interface{} { return new([8]encStructFieldKV) }
- encStructPool[1].New = func() interface{} { return new([16]encStructFieldKV) }
- encStructPool[2].New = func() interface{} { return new([32]encStructFieldKV) }
- encStructPool[3].New = func() interface{} { return new([64]encStructFieldKV) }
+ encStructPool[0].New = func() interface{} { return new([8]stringRv) }
+ encStructPool[1].New = func() interface{} { return new([16]stringRv) }
+ encStructPool[2].New = func() interface{} { return new([32]stringRv) }
+ encStructPool[3].New = func() interface{} { return new([64]stringRv) }
+ encStructPool[4].New = func() interface{} { return new([128]stringRv) }
+}
+
+func encStructPoolGet(newlen int) (p *sync.Pool, v interface{}, s []stringRv) {
+ // if encStructPoolLen != 5 { // constant chec, so removed at build time.
+ // panic(errors.New("encStructPoolLen must be equal to 4")) // defensive, in case it is changed
+ // }
+ // idxpool := newlen / 8
+ if newlen <= 8 {
+ p = &encStructPool[0]
+ v = p.Get()
+ s = v.(*[8]stringRv)[:newlen]
+ } else if newlen <= 16 {
+ p = &encStructPool[1]
+ v = p.Get()
+ s = v.(*[16]stringRv)[:newlen]
+ } else if newlen <= 32 {
+ p = &encStructPool[2]
+ v = p.Get()
+ s = v.(*[32]stringRv)[:newlen]
+ } else if newlen <= 64 {
+ p = &encStructPool[3]
+ v = p.Get()
+ s = v.(*[64]stringRv)[:newlen]
+ } else if newlen <= 128 {
+ p = &encStructPool[4]
+ v = p.Get()
+ s = v.(*[128]stringRv)[:newlen]
+ } else {
+ s = make([]stringRv, newlen)
+ }
+ return
}
// ----------------------------------------
diff --git a/Godeps/_workspace/src/github.com/ugorji/go/codec/fast-path.generated.go b/Godeps/_workspace/src/github.com/ugorji/go/codec/fast-path.generated.go
index b0f7f8070f..cf6e00df21 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/fast-path.generated.go
+++ b/Godeps/_workspace/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,12830 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool {
// -- -- fast path functions
-func (f encFnInfo) fastpathEncSliceIntfR(rv reflect.Value) {
- fastpathTV.EncSliceIntfV(rv.Interface().([]interface{}), fastpathCheckNilFalse, f.e)
+func (f *encFnInfo) fastpathEncSliceIntfR(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceIntfV(rv.Interface().([]interface{}), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceIntfV(rv.Interface().([]interface{}), fastpathCheckNilFalse, f.e)
+ }
}
func (_ fastpathT) EncSliceIntfV(v []interface{}, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeArrayStart(len(v))
- if e.be {
- for _, v2 := range v {
- e.encode(v2)
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
- } else {
- for j, v2 := range v {
- if j > 0 {
- ee.EncodeArrayEntrySeparator()
- }
- e.encode(v2)
- }
- ee.EncodeArrayEnd()
+ e.encode(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
}
}
-func (f encFnInfo) fastpathEncSliceStringR(rv reflect.Value) {
- fastpathTV.EncSliceStringV(rv.Interface().([]string), fastpathCheckNilFalse, f.e)
+func (_ fastpathT) EncAsMapSliceIntfV(v []interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ e.encode(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceStringR(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceStringV(rv.Interface().([]string), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceStringV(rv.Interface().([]string), fastpathCheckNilFalse, f.e)
+ }
}
func (_ fastpathT) EncSliceStringV(v []string, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeArrayStart(len(v))
- if e.be {
- for _, v2 := range v {
- ee.EncodeString(c_UTF8, v2)
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
- } else {
- for j, v2 := range v {
- if j > 0 {
- ee.EncodeArrayEntrySeparator()
- }
- ee.EncodeString(c_UTF8, v2)
- }
- ee.EncodeArrayEnd()
+ ee.EncodeString(c_UTF8, v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
}
}
-func (f encFnInfo) fastpathEncSliceFloat32R(rv reflect.Value) {
- fastpathTV.EncSliceFloat32V(rv.Interface().([]float32), fastpathCheckNilFalse, f.e)
+func (_ fastpathT) EncAsMapSliceStringV(v []string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeString(c_UTF8, v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceFloat32R(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceFloat32V(rv.Interface().([]float32), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceFloat32V(rv.Interface().([]float32), fastpathCheckNilFalse, f.e)
+ }
}
func (_ fastpathT) EncSliceFloat32V(v []float32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeArrayStart(len(v))
- if e.be {
- for _, v2 := range v {
- ee.EncodeFloat32(v2)
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
- } else {
- for j, v2 := range v {
- if j > 0 {
- ee.EncodeArrayEntrySeparator()
- }
- ee.EncodeFloat32(v2)
- }
- ee.EncodeArrayEnd()
+ ee.EncodeFloat32(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
}
}
-func (f encFnInfo) fastpathEncSliceFloat64R(rv reflect.Value) {
- fastpathTV.EncSliceFloat64V(rv.Interface().([]float64), fastpathCheckNilFalse, f.e)
+func (_ fastpathT) EncAsMapSliceFloat32V(v []float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeFloat32(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceFloat64R(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceFloat64V(rv.Interface().([]float64), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceFloat64V(rv.Interface().([]float64), fastpathCheckNilFalse, f.e)
+ }
}
func (_ fastpathT) EncSliceFloat64V(v []float64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeArrayStart(len(v))
- if e.be {
- for _, v2 := range v {
- ee.EncodeFloat64(v2)
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
- } else {
- for j, v2 := range v {
- if j > 0 {
- ee.EncodeArrayEntrySeparator()
- }
- ee.EncodeFloat64(v2)
- }
- ee.EncodeArrayEnd()
+ ee.EncodeFloat64(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
}
}
-func (f encFnInfo) fastpathEncSliceUintR(rv reflect.Value) {
- fastpathTV.EncSliceUintV(rv.Interface().([]uint), fastpathCheckNilFalse, f.e)
+func (_ fastpathT) EncAsMapSliceFloat64V(v []float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeFloat64(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceUintR(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceUintV(rv.Interface().([]uint), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceUintV(rv.Interface().([]uint), fastpathCheckNilFalse, f.e)
+ }
}
func (_ fastpathT) EncSliceUintV(v []uint, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeArrayStart(len(v))
- if e.be {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
- } else {
- for j, v2 := range v {
- if j > 0 {
- ee.EncodeArrayEntrySeparator()
- }
- ee.EncodeUint(uint64(v2))
- }
- ee.EncodeArrayEnd()
+ ee.EncodeUint(uint64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
}
}
-func (f encFnInfo) fastpathEncSliceUint16R(rv reflect.Value) {
- fastpathTV.EncSliceUint16V(rv.Interface().([]uint16), fastpathCheckNilFalse, f.e)
+func (_ fastpathT) EncAsMapSliceUintV(v []uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceUint16R(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceUint16V(rv.Interface().([]uint16), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceUint16V(rv.Interface().([]uint16), fastpathCheckNilFalse, f.e)
+ }
}
func (_ fastpathT) EncSliceUint16V(v []uint16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeArrayStart(len(v))
- if e.be {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
- } else {
- for j, v2 := range v {
- if j > 0 {
- ee.EncodeArrayEntrySeparator()
- }
- ee.EncodeUint(uint64(v2))
- }
- ee.EncodeArrayEnd()
+ ee.EncodeUint(uint64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
}
}
-func (f encFnInfo) fastpathEncSliceUint32R(rv reflect.Value) {
- fastpathTV.EncSliceUint32V(rv.Interface().([]uint32), fastpathCheckNilFalse, f.e)
+func (_ fastpathT) EncAsMapSliceUint16V(v []uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceUint32R(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceUint32V(rv.Interface().([]uint32), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceUint32V(rv.Interface().([]uint32), fastpathCheckNilFalse, f.e)
+ }
}
func (_ fastpathT) EncSliceUint32V(v []uint32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeArrayStart(len(v))
- if e.be {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
- } else {
- for j, v2 := range v {
- if j > 0 {
- ee.EncodeArrayEntrySeparator()
- }
- ee.EncodeUint(uint64(v2))
- }
- ee.EncodeArrayEnd()
+ ee.EncodeUint(uint64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
}
}
-func (f encFnInfo) fastpathEncSliceUint64R(rv reflect.Value) {
- fastpathTV.EncSliceUint64V(rv.Interface().([]uint64), fastpathCheckNilFalse, f.e)
+func (_ fastpathT) EncAsMapSliceUint32V(v []uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceUint64R(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceUint64V(rv.Interface().([]uint64), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceUint64V(rv.Interface().([]uint64), fastpathCheckNilFalse, f.e)
+ }
}
func (_ fastpathT) EncSliceUint64V(v []uint64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeArrayStart(len(v))
- if e.be {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
- } else {
- for j, v2 := range v {
- if j > 0 {
- ee.EncodeArrayEntrySeparator()
- }
- ee.EncodeUint(uint64(v2))
- }
- ee.EncodeArrayEnd()
+ ee.EncodeUint(uint64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
}
}
-func (f encFnInfo) fastpathEncSliceIntR(rv reflect.Value) {
- fastpathTV.EncSliceIntV(rv.Interface().([]int), fastpathCheckNilFalse, f.e)
+func (_ fastpathT) EncAsMapSliceUint64V(v []uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceUintptrR(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceUintptrV(rv.Interface().([]uintptr), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceUintptrV(rv.Interface().([]uintptr), fastpathCheckNilFalse, f.e)
+ }
+}
+func (_ fastpathT) EncSliceUintptrV(v []uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeArrayStart(len(v))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
+ }
+ e.encode(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
+ }
+}
+
+func (_ fastpathT) EncAsMapSliceUintptrV(v []uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ e.encode(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceIntR(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceIntV(rv.Interface().([]int), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceIntV(rv.Interface().([]int), fastpathCheckNilFalse, f.e)
+ }
}
func (_ fastpathT) EncSliceIntV(v []int, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeArrayStart(len(v))
- if e.be {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
- } else {
- for j, v2 := range v {
- if j > 0 {
- ee.EncodeArrayEntrySeparator()
- }
- ee.EncodeInt(int64(v2))
- }
- ee.EncodeArrayEnd()
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
}
}
-func (f encFnInfo) fastpathEncSliceInt8R(rv reflect.Value) {
- fastpathTV.EncSliceInt8V(rv.Interface().([]int8), fastpathCheckNilFalse, f.e)
+func (_ fastpathT) EncAsMapSliceIntV(v []int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceInt8R(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceInt8V(rv.Interface().([]int8), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceInt8V(rv.Interface().([]int8), fastpathCheckNilFalse, f.e)
+ }
}
func (_ fastpathT) EncSliceInt8V(v []int8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeArrayStart(len(v))
- if e.be {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
- } else {
- for j, v2 := range v {
- if j > 0 {
- ee.EncodeArrayEntrySeparator()
- }
- ee.EncodeInt(int64(v2))
- }
- ee.EncodeArrayEnd()
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
}
}
-func (f encFnInfo) fastpathEncSliceInt16R(rv reflect.Value) {
- fastpathTV.EncSliceInt16V(rv.Interface().([]int16), fastpathCheckNilFalse, f.e)
+func (_ fastpathT) EncAsMapSliceInt8V(v []int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceInt16R(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceInt16V(rv.Interface().([]int16), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceInt16V(rv.Interface().([]int16), fastpathCheckNilFalse, f.e)
+ }
}
func (_ fastpathT) EncSliceInt16V(v []int16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeArrayStart(len(v))
- if e.be {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
- } else {
- for j, v2 := range v {
- if j > 0 {
- ee.EncodeArrayEntrySeparator()
- }
- ee.EncodeInt(int64(v2))
- }
- ee.EncodeArrayEnd()
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
}
}
-func (f encFnInfo) fastpathEncSliceInt32R(rv reflect.Value) {
- fastpathTV.EncSliceInt32V(rv.Interface().([]int32), fastpathCheckNilFalse, f.e)
+func (_ fastpathT) EncAsMapSliceInt16V(v []int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceInt32R(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceInt32V(rv.Interface().([]int32), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceInt32V(rv.Interface().([]int32), fastpathCheckNilFalse, f.e)
+ }
}
func (_ fastpathT) EncSliceInt32V(v []int32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeArrayStart(len(v))
- if e.be {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
- } else {
- for j, v2 := range v {
- if j > 0 {
- ee.EncodeArrayEntrySeparator()
- }
- ee.EncodeInt(int64(v2))
- }
- ee.EncodeArrayEnd()
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
}
}
-func (f encFnInfo) fastpathEncSliceInt64R(rv reflect.Value) {
- fastpathTV.EncSliceInt64V(rv.Interface().([]int64), fastpathCheckNilFalse, f.e)
+func (_ fastpathT) EncAsMapSliceInt32V(v []int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceInt64R(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceInt64V(rv.Interface().([]int64), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceInt64V(rv.Interface().([]int64), fastpathCheckNilFalse, f.e)
+ }
}
func (_ fastpathT) EncSliceInt64V(v []int64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeArrayStart(len(v))
- if e.be {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
- } else {
- for j, v2 := range v {
- if j > 0 {
- ee.EncodeArrayEntrySeparator()
- }
- ee.EncodeInt(int64(v2))
- }
- ee.EncodeArrayEnd()
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
}
}
-func (f encFnInfo) fastpathEncSliceBoolR(rv reflect.Value) {
- fastpathTV.EncSliceBoolV(rv.Interface().([]bool), fastpathCheckNilFalse, f.e)
+func (_ fastpathT) EncAsMapSliceInt64V(v []int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceBoolR(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceBoolV(rv.Interface().([]bool), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceBoolV(rv.Interface().([]bool), fastpathCheckNilFalse, f.e)
+ }
}
func (_ fastpathT) EncSliceBoolV(v []bool, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeArrayStart(len(v))
- if e.be {
- for _, v2 := range v {
- ee.EncodeBool(v2)
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
- } else {
- for j, v2 := range v {
- if j > 0 {
- ee.EncodeArrayEntrySeparator()
- }
- ee.EncodeBool(v2)
- }
- ee.EncodeArrayEnd()
+ ee.EncodeBool(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntfIntfR(rv reflect.Value) {
+func (_ fastpathT) EncAsMapSliceBoolV(v []bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeBool(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapIntfIntfR(rv reflect.Value) {
fastpathTV.EncMapIntfIntfV(rv.Interface().(map[interface{}]interface{}), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntfIntfV(v map[interface{}]interface{}, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- e.encode(k2)
- e.encode(v2)
+ if e.h.Canonical {
+ var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
+ e2 := NewEncoderBytes(&mksv, e.hh)
+ v2 := make([]bytesI, len(v))
+ var i, l int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
e.encode(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
e.encode(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntfStringR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntfStringR(rv reflect.Value) {
fastpathTV.EncMapIntfStringV(rv.Interface().(map[interface{}]string), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntfStringV(v map[interface{}]string, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeString(c_UTF8, v2)
+ if e.h.Canonical {
+ var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
+ e2 := NewEncoderBytes(&mksv, e.hh)
+ v2 := make([]bytesI, len(v))
+ var i, l int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
e.encode(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeString(c_UTF8, v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntfUintR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntfUintR(rv reflect.Value) {
fastpathTV.EncMapIntfUintV(rv.Interface().(map[interface{}]uint), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntfUintV(v map[interface{}]uint, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
+ e2 := NewEncoderBytes(&mksv, e.hh)
+ v2 := make([]bytesI, len(v))
+ var i, l int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
e.encode(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntfUint8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntfUint8R(rv reflect.Value) {
fastpathTV.EncMapIntfUint8V(rv.Interface().(map[interface{}]uint8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntfUint8V(v map[interface{}]uint8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
+ e2 := NewEncoderBytes(&mksv, e.hh)
+ v2 := make([]bytesI, len(v))
+ var i, l int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
e.encode(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntfUint16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntfUint16R(rv reflect.Value) {
fastpathTV.EncMapIntfUint16V(rv.Interface().(map[interface{}]uint16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntfUint16V(v map[interface{}]uint16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
+ e2 := NewEncoderBytes(&mksv, e.hh)
+ v2 := make([]bytesI, len(v))
+ var i, l int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
e.encode(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntfUint32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntfUint32R(rv reflect.Value) {
fastpathTV.EncMapIntfUint32V(rv.Interface().(map[interface{}]uint32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntfUint32V(v map[interface{}]uint32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
+ e2 := NewEncoderBytes(&mksv, e.hh)
+ v2 := make([]bytesI, len(v))
+ var i, l int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
e.encode(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntfUint64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntfUint64R(rv reflect.Value) {
fastpathTV.EncMapIntfUint64V(rv.Interface().(map[interface{}]uint64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntfUint64V(v map[interface{}]uint64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
+ e2 := NewEncoderBytes(&mksv, e.hh)
+ v2 := make([]bytesI, len(v))
+ var i, l int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
e.encode(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntfIntR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntfUintptrR(rv reflect.Value) {
+ fastpathTV.EncMapIntfUintptrV(rv.Interface().(map[interface{}]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapIntfUintptrV(v map[interface{}]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
+ e2 := NewEncoderBytes(&mksv, e.hh)
+ v2 := make([]bytesI, len(v))
+ var i, l int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapIntfIntR(rv reflect.Value) {
fastpathTV.EncMapIntfIntV(rv.Interface().(map[interface{}]int), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntfIntV(v map[interface{}]int, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
+ e2 := NewEncoderBytes(&mksv, e.hh)
+ v2 := make([]bytesI, len(v))
+ var i, l int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
e.encode(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntfInt8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntfInt8R(rv reflect.Value) {
fastpathTV.EncMapIntfInt8V(rv.Interface().(map[interface{}]int8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntfInt8V(v map[interface{}]int8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
+ e2 := NewEncoderBytes(&mksv, e.hh)
+ v2 := make([]bytesI, len(v))
+ var i, l int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
e.encode(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntfInt16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntfInt16R(rv reflect.Value) {
fastpathTV.EncMapIntfInt16V(rv.Interface().(map[interface{}]int16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntfInt16V(v map[interface{}]int16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
+ e2 := NewEncoderBytes(&mksv, e.hh)
+ v2 := make([]bytesI, len(v))
+ var i, l int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
e.encode(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntfInt32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntfInt32R(rv reflect.Value) {
fastpathTV.EncMapIntfInt32V(rv.Interface().(map[interface{}]int32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntfInt32V(v map[interface{}]int32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
+ e2 := NewEncoderBytes(&mksv, e.hh)
+ v2 := make([]bytesI, len(v))
+ var i, l int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
e.encode(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntfInt64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntfInt64R(rv reflect.Value) {
fastpathTV.EncMapIntfInt64V(rv.Interface().(map[interface{}]int64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntfInt64V(v map[interface{}]int64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
+ e2 := NewEncoderBytes(&mksv, e.hh)
+ v2 := make([]bytesI, len(v))
+ var i, l int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
e.encode(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntfFloat32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntfFloat32R(rv reflect.Value) {
fastpathTV.EncMapIntfFloat32V(rv.Interface().(map[interface{}]float32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntfFloat32V(v map[interface{}]float32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeFloat32(v2)
+ if e.h.Canonical {
+ var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
+ e2 := NewEncoderBytes(&mksv, e.hh)
+ v2 := make([]bytesI, len(v))
+ var i, l int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
e.encode(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat32(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntfFloat64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntfFloat64R(rv reflect.Value) {
fastpathTV.EncMapIntfFloat64V(rv.Interface().(map[interface{}]float64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntfFloat64V(v map[interface{}]float64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeFloat64(v2)
+ if e.h.Canonical {
+ var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
+ e2 := NewEncoderBytes(&mksv, e.hh)
+ v2 := make([]bytesI, len(v))
+ var i, l int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
e.encode(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat64(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntfBoolR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntfBoolR(rv reflect.Value) {
fastpathTV.EncMapIntfBoolV(rv.Interface().(map[interface{}]bool), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntfBoolV(v map[interface{}]bool, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeBool(v2)
+ if e.h.Canonical {
+ var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
+ e2 := NewEncoderBytes(&mksv, e.hh)
+ v2 := make([]bytesI, len(v))
+ var i, l int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
e.encode(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeBool(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapStringIntfR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapStringIntfR(rv reflect.Value) {
fastpathTV.EncMapStringIntfV(rv.Interface().(map[string]interface{}), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapStringIntfV(v map[string]interface{}, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
- if e.be {
- for k2, v2 := range v {
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- e.encode(v2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[string(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
e.encode(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapStringStringR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapStringStringR(rv reflect.Value) {
fastpathTV.EncMapStringStringV(rv.Interface().(map[string]string), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapStringStringV(v map[string]string, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
- if e.be {
- for k2, v2 := range v {
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeString(c_UTF8, v2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[string(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeString(c_UTF8, v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapStringUintR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapStringUintR(rv reflect.Value) {
fastpathTV.EncMapStringUintV(rv.Interface().(map[string]uint), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapStringUintV(v map[string]uint, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
- if e.be {
- for k2, v2 := range v {
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeUint(uint64(v2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[string(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapStringUint8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapStringUint8R(rv reflect.Value) {
fastpathTV.EncMapStringUint8V(rv.Interface().(map[string]uint8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapStringUint8V(v map[string]uint8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
- if e.be {
- for k2, v2 := range v {
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeUint(uint64(v2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[string(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapStringUint16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapStringUint16R(rv reflect.Value) {
fastpathTV.EncMapStringUint16V(rv.Interface().(map[string]uint16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapStringUint16V(v map[string]uint16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
- if e.be {
- for k2, v2 := range v {
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeUint(uint64(v2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[string(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapStringUint32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapStringUint32R(rv reflect.Value) {
fastpathTV.EncMapStringUint32V(rv.Interface().(map[string]uint32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapStringUint32V(v map[string]uint32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
- if e.be {
- for k2, v2 := range v {
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeUint(uint64(v2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[string(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapStringUint64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapStringUint64R(rv reflect.Value) {
fastpathTV.EncMapStringUint64V(rv.Interface().(map[string]uint64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapStringUint64V(v map[string]uint64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
- if e.be {
- for k2, v2 := range v {
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeUint(uint64(v2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[string(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapStringIntR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapStringUintptrR(rv reflect.Value) {
+ fastpathTV.EncMapStringUintptrV(rv.Interface().(map[string]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapStringUintptrV(v map[string]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[string(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapStringIntR(rv reflect.Value) {
fastpathTV.EncMapStringIntV(rv.Interface().(map[string]int), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapStringIntV(v map[string]int, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
- if e.be {
- for k2, v2 := range v {
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeInt(int64(v2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[string(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapStringInt8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapStringInt8R(rv reflect.Value) {
fastpathTV.EncMapStringInt8V(rv.Interface().(map[string]int8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapStringInt8V(v map[string]int8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
- if e.be {
- for k2, v2 := range v {
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeInt(int64(v2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[string(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapStringInt16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapStringInt16R(rv reflect.Value) {
fastpathTV.EncMapStringInt16V(rv.Interface().(map[string]int16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapStringInt16V(v map[string]int16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
- if e.be {
- for k2, v2 := range v {
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeInt(int64(v2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[string(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapStringInt32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapStringInt32R(rv reflect.Value) {
fastpathTV.EncMapStringInt32V(rv.Interface().(map[string]int32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapStringInt32V(v map[string]int32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
- if e.be {
- for k2, v2 := range v {
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeInt(int64(v2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[string(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapStringInt64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapStringInt64R(rv reflect.Value) {
fastpathTV.EncMapStringInt64V(rv.Interface().(map[string]int64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapStringInt64V(v map[string]int64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
- if e.be {
- for k2, v2 := range v {
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeInt(int64(v2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[string(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapStringFloat32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapStringFloat32R(rv reflect.Value) {
fastpathTV.EncMapStringFloat32V(rv.Interface().(map[string]float32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapStringFloat32V(v map[string]float32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
- if e.be {
- for k2, v2 := range v {
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeFloat32(v2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[string(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat32(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapStringFloat64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapStringFloat64R(rv reflect.Value) {
fastpathTV.EncMapStringFloat64V(rv.Interface().(map[string]float64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapStringFloat64V(v map[string]float64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
- if e.be {
- for k2, v2 := range v {
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeFloat64(v2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[string(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat64(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapStringBoolR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapStringBoolR(rv reflect.Value) {
fastpathTV.EncMapStringBoolV(rv.Interface().(map[string]bool), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapStringBoolV(v map[string]bool, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
- if e.be {
- for k2, v2 := range v {
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeBool(v2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[string(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
if asSymbols {
ee.EncodeSymbol(k2)
} else {
ee.EncodeString(c_UTF8, k2)
}
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeBool(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat32IntfR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat32IntfR(rv reflect.Value) {
fastpathTV.EncMapFloat32IntfV(rv.Interface().(map[float32]interface{}), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat32IntfV(v map[float32]interface{}, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- e.encode(v2)
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[float32(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat32(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
e.encode(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat32StringR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat32StringR(rv reflect.Value) {
fastpathTV.EncMapFloat32StringV(rv.Interface().(map[float32]string), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat32StringV(v map[float32]string, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeString(c_UTF8, v2)
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[float32(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat32(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeString(c_UTF8, v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat32UintR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat32UintR(rv reflect.Value) {
fastpathTV.EncMapFloat32UintV(rv.Interface().(map[float32]uint), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat32UintV(v map[float32]uint, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat32(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat32Uint8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat32Uint8R(rv reflect.Value) {
fastpathTV.EncMapFloat32Uint8V(rv.Interface().(map[float32]uint8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat32Uint8V(v map[float32]uint8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat32(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat32Uint16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat32Uint16R(rv reflect.Value) {
fastpathTV.EncMapFloat32Uint16V(rv.Interface().(map[float32]uint16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat32Uint16V(v map[float32]uint16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat32(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat32Uint32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat32Uint32R(rv reflect.Value) {
fastpathTV.EncMapFloat32Uint32V(rv.Interface().(map[float32]uint32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat32Uint32V(v map[float32]uint32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat32(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat32Uint64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat32Uint64R(rv reflect.Value) {
fastpathTV.EncMapFloat32Uint64V(rv.Interface().(map[float32]uint64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat32Uint64V(v map[float32]uint64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat32(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat32IntR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat32UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapFloat32UintptrV(rv.Interface().(map[float32]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat32UintptrV(v map[float32]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[float32(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat32IntR(rv reflect.Value) {
fastpathTV.EncMapFloat32IntV(rv.Interface().(map[float32]int), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat32IntV(v map[float32]int, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat32(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat32Int8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat32Int8R(rv reflect.Value) {
fastpathTV.EncMapFloat32Int8V(rv.Interface().(map[float32]int8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat32Int8V(v map[float32]int8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat32(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat32Int16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat32Int16R(rv reflect.Value) {
fastpathTV.EncMapFloat32Int16V(rv.Interface().(map[float32]int16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat32Int16V(v map[float32]int16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat32(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat32Int32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat32Int32R(rv reflect.Value) {
fastpathTV.EncMapFloat32Int32V(rv.Interface().(map[float32]int32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat32Int32V(v map[float32]int32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat32(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat32Int64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat32Int64R(rv reflect.Value) {
fastpathTV.EncMapFloat32Int64V(rv.Interface().(map[float32]int64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat32Int64V(v map[float32]int64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat32(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat32Float32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat32Float32R(rv reflect.Value) {
fastpathTV.EncMapFloat32Float32V(rv.Interface().(map[float32]float32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat32Float32V(v map[float32]float32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeFloat32(v2)
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[float32(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat32(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat32(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat32Float64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat32Float64R(rv reflect.Value) {
fastpathTV.EncMapFloat32Float64V(rv.Interface().(map[float32]float64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat32Float64V(v map[float32]float64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeFloat64(v2)
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[float32(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat32(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat64(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat32BoolR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat32BoolR(rv reflect.Value) {
fastpathTV.EncMapFloat32BoolV(rv.Interface().(map[float32]bool), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat32BoolV(v map[float32]bool, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeBool(v2)
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[float32(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat32(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeBool(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat64IntfR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat64IntfR(rv reflect.Value) {
fastpathTV.EncMapFloat64IntfV(rv.Interface().(map[float64]interface{}), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat64IntfV(v map[float64]interface{}, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- e.encode(v2)
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[float64(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat64(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
e.encode(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat64StringR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat64StringR(rv reflect.Value) {
fastpathTV.EncMapFloat64StringV(rv.Interface().(map[float64]string), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat64StringV(v map[float64]string, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeString(c_UTF8, v2)
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[float64(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat64(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeString(c_UTF8, v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat64UintR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat64UintR(rv reflect.Value) {
fastpathTV.EncMapFloat64UintV(rv.Interface().(map[float64]uint), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat64UintV(v map[float64]uint, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat64(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat64Uint8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat64Uint8R(rv reflect.Value) {
fastpathTV.EncMapFloat64Uint8V(rv.Interface().(map[float64]uint8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat64Uint8V(v map[float64]uint8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat64(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat64Uint16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat64Uint16R(rv reflect.Value) {
fastpathTV.EncMapFloat64Uint16V(rv.Interface().(map[float64]uint16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat64Uint16V(v map[float64]uint16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat64(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat64Uint32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat64Uint32R(rv reflect.Value) {
fastpathTV.EncMapFloat64Uint32V(rv.Interface().(map[float64]uint32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat64Uint32V(v map[float64]uint32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat64(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat64Uint64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat64Uint64R(rv reflect.Value) {
fastpathTV.EncMapFloat64Uint64V(rv.Interface().(map[float64]uint64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat64Uint64V(v map[float64]uint64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat64(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat64IntR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat64UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapFloat64UintptrV(rv.Interface().(map[float64]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat64UintptrV(v map[float64]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[float64(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat64IntR(rv reflect.Value) {
fastpathTV.EncMapFloat64IntV(rv.Interface().(map[float64]int), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat64IntV(v map[float64]int, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat64(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat64Int8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat64Int8R(rv reflect.Value) {
fastpathTV.EncMapFloat64Int8V(rv.Interface().(map[float64]int8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat64Int8V(v map[float64]int8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat64(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat64Int16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat64Int16R(rv reflect.Value) {
fastpathTV.EncMapFloat64Int16V(rv.Interface().(map[float64]int16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat64Int16V(v map[float64]int16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat64(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat64Int32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat64Int32R(rv reflect.Value) {
fastpathTV.EncMapFloat64Int32V(rv.Interface().(map[float64]int32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat64Int32V(v map[float64]int32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat64(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat64Int64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat64Int64R(rv reflect.Value) {
fastpathTV.EncMapFloat64Int64V(rv.Interface().(map[float64]int64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat64Int64V(v map[float64]int64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat64(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat64Float32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat64Float32R(rv reflect.Value) {
fastpathTV.EncMapFloat64Float32V(rv.Interface().(map[float64]float32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat64Float32V(v map[float64]float32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeFloat32(v2)
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[float64(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat64(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat32(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat64Float64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat64Float64R(rv reflect.Value) {
fastpathTV.EncMapFloat64Float64V(rv.Interface().(map[float64]float64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat64Float64V(v map[float64]float64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeFloat64(v2)
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[float64(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat64(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat64(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapFloat64BoolR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapFloat64BoolR(rv reflect.Value) {
fastpathTV.EncMapFloat64BoolV(rv.Interface().(map[float64]bool), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapFloat64BoolV(v map[float64]bool, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeBool(v2)
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[float64(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeFloat64(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeBool(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUintIntfR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUintIntfR(rv reflect.Value) {
fastpathTV.EncMapUintIntfV(rv.Interface().(map[uint]interface{}), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUintIntfV(v map[uint]interface{}, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[uint(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
e.encode(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUintStringR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUintStringR(rv reflect.Value) {
fastpathTV.EncMapUintStringV(rv.Interface().(map[uint]string), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUintStringV(v map[uint]string, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeString(c_UTF8, v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[uint(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeString(c_UTF8, v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUintUintR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUintUintR(rv reflect.Value) {
fastpathTV.EncMapUintUintV(rv.Interface().(map[uint]uint), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUintUintV(v map[uint]uint, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUintUint8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUintUint8R(rv reflect.Value) {
fastpathTV.EncMapUintUint8V(rv.Interface().(map[uint]uint8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUintUint8V(v map[uint]uint8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUintUint16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUintUint16R(rv reflect.Value) {
fastpathTV.EncMapUintUint16V(rv.Interface().(map[uint]uint16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUintUint16V(v map[uint]uint16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUintUint32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUintUint32R(rv reflect.Value) {
fastpathTV.EncMapUintUint32V(rv.Interface().(map[uint]uint32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUintUint32V(v map[uint]uint32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUintUint64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUintUint64R(rv reflect.Value) {
fastpathTV.EncMapUintUint64V(rv.Interface().(map[uint]uint64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUintUint64V(v map[uint]uint64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUintIntR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUintUintptrR(rv reflect.Value) {
+ fastpathTV.EncMapUintUintptrV(rv.Interface().(map[uint]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintUintptrV(v map[uint]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[uint(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintIntR(rv reflect.Value) {
fastpathTV.EncMapUintIntV(rv.Interface().(map[uint]int), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUintIntV(v map[uint]int, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUintInt8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUintInt8R(rv reflect.Value) {
fastpathTV.EncMapUintInt8V(rv.Interface().(map[uint]int8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUintInt8V(v map[uint]int8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUintInt16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUintInt16R(rv reflect.Value) {
fastpathTV.EncMapUintInt16V(rv.Interface().(map[uint]int16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUintInt16V(v map[uint]int16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUintInt32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUintInt32R(rv reflect.Value) {
fastpathTV.EncMapUintInt32V(rv.Interface().(map[uint]int32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUintInt32V(v map[uint]int32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUintInt64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUintInt64R(rv reflect.Value) {
fastpathTV.EncMapUintInt64V(rv.Interface().(map[uint]int64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUintInt64V(v map[uint]int64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUintFloat32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUintFloat32R(rv reflect.Value) {
fastpathTV.EncMapUintFloat32V(rv.Interface().(map[uint]float32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUintFloat32V(v map[uint]float32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat32(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[uint(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat32(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUintFloat64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUintFloat64R(rv reflect.Value) {
fastpathTV.EncMapUintFloat64V(rv.Interface().(map[uint]float64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUintFloat64V(v map[uint]float64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat64(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[uint(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat64(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUintBoolR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUintBoolR(rv reflect.Value) {
fastpathTV.EncMapUintBoolV(rv.Interface().(map[uint]bool), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUintBoolV(v map[uint]bool, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeBool(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[uint(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeBool(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint8IntfR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint8IntfR(rv reflect.Value) {
fastpathTV.EncMapUint8IntfV(rv.Interface().(map[uint8]interface{}), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint8IntfV(v map[uint8]interface{}, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[uint8(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
e.encode(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint8StringR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint8StringR(rv reflect.Value) {
fastpathTV.EncMapUint8StringV(rv.Interface().(map[uint8]string), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint8StringV(v map[uint8]string, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeString(c_UTF8, v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[uint8(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeString(c_UTF8, v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint8UintR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint8UintR(rv reflect.Value) {
fastpathTV.EncMapUint8UintV(rv.Interface().(map[uint8]uint), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint8UintV(v map[uint8]uint, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint8Uint8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint8Uint8R(rv reflect.Value) {
fastpathTV.EncMapUint8Uint8V(rv.Interface().(map[uint8]uint8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint8Uint8V(v map[uint8]uint8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint8Uint16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint8Uint16R(rv reflect.Value) {
fastpathTV.EncMapUint8Uint16V(rv.Interface().(map[uint8]uint16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint8Uint16V(v map[uint8]uint16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint8Uint32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint8Uint32R(rv reflect.Value) {
fastpathTV.EncMapUint8Uint32V(rv.Interface().(map[uint8]uint32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint8Uint32V(v map[uint8]uint32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint8Uint64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint8Uint64R(rv reflect.Value) {
fastpathTV.EncMapUint8Uint64V(rv.Interface().(map[uint8]uint64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint8Uint64V(v map[uint8]uint64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint8IntR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint8UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapUint8UintptrV(rv.Interface().(map[uint8]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint8UintptrV(v map[uint8]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[uint8(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint8IntR(rv reflect.Value) {
fastpathTV.EncMapUint8IntV(rv.Interface().(map[uint8]int), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint8IntV(v map[uint8]int, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint8Int8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint8Int8R(rv reflect.Value) {
fastpathTV.EncMapUint8Int8V(rv.Interface().(map[uint8]int8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint8Int8V(v map[uint8]int8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint8Int16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint8Int16R(rv reflect.Value) {
fastpathTV.EncMapUint8Int16V(rv.Interface().(map[uint8]int16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint8Int16V(v map[uint8]int16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint8Int32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint8Int32R(rv reflect.Value) {
fastpathTV.EncMapUint8Int32V(rv.Interface().(map[uint8]int32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint8Int32V(v map[uint8]int32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint8Int64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint8Int64R(rv reflect.Value) {
fastpathTV.EncMapUint8Int64V(rv.Interface().(map[uint8]int64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint8Int64V(v map[uint8]int64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint8Float32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint8Float32R(rv reflect.Value) {
fastpathTV.EncMapUint8Float32V(rv.Interface().(map[uint8]float32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint8Float32V(v map[uint8]float32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat32(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[uint8(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat32(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint8Float64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint8Float64R(rv reflect.Value) {
fastpathTV.EncMapUint8Float64V(rv.Interface().(map[uint8]float64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint8Float64V(v map[uint8]float64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat64(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[uint8(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat64(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint8BoolR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint8BoolR(rv reflect.Value) {
fastpathTV.EncMapUint8BoolV(rv.Interface().(map[uint8]bool), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint8BoolV(v map[uint8]bool, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeBool(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[uint8(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeBool(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint16IntfR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint16IntfR(rv reflect.Value) {
fastpathTV.EncMapUint16IntfV(rv.Interface().(map[uint16]interface{}), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint16IntfV(v map[uint16]interface{}, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[uint16(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
e.encode(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint16StringR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint16StringR(rv reflect.Value) {
fastpathTV.EncMapUint16StringV(rv.Interface().(map[uint16]string), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint16StringV(v map[uint16]string, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeString(c_UTF8, v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[uint16(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeString(c_UTF8, v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint16UintR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint16UintR(rv reflect.Value) {
fastpathTV.EncMapUint16UintV(rv.Interface().(map[uint16]uint), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint16UintV(v map[uint16]uint, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint16Uint8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint16Uint8R(rv reflect.Value) {
fastpathTV.EncMapUint16Uint8V(rv.Interface().(map[uint16]uint8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint16Uint8V(v map[uint16]uint8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint16Uint16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint16Uint16R(rv reflect.Value) {
fastpathTV.EncMapUint16Uint16V(rv.Interface().(map[uint16]uint16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint16Uint16V(v map[uint16]uint16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint16Uint32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint16Uint32R(rv reflect.Value) {
fastpathTV.EncMapUint16Uint32V(rv.Interface().(map[uint16]uint32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint16Uint32V(v map[uint16]uint32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint16Uint64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint16Uint64R(rv reflect.Value) {
fastpathTV.EncMapUint16Uint64V(rv.Interface().(map[uint16]uint64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint16Uint64V(v map[uint16]uint64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint16IntR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint16UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapUint16UintptrV(rv.Interface().(map[uint16]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint16UintptrV(v map[uint16]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[uint16(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint16IntR(rv reflect.Value) {
fastpathTV.EncMapUint16IntV(rv.Interface().(map[uint16]int), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint16IntV(v map[uint16]int, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint16Int8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint16Int8R(rv reflect.Value) {
fastpathTV.EncMapUint16Int8V(rv.Interface().(map[uint16]int8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint16Int8V(v map[uint16]int8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint16Int16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint16Int16R(rv reflect.Value) {
fastpathTV.EncMapUint16Int16V(rv.Interface().(map[uint16]int16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint16Int16V(v map[uint16]int16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint16Int32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint16Int32R(rv reflect.Value) {
fastpathTV.EncMapUint16Int32V(rv.Interface().(map[uint16]int32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint16Int32V(v map[uint16]int32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint16Int64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint16Int64R(rv reflect.Value) {
fastpathTV.EncMapUint16Int64V(rv.Interface().(map[uint16]int64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint16Int64V(v map[uint16]int64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint16Float32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint16Float32R(rv reflect.Value) {
fastpathTV.EncMapUint16Float32V(rv.Interface().(map[uint16]float32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint16Float32V(v map[uint16]float32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat32(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[uint16(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat32(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint16Float64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint16Float64R(rv reflect.Value) {
fastpathTV.EncMapUint16Float64V(rv.Interface().(map[uint16]float64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint16Float64V(v map[uint16]float64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat64(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[uint16(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat64(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint16BoolR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint16BoolR(rv reflect.Value) {
fastpathTV.EncMapUint16BoolV(rv.Interface().(map[uint16]bool), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint16BoolV(v map[uint16]bool, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeBool(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[uint16(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeBool(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint32IntfR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint32IntfR(rv reflect.Value) {
fastpathTV.EncMapUint32IntfV(rv.Interface().(map[uint32]interface{}), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint32IntfV(v map[uint32]interface{}, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[uint32(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
e.encode(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint32StringR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint32StringR(rv reflect.Value) {
fastpathTV.EncMapUint32StringV(rv.Interface().(map[uint32]string), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint32StringV(v map[uint32]string, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeString(c_UTF8, v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[uint32(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeString(c_UTF8, v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint32UintR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint32UintR(rv reflect.Value) {
fastpathTV.EncMapUint32UintV(rv.Interface().(map[uint32]uint), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint32UintV(v map[uint32]uint, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint32Uint8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint32Uint8R(rv reflect.Value) {
fastpathTV.EncMapUint32Uint8V(rv.Interface().(map[uint32]uint8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint32Uint8V(v map[uint32]uint8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint32Uint16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint32Uint16R(rv reflect.Value) {
fastpathTV.EncMapUint32Uint16V(rv.Interface().(map[uint32]uint16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint32Uint16V(v map[uint32]uint16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint32Uint32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint32Uint32R(rv reflect.Value) {
fastpathTV.EncMapUint32Uint32V(rv.Interface().(map[uint32]uint32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint32Uint32V(v map[uint32]uint32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint32Uint64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint32Uint64R(rv reflect.Value) {
fastpathTV.EncMapUint32Uint64V(rv.Interface().(map[uint32]uint64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint32Uint64V(v map[uint32]uint64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint32IntR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint32UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapUint32UintptrV(rv.Interface().(map[uint32]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint32UintptrV(v map[uint32]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[uint32(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint32IntR(rv reflect.Value) {
fastpathTV.EncMapUint32IntV(rv.Interface().(map[uint32]int), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint32IntV(v map[uint32]int, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint32Int8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint32Int8R(rv reflect.Value) {
fastpathTV.EncMapUint32Int8V(rv.Interface().(map[uint32]int8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint32Int8V(v map[uint32]int8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint32Int16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint32Int16R(rv reflect.Value) {
fastpathTV.EncMapUint32Int16V(rv.Interface().(map[uint32]int16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint32Int16V(v map[uint32]int16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint32Int32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint32Int32R(rv reflect.Value) {
fastpathTV.EncMapUint32Int32V(rv.Interface().(map[uint32]int32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint32Int32V(v map[uint32]int32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint32Int64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint32Int64R(rv reflect.Value) {
fastpathTV.EncMapUint32Int64V(rv.Interface().(map[uint32]int64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint32Int64V(v map[uint32]int64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint32Float32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint32Float32R(rv reflect.Value) {
fastpathTV.EncMapUint32Float32V(rv.Interface().(map[uint32]float32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint32Float32V(v map[uint32]float32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat32(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[uint32(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat32(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint32Float64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint32Float64R(rv reflect.Value) {
fastpathTV.EncMapUint32Float64V(rv.Interface().(map[uint32]float64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint32Float64V(v map[uint32]float64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat64(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[uint32(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat64(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint32BoolR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint32BoolR(rv reflect.Value) {
fastpathTV.EncMapUint32BoolV(rv.Interface().(map[uint32]bool), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint32BoolV(v map[uint32]bool, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeBool(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[uint32(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeBool(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint64IntfR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint64IntfR(rv reflect.Value) {
fastpathTV.EncMapUint64IntfV(rv.Interface().(map[uint64]interface{}), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint64IntfV(v map[uint64]interface{}, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[uint64(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
e.encode(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint64StringR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint64StringR(rv reflect.Value) {
fastpathTV.EncMapUint64StringV(rv.Interface().(map[uint64]string), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint64StringV(v map[uint64]string, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeString(c_UTF8, v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[uint64(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeString(c_UTF8, v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint64UintR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint64UintR(rv reflect.Value) {
fastpathTV.EncMapUint64UintV(rv.Interface().(map[uint64]uint), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint64UintV(v map[uint64]uint, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint64Uint8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint64Uint8R(rv reflect.Value) {
fastpathTV.EncMapUint64Uint8V(rv.Interface().(map[uint64]uint8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint64Uint8V(v map[uint64]uint8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint64Uint16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint64Uint16R(rv reflect.Value) {
fastpathTV.EncMapUint64Uint16V(rv.Interface().(map[uint64]uint16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint64Uint16V(v map[uint64]uint16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint64Uint32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint64Uint32R(rv reflect.Value) {
fastpathTV.EncMapUint64Uint32V(rv.Interface().(map[uint64]uint32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint64Uint32V(v map[uint64]uint32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint64Uint64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint64Uint64R(rv reflect.Value) {
fastpathTV.EncMapUint64Uint64V(rv.Interface().(map[uint64]uint64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint64Uint64V(v map[uint64]uint64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint64IntR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint64UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapUint64UintptrV(rv.Interface().(map[uint64]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint64UintptrV(v map[uint64]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[uint64(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint64IntR(rv reflect.Value) {
fastpathTV.EncMapUint64IntV(rv.Interface().(map[uint64]int), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint64IntV(v map[uint64]int, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint64Int8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint64Int8R(rv reflect.Value) {
fastpathTV.EncMapUint64Int8V(rv.Interface().(map[uint64]int8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint64Int8V(v map[uint64]int8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint64Int16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint64Int16R(rv reflect.Value) {
fastpathTV.EncMapUint64Int16V(rv.Interface().(map[uint64]int16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint64Int16V(v map[uint64]int16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint64Int32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint64Int32R(rv reflect.Value) {
fastpathTV.EncMapUint64Int32V(rv.Interface().(map[uint64]int32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint64Int32V(v map[uint64]int32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint64Int64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint64Int64R(rv reflect.Value) {
fastpathTV.EncMapUint64Int64V(rv.Interface().(map[uint64]int64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint64Int64V(v map[uint64]int64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint64Float32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint64Float32R(rv reflect.Value) {
fastpathTV.EncMapUint64Float32V(rv.Interface().(map[uint64]float32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint64Float32V(v map[uint64]float32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat32(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[uint64(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat32(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint64Float64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint64Float64R(rv reflect.Value) {
fastpathTV.EncMapUint64Float64V(rv.Interface().(map[uint64]float64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint64Float64V(v map[uint64]float64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat64(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[uint64(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat64(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapUint64BoolR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUint64BoolR(rv reflect.Value) {
fastpathTV.EncMapUint64BoolV(rv.Interface().(map[uint64]bool), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapUint64BoolV(v map[uint64]bool, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeBool(v2)
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[uint64(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeUint(uint64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeBool(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntIntfR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapUintptrIntfR(rv reflect.Value) {
+ fastpathTV.EncMapUintptrIntfV(rv.Interface().(map[uintptr]interface{}), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintptrIntfV(v map[uintptr]interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[uintptr(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintptrStringR(rv reflect.Value) {
+ fastpathTV.EncMapUintptrStringV(rv.Interface().(map[uintptr]string), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintptrStringV(v map[uintptr]string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[uintptr(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintptrUintR(rv reflect.Value) {
+ fastpathTV.EncMapUintptrUintV(rv.Interface().(map[uintptr]uint), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintptrUintV(v map[uintptr]uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uintptr(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintptrUint8R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrUint8V(rv.Interface().(map[uintptr]uint8), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintptrUint8V(v map[uintptr]uint8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uintptr(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintptrUint16R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrUint16V(rv.Interface().(map[uintptr]uint16), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintptrUint16V(v map[uintptr]uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uintptr(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintptrUint32R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrUint32V(rv.Interface().(map[uintptr]uint32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintptrUint32V(v map[uintptr]uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uintptr(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintptrUint64R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrUint64V(rv.Interface().(map[uintptr]uint64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintptrUint64V(v map[uintptr]uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uintptr(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintptrUintptrR(rv reflect.Value) {
+ fastpathTV.EncMapUintptrUintptrV(rv.Interface().(map[uintptr]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintptrUintptrV(v map[uintptr]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[uintptr(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintptrIntR(rv reflect.Value) {
+ fastpathTV.EncMapUintptrIntV(rv.Interface().(map[uintptr]int), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintptrIntV(v map[uintptr]int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uintptr(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintptrInt8R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrInt8V(rv.Interface().(map[uintptr]int8), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintptrInt8V(v map[uintptr]int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uintptr(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintptrInt16R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrInt16V(rv.Interface().(map[uintptr]int16), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintptrInt16V(v map[uintptr]int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uintptr(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintptrInt32R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrInt32V(rv.Interface().(map[uintptr]int32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintptrInt32V(v map[uintptr]int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uintptr(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintptrInt64R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrInt64V(rv.Interface().(map[uintptr]int64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintptrInt64V(v map[uintptr]int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uintptr(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintptrFloat32R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrFloat32V(rv.Interface().(map[uintptr]float32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintptrFloat32V(v map[uintptr]float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[uintptr(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintptrFloat64R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrFloat64V(rv.Interface().(map[uintptr]float64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintptrFloat64V(v map[uintptr]float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[uintptr(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintptrBoolR(rv reflect.Value) {
+ fastpathTV.EncMapUintptrBoolV(rv.Interface().(map[uintptr]bool), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintptrBoolV(v map[uintptr]bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[uintptr(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapIntIntfR(rv reflect.Value) {
fastpathTV.EncMapIntIntfV(rv.Interface().(map[int]interface{}), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntIntfV(v map[int]interface{}, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[int(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
e.encode(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntStringR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntStringR(rv reflect.Value) {
fastpathTV.EncMapIntStringV(rv.Interface().(map[int]string), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntStringV(v map[int]string, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeString(c_UTF8, v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[int(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeString(c_UTF8, v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntUintR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntUintR(rv reflect.Value) {
fastpathTV.EncMapIntUintV(rv.Interface().(map[int]uint), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntUintV(v map[int]uint, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntUint8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntUint8R(rv reflect.Value) {
fastpathTV.EncMapIntUint8V(rv.Interface().(map[int]uint8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntUint8V(v map[int]uint8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntUint16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntUint16R(rv reflect.Value) {
fastpathTV.EncMapIntUint16V(rv.Interface().(map[int]uint16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntUint16V(v map[int]uint16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntUint32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntUint32R(rv reflect.Value) {
fastpathTV.EncMapIntUint32V(rv.Interface().(map[int]uint32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntUint32V(v map[int]uint32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntUint64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntUint64R(rv reflect.Value) {
fastpathTV.EncMapIntUint64V(rv.Interface().(map[int]uint64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntUint64V(v map[int]uint64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntIntR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntUintptrR(rv reflect.Value) {
+ fastpathTV.EncMapIntUintptrV(rv.Interface().(map[int]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapIntUintptrV(v map[int]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[int(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapIntIntR(rv reflect.Value) {
fastpathTV.EncMapIntIntV(rv.Interface().(map[int]int), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntIntV(v map[int]int, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntInt8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntInt8R(rv reflect.Value) {
fastpathTV.EncMapIntInt8V(rv.Interface().(map[int]int8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntInt8V(v map[int]int8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntInt16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntInt16R(rv reflect.Value) {
fastpathTV.EncMapIntInt16V(rv.Interface().(map[int]int16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntInt16V(v map[int]int16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntInt32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntInt32R(rv reflect.Value) {
fastpathTV.EncMapIntInt32V(rv.Interface().(map[int]int32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntInt32V(v map[int]int32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntInt64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntInt64R(rv reflect.Value) {
fastpathTV.EncMapIntInt64V(rv.Interface().(map[int]int64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntInt64V(v map[int]int64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntFloat32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntFloat32R(rv reflect.Value) {
fastpathTV.EncMapIntFloat32V(rv.Interface().(map[int]float32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntFloat32V(v map[int]float32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat32(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[int(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat32(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntFloat64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntFloat64R(rv reflect.Value) {
fastpathTV.EncMapIntFloat64V(rv.Interface().(map[int]float64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntFloat64V(v map[int]float64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat64(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[int(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat64(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapIntBoolR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapIntBoolR(rv reflect.Value) {
fastpathTV.EncMapIntBoolV(rv.Interface().(map[int]bool), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapIntBoolV(v map[int]bool, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeBool(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[int(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeBool(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt8IntfR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt8IntfR(rv reflect.Value) {
fastpathTV.EncMapInt8IntfV(rv.Interface().(map[int8]interface{}), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt8IntfV(v map[int8]interface{}, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[int8(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
e.encode(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt8StringR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt8StringR(rv reflect.Value) {
fastpathTV.EncMapInt8StringV(rv.Interface().(map[int8]string), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt8StringV(v map[int8]string, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeString(c_UTF8, v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[int8(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeString(c_UTF8, v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt8UintR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt8UintR(rv reflect.Value) {
fastpathTV.EncMapInt8UintV(rv.Interface().(map[int8]uint), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt8UintV(v map[int8]uint, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt8Uint8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt8Uint8R(rv reflect.Value) {
fastpathTV.EncMapInt8Uint8V(rv.Interface().(map[int8]uint8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt8Uint8V(v map[int8]uint8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt8Uint16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt8Uint16R(rv reflect.Value) {
fastpathTV.EncMapInt8Uint16V(rv.Interface().(map[int8]uint16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt8Uint16V(v map[int8]uint16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt8Uint32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt8Uint32R(rv reflect.Value) {
fastpathTV.EncMapInt8Uint32V(rv.Interface().(map[int8]uint32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt8Uint32V(v map[int8]uint32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt8Uint64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt8Uint64R(rv reflect.Value) {
fastpathTV.EncMapInt8Uint64V(rv.Interface().(map[int8]uint64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt8Uint64V(v map[int8]uint64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt8IntR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt8UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapInt8UintptrV(rv.Interface().(map[int8]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapInt8UintptrV(v map[int8]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[int8(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapInt8IntR(rv reflect.Value) {
fastpathTV.EncMapInt8IntV(rv.Interface().(map[int8]int), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt8IntV(v map[int8]int, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt8Int8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt8Int8R(rv reflect.Value) {
fastpathTV.EncMapInt8Int8V(rv.Interface().(map[int8]int8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt8Int8V(v map[int8]int8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt8Int16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt8Int16R(rv reflect.Value) {
fastpathTV.EncMapInt8Int16V(rv.Interface().(map[int8]int16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt8Int16V(v map[int8]int16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt8Int32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt8Int32R(rv reflect.Value) {
fastpathTV.EncMapInt8Int32V(rv.Interface().(map[int8]int32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt8Int32V(v map[int8]int32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt8Int64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt8Int64R(rv reflect.Value) {
fastpathTV.EncMapInt8Int64V(rv.Interface().(map[int8]int64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt8Int64V(v map[int8]int64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int8(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt8Float32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt8Float32R(rv reflect.Value) {
fastpathTV.EncMapInt8Float32V(rv.Interface().(map[int8]float32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt8Float32V(v map[int8]float32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat32(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[int8(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat32(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt8Float64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt8Float64R(rv reflect.Value) {
fastpathTV.EncMapInt8Float64V(rv.Interface().(map[int8]float64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt8Float64V(v map[int8]float64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat64(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[int8(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat64(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt8BoolR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt8BoolR(rv reflect.Value) {
fastpathTV.EncMapInt8BoolV(rv.Interface().(map[int8]bool), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt8BoolV(v map[int8]bool, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeBool(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[int8(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeBool(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt16IntfR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt16IntfR(rv reflect.Value) {
fastpathTV.EncMapInt16IntfV(rv.Interface().(map[int16]interface{}), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt16IntfV(v map[int16]interface{}, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[int16(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
e.encode(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt16StringR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt16StringR(rv reflect.Value) {
fastpathTV.EncMapInt16StringV(rv.Interface().(map[int16]string), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt16StringV(v map[int16]string, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeString(c_UTF8, v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[int16(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeString(c_UTF8, v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt16UintR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt16UintR(rv reflect.Value) {
fastpathTV.EncMapInt16UintV(rv.Interface().(map[int16]uint), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt16UintV(v map[int16]uint, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt16Uint8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt16Uint8R(rv reflect.Value) {
fastpathTV.EncMapInt16Uint8V(rv.Interface().(map[int16]uint8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt16Uint8V(v map[int16]uint8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt16Uint16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt16Uint16R(rv reflect.Value) {
fastpathTV.EncMapInt16Uint16V(rv.Interface().(map[int16]uint16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt16Uint16V(v map[int16]uint16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt16Uint32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt16Uint32R(rv reflect.Value) {
fastpathTV.EncMapInt16Uint32V(rv.Interface().(map[int16]uint32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt16Uint32V(v map[int16]uint32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt16Uint64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt16Uint64R(rv reflect.Value) {
fastpathTV.EncMapInt16Uint64V(rv.Interface().(map[int16]uint64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt16Uint64V(v map[int16]uint64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt16IntR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt16UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapInt16UintptrV(rv.Interface().(map[int16]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapInt16UintptrV(v map[int16]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[int16(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapInt16IntR(rv reflect.Value) {
fastpathTV.EncMapInt16IntV(rv.Interface().(map[int16]int), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt16IntV(v map[int16]int, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt16Int8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt16Int8R(rv reflect.Value) {
fastpathTV.EncMapInt16Int8V(rv.Interface().(map[int16]int8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt16Int8V(v map[int16]int8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt16Int16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt16Int16R(rv reflect.Value) {
fastpathTV.EncMapInt16Int16V(rv.Interface().(map[int16]int16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt16Int16V(v map[int16]int16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt16Int32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt16Int32R(rv reflect.Value) {
fastpathTV.EncMapInt16Int32V(rv.Interface().(map[int16]int32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt16Int32V(v map[int16]int32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt16Int64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt16Int64R(rv reflect.Value) {
fastpathTV.EncMapInt16Int64V(rv.Interface().(map[int16]int64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt16Int64V(v map[int16]int64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int16(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt16Float32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt16Float32R(rv reflect.Value) {
fastpathTV.EncMapInt16Float32V(rv.Interface().(map[int16]float32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt16Float32V(v map[int16]float32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat32(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[int16(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat32(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt16Float64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt16Float64R(rv reflect.Value) {
fastpathTV.EncMapInt16Float64V(rv.Interface().(map[int16]float64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt16Float64V(v map[int16]float64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat64(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[int16(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat64(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt16BoolR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt16BoolR(rv reflect.Value) {
fastpathTV.EncMapInt16BoolV(rv.Interface().(map[int16]bool), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt16BoolV(v map[int16]bool, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeBool(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[int16(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeBool(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt32IntfR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt32IntfR(rv reflect.Value) {
fastpathTV.EncMapInt32IntfV(rv.Interface().(map[int32]interface{}), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt32IntfV(v map[int32]interface{}, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[int32(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
e.encode(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt32StringR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt32StringR(rv reflect.Value) {
fastpathTV.EncMapInt32StringV(rv.Interface().(map[int32]string), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt32StringV(v map[int32]string, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeString(c_UTF8, v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[int32(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeString(c_UTF8, v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt32UintR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt32UintR(rv reflect.Value) {
fastpathTV.EncMapInt32UintV(rv.Interface().(map[int32]uint), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt32UintV(v map[int32]uint, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt32Uint8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt32Uint8R(rv reflect.Value) {
fastpathTV.EncMapInt32Uint8V(rv.Interface().(map[int32]uint8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt32Uint8V(v map[int32]uint8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt32Uint16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt32Uint16R(rv reflect.Value) {
fastpathTV.EncMapInt32Uint16V(rv.Interface().(map[int32]uint16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt32Uint16V(v map[int32]uint16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt32Uint32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt32Uint32R(rv reflect.Value) {
fastpathTV.EncMapInt32Uint32V(rv.Interface().(map[int32]uint32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt32Uint32V(v map[int32]uint32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt32Uint64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt32Uint64R(rv reflect.Value) {
fastpathTV.EncMapInt32Uint64V(rv.Interface().(map[int32]uint64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt32Uint64V(v map[int32]uint64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt32IntR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt32UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapInt32UintptrV(rv.Interface().(map[int32]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapInt32UintptrV(v map[int32]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[int32(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapInt32IntR(rv reflect.Value) {
fastpathTV.EncMapInt32IntV(rv.Interface().(map[int32]int), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt32IntV(v map[int32]int, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt32Int8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt32Int8R(rv reflect.Value) {
fastpathTV.EncMapInt32Int8V(rv.Interface().(map[int32]int8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt32Int8V(v map[int32]int8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt32Int16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt32Int16R(rv reflect.Value) {
fastpathTV.EncMapInt32Int16V(rv.Interface().(map[int32]int16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt32Int16V(v map[int32]int16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt32Int32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt32Int32R(rv reflect.Value) {
fastpathTV.EncMapInt32Int32V(rv.Interface().(map[int32]int32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt32Int32V(v map[int32]int32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt32Int64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt32Int64R(rv reflect.Value) {
fastpathTV.EncMapInt32Int64V(rv.Interface().(map[int32]int64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt32Int64V(v map[int32]int64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int32(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt32Float32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt32Float32R(rv reflect.Value) {
fastpathTV.EncMapInt32Float32V(rv.Interface().(map[int32]float32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt32Float32V(v map[int32]float32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat32(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[int32(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat32(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt32Float64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt32Float64R(rv reflect.Value) {
fastpathTV.EncMapInt32Float64V(rv.Interface().(map[int32]float64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt32Float64V(v map[int32]float64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat64(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[int32(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat64(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt32BoolR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt32BoolR(rv reflect.Value) {
fastpathTV.EncMapInt32BoolV(rv.Interface().(map[int32]bool), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt32BoolV(v map[int32]bool, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeBool(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[int32(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeBool(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt64IntfR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt64IntfR(rv reflect.Value) {
fastpathTV.EncMapInt64IntfV(rv.Interface().(map[int64]interface{}), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt64IntfV(v map[int64]interface{}, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[int64(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
e.encode(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt64StringR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt64StringR(rv reflect.Value) {
fastpathTV.EncMapInt64StringV(rv.Interface().(map[int64]string), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt64StringV(v map[int64]string, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeString(c_UTF8, v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[int64(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeString(c_UTF8, v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt64UintR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt64UintR(rv reflect.Value) {
fastpathTV.EncMapInt64UintV(rv.Interface().(map[int64]uint), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt64UintV(v map[int64]uint, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt64Uint8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt64Uint8R(rv reflect.Value) {
fastpathTV.EncMapInt64Uint8V(rv.Interface().(map[int64]uint8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt64Uint8V(v map[int64]uint8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt64Uint16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt64Uint16R(rv reflect.Value) {
fastpathTV.EncMapInt64Uint16V(rv.Interface().(map[int64]uint16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt64Uint16V(v map[int64]uint16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt64Uint32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt64Uint32R(rv reflect.Value) {
fastpathTV.EncMapInt64Uint32V(rv.Interface().(map[int64]uint32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt64Uint32V(v map[int64]uint32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt64Uint64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt64Uint64R(rv reflect.Value) {
fastpathTV.EncMapInt64Uint64V(rv.Interface().(map[int64]uint64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt64Uint64V(v map[int64]uint64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[int64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt64IntR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt64UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapInt64UintptrV(rv.Interface().(map[int64]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapInt64UintptrV(v map[int64]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[int64(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapInt64IntR(rv reflect.Value) {
fastpathTV.EncMapInt64IntV(rv.Interface().(map[int64]int), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt64IntV(v map[int64]int, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt64Int8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt64Int8R(rv reflect.Value) {
fastpathTV.EncMapInt64Int8V(rv.Interface().(map[int64]int8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt64Int8V(v map[int64]int8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt64Int16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt64Int16R(rv reflect.Value) {
fastpathTV.EncMapInt64Int16V(rv.Interface().(map[int64]int16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt64Int16V(v map[int64]int16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt64Int32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt64Int32R(rv reflect.Value) {
fastpathTV.EncMapInt64Int32V(rv.Interface().(map[int64]int32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt64Int32V(v map[int64]int32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt64Int64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt64Int64R(rv reflect.Value) {
fastpathTV.EncMapInt64Int64V(rv.Interface().(map[int64]int64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt64Int64V(v map[int64]int64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[int64(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt64Float32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt64Float32R(rv reflect.Value) {
fastpathTV.EncMapInt64Float32V(rv.Interface().(map[int64]float32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt64Float32V(v map[int64]float32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat32(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[int64(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat32(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt64Float64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt64Float64R(rv reflect.Value) {
fastpathTV.EncMapInt64Float64V(rv.Interface().(map[int64]float64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt64Float64V(v map[int64]float64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat64(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[int64(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat64(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapInt64BoolR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapInt64BoolR(rv reflect.Value) {
fastpathTV.EncMapInt64BoolV(rv.Interface().(map[int64]bool), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapInt64BoolV(v map[int64]bool, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeBool(v2)
+ if e.h.Canonical {
+ v2 := make([]int64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = int64(k)
+ i++
+ }
+ sort.Sort(intSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[int64(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeInt(int64(k2))
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeBool(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapBoolIntfR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapBoolIntfR(rv reflect.Value) {
fastpathTV.EncMapBoolIntfV(rv.Interface().(map[bool]interface{}), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapBoolIntfV(v map[bool]interface{}, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- e.encode(v2)
+ if e.h.Canonical {
+ v2 := make([]bool, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = bool(k)
+ i++
+ }
+ sort.Sort(boolSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[bool(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeBool(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
e.encode(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapBoolStringR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapBoolStringR(rv reflect.Value) {
fastpathTV.EncMapBoolStringV(rv.Interface().(map[bool]string), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapBoolStringV(v map[bool]string, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeString(c_UTF8, v2)
+ if e.h.Canonical {
+ v2 := make([]bool, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = bool(k)
+ i++
+ }
+ sort.Sort(boolSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[bool(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeBool(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeString(c_UTF8, v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapBoolUintR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapBoolUintR(rv reflect.Value) {
fastpathTV.EncMapBoolUintV(rv.Interface().(map[bool]uint), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapBoolUintV(v map[bool]uint, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]bool, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = bool(k)
+ i++
+ }
+ sort.Sort(boolSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[bool(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeBool(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapBoolUint8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapBoolUint8R(rv reflect.Value) {
fastpathTV.EncMapBoolUint8V(rv.Interface().(map[bool]uint8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapBoolUint8V(v map[bool]uint8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]bool, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = bool(k)
+ i++
+ }
+ sort.Sort(boolSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[bool(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeBool(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapBoolUint16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapBoolUint16R(rv reflect.Value) {
fastpathTV.EncMapBoolUint16V(rv.Interface().(map[bool]uint16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapBoolUint16V(v map[bool]uint16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]bool, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = bool(k)
+ i++
+ }
+ sort.Sort(boolSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[bool(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeBool(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapBoolUint32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapBoolUint32R(rv reflect.Value) {
fastpathTV.EncMapBoolUint32V(rv.Interface().(map[bool]uint32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapBoolUint32V(v map[bool]uint32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]bool, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = bool(k)
+ i++
+ }
+ sort.Sort(boolSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[bool(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeBool(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapBoolUint64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapBoolUint64R(rv reflect.Value) {
fastpathTV.EncMapBoolUint64V(rv.Interface().(map[bool]uint64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapBoolUint64V(v map[bool]uint64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeUint(uint64(v2))
+ if e.h.Canonical {
+ v2 := make([]bool, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = bool(k)
+ i++
+ }
+ sort.Sort(boolSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[bool(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeBool(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeUint(uint64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapBoolIntR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapBoolUintptrR(rv reflect.Value) {
+ fastpathTV.EncMapBoolUintptrV(rv.Interface().(map[bool]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapBoolUintptrV(v map[bool]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]bool, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = bool(k)
+ i++
+ }
+ sort.Sort(boolSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[bool(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeBool(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapBoolIntR(rv reflect.Value) {
fastpathTV.EncMapBoolIntV(rv.Interface().(map[bool]int), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapBoolIntV(v map[bool]int, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]bool, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = bool(k)
+ i++
+ }
+ sort.Sort(boolSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[bool(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeBool(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapBoolInt8R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapBoolInt8R(rv reflect.Value) {
fastpathTV.EncMapBoolInt8V(rv.Interface().(map[bool]int8), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapBoolInt8V(v map[bool]int8, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]bool, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = bool(k)
+ i++
+ }
+ sort.Sort(boolSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[bool(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeBool(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapBoolInt16R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapBoolInt16R(rv reflect.Value) {
fastpathTV.EncMapBoolInt16V(rv.Interface().(map[bool]int16), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapBoolInt16V(v map[bool]int16, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]bool, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = bool(k)
+ i++
+ }
+ sort.Sort(boolSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[bool(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeBool(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapBoolInt32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapBoolInt32R(rv reflect.Value) {
fastpathTV.EncMapBoolInt32V(rv.Interface().(map[bool]int32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapBoolInt32V(v map[bool]int32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]bool, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = bool(k)
+ i++
+ }
+ sort.Sort(boolSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[bool(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeBool(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapBoolInt64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapBoolInt64R(rv reflect.Value) {
fastpathTV.EncMapBoolInt64V(rv.Interface().(map[bool]int64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapBoolInt64V(v map[bool]int64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeInt(int64(v2))
+ if e.h.Canonical {
+ v2 := make([]bool, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = bool(k)
+ i++
+ }
+ sort.Sort(boolSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[bool(k2)]))
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeBool(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeInt(int64(v2))
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapBoolFloat32R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapBoolFloat32R(rv reflect.Value) {
fastpathTV.EncMapBoolFloat32V(rv.Interface().(map[bool]float32), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapBoolFloat32V(v map[bool]float32, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeFloat32(v2)
+ if e.h.Canonical {
+ v2 := make([]bool, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = bool(k)
+ i++
+ }
+ sort.Sort(boolSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[bool(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeBool(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat32(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapBoolFloat64R(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapBoolFloat64R(rv reflect.Value) {
fastpathTV.EncMapBoolFloat64V(rv.Interface().(map[bool]float64), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapBoolFloat64V(v map[bool]float64, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeFloat64(v2)
+ if e.h.Canonical {
+ v2 := make([]bool, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = bool(k)
+ i++
+ }
+ sort.Sort(boolSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[bool(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeBool(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat64(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
-func (f encFnInfo) fastpathEncMapBoolBoolR(rv reflect.Value) {
+func (f *encFnInfo) fastpathEncMapBoolBoolR(rv reflect.Value) {
fastpathTV.EncMapBoolBoolV(rv.Interface().(map[bool]bool), fastpathCheckNilFalse, f.e)
}
func (_ fastpathT) EncMapBoolBoolV(v map[bool]bool, checkNil bool, e *Encoder) {
ee := e.e
+ cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
ee.EncodeMapStart(len(v))
-
- if e.be {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeBool(v2)
+ if e.h.Canonical {
+ v2 := make([]bool, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = bool(k)
+ i++
+ }
+ sort.Sort(boolSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[bool(k2)])
}
} else {
- j := 0
for k2, v2 := range v {
- if j > 0 {
- ee.EncodeMapEntrySeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
ee.EncodeBool(k2)
- ee.EncodeMapKVSeparator()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeBool(v2)
- j++
}
- ee.EncodeMapEnd()
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
}
@@ -10208,6 +15954,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 +16023,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 +16159,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 +16295,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 +16431,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 +16567,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 +16695,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 +16831,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 +16967,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 +17103,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 +17175,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 +17375,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 +17511,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 +17647,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 +17783,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 +17919,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 +18055,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 +18128,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 +18136,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 +18156,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 +18167,83 @@ func (_ fastpathT) DecSliceIntfV(v []interface{}, checkNil bool, canChange bool,
}
slh, containerLenS := d.decSliceHelperStart()
- if canChange && v == nil {
- if containerLenS <= 0 {
- v = []interface{}{}
- } else {
- v = make([]interface{}, containerLenS, containerLenS)
- }
- changed = true
- }
if containerLenS == 0 {
- if canChange && len(v) != 0 {
- v = v[:0]
+ if canChange {
+ if v == nil {
+ v = []interface{}{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
changed = true
}
+ slh.End()
return v, changed
}
- // for j := 0; j < containerLenS; j++ {
if containerLenS > 0 {
- decLen := containerLenS
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
if canChange {
- s := make([]interface{}, containerLenS, containerLenS)
- // copy(s, v[:cap(v)])
- v = s
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 16)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]interface{}, xlen)
+ }
+ } else {
+ v = make([]interface{}, xlen)
+ }
changed = true
} else {
d.arrayCannotExpand(len(v), containerLenS)
- decLen = len(v)
}
+ x2read = len(v)
} else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
+ }
}
- // all checks done. cannot go past len.
j := 0
- for ; j < decLen; j++ {
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
d.decode(&v[j])
}
- if !canChange {
+ if xtrunc {
for ; j < containerLenS; j++ {
+ v = append(v, nil)
+ slh.ElemContainerState(j)
+ d.decode(&v[j])
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
d.swallow()
}
}
} else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []interface{}{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]interface{}, 1, 4)
+ changed = true
+ }
j := 0
- for ; !dd.CheckBreak(); j++ {
+ for ; !breakFound; j++ {
if j >= len(v) {
if canChange {
v = append(v, nil)
@@ -12216,24 +18252,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 +18290,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 +18301,83 @@ func (_ fastpathT) DecSliceStringV(v []string, checkNil bool, canChange bool,
}
slh, containerLenS := d.decSliceHelperStart()
- if canChange && v == nil {
- if containerLenS <= 0 {
- v = []string{}
- } else {
- v = make([]string, containerLenS, containerLenS)
- }
- changed = true
- }
if containerLenS == 0 {
- if canChange && len(v) != 0 {
- v = v[:0]
+ if canChange {
+ if v == nil {
+ v = []string{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
changed = true
}
+ slh.End()
return v, changed
}
- // for j := 0; j < containerLenS; j++ {
if containerLenS > 0 {
- decLen := containerLenS
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
if canChange {
- s := make([]string, containerLenS, containerLenS)
- // copy(s, v[:cap(v)])
- v = s
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 16)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]string, xlen)
+ }
+ } else {
+ v = make([]string, xlen)
+ }
changed = true
} else {
d.arrayCannotExpand(len(v), containerLenS)
- decLen = len(v)
}
+ x2read = len(v)
} else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
+ }
}
- // all checks done. cannot go past len.
j := 0
- for ; j < decLen; j++ {
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
v[j] = dd.DecodeString()
}
- if !canChange {
+ if xtrunc {
for ; j < containerLenS; j++ {
+ v = append(v, "")
+ slh.ElemContainerState(j)
+ v[j] = dd.DecodeString()
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
d.swallow()
}
}
} else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []string{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]string, 1, 4)
+ changed = true
+ }
j := 0
- for ; !dd.CheckBreak(); j++ {
+ for ; !breakFound; j++ {
if j >= len(v) {
if canChange {
v = append(v, "")
@@ -12317,23 +18386,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 +18423,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 +18434,83 @@ func (_ fastpathT) DecSliceFloat32V(v []float32, checkNil bool, canChange bool,
}
slh, containerLenS := d.decSliceHelperStart()
- if canChange && v == nil {
- if containerLenS <= 0 {
- v = []float32{}
- } else {
- v = make([]float32, containerLenS, containerLenS)
- }
- changed = true
- }
if containerLenS == 0 {
- if canChange && len(v) != 0 {
- v = v[:0]
+ if canChange {
+ if v == nil {
+ v = []float32{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
changed = true
}
+ slh.End()
return v, changed
}
- // for j := 0; j < containerLenS; j++ {
if containerLenS > 0 {
- decLen := containerLenS
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
if canChange {
- s := make([]float32, containerLenS, containerLenS)
- // copy(s, v[:cap(v)])
- v = s
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 4)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]float32, xlen)
+ }
+ } else {
+ v = make([]float32, xlen)
+ }
changed = true
} else {
d.arrayCannotExpand(len(v), containerLenS)
- decLen = len(v)
}
+ x2read = len(v)
} else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
+ }
}
- // all checks done. cannot go past len.
j := 0
- for ; j < decLen; j++ {
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
v[j] = float32(dd.DecodeFloat(true))
}
- if !canChange {
+ if xtrunc {
for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = float32(dd.DecodeFloat(true))
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
d.swallow()
}
}
} else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []float32{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]float32, 1, 4)
+ changed = true
+ }
j := 0
- for ; !dd.CheckBreak(); j++ {
+ for ; !breakFound; j++ {
if j >= len(v) {
if canChange {
v = append(v, 0)
@@ -12417,23 +18519,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 +18556,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 +18567,83 @@ func (_ fastpathT) DecSliceFloat64V(v []float64, checkNil bool, canChange bool,
}
slh, containerLenS := d.decSliceHelperStart()
- if canChange && v == nil {
- if containerLenS <= 0 {
- v = []float64{}
- } else {
- v = make([]float64, containerLenS, containerLenS)
- }
- changed = true
- }
if containerLenS == 0 {
- if canChange && len(v) != 0 {
- v = v[:0]
+ if canChange {
+ if v == nil {
+ v = []float64{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
changed = true
}
+ slh.End()
return v, changed
}
- // for j := 0; j < containerLenS; j++ {
if containerLenS > 0 {
- decLen := containerLenS
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
if canChange {
- s := make([]float64, containerLenS, containerLenS)
- // copy(s, v[:cap(v)])
- v = s
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]float64, xlen)
+ }
+ } else {
+ v = make([]float64, xlen)
+ }
changed = true
} else {
d.arrayCannotExpand(len(v), containerLenS)
- decLen = len(v)
}
+ x2read = len(v)
} else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
+ }
}
- // all checks done. cannot go past len.
j := 0
- for ; j < decLen; j++ {
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
v[j] = dd.DecodeFloat(false)
}
- if !canChange {
+ if xtrunc {
for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = dd.DecodeFloat(false)
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
d.swallow()
}
}
} else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []float64{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]float64, 1, 4)
+ changed = true
+ }
j := 0
- for ; !dd.CheckBreak(); j++ {
+ for ; !breakFound; j++ {
if j >= len(v) {
if canChange {
v = append(v, 0)
@@ -12517,23 +18652,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 +18689,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 +18700,83 @@ func (_ fastpathT) DecSliceUintV(v []uint, checkNil bool, canChange bool,
}
slh, containerLenS := d.decSliceHelperStart()
- if canChange && v == nil {
- if containerLenS <= 0 {
- v = []uint{}
- } else {
- v = make([]uint, containerLenS, containerLenS)
- }
- changed = true
- }
if containerLenS == 0 {
- if canChange && len(v) != 0 {
- v = v[:0]
+ if canChange {
+ if v == nil {
+ v = []uint{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
changed = true
}
+ slh.End()
return v, changed
}
- // for j := 0; j < containerLenS; j++ {
if containerLenS > 0 {
- decLen := containerLenS
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
if canChange {
- s := make([]uint, containerLenS, containerLenS)
- // copy(s, v[:cap(v)])
- v = s
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]uint, xlen)
+ }
+ } else {
+ v = make([]uint, xlen)
+ }
changed = true
} else {
d.arrayCannotExpand(len(v), containerLenS)
- decLen = len(v)
}
+ x2read = len(v)
} else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
+ }
}
- // all checks done. cannot go past len.
j := 0
- for ; j < decLen; j++ {
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
v[j] = uint(dd.DecodeUint(uintBitsize))
}
- if !canChange {
+ if xtrunc {
for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = uint(dd.DecodeUint(uintBitsize))
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
d.swallow()
}
}
} else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []uint{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]uint, 1, 4)
+ changed = true
+ }
j := 0
- for ; !dd.CheckBreak(); j++ {
+ for ; !breakFound; j++ {
if j >= len(v) {
if canChange {
v = append(v, 0)
@@ -12617,23 +18785,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 +18822,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 +18833,83 @@ func (_ fastpathT) DecSliceUint16V(v []uint16, checkNil bool, canChange bool,
}
slh, containerLenS := d.decSliceHelperStart()
- if canChange && v == nil {
- if containerLenS <= 0 {
- v = []uint16{}
- } else {
- v = make([]uint16, containerLenS, containerLenS)
- }
- changed = true
- }
if containerLenS == 0 {
- if canChange && len(v) != 0 {
- v = v[:0]
+ if canChange {
+ if v == nil {
+ v = []uint16{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
changed = true
}
+ slh.End()
return v, changed
}
- // for j := 0; j < containerLenS; j++ {
if containerLenS > 0 {
- decLen := containerLenS
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
if canChange {
- s := make([]uint16, containerLenS, containerLenS)
- // copy(s, v[:cap(v)])
- v = s
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 2)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]uint16, xlen)
+ }
+ } else {
+ v = make([]uint16, xlen)
+ }
changed = true
} else {
d.arrayCannotExpand(len(v), containerLenS)
- decLen = len(v)
}
+ x2read = len(v)
} else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
+ }
}
- // all checks done. cannot go past len.
j := 0
- for ; j < decLen; j++ {
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
v[j] = uint16(dd.DecodeUint(16))
}
- if !canChange {
+ if xtrunc {
for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = uint16(dd.DecodeUint(16))
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
d.swallow()
}
}
} else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []uint16{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]uint16, 1, 4)
+ changed = true
+ }
j := 0
- for ; !dd.CheckBreak(); j++ {
+ for ; !breakFound; j++ {
if j >= len(v) {
if canChange {
v = append(v, 0)
@@ -12717,23 +18918,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 +18955,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 +18966,83 @@ func (_ fastpathT) DecSliceUint32V(v []uint32, checkNil bool, canChange bool,
}
slh, containerLenS := d.decSliceHelperStart()
- if canChange && v == nil {
- if containerLenS <= 0 {
- v = []uint32{}
- } else {
- v = make([]uint32, containerLenS, containerLenS)
- }
- changed = true
- }
if containerLenS == 0 {
- if canChange && len(v) != 0 {
- v = v[:0]
+ if canChange {
+ if v == nil {
+ v = []uint32{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
changed = true
}
+ slh.End()
return v, changed
}
- // for j := 0; j < containerLenS; j++ {
if containerLenS > 0 {
- decLen := containerLenS
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
if canChange {
- s := make([]uint32, containerLenS, containerLenS)
- // copy(s, v[:cap(v)])
- v = s
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 4)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]uint32, xlen)
+ }
+ } else {
+ v = make([]uint32, xlen)
+ }
changed = true
} else {
d.arrayCannotExpand(len(v), containerLenS)
- decLen = len(v)
}
+ x2read = len(v)
} else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
+ }
}
- // all checks done. cannot go past len.
j := 0
- for ; j < decLen; j++ {
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
v[j] = uint32(dd.DecodeUint(32))
}
- if !canChange {
+ if xtrunc {
for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = uint32(dd.DecodeUint(32))
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
d.swallow()
}
}
} else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []uint32{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]uint32, 1, 4)
+ changed = true
+ }
j := 0
- for ; !dd.CheckBreak(); j++ {
+ for ; !breakFound; j++ {
if j >= len(v) {
if canChange {
v = append(v, 0)
@@ -12817,23 +19051,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 +19088,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 +19099,83 @@ func (_ fastpathT) DecSliceUint64V(v []uint64, checkNil bool, canChange bool,
}
slh, containerLenS := d.decSliceHelperStart()
- if canChange && v == nil {
- if containerLenS <= 0 {
- v = []uint64{}
- } else {
- v = make([]uint64, containerLenS, containerLenS)
- }
- changed = true
- }
if containerLenS == 0 {
- if canChange && len(v) != 0 {
- v = v[:0]
+ if canChange {
+ if v == nil {
+ v = []uint64{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
changed = true
}
+ slh.End()
return v, changed
}
- // for j := 0; j < containerLenS; j++ {
if containerLenS > 0 {
- decLen := containerLenS
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
if canChange {
- s := make([]uint64, containerLenS, containerLenS)
- // copy(s, v[:cap(v)])
- v = s
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]uint64, xlen)
+ }
+ } else {
+ v = make([]uint64, xlen)
+ }
changed = true
} else {
d.arrayCannotExpand(len(v), containerLenS)
- decLen = len(v)
}
+ x2read = len(v)
} else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
+ }
}
- // all checks done. cannot go past len.
j := 0
- for ; j < decLen; j++ {
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
v[j] = dd.DecodeUint(64)
}
- if !canChange {
+ if xtrunc {
for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = dd.DecodeUint(64)
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
d.swallow()
}
}
} else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []uint64{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]uint64, 1, 4)
+ changed = true
+ }
j := 0
- for ; !dd.CheckBreak(); j++ {
+ for ; !breakFound; j++ {
if j >= len(v) {
if canChange {
v = append(v, 0)
@@ -12917,23 +19184,159 @@ func (_ fastpathT) DecSliceUint64V(v []uint64, checkNil bool, canChange bool,
d.arrayCannotExpand(len(v), j+1)
}
}
- if j > 0 {
- slh.Sep(j)
- }
- if j < len(v) { // all checks done. cannot go past len.
+ slh.ElemContainerState(j)
+ if j < len(v) {
v[j] = dd.DecodeUint(64)
} else {
d.swallow()
}
+ breakFound = dd.CheckBreak()
+ }
+ if canChange && j < len(v) {
+ v = v[:j]
+ changed = true
}
- slh.End()
}
+ slh.End()
return v, changed
}
-func (f decFnInfo) fastpathDecSliceIntR(rv reflect.Value) {
+func (f *decFnInfo) fastpathDecSliceUintptrR(rv reflect.Value) {
array := f.seq == seqTypeArray
- if !array && rv.CanAddr() { // CanSet => CanAddr + Exported
+ if !array && rv.CanAddr() {
+ vp := rv.Addr().Interface().(*[]uintptr)
+ v, changed := fastpathTV.DecSliceUintptrV(*vp, fastpathCheckNilFalse, !array, f.d)
+ if changed {
+ *vp = v
+ }
+ } else {
+ v := rv.Interface().([]uintptr)
+ fastpathTV.DecSliceUintptrV(v, fastpathCheckNilFalse, false, f.d)
+ }
+}
+
+func (f fastpathT) DecSliceUintptrX(vp *[]uintptr, checkNil bool, d *Decoder) {
+ v, changed := f.DecSliceUintptrV(*vp, checkNil, true, d)
+ if changed {
+ *vp = v
+ }
+}
+func (_ fastpathT) DecSliceUintptrV(v []uintptr, checkNil bool, canChange bool, d *Decoder) (_ []uintptr, changed bool) {
+ dd := d.d
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
+ slh, containerLenS := d.decSliceHelperStart()
+ if containerLenS == 0 {
+ if canChange {
+ if v == nil {
+ v = []uintptr{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+
+ if containerLenS > 0 {
+ x2read := containerLenS
+ var xtrunc bool
+ if containerLenS > cap(v) {
+ if canChange {
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]uintptr, xlen)
+ }
+ } else {
+ v = make([]uintptr, xlen)
+ }
+ changed = true
+ } else {
+ d.arrayCannotExpand(len(v), containerLenS)
+ }
+ x2read = len(v)
+ } else if containerLenS != len(v) {
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
+ }
+ }
+ j := 0
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
+ v[j] = uintptr(dd.DecodeUint(uintBitsize))
+ }
+ if xtrunc {
+ for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = uintptr(dd.DecodeUint(uintBitsize))
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
+ d.swallow()
+ }
+ }
+ } else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []uintptr{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]uintptr, 1, 4)
+ changed = true
+ }
+ j := 0
+ for ; !breakFound; j++ {
+ if j >= len(v) {
+ if canChange {
+ v = append(v, 0)
+ changed = true
+ } else {
+ d.arrayCannotExpand(len(v), j+1)
+ }
+ }
+ slh.ElemContainerState(j)
+ if j < len(v) {
+ v[j] = uintptr(dd.DecodeUint(uintBitsize))
+ } else {
+ d.swallow()
+ }
+ breakFound = dd.CheckBreak()
+ }
+ if canChange && j < len(v) {
+ v = v[:j]
+ changed = true
+ }
+ }
+ slh.End()
+ return v, changed
+}
+
+func (f *decFnInfo) fastpathDecSliceIntR(rv reflect.Value) {
+ array := f.seq == seqTypeArray
+ if !array && rv.CanAddr() {
vp := rv.Addr().Interface().(*[]int)
v, changed := fastpathTV.DecSliceIntV(*vp, fastpathCheckNilFalse, !array, f.d)
if changed {
@@ -12951,10 +19354,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 +19365,83 @@ func (_ fastpathT) DecSliceIntV(v []int, checkNil bool, canChange bool,
}
slh, containerLenS := d.decSliceHelperStart()
- if canChange && v == nil {
- if containerLenS <= 0 {
- v = []int{}
- } else {
- v = make([]int, containerLenS, containerLenS)
- }
- changed = true
- }
if containerLenS == 0 {
- if canChange && len(v) != 0 {
- v = v[:0]
+ if canChange {
+ if v == nil {
+ v = []int{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
changed = true
}
+ slh.End()
return v, changed
}
- // for j := 0; j < containerLenS; j++ {
if containerLenS > 0 {
- decLen := containerLenS
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
if canChange {
- s := make([]int, containerLenS, containerLenS)
- // copy(s, v[:cap(v)])
- v = s
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]int, xlen)
+ }
+ } else {
+ v = make([]int, xlen)
+ }
changed = true
} else {
d.arrayCannotExpand(len(v), containerLenS)
- decLen = len(v)
}
+ x2read = len(v)
} else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
+ }
}
- // all checks done. cannot go past len.
j := 0
- for ; j < decLen; j++ {
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
v[j] = int(dd.DecodeInt(intBitsize))
}
- if !canChange {
+ if xtrunc {
for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = int(dd.DecodeInt(intBitsize))
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
d.swallow()
}
}
} else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []int{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]int, 1, 4)
+ changed = true
+ }
j := 0
- for ; !dd.CheckBreak(); j++ {
+ for ; !breakFound; j++ {
if j >= len(v) {
if canChange {
v = append(v, 0)
@@ -13017,23 +19450,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 +19487,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 +19498,83 @@ func (_ fastpathT) DecSliceInt8V(v []int8, checkNil bool, canChange bool,
}
slh, containerLenS := d.decSliceHelperStart()
- if canChange && v == nil {
- if containerLenS <= 0 {
- v = []int8{}
- } else {
- v = make([]int8, containerLenS, containerLenS)
- }
- changed = true
- }
if containerLenS == 0 {
- if canChange && len(v) != 0 {
- v = v[:0]
+ if canChange {
+ if v == nil {
+ v = []int8{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
changed = true
}
+ slh.End()
return v, changed
}
- // for j := 0; j < containerLenS; j++ {
if containerLenS > 0 {
- decLen := containerLenS
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
if canChange {
- s := make([]int8, containerLenS, containerLenS)
- // copy(s, v[:cap(v)])
- v = s
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 1)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]int8, xlen)
+ }
+ } else {
+ v = make([]int8, xlen)
+ }
changed = true
} else {
d.arrayCannotExpand(len(v), containerLenS)
- decLen = len(v)
}
+ x2read = len(v)
} else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
+ }
}
- // all checks done. cannot go past len.
j := 0
- for ; j < decLen; j++ {
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
v[j] = int8(dd.DecodeInt(8))
}
- if !canChange {
+ if xtrunc {
for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = int8(dd.DecodeInt(8))
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
d.swallow()
}
}
} else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []int8{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]int8, 1, 4)
+ changed = true
+ }
j := 0
- for ; !dd.CheckBreak(); j++ {
+ for ; !breakFound; j++ {
if j >= len(v) {
if canChange {
v = append(v, 0)
@@ -13117,23 +19583,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 +19620,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 +19631,83 @@ func (_ fastpathT) DecSliceInt16V(v []int16, checkNil bool, canChange bool,
}
slh, containerLenS := d.decSliceHelperStart()
- if canChange && v == nil {
- if containerLenS <= 0 {
- v = []int16{}
- } else {
- v = make([]int16, containerLenS, containerLenS)
- }
- changed = true
- }
if containerLenS == 0 {
- if canChange && len(v) != 0 {
- v = v[:0]
+ if canChange {
+ if v == nil {
+ v = []int16{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
changed = true
}
+ slh.End()
return v, changed
}
- // for j := 0; j < containerLenS; j++ {
if containerLenS > 0 {
- decLen := containerLenS
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
if canChange {
- s := make([]int16, containerLenS, containerLenS)
- // copy(s, v[:cap(v)])
- v = s
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 2)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]int16, xlen)
+ }
+ } else {
+ v = make([]int16, xlen)
+ }
changed = true
} else {
d.arrayCannotExpand(len(v), containerLenS)
- decLen = len(v)
}
+ x2read = len(v)
} else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
+ }
}
- // all checks done. cannot go past len.
j := 0
- for ; j < decLen; j++ {
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
v[j] = int16(dd.DecodeInt(16))
}
- if !canChange {
+ if xtrunc {
for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = int16(dd.DecodeInt(16))
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
d.swallow()
}
}
} else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []int16{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]int16, 1, 4)
+ changed = true
+ }
j := 0
- for ; !dd.CheckBreak(); j++ {
+ for ; !breakFound; j++ {
if j >= len(v) {
if canChange {
v = append(v, 0)
@@ -13217,23 +19716,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 +19753,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 +19764,83 @@ func (_ fastpathT) DecSliceInt32V(v []int32, checkNil bool, canChange bool,
}
slh, containerLenS := d.decSliceHelperStart()
- if canChange && v == nil {
- if containerLenS <= 0 {
- v = []int32{}
- } else {
- v = make([]int32, containerLenS, containerLenS)
- }
- changed = true
- }
if containerLenS == 0 {
- if canChange && len(v) != 0 {
- v = v[:0]
+ if canChange {
+ if v == nil {
+ v = []int32{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
changed = true
}
+ slh.End()
return v, changed
}
- // for j := 0; j < containerLenS; j++ {
if containerLenS > 0 {
- decLen := containerLenS
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
if canChange {
- s := make([]int32, containerLenS, containerLenS)
- // copy(s, v[:cap(v)])
- v = s
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 4)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]int32, xlen)
+ }
+ } else {
+ v = make([]int32, xlen)
+ }
changed = true
} else {
d.arrayCannotExpand(len(v), containerLenS)
- decLen = len(v)
}
+ x2read = len(v)
} else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
+ }
}
- // all checks done. cannot go past len.
j := 0
- for ; j < decLen; j++ {
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
v[j] = int32(dd.DecodeInt(32))
}
- if !canChange {
+ if xtrunc {
for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = int32(dd.DecodeInt(32))
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
d.swallow()
}
}
} else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []int32{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]int32, 1, 4)
+ changed = true
+ }
j := 0
- for ; !dd.CheckBreak(); j++ {
+ for ; !breakFound; j++ {
if j >= len(v) {
if canChange {
v = append(v, 0)
@@ -13317,23 +19849,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 +19886,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 +19897,83 @@ func (_ fastpathT) DecSliceInt64V(v []int64, checkNil bool, canChange bool,
}
slh, containerLenS := d.decSliceHelperStart()
- if canChange && v == nil {
- if containerLenS <= 0 {
- v = []int64{}
- } else {
- v = make([]int64, containerLenS, containerLenS)
- }
- changed = true
- }
if containerLenS == 0 {
- if canChange && len(v) != 0 {
- v = v[:0]
+ if canChange {
+ if v == nil {
+ v = []int64{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
changed = true
}
+ slh.End()
return v, changed
}
- // for j := 0; j < containerLenS; j++ {
if containerLenS > 0 {
- decLen := containerLenS
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
if canChange {
- s := make([]int64, containerLenS, containerLenS)
- // copy(s, v[:cap(v)])
- v = s
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]int64, xlen)
+ }
+ } else {
+ v = make([]int64, xlen)
+ }
changed = true
} else {
d.arrayCannotExpand(len(v), containerLenS)
- decLen = len(v)
}
+ x2read = len(v)
} else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
+ }
}
- // all checks done. cannot go past len.
j := 0
- for ; j < decLen; j++ {
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
v[j] = dd.DecodeInt(64)
}
- if !canChange {
+ if xtrunc {
for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = dd.DecodeInt(64)
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
d.swallow()
}
}
} else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []int64{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]int64, 1, 4)
+ changed = true
+ }
j := 0
- for ; !dd.CheckBreak(); j++ {
+ for ; !breakFound; j++ {
if j >= len(v) {
if canChange {
v = append(v, 0)
@@ -13417,23 +19982,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 +20019,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 +20030,83 @@ func (_ fastpathT) DecSliceBoolV(v []bool, checkNil bool, canChange bool,
}
slh, containerLenS := d.decSliceHelperStart()
- if canChange && v == nil {
- if containerLenS <= 0 {
- v = []bool{}
- } else {
- v = make([]bool, containerLenS, containerLenS)
- }
- changed = true
- }
if containerLenS == 0 {
- if canChange && len(v) != 0 {
- v = v[:0]
+ if canChange {
+ if v == nil {
+ v = []bool{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
changed = true
}
+ slh.End()
return v, changed
}
- // for j := 0; j < containerLenS; j++ {
if containerLenS > 0 {
- decLen := containerLenS
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
if canChange {
- s := make([]bool, containerLenS, containerLenS)
- // copy(s, v[:cap(v)])
- v = s
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 1)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]bool, xlen)
+ }
+ } else {
+ v = make([]bool, xlen)
+ }
changed = true
} else {
d.arrayCannotExpand(len(v), containerLenS)
- decLen = len(v)
}
+ x2read = len(v)
} else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
+ }
}
- // all checks done. cannot go past len.
j := 0
- for ; j < decLen; j++ {
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
v[j] = dd.DecodeBool()
}
- if !canChange {
+ if xtrunc {
for ; j < containerLenS; j++ {
+ v = append(v, false)
+ slh.ElemContainerState(j)
+ v[j] = dd.DecodeBool()
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
d.swallow()
}
}
} else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []bool{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]bool, 1, 4)
+ changed = true
+ }
j := 0
- for ; !dd.CheckBreak(); j++ {
+ for ; !breakFound; j++ {
if j >= len(v) {
if canChange {
v = append(v, false)
@@ -13517,21 +20115,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 +20153,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 +20164,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 +20245,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 +20256,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 +20283,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 +20327,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 +20338,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 +20365,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 +20409,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 +20420,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 +20447,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 +20491,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 +20502,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 +20529,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 +20573,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 +20584,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 +20611,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 +20655,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 +20666,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 +20693,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 +20819,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 +20830,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 +20857,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 +20901,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 +20912,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 +20939,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 +20983,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 +20994,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 +21021,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 +21065,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 +21076,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 +21103,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 +21147,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 +21158,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 +21185,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 +21229,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 +21240,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 +21267,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 +21311,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 +21322,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 +21349,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 +21393,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 +21404,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 +21431,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 +21475,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 +21486,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 +21559,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 +21570,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 +21593,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 +21633,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 +21644,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 +21667,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 +21707,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 +21718,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 +21741,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 +21781,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 +21792,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 +21815,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 +21855,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 +21866,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 +21889,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 +21929,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 +21940,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 +21963,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 +22077,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 +22088,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 +22111,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 +22151,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 +22162,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 +22185,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 +22225,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 +22236,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 +22259,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 +22299,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 +22310,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 +22333,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 +22373,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 +22384,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 +22407,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 +22447,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 +22458,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 +22481,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 +22521,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 +22532,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 +22555,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 +22595,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 +22606,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 +22629,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 +22669,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 +22680,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 +22753,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 +22764,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 +22787,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 +22827,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 +22838,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 +22861,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 +22901,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 +22912,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 +22935,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 +22975,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 +22986,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 +23009,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 +23049,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 +23060,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 +23083,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 +23123,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 +23134,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 +23157,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 +23271,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 +23282,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 +23305,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 +23345,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 +23356,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 +23379,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 +23419,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 +23430,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 +23453,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 +23493,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 +23504,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 +23527,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 +23567,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 +23578,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 +23601,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 +23641,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 +23652,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 +23675,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 +23715,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 +23726,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 +23749,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 +23789,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 +23800,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 +23823,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 +23863,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 +23874,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 +23947,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 +23958,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 +23981,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 +24021,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 +24032,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 +24055,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 +24095,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 +24106,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 +24129,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 +24169,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 +24180,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 +24203,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 +24243,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 +24254,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 +24277,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 +24317,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 +24328,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 +24351,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 +24465,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 +24476,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 +24499,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 +24539,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 +24550,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 +24573,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 +24613,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 +24624,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 +24647,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 +24687,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 +24698,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 +24721,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 +24761,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 +24772,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 +24795,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 +24835,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 +24846,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 +24869,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 +24909,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 +24920,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 +24943,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 +24983,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 +24994,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 +25017,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 +25057,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 +25068,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 +25141,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 +25152,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 +25175,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 +25215,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 +25226,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 +25249,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 +25289,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 +25300,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 +25323,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 +25363,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 +25374,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 +25397,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 +25437,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 +25448,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 +25471,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 +25511,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 +25522,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 +25545,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 +25659,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 +25670,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 +25693,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 +25733,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 +25744,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 +25767,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 +25807,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 +25818,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 +25841,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 +25881,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 +25892,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 +25915,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 +25955,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 +25966,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 +25989,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 +26029,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 +26040,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 +26063,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 +26103,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 +26114,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 +26137,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 +26177,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 +26188,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 +26211,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 +26251,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 +26262,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 +26335,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 +26346,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 +26369,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 +26409,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 +26420,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 +26443,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 +26483,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 +26494,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 +26517,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 +26557,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 +26568,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 +26591,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 +26631,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 +26642,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 +26665,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 +26705,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 +26716,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 +26739,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 +26853,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 +26864,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 +26887,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 +26927,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 +26938,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 +26961,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 +27001,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 +27012,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 +27035,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 +27075,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 +27086,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 +27109,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 +27149,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 +27160,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 +27183,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 +27223,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 +27234,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 +27257,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 +27297,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 +27308,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 +27331,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 +27371,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 +27382,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 +27405,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 +27445,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 +27456,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 +27529,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 +27540,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 +27563,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 +27603,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 +27614,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 +27637,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 +27677,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 +27688,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 +27711,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 +27751,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 +27762,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 +27785,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 +27825,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 +27836,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 +27859,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 +27899,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 +27910,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 +27933,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 +28047,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 +28058,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 +28081,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 +28121,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 +28132,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 +28155,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 +28195,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 +28206,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 +28229,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 +28269,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 +28280,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 +28303,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 +28343,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 +28354,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 +28377,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 +28417,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 +28428,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 +28451,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 +28491,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 +28502,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 +28525,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 +28565,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 +28576,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 +28599,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 +28639,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 +28650,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 +28723,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 +28734,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 +28757,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 +28797,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 +28808,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 +28831,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 +28871,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 +28882,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 +28905,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 +28945,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 +28956,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 +28979,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 +29019,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 +29030,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 +29053,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 +29093,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 +29104,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 +29127,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 +29241,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 +29252,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 +29275,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 +29315,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 +29326,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 +29349,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 +29389,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 +29400,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 +29423,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 +29463,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 +29474,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 +29497,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 +29537,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 +29548,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 +29571,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 +29611,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 +29622,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 +29645,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 +29685,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 +29696,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 +29719,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 +29759,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 +29770,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 +29793,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 +29833,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 +29844,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 +29917,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 +29928,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 +29951,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 +29991,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 +30002,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 +30025,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 +30065,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 +30076,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 +30099,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 +30139,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 +30150,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 +30173,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 +30213,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 +30224,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 +30247,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 +30287,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 +30298,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 +30321,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 +30435,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 +30446,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 +30469,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 +30509,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 +30520,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 +30543,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 +30583,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 +30594,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 +30617,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 +30657,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 +30668,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 +30691,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 +30731,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 +30742,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 +30765,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 +30805,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 +30816,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 +30839,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 +30879,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 +30890,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 +30913,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 +30953,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 +30964,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 +30987,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 +32221,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 +32232,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 +32305,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 +32316,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 +32339,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 +32379,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 +32390,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 +32413,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 +32453,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 +32464,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 +32487,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 +32527,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 +32538,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 +32561,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 +32601,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 +32612,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 +32635,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 +32675,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 +32686,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 +32709,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 +32823,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 +32834,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 +32857,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 +32897,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 +32908,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 +32931,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 +32971,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 +32982,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 +33005,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 +33045,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 +33056,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 +33079,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 +33119,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 +33130,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 +33153,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 +33193,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 +33204,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 +33227,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 +33267,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 +33278,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 +33301,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 +33341,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 +33352,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 +33375,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 +33415,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 +33426,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 +33499,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 +33510,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 +33533,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 +33573,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 +33584,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 +33607,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 +33647,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 +33658,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 +33681,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 +33721,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 +33732,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 +33755,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 +33795,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 +33806,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 +33829,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 +33869,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 +33880,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 +33903,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 +34017,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 +34028,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 +34051,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 +34091,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 +34102,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 +34125,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 +34165,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 +34176,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 +34199,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 +34239,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 +34250,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 +34273,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 +34313,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 +34324,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 +34347,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 +34387,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 +34398,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 +34421,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 +34461,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 +34472,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 +34495,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 +34535,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 +34546,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 +34569,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 +34609,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 +34620,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 +34693,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 +34704,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 +34727,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 +34767,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 +34778,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 +34801,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 +34841,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 +34852,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 +34875,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 +34915,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 +34926,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 +34949,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 +34989,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 +35000,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 +35023,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 +35063,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 +35074,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 +35097,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 +35211,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 +35222,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 +35245,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 +35285,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 +35296,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 +35319,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 +35359,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 +35370,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 +35393,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 +35433,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 +35444,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 +35467,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 +35507,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 +35518,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 +35541,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 +35581,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 +35592,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 +35615,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 +35655,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 +35666,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 +35689,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 +35729,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 +35740,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 +35763,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 +35803,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 +35814,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 +35887,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 +35898,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 +35921,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 +35961,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 +35972,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 +35995,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 +36035,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 +36046,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 +36069,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 +36109,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 +36120,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 +36143,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 +36183,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 +36194,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 +36217,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 +36257,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 +36268,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 +36291,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 +36405,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 +36416,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 +36439,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 +36479,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 +36490,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 +36513,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 +36553,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 +36564,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 +36587,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 +36627,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 +36638,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 +36661,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 +36701,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 +36712,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 +36735,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 +36775,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 +36786,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 +36809,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 +36849,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 +36860,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 +36883,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 +36923,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 +36934,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 +36957,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 +36997,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 +37008,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 +37081,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 +37092,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 +37115,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 +37155,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 +37166,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 +37189,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 +37229,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 +37240,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 +37263,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 +37303,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 +37314,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 +37337,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 +37377,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 +37388,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 +37411,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 +37451,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 +37462,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 +37485,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 +37599,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 +37610,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 +37633,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 +37673,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 +37684,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 +37707,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 +37747,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 +37758,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 +37781,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 +37821,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 +37832,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 +37855,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 +37895,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 +37906,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 +37929,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 +37969,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 +37980,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 +38003,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 +38043,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 +38054,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 +38077,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 +38117,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 +38128,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 +38151,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 +38191,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 +38202,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 +38275,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 +38286,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 +38309,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 +38349,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 +38360,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 +38383,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 +38423,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 +38434,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 +38457,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 +38497,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 +38508,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 +38531,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 +38571,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 +38582,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 +38605,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 +38645,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 +38656,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 +38679,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 +38793,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 +38804,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 +38827,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 +38867,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 +38878,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 +38901,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 +38941,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 +38952,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 +38975,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 +39015,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 +39026,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 +39049,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 +39089,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 +39100,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 +39123,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 +39163,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 +39174,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 +39197,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 +39237,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 +39248,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 +39271,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 +39311,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 +39322,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 +39345,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/Godeps/_workspace/src/github.com/ugorji/go/codec/fast-path.go.tmpl b/Godeps/_workspace/src/github.com/ugorji/go/codec/fast-path.go.tmpl
index 9f0adccf83..04c173fbaa 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/fast-path.go.tmpl
+++ b/Godeps/_workspace/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,178 @@ 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) {
- fastpathTV.{{ .MethodNamePfx "Enc" false }}V(rv.Interface().([]{{ .Elem }}), fastpathCheckNilFalse, f.e)
+func (f *encFnInfo) {{ .MethodNamePfx "fastpathEnc" false }}R(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.{{ .MethodNamePfx "EncAsMap" false }}V(rv.Interface().([]{{ .Elem }}), fastpathCheckNilFalse, f.e)
+ } else {
+ 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() */}}
+}
+
+func (_ fastpathT) {{ .MethodNamePfx "EncAsMap" false }}V(v []{{ .Elem }}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ {{ encmd .Elem "v2"}}
+ }
+ if cr != nil { cr.sendContainerState(containerMapEnd) }
}
{{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 +286,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 +302,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 +336,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 +347,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 v, changed
}
- // for j := 0; j < containerLenS; j++ {
if containerLenS > 0 {
- decLen := containerLenS
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
- if canChange {
- s := make([]{{ .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 v, changed
+ }
+ 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 +435,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 +484,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 +495,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/Godeps/_workspace/src/github.com/ugorji/go/codec/fast-path.not.go b/Godeps/_workspace/src/github.com/ugorji/go/codec/fast-path.not.go
new file mode 100644
index 0000000000..d6f5f0c911
--- /dev/null
+++ b/Godeps/_workspace/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/Godeps/_workspace/src/github.com/ugorji/go/codec/gen-dec-array.go.tmpl b/Godeps/_workspace/src/github.com/ugorji/go/codec/gen-dec-array.go.tmpl
index 0f4ea91d21..32df54144c 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/gen-dec-array.go.tmpl
+++ b/Godeps/_workspace/src/github.com/ugorji/go/codec/gen-dec-array.go.tmpl
@@ -1,80 +1,104 @@
-{{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 */}}{{if not isArray}}
+var {{var "c"}} bool {{/* // changed */}}
+_ = {{var "c"}}{{end}}
+if {{var "l"}} == 0 {
+ {{if isSlice }}if {{var "v"}} == nil {
+ {{var "v"}} = []{{ .Typ }}{}
+ {{var "c"}} = true
+ } else if len({{var "v"}}) != 0 {
+ {{var "v"}} = {{var "v"}}[:0]
+ {{var "c"}} = true
+ } {{end}} {{if isChan }}if {{var "v"}} == nil {
+ {{var "v"}} = make({{ .CTyp }}, 0)
+ {{var "c"}} = true
+ } {{end}}
} else if {{var "l"}} > 0 {
- {{ if isChan }}
+ {{if 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 */}}
+ _, _ = {{var "rl"}}, {{var "rt"}}
+ {{var "rr"}} = {{var "l"}} // len({{var "v"}})
+ if {{var "l"}} > cap({{var "v"}}) {
+ {{if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "l"}})
+ {{ else }}{{if not .Immutable }}
+ {{var "rg"}} := len({{var "v"}}) > 0
+ {{var "v2"}} := {{var "v"}} {{end}}
+ {{var "rl"}}, {{var "rt"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})
+ if {{var "rt"}} {
+ if {{var "rl"}} <= cap({{var "v"}}) {
+ {{var "v"}} = {{var "v"}}[:{{var "rl"}}]
+ } else {
+ {{var "v"}} = make([]{{ .Typ }}, {{var "rl"}})
+ }
+ } else {
+ {{var "v"}} = make([]{{ .Typ }}, {{var "rl"}})
+ }
+ {{var "c"}} = true
+ {{var "rr"}} = len({{var "v"}}) {{if not .Immutable }}
+ if {{var "rg"}} { copy({{var "v"}}, {{var "v2"}}) } {{end}} {{end}}{{/* end not Immutable, isArray */}}
+ } {{if isSlice }} else if {{var "l"}} != len({{var "v"}}) {
+ {{var "v"}} = {{var "v"}}[:{{var "l"}}]
+ {{var "c"}} = true
+ } {{end}} {{/* end isSlice:47 */}}
{{var "j"}} := 0
- for ; {{var "j"}} < {{var "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/Godeps/_workspace/src/github.com/ugorji/go/codec/gen-dec-map.go.tmpl b/Godeps/_workspace/src/github.com/ugorji/go/codec/gen-dec-map.go.tmpl
index 9f8dafa548..77400e0a11 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/gen-dec-map.go.tmpl
+++ b/Godeps/_workspace/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/Godeps/_workspace/src/github.com/ugorji/go/codec/gen-helper.generated.go b/Godeps/_workspace/src/github.com/ugorji/go/codec/gen-helper.generated.go
index ecf3ee54cf..22bce776bb 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/gen-helper.generated.go
+++ b/Godeps/_workspace/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/Godeps/_workspace/src/github.com/ugorji/go/codec/gen-helper.go.tmpl b/Godeps/_workspace/src/github.com/ugorji/go/codec/gen-helper.go.tmpl
index 89d75185a6..31958574ff 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/gen-helper.go.tmpl
+++ b/Godeps/_workspace/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/Godeps/_workspace/src/github.com/ugorji/go/codec/gen.generated.go b/Godeps/_workspace/src/github.com/ugorji/go/codec/gen.generated.go
index 8cc254ebff..2ace97b78c 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/gen.generated.go
+++ b/Godeps/_workspace/src/github.com/ugorji/go/codec/gen.generated.go
@@ -8,132 +8,168 @@ 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 */}}{{if not isArray}}
+var {{var "c"}} bool {{/* // changed */}}
+_ = {{var "c"}}{{end}}
+if {{var "l"}} == 0 {
+ {{if isSlice }}if {{var "v"}} == nil {
+ {{var "v"}} = []{{ .Typ }}{}
+ {{var "c"}} = true
+ } else if len({{var "v"}}) != 0 {
+ {{var "v"}} = {{var "v"}}[:0]
+ {{var "c"}} = true
+ } {{end}} {{if isChan }}if {{var "v"}} == nil {
+ {{var "v"}} = make({{ .CTyp }}, 0)
+ {{var "c"}} = true
+ } {{end}}
} else if {{var "l"}} > 0 {
- {{ if isChan }}
+ {{if 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 */}}
+ _, _ = {{var "rl"}}, {{var "rt"}}
+ {{var "rr"}} = {{var "l"}} // len({{var "v"}})
+ if {{var "l"}} > cap({{var "v"}}) {
+ {{if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "l"}})
+ {{ else }}{{if not .Immutable }}
+ {{var "rg"}} := len({{var "v"}}) > 0
+ {{var "v2"}} := {{var "v"}} {{end}}
+ {{var "rl"}}, {{var "rt"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})
+ if {{var "rt"}} {
+ if {{var "rl"}} <= cap({{var "v"}}) {
+ {{var "v"}} = {{var "v"}}[:{{var "rl"}}]
+ } else {
+ {{var "v"}} = make([]{{ .Typ }}, {{var "rl"}})
+ }
+ } else {
+ {{var "v"}} = make([]{{ .Typ }}, {{var "rl"}})
+ }
+ {{var "c"}} = true
+ {{var "rr"}} = len({{var "v"}}) {{if not .Immutable }}
+ if {{var "rg"}} { copy({{var "v"}}, {{var "v2"}}) } {{end}} {{end}}{{/* end not Immutable, isArray */}}
+ } {{if isSlice }} else if {{var "l"}} != len({{var "v"}}) {
+ {{var "v"}} = {{var "v"}}[:{{var "l"}}]
+ {{var "c"}} = true
+ } {{end}} {{/* end isSlice:47 */}}
{{var "j"}} := 0
- for ; {{var "j"}} < {{var "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/Godeps/_workspace/src/github.com/ugorji/go/codec/gen.go b/Godeps/_workspace/src/github.com/ugorji/go/codec/gen.go
index b1eee33fe0..d4dcbdcc08 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/gen.go
+++ b/Godeps/_workspace/src/github.com/ugorji/go/codec/gen.go
@@ -12,24 +12,39 @@ import (
"io"
"io/ioutil"
"math/rand"
+ "os"
"reflect"
"regexp"
+ "sort"
"strconv"
"strings"
"sync"
"text/template"
"time"
+ "unicode"
+ "unicode/utf8"
)
// ---------------------------------------------------
-// codecgen only works in the following:
-// - extensions are not supported. Do not make a type a Selfer and an extension.
-// - Selfer takes precedence.
-// Any type that implements it knows how to encode/decode itself statically.
-// Extensions are only known at runtime.
-// codecgen only looks at the Kind of the type.
+// codecgen supports the full cycle of reflection-based codec:
+// - RawExt
+// - Builtins
+// - Extensions
+// - (Binary|Text|JSON)(Unm|M)arshal
+// - generic by-kind
//
-// - the following types are supported:
+// This means that, for dynamic things, we MUST use reflection to at least get the reflect.Type.
+// In those areas, we try to only do reflection or interface-conversion when NECESSARY:
+// - Extensions, only if Extensions are configured.
+//
+// However, codecgen doesn't support the following:
+// - Canonical option. (codecgen IGNORES it currently)
+// This is just because it has not been implemented.
+//
+// During encode/decode, Selfer takes precedence.
+// A type implementing Selfer will know how to encode/decode itself statically.
+//
+// The following field types are supported:
// array: [n]T
// slice: []T
// map: map[K]V
@@ -66,11 +81,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 +113,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 +131,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 +174,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 +219,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 +240,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 +274,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 +308,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 +342,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 +369,19 @@ func (x *genRunner) genRefPkgs(t reflect.Type) {
if _, ok := x.is[t]; ok {
return
}
- // fmt.Printf(">>>>>>: PkgPath: '%v', Name: '%s'\n", t.PkgPath(), t.Name())
+ // fmt.Printf(">>>>>>: PkgPath: '%v', Name: '%s'\n", genImportPath(t), t.Name())
x.is[t] = struct{}{}
- tpkg, tname := t.PkgPath(), t.Name()
+ tpkg, tname := genImportPath(t), t.Name()
if tpkg != "" && tpkg != x.bp && tpkg != x.cp && tname != "" && tname[0] >= 'A' && tname[0] <= 'Z' {
- x.im[tpkg] = t
+ if _, ok := x.im[tpkg]; !ok {
+ x.im[tpkg] = t
+ if idx := strings.LastIndex(tpkg, "/"); idx < 0 {
+ x.imn[tpkg] = tpkg
+ } else {
+ x.imc++
+ x.imn[tpkg] = "pkg" + strconv.FormatUint(x.imc, 10) + "_" + genGoIdentifier(tpkg[idx+1:], false)
+ }
+ }
}
switch t.Kind() {
case reflect.Array, reflect.Slice, reflect.Ptr, reflect.Chan:
@@ -342,7 +425,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 +509,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 +532,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 +555,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 +565,38 @@ func (x *genRunner) selfer(encode bool) {
func (x *genRunner) xtraSM(varname string, encode bool, t reflect.Type) {
if encode {
x.linef("h.enc%s((%s%s)(%s), e)", x.genMethodNameT(t), x.arr2str(t, "*"), x.genTypeName(t), varname)
- // x.line("h.enc" + x.genMethodNameT(t) + "(" + x.genTypeName(t) + "(" + varname + "), e)")
} else {
x.linef("h.dec%s((*%s)(%s), d)", x.genMethodNameT(t), x.genTypeName(t), varname)
- // x.line("h.dec" + x.genMethodNameT(t) + "((*" + x.genTypeName(t) + ")(" + varname + "), d)")
}
- x.ts[t] = struct{}{}
+ x.registerXtraT(t)
+}
+
+func (x *genRunner) registerXtraT(t reflect.Type) {
+ // recursively register the types
+ if _, ok := x.tm[t]; ok {
+ return
+ }
+ var tkey reflect.Type
+ switch t.Kind() {
+ case reflect.Chan, reflect.Slice, reflect.Array:
+ case reflect.Map:
+ tkey = t.Key()
+ default:
+ return
+ }
+ x.tm[t] = struct{}{}
+ x.ts = append(x.ts, t)
+ // check if this refers to any xtra types eg. a slice of array: add the array
+ x.registerXtraT(t.Elem())
+ if tkey != nil {
+ x.registerXtraT(tkey)
+ }
}
// encVar will encode a variable.
// The parameter, t, is the reflect.Type of the variable itself
func (x *genRunner) encVar(varname string, t reflect.Type) {
+ // fmt.Printf(">>>>>> varname: %s, t: %v\n", varname, t)
var checkNil bool
switch t.Kind() {
case reflect.Ptr, reflect.Interface, reflect.Slice, reflect.Map, reflect.Chan:
@@ -467,49 +629,115 @@ func (x *genRunner) encVar(varname string, t reflect.Type) {
}
-// enc will encode a variable (varname) of type T,
-// except t is of kind reflect.Struct or reflect.Array, wherein varname is of type *T (to prevent copying)
+// enc will encode a variable (varname) of type t,
+// except t is of kind reflect.Struct or reflect.Array, wherein varname is of type ptrTo(T) (to prevent copying)
func (x *genRunner) enc(varname string, t reflect.Type) {
- // varName here must be to a pointer to a struct, or to a value directly.
rtid := reflect.ValueOf(t).Pointer()
// We call CodecEncodeSelf if one of the following are honored:
// - the type already implements Selfer, call that
// - the type has a Selfer implementation just created, use that
// - the type is in the list of the ones we will generate for, but it is not currently being generated
- if t.Implements(selferTyp) {
- x.line(varname + ".CodecEncodeSelf(e)")
- return
- }
- if t.Kind() == reflect.Struct && reflect.PtrTo(t).Implements(selferTyp) {
- x.line(varname + ".CodecEncodeSelf(e)")
- return
- }
- if _, ok := x.te[rtid]; ok {
- x.line(varname + ".CodecEncodeSelf(e)")
- return
+
+ mi := x.varsfx()
+ tptr := reflect.PtrTo(t)
+ tk := t.Kind()
+ if x.checkForSelfer(t, varname) {
+ if tk == reflect.Array || tk == reflect.Struct { // varname is of type *T
+ if tptr.Implements(selferTyp) || t.Implements(selferTyp) {
+ x.line(varname + ".CodecEncodeSelf(e)")
+ return
+ }
+ } else { // varname is of type T
+ if t.Implements(selferTyp) {
+ x.line(varname + ".CodecEncodeSelf(e)")
+ return
+ } else if tptr.Implements(selferTyp) {
+ x.linef("%ssf%s := &%s", genTempVarPfx, mi, varname)
+ x.linef("%ssf%s.CodecEncodeSelf(e)", genTempVarPfx, mi)
+ return
+ }
+ }
+
+ if _, ok := x.te[rtid]; ok {
+ x.line(varname + ".CodecEncodeSelf(e)")
+ return
+ }
}
inlist := false
for _, t0 := range x.t {
if t == t0 {
inlist = true
- if t != x.tc {
+ if x.checkForSelfer(t, varname) {
x.line(varname + ".CodecEncodeSelf(e)")
return
}
break
}
}
+
var rtidAdded bool
if t == x.tc {
x.te[rtid] = true
rtidAdded = true
}
+ // check if
+ // - type is RawExt
+ // - the type implements (Text|JSON|Binary)(Unm|M)arshal
+ x.linef("%sm%s := z.EncBinary()", genTempVarPfx, mi)
+ x.linef("_ = %sm%s", genTempVarPfx, mi)
+ x.line("if false {") //start if block
+ defer func() { x.line("}") }() //end if block
+
+ if t == rawExtTyp {
+ x.linef("} else { r.EncodeRawExt(%v, e)", varname)
+ return
+ }
+ // HACK: Support for Builtins.
+ // Currently, only Binc supports builtins, and the only builtin type is time.Time.
+ // Have a method that returns the rtid for time.Time if Handle is Binc.
+ if t == timeTyp {
+ vrtid := genTempVarPfx + "m" + x.varsfx()
+ x.linef("} else if %s := z.TimeRtidIfBinc(); %s != 0 { ", vrtid, vrtid)
+ x.linef("r.EncodeBuiltin(%s, %s)", vrtid, varname)
+ }
+ // only check for extensions if the type is named, and has a packagePath.
+ if genImportPath(t) != "" && t.Name() != "" {
+ // first check if extensions are configued, before doing the interface conversion
+ x.linef("} else if z.HasExtensions() && z.EncExt(%s) {", varname)
+ }
+ if tk == reflect.Array || tk == reflect.Struct { // varname is of type *T
+ if t.Implements(binaryMarshalerTyp) || tptr.Implements(binaryMarshalerTyp) {
+ x.linef("} else if %sm%s { z.EncBinaryMarshal(%v) ", genTempVarPfx, mi, varname)
+ }
+ if t.Implements(jsonMarshalerTyp) || tptr.Implements(jsonMarshalerTyp) {
+ x.linef("} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", genTempVarPfx, mi, varname)
+ } else if t.Implements(textMarshalerTyp) || tptr.Implements(textMarshalerTyp) {
+ x.linef("} else if !%sm%s { z.EncTextMarshal(%v) ", genTempVarPfx, mi, varname)
+ }
+ } else { // varname is of type T
+ if t.Implements(binaryMarshalerTyp) {
+ x.linef("} else if %sm%s { z.EncBinaryMarshal(%v) ", genTempVarPfx, mi, varname)
+ } else if tptr.Implements(binaryMarshalerTyp) {
+ x.linef("} else if %sm%s { z.EncBinaryMarshal(&%v) ", genTempVarPfx, mi, varname)
+ }
+ if t.Implements(jsonMarshalerTyp) {
+ x.linef("} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", genTempVarPfx, mi, varname)
+ } else if tptr.Implements(jsonMarshalerTyp) {
+ x.linef("} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(&%v) ", genTempVarPfx, mi, varname)
+ } else if t.Implements(textMarshalerTyp) {
+ x.linef("} else if !%sm%s { z.EncTextMarshal(%v) ", genTempVarPfx, mi, varname)
+ } else if tptr.Implements(textMarshalerTyp) {
+ x.linef("} else if !%sm%s { z.EncTextMarshal(&%v) ", genTempVarPfx, mi, varname)
+ }
+ }
+ x.line("} else {")
+
switch t.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
x.line("r.EncodeInt(int64(" + varname + "))")
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
x.line("r.EncodeUint(uint64(" + varname + "))")
case reflect.Float32:
x.line("r.EncodeFloat32(float32(" + varname + "))")
@@ -534,7 +762,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 +776,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 +801,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 +821,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 +871,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 +923,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 +939,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 +960,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 +1015,17 @@ func (x *genRunner) decVar(varname string, t reflect.Type, canBeNil bool) {
x.line("if r.TryDecodeAsNil() {")
if t.Kind() == reflect.Ptr {
x.line("if " + varname + " != nil { ")
- // x.line("var " + genTempVarPfx + i + " " + x.genTypeName(t.Elem()))
- // x.line("*" + varname + " = " + genTempVarPfx + i)
// if varname is a field of a struct (has a dot in it),
// then just set it to nil
if strings.IndexByte(varname, '.') != -1 {
x.line(varname + " = nil")
} else {
- x.line("*" + varname + " = " + genZeroValueR(t.Elem(), x.tc))
+ x.line("*" + varname + " = " + x.genZeroValueR(t.Elem()))
}
- // x.line("*" + varname + " = nil")
x.line("}")
-
} else {
- // x.line("var " + genTempVarPfx + i + " " + x.genTypeName(t))
- // x.line(varname + " = " + genTempVarPfx + i)
- x.line(varname + " = " + genZeroValueR(t, x.tc))
+ x.line(varname + " = " + x.genZeroValueR(t))
}
x.line("} else {")
} else {
@@ -894,38 +1067,82 @@ func (x *genRunner) decVar(varname string, t reflect.Type, canBeNil bool) {
}
}
+// dec will decode a variable (varname) of type ptrTo(t).
+// t is always a basetype (i.e. not of kind reflect.Ptr).
func (x *genRunner) dec(varname string, t reflect.Type) {
// assumptions:
// - the varname is to a pointer already. No need to take address of it
-
+ // - t is always a baseType T (not a *T, etc).
rtid := reflect.ValueOf(t).Pointer()
- if t.Implements(selferTyp) || (t.Kind() == reflect.Struct &&
- reflect.PtrTo(t).Implements(selferTyp)) {
- x.line(varname + ".CodecDecodeSelf(d)")
- return
- }
- if _, ok := x.td[rtid]; ok {
- x.line(varname + ".CodecDecodeSelf(d)")
- return
+ tptr := reflect.PtrTo(t)
+ if x.checkForSelfer(t, varname) {
+ if t.Implements(selferTyp) || tptr.Implements(selferTyp) {
+ x.line(varname + ".CodecDecodeSelf(d)")
+ return
+ }
+ if _, ok := x.td[rtid]; ok {
+ x.line(varname + ".CodecDecodeSelf(d)")
+ return
+ }
}
inlist := false
for _, t0 := range x.t {
if t == t0 {
inlist = true
- if t != x.tc {
+ if x.checkForSelfer(t, varname) {
x.line(varname + ".CodecDecodeSelf(d)")
return
}
break
}
}
+
var rtidAdded bool
if t == x.tc {
x.td[rtid] = true
rtidAdded = true
}
+ // check if
+ // - type is RawExt
+ // - the type implements (Text|JSON|Binary)(Unm|M)arshal
+ mi := x.varsfx()
+ x.linef("%sm%s := z.DecBinary()", genTempVarPfx, mi)
+ x.linef("_ = %sm%s", genTempVarPfx, mi)
+ x.line("if false {") //start if block
+ defer func() { x.line("}") }() //end if block
+
+ if t == rawExtTyp {
+ x.linef("} else { r.DecodeExt(%v, 0, nil)", varname)
+ return
+ }
+
+ // HACK: Support for Builtins.
+ // Currently, only Binc supports builtins, and the only builtin type is time.Time.
+ // Have a method that returns the rtid for time.Time if Handle is Binc.
+ if t == timeTyp {
+ vrtid := genTempVarPfx + "m" + x.varsfx()
+ x.linef("} else if %s := z.TimeRtidIfBinc(); %s != 0 { ", vrtid, vrtid)
+ x.linef("r.DecodeBuiltin(%s, %s)", vrtid, varname)
+ }
+ // only check for extensions if the type is named, and has a packagePath.
+ if genImportPath(t) != "" && t.Name() != "" {
+ // first check if extensions are configued, before doing the interface conversion
+ x.linef("} else if z.HasExtensions() && z.DecExt(%s) {", varname)
+ }
+
+ if t.Implements(binaryUnmarshalerTyp) || tptr.Implements(binaryUnmarshalerTyp) {
+ x.linef("} else if %sm%s { z.DecBinaryUnmarshal(%v) ", genTempVarPfx, mi, varname)
+ }
+ if t.Implements(jsonUnmarshalerTyp) || tptr.Implements(jsonUnmarshalerTyp) {
+ x.linef("} else if !%sm%s && z.IsJSONHandle() { z.DecJSONUnmarshal(%v)", genTempVarPfx, mi, varname)
+ } else if t.Implements(textUnmarshalerTyp) || tptr.Implements(textUnmarshalerTyp) {
+ x.linef("} else if !%sm%s { z.DecTextUnmarshal(%v)", genTempVarPfx, mi, varname)
+ }
+
+ x.line("} else {")
+
// Since these are pointers, we cannot share, and have to use them one by one
switch t.Kind() {
case reflect.Int:
@@ -959,6 +1176,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 +1204,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 +1216,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 +1252,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 +1279,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 +1305,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 +1324,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 +1347,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 +1404,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 +1413,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 +1425,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 +1434,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 +1459,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 +1481,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 +1532,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 +1558,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 +1606,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 +1618,49 @@ 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
+}
+
+// A go identifier is (letter|_)[letter|number|_]*
+func genGoIdentifier(s string, checkFirstChar bool) string {
+ b := make([]byte, 0, len(s))
+ t := make([]byte, 4)
+ var n int
+ for i, r := range s {
+ if checkFirstChar && i == 0 && !unicode.IsLetter(r) {
+ b = append(b, '_')
+ }
+ // r must be unicode_letter, unicode_digit or _
+ if unicode.IsLetter(r) || unicode.IsDigit(r) {
+ n = utf8.EncodeRune(t, r)
+ b = append(b, t[:n]...)
+ } else {
+ b = append(b, '_')
+ }
+ }
+ return string(b)
+}
+
func genNonPtr(t reflect.Type) reflect.Type {
for t.Kind() == reflect.Ptr {
t = t.Elem()
@@ -1393,59 +1677,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 +1717,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 +1754,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 +1817,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 +1839,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 +1875,7 @@ func genInternalInit() {
"uint16",
"uint32",
"uint64",
+ "uintptr",
"int",
"int8",
"int16",
@@ -1651,6 +1893,7 @@ func genInternalInit() {
"uint16",
"uint32",
"uint64",
+ "uintptr",
"int",
"int8",
"int16",
@@ -1660,23 +1903,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 +1944,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/Godeps/_workspace/src/github.com/ugorji/go/codec/helper.go b/Godeps/_workspace/src/github.com/ugorji/go/codec/helper.go
index 7848ea1359..40065a01c8 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/helper.go
+++ b/Godeps/_workspace/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,10 +147,18 @@ 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}
-var zeroByteSlice = oneByteArr[:0:0]
+var (
+ oneByteArr = [1]byte{0}
+ zeroByteSlice = oneByteArr[:0:0]
+)
type charEncoding uint8
@@ -193,16 +201,61 @@ 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 rgetPoolT struct {
+ encNames [8]string
+ fNames [8]string
+ etypes [8]uintptr
+ sfis [8]*structFieldInfo
+}
+
+var rgetPool = sync.Pool{
+ New: func() interface{} { return new(rgetPoolT) },
+}
+
+type rgetT struct {
+ fNames []string
+ encNames []string
+ etypes []uintptr
+ sfis []*structFieldInfo
+}
+
+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 +270,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 +281,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 +297,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 +324,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 +338,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 +371,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 +417,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 +519,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 +533,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 +558,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 +577,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 +598,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 +647,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 +702,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 +722,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 +761,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 +818,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,67 +850,131 @@ 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)
-
- ti.sfip = make([]*structFieldInfo, len(sfip))
- ti.sfi = make([]*structFieldInfo, len(sfip))
- copy(ti.sfip, sfip)
- sort.Sort(sfiSortedByEncName(sfip))
- copy(ti.sfi, sfip)
+ pi := rgetPool.Get()
+ pv := pi.(*rgetPoolT)
+ pv.etypes[0] = ti.baseId
+ vv := rgetT{pv.fNames[:0], pv.encNames[:0], pv.etypes[:1], pv.sfis[:0]}
+ x.rget(rt, rtid, nil, &vv, siInfo)
+ ti.sfip = make([]*structFieldInfo, len(vv.sfis))
+ ti.sfi = make([]*structFieldInfo, len(vv.sfis))
+ copy(ti.sfip, vv.sfis)
+ sort.Sort(sfiSortedByEncName(vv.sfis))
+ copy(ti.sfi, vv.sfis)
+ rgetPool.Put(pi)
}
// sfi = sfip
- cachedTypeInfo[rtid] = pti
+
+ x.mu.Lock()
+ if pti, ok = x.infos[rtid]; !ok {
+ pti = &ti
+ x.infos[rtid] = pti
+ }
+ x.mu.Unlock()
return
}
-func rgetTypeInfo(rt reflect.Type, indexstack []int, fnameToHastag map[string]bool,
- sfi *[]*structFieldInfo, siInfo *structFieldInfo,
+func (x *TypeInfos) rget(rt reflect.Type, rtid uintptr,
+ indexstack []int, pv *rgetT, siInfo *structFieldInfo,
) {
- for j := 0; j < rt.NumField(); j++ {
+ // This will read up the fields and store how to access the value.
+ // It uses the go language's rules for embedding, as below:
+ // - if a field has been seen while traversing, skip it
+ // - if an encName has been seen while traversing, skip it
+ // - if an embedded type has been seen, skip it
+ //
+ // Also, per Go's rules, embedded fields must be analyzed AFTER all top-level fields.
+ //
+ // Note: we consciously use slices, not a map, to simulate a set.
+ // Typically, types have < 16 fields, and iteration using equals is faster than maps there
+
+ type anonField struct {
+ ft reflect.Type
+ idx int
+ }
+
+ var anonFields []anonField
+
+LOOP:
+ for j, jlen := 0, rt.NumField(); j < jlen; j++ {
f := rt.Field(j)
- // func types are skipped.
- if tk := f.Type.Kind(); tk == reflect.Func {
+ fkind := f.Type.Kind()
+ // skip if a func type, or is unexported, or structTag value == "-"
+ switch fkind {
+ case reflect.Func, reflect.Complex64, reflect.Complex128, reflect.UnsafePointer:
+ continue LOOP
+ }
+
+ // if r1, _ := utf8.DecodeRuneInString(f.Name); r1 == utf8.RuneError || !unicode.IsUpper(r1) {
+ if f.PkgPath != "" && !f.Anonymous { // unexported, not embedded
continue
}
- stag := getStructTag(f.Tag)
+ stag := x.structTag(f.Tag)
if stag == "-" {
continue
}
- if r1, _ := utf8.DecodeRuneInString(f.Name); r1 == utf8.RuneError || !unicode.IsUpper(r1) {
- continue
- }
- // if anonymous and there is no struct tag and its a struct (or pointer to struct), inline it.
- if f.Anonymous && stag == "" {
- ft := f.Type
- for ft.Kind() == reflect.Ptr {
- ft = ft.Elem()
+ var si *structFieldInfo
+ // if anonymous and no struct tag (or it's blank), and a struct (or pointer to struct), inline it.
+ if f.Anonymous && fkind != reflect.Interface {
+ doInline := stag == ""
+ if !doInline {
+ si = parseStructFieldInfo("", stag)
+ doInline = si.encName == ""
+ // doInline = si.isZero()
}
- if ft.Kind() == reflect.Struct {
- indexstack2 := make([]int, len(indexstack)+1, len(indexstack)+4)
- copy(indexstack2, indexstack)
- indexstack2[len(indexstack)] = j
- // indexstack2 := append(append(make([]int, 0, len(indexstack)+4), indexstack...), j)
- rgetTypeInfo(ft, indexstack2, fnameToHastag, sfi, siInfo)
- continue
+ if doInline {
+ ft := f.Type
+ for ft.Kind() == reflect.Ptr {
+ ft = ft.Elem()
+ }
+ if ft.Kind() == reflect.Struct {
+ // handle anonymous fields after handling all the non-anon fields
+ anonFields = append(anonFields, anonField{ft, j})
+ continue
+ }
}
}
- // do not let fields with same name in embedded structs override field at higher level.
- // this must be done after anonymous check, to allow anonymous field
- // still include their child fields
- if _, ok := fnameToHastag[f.Name]; ok {
+
+ // after the anonymous dance: if an unexported field, skip
+ if f.PkgPath != "" { // unexported
continue
}
- si := parseStructFieldInfo(f.Name, stag)
+
+ if f.Name == "" {
+ panic(noFieldNameToStructFieldInfoErr)
+ }
+
+ for _, k := range pv.fNames {
+ if k == f.Name {
+ continue LOOP
+ }
+ }
+ pv.fNames = append(pv.fNames, f.Name)
+
+ if si == nil {
+ si = parseStructFieldInfo(f.Name, stag)
+ } else if si.encName == "" {
+ si.encName = f.Name
+ }
+
+ for _, k := range pv.encNames {
+ if k == si.encName {
+ continue LOOP
+ }
+ }
+ pv.encNames = append(pv.encNames, si.encName)
+
// si.ikind = int(f.Type.Kind())
if len(indexstack) == 0 {
si.i = int16(j)
} else {
si.i = -1
- si.is = append(append(make([]int, 0, len(indexstack)+4), indexstack...), j)
+ si.is = make([]int, len(indexstack)+1)
+ copy(si.is, indexstack)
+ si.is[len(indexstack)] = j
+ // si.is = append(append(make([]int, 0, len(indexstack)+4), indexstack...), j)
}
if siInfo != nil {
@@ -758,8 +982,26 @@ func rgetTypeInfo(rt reflect.Type, indexstack []int, fnameToHastag map[string]bo
si.omitEmpty = true
}
}
- *sfi = append(*sfi, si)
- fnameToHastag[f.Name] = stag != ""
+ pv.sfis = append(pv.sfis, si)
+ }
+
+ // now handle anonymous fields
+LOOP2:
+ for _, af := range anonFields {
+ // if etypes contains this, then do not call rget again (as the fields are already seen here)
+ ftid := reflect.ValueOf(af.ft).Pointer()
+ for _, k := range pv.etypes {
+ if k == ftid {
+ continue LOOP2
+ }
+ }
+ pv.etypes = append(pv.etypes, ftid)
+
+ indexstack2 := make([]int, len(indexstack)+1)
+ copy(indexstack2, indexstack)
+ indexstack2[len(indexstack)] = af.idx
+ // indexstack2 := append(append(make([]int, 0, len(indexstack)+4), indexstack...), j)
+ x.rget(af.ft, ftid, indexstack2, pv, siInfo)
}
}
@@ -779,8 +1021,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 +1033,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 +1088,184 @@ func (_ checkOverflow) SignedInt(v uint64) (i int64, overflow bool) {
i = int64(v)
return
}
+
+// ------------------ SORT -----------------
+
+func isNaN(f float64) bool { return f != f }
+
+// -----------------------
+
+type intSlice []int64
+type uintSlice []uint64
+type floatSlice []float64
+type boolSlice []bool
+type stringSlice []string
+type bytesSlice [][]byte
+
+func (p intSlice) Len() int { return len(p) }
+func (p intSlice) Less(i, j int) bool { return p[i] < p[j] }
+func (p intSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+
+func (p uintSlice) Len() int { return len(p) }
+func (p uintSlice) Less(i, j int) bool { return p[i] < p[j] }
+func (p uintSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+
+func (p floatSlice) Len() int { return len(p) }
+func (p floatSlice) Less(i, j int) bool {
+ return p[i] < p[j] || isNaN(p[i]) && !isNaN(p[j])
+}
+func (p floatSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+
+func (p stringSlice) Len() int { return len(p) }
+func (p stringSlice) Less(i, j int) bool { return p[i] < p[j] }
+func (p stringSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+
+func (p bytesSlice) Len() int { return len(p) }
+func (p bytesSlice) Less(i, j int) bool { return bytes.Compare(p[i], p[j]) == -1 }
+func (p bytesSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+
+func (p boolSlice) Len() int { return len(p) }
+func (p boolSlice) Less(i, j int) bool { return !p[i] && p[j] }
+func (p boolSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+
+// ---------------------
+
+type intRv struct {
+ v int64
+ r reflect.Value
+}
+type intRvSlice []intRv
+type uintRv struct {
+ v uint64
+ r reflect.Value
+}
+type uintRvSlice []uintRv
+type floatRv struct {
+ v float64
+ r reflect.Value
+}
+type floatRvSlice []floatRv
+type boolRv struct {
+ v bool
+ r reflect.Value
+}
+type boolRvSlice []boolRv
+type stringRv struct {
+ v string
+ r reflect.Value
+}
+type stringRvSlice []stringRv
+type bytesRv struct {
+ v []byte
+ r reflect.Value
+}
+type bytesRvSlice []bytesRv
+
+func (p intRvSlice) Len() int { return len(p) }
+func (p intRvSlice) Less(i, j int) bool { return p[i].v < p[j].v }
+func (p intRvSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+
+func (p uintRvSlice) Len() int { return len(p) }
+func (p uintRvSlice) Less(i, j int) bool { return p[i].v < p[j].v }
+func (p uintRvSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+
+func (p floatRvSlice) Len() int { return len(p) }
+func (p floatRvSlice) Less(i, j int) bool {
+ return p[i].v < p[j].v || isNaN(p[i].v) && !isNaN(p[j].v)
+}
+func (p floatRvSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+
+func (p stringRvSlice) Len() int { return len(p) }
+func (p stringRvSlice) Less(i, j int) bool { return p[i].v < p[j].v }
+func (p stringRvSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+
+func (p bytesRvSlice) Len() int { return len(p) }
+func (p bytesRvSlice) Less(i, j int) bool { return bytes.Compare(p[i].v, p[j].v) == -1 }
+func (p bytesRvSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+
+func (p boolRvSlice) Len() int { return len(p) }
+func (p boolRvSlice) Less(i, j int) bool { return !p[i].v && p[j].v }
+func (p boolRvSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+
+// -----------------
+
+type bytesI struct {
+ v []byte
+ i interface{}
+}
+
+type bytesISlice []bytesI
+
+func (p bytesISlice) Len() int { return len(p) }
+func (p bytesISlice) Less(i, j int) bool { return bytes.Compare(p[i].v, p[j].v) == -1 }
+func (p bytesISlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+
+// -----------------
+
+type set []uintptr
+
+func (s *set) add(v uintptr) (exists bool) {
+ // e.ci is always nil, or len >= 1
+ // defer func() { fmt.Printf("$$$$$$$$$$$ cirRef Add: %v, exists: %v\n", v, exists) }()
+ x := *s
+ if x == nil {
+ x = make([]uintptr, 1, 8)
+ x[0] = v
+ *s = x
+ return
+ }
+ // typically, length will be 1. make this perform.
+ if len(x) == 1 {
+ if j := x[0]; j == 0 {
+ x[0] = v
+ } else if j == v {
+ exists = true
+ } else {
+ x = append(x, v)
+ *s = x
+ }
+ return
+ }
+ // check if it exists
+ for _, j := range x {
+ if j == v {
+ exists = true
+ return
+ }
+ }
+ // try to replace a "deleted" slot
+ for i, j := range x {
+ if j == 0 {
+ x[i] = v
+ return
+ }
+ }
+ // if unable to replace deleted slot, just append it.
+ x = append(x, v)
+ *s = x
+ return
+}
+
+func (s *set) remove(v uintptr) (exists bool) {
+ // defer func() { fmt.Printf("$$$$$$$$$$$ cirRef Rm: %v, exists: %v\n", v, exists) }()
+ x := *s
+ if len(x) == 0 {
+ return
+ }
+ if len(x) == 1 {
+ if x[0] == v {
+ x[0] = 0
+ }
+ return
+ }
+ for i, j := range x {
+ if j == v {
+ exists = true
+ x[i] = 0 // set it to 0, as way to delete it.
+ // copy(x[i:], x[i+1:])
+ // x = x[:len(x)-1]
+ return
+ }
+ }
+ return
+}
diff --git a/Godeps/_workspace/src/github.com/ugorji/go/codec/helper_internal.go b/Godeps/_workspace/src/github.com/ugorji/go/codec/helper_internal.go
index c865246f49..dea981fbb7 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/helper_internal.go
+++ b/Godeps/_workspace/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/Godeps/_workspace/src/github.com/ugorji/go/codec/helper_unsafe.go b/Godeps/_workspace/src/github.com/ugorji/go/codec/helper_unsafe.go
index d7994961ea..373b2b1027 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/helper_unsafe.go
+++ b/Godeps/_workspace/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/Godeps/_workspace/src/github.com/ugorji/go/codec/json.go b/Godeps/_workspace/src/github.com/ugorji/go/codec/json.go
index cb370d48e7..a04dfcb9d3 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/json.go
+++ b/Godeps/_workspace/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"
@@ -38,26 +43,32 @@ import (
//--------------------------------
-var jsonLiterals = [...]byte{'t', 'r', 'u', 'e', 'f', 'a', 'l', 's', 'e', 'n', 'u', 'l', 'l'}
+var (
+ jsonLiterals = [...]byte{'t', 'r', 'u', 'e', 'f', 'a', 'l', 's', 'e', 'n', 'u', 'l', 'l'}
-var jsonFloat64Pow10 = [...]float64{
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
- 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
- 1e20, 1e21, 1e22,
-}
+ jsonFloat64Pow10 = [...]float64{
+ 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
+ 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
+ 1e20, 1e21, 1e22,
+ }
-var jsonUint64Pow10 = [...]uint64{
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
- 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
-}
+ jsonUint64Pow10 = [...]uint64{
+ 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
+ 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
+ }
+
+ // jsonTabs and jsonSpaces are used as caches for indents
+ jsonTabs, jsonSpaces string
+)
const (
- // if jsonTrackSkipWhitespace, we track Whitespace and reduce the number of redundant checks.
- // Make it a const flag, so that it can be elided during linking if false.
+ // jsonUnreadAfterDecNum controls whether we unread after decoding a number.
//
- // It is not a clear win, because we continually set a flag behind a pointer
- // and then check it each time, as opposed to just 4 conditionals on a stack variable.
- jsonTrackSkipWhitespace = true
+ // instead of unreading, just update d.tok (iff it's not a whitespace char)
+ // However, doing this means that we may HOLD onto some data which belongs to another stream.
+ // Thus, it is safest to unread the data when done.
+ // keep behind a constant flag for now.
+ jsonUnreadAfterDecNum = true
// If !jsonValidateSymbols, decoding will be faster, by skipping some checks:
// - If we see first character of null, false or true,
@@ -79,17 +90,100 @@ const (
jsonNumUintMaxVal = 1< 1<<53 || v < -(1<<53)) {
+ e.w.writen1('"')
+ e.w.writeb(strconv.AppendInt(e.b[:0], v, 10))
+ e.w.writen1('"')
+ return
+ }
e.w.writeb(strconv.AppendInt(e.b[:0], v, 10))
}
func (e *jsonEncDriver) EncodeUint(v uint64) {
+ if x := e.h.IntegerAsString; x == 'A' || x == 'L' && v > 1<<53 {
+ e.w.writen1('"')
+ e.w.writeb(strconv.AppendUint(e.b[:0], v, 10))
+ e.w.writen1('"')
+ return
+ }
e.w.writeb(strconv.AppendUint(e.b[:0], v, 10))
}
func (e *jsonEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext, en *Encoder) {
if v := ext.ConvertExt(rv); v == nil {
- e.EncodeNil()
+ e.w.writeb(jsonLiterals[9:13]) // null // e.EncodeNil()
} else {
en.encode(v)
}
@@ -130,38 +236,26 @@ func (e *jsonEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext, en *Enco
func (e *jsonEncDriver) EncodeRawExt(re *RawExt, en *Encoder) {
// only encodes re.Value (never re.Data)
if re.Value == nil {
- e.EncodeNil()
+ e.w.writeb(jsonLiterals[9:13]) // null // e.EncodeNil()
} else {
en.encode(re.Value)
}
}
func (e *jsonEncDriver) EncodeArrayStart(length int) {
+ if e.d {
+ e.dl++
+ }
e.w.writen1('[')
-}
-
-func (e *jsonEncDriver) EncodeArrayEntrySeparator() {
- e.w.writen1(',')
-}
-
-func (e *jsonEncDriver) EncodeArrayEnd() {
- e.w.writen1(']')
+ e.c = containerArrayStart
}
func (e *jsonEncDriver) EncodeMapStart(length int) {
+ if e.d {
+ e.dl++
+ }
e.w.writen1('{')
-}
-
-func (e *jsonEncDriver) EncodeMapEntrySeparator() {
- e.w.writen1(',')
-}
-
-func (e *jsonEncDriver) EncodeMapKVSeparator() {
- e.w.writen1(':')
-}
-
-func (e *jsonEncDriver) EncodeMapEnd() {
- e.w.writen1('}')
+ e.c = containerMapStart
}
func (e *jsonEncDriver) EncodeString(c charEncoding, v string) {
@@ -175,11 +269,13 @@ func (e *jsonEncDriver) EncodeSymbol(v string) {
}
func (e *jsonEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
+ // if encoding raw bytes and RawBytesExt is configured, use it to encode
+ if c == c_RAW && e.se.i != nil {
+ e.EncodeExt(v, 0, &e.se, e.e)
+ return
+ }
if c == c_RAW {
slen := base64.StdEncoding.EncodedLen(len(v))
- if e.bs == nil {
- e.bs = e.b[:]
- }
if cap(e.bs) >= slen {
e.bs = e.bs[:slen]
} else {
@@ -195,6 +291,10 @@ func (e *jsonEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
}
}
+func (e *jsonEncDriver) EncodeAsis(v []byte) {
+ e.w.writeb(v)
+}
+
func (e *jsonEncDriver) quoteStr(s string) {
// adapted from std pkg encoding/json
const hex = "0123456789abcdef"
@@ -266,7 +366,7 @@ func (e *jsonEncDriver) quoteStr(s string) {
//--------------------------------
type jsonNum struct {
- bytes []byte // may have [+-.eE0-9]
+ // bytes []byte // may have [+-.eE0-9]
mantissa uint64 // where mantissa ends, and maybe dot begins.
exponent int16 // exponent value.
manOverflow bool
@@ -276,7 +376,6 @@ type jsonNum struct {
}
func (x *jsonNum) reset() {
- x.bytes = x.bytes[:0]
x.manOverflow = false
x.neg = false
x.dot = false
@@ -309,29 +408,26 @@ func (x *jsonNum) uintExp() (n uint64, overflow bool) {
// return
}
-func (x *jsonNum) floatVal() (f float64) {
+// these constants are only used withn floatVal.
+// They are brought out, so that floatVal can be inlined.
+const (
+ jsonUint64MantissaBits = 52
+ jsonMaxExponent = int16(len(jsonFloat64Pow10)) - 1
+)
+
+func (x *jsonNum) floatVal() (f float64, parseUsingStrConv bool) {
// We do not want to lose precision.
// Consequently, we will delegate to strconv.ParseFloat if any of the following happen:
// - There are more digits than in math.MaxUint64: 18446744073709551615 (20 digits)
// We expect up to 99.... (19 digits)
// - The mantissa cannot fit into a 52 bits of uint64
// - The exponent is beyond our scope ie beyong 22.
- const uint64MantissaBits = 52
- const maxExponent = int16(len(jsonFloat64Pow10)) - 1
+ parseUsingStrConv = x.manOverflow ||
+ x.exponent > jsonMaxExponent ||
+ (x.exponent < 0 && -(x.exponent) > jsonMaxExponent) ||
+ x.mantissa>>jsonUint64MantissaBits != 0
- parseUsingStrConv := x.manOverflow ||
- x.exponent > maxExponent ||
- (x.exponent < 0 && -(x.exponent) > maxExponent) ||
- x.mantissa>>uint64MantissaBits != 0
if parseUsingStrConv {
- var err error
- if f, err = strconv.ParseFloat(stringView(x.bytes), 64); err != nil {
- panic(fmt.Errorf("parse float: %s, %v", x.bytes, err))
- return
- }
- if x.neg {
- f = -f
- }
return
}
@@ -350,162 +446,230 @@ func (x *jsonNum) floatVal() (f float64) {
}
type jsonDecDriver struct {
- d *Decoder
- h *JsonHandle
- r decReader // *bytesDecReader decReader
- ct valueType // container type. one of unset, array or map.
- bstr [8]byte // scratch used for string \UXXX parsing
- b [64]byte // scratch
+ noBuiltInTypes
+ d *Decoder
+ h *JsonHandle
+ r decReader
- wsSkipped bool // whitespace skipped
+ c containerState
+ // tok is used to store the token read right after skipWhiteSpace.
+ tok uint8
+
+ bstr [8]byte // scratch used for string \UXXX parsing
+ b [64]byte // scratch, used for parsing strings or numbers
+ b2 [64]byte // scratch, used only for decodeBytes (after base64)
+ bs []byte // scratch. Initialized from b. Used for parsing strings or numbers.
+
+ se setExtWrapper
n jsonNum
- noBuiltInTypes
}
-// This will skip whitespace characters and return the next byte to read.
-// The next byte determines what the value will be one of.
-func (d *jsonDecDriver) skipWhitespace(unread bool) (b byte) {
- // as initReadNext is not called all the time, we set ct to unSet whenever
- // we skipwhitespace, as this is the signal that something new is about to be read.
- d.ct = valueTypeUnset
- b = d.r.readn1()
- if !jsonTrackSkipWhitespace || !d.wsSkipped {
- for ; b == ' ' || b == '\t' || b == '\r' || b == '\n'; b = d.r.readn1() {
- }
- if jsonTrackSkipWhitespace {
- d.wsSkipped = true
- }
- }
- if unread {
+func jsonIsWS(b byte) bool {
+ return b == ' ' || b == '\t' || b == '\r' || b == '\n'
+}
+
+// // This will skip whitespace characters and return the next byte to read.
+// // The next byte determines what the value will be one of.
+// func (d *jsonDecDriver) skipWhitespace() {
+// // fast-path: do not enter loop. Just check first (in case no whitespace).
+// b := d.r.readn1()
+// if jsonIsWS(b) {
+// r := d.r
+// for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+// }
+// }
+// d.tok = b
+// }
+
+func (d *jsonDecDriver) uncacheRead() {
+ if d.tok != 0 {
d.r.unreadn1()
+ d.tok = 0
}
- return b
+}
+
+func (d *jsonDecDriver) sendContainerState(c containerState) {
+ if d.tok == 0 {
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+ }
+ d.tok = b
+ }
+ var xc uint8 // char expected
+ if c == containerMapKey {
+ if d.c != containerMapStart {
+ xc = ','
+ }
+ } else if c == containerMapValue {
+ xc = ':'
+ } else if c == containerMapEnd {
+ xc = '}'
+ } else if c == containerArrayElem {
+ if d.c != containerArrayStart {
+ xc = ','
+ }
+ } else if c == containerArrayEnd {
+ xc = ']'
+ }
+ if xc != 0 {
+ if d.tok != xc {
+ d.d.errorf("json: expect char '%c' but got char '%c'", xc, d.tok)
+ }
+ d.tok = 0
+ }
+ d.c = c
}
func (d *jsonDecDriver) CheckBreak() bool {
- b := d.skipWhitespace(true)
- return b == '}' || b == ']'
+ if d.tok == 0 {
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+ }
+ d.tok = b
+ }
+ if d.tok == '}' || d.tok == ']' {
+ // d.tok = 0 // only checking, not consuming
+ return true
+ }
+ return false
}
func (d *jsonDecDriver) readStrIdx(fromIdx, toIdx uint8) {
bs := d.r.readx(int(toIdx - fromIdx))
+ d.tok = 0
if jsonValidateSymbols {
if !bytes.Equal(bs, jsonLiterals[fromIdx:toIdx]) {
d.d.errorf("json: expecting %s: got %s", jsonLiterals[fromIdx:toIdx], bs)
return
}
}
- if jsonTrackSkipWhitespace {
- d.wsSkipped = false
- }
}
func (d *jsonDecDriver) TryDecodeAsNil() bool {
- b := d.skipWhitespace(true)
- if b == 'n' {
- d.readStrIdx(9, 13) // null
- d.ct = valueTypeNil
+ if d.tok == 0 {
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+ }
+ d.tok = b
+ }
+ if d.tok == 'n' {
+ d.readStrIdx(10, 13) // ull
return true
}
return false
}
func (d *jsonDecDriver) DecodeBool() bool {
- b := d.skipWhitespace(false)
- if b == 'f' {
+ if d.tok == 0 {
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+ }
+ d.tok = b
+ }
+ if d.tok == 'f' {
d.readStrIdx(5, 9) // alse
return false
}
- if b == 't' {
+ if d.tok == 't' {
d.readStrIdx(1, 4) // rue
return true
}
- d.d.errorf("json: decode bool: got first char %c", b)
+ d.d.errorf("json: decode bool: got first char %c", d.tok)
return false // "unreachable"
}
func (d *jsonDecDriver) ReadMapStart() int {
- d.expectChar('{')
- d.ct = valueTypeMap
+ if d.tok == 0 {
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+ }
+ d.tok = b
+ }
+ if d.tok != '{' {
+ d.d.errorf("json: expect char '%c' but got char '%c'", '{', d.tok)
+ }
+ d.tok = 0
+ d.c = containerMapStart
return -1
}
func (d *jsonDecDriver) ReadArrayStart() int {
- d.expectChar('[')
- d.ct = valueTypeArray
+ if d.tok == 0 {
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+ }
+ d.tok = b
+ }
+ if d.tok != '[' {
+ d.d.errorf("json: expect char '%c' but got char '%c'", '[', d.tok)
+ }
+ d.tok = 0
+ d.c = containerArrayStart
return -1
}
-func (d *jsonDecDriver) ReadMapEnd() {
- d.expectChar('}')
-}
-func (d *jsonDecDriver) ReadArrayEnd() {
- d.expectChar(']')
-}
-func (d *jsonDecDriver) ReadArrayEntrySeparator() {
- d.expectChar(',')
-}
-func (d *jsonDecDriver) ReadMapEntrySeparator() {
- d.expectChar(',')
-}
-func (d *jsonDecDriver) ReadMapKVSeparator() {
- d.expectChar(':')
-}
-func (d *jsonDecDriver) expectChar(c uint8) {
- b := d.skipWhitespace(false)
- if b != c {
- d.d.errorf("json: expect char %c but got char %c", c, b)
- return
- }
- if jsonTrackSkipWhitespace {
- d.wsSkipped = false
- }
-}
-func (d *jsonDecDriver) IsContainerType(vt valueType) bool {
+func (d *jsonDecDriver) ContainerType() (vt valueType) {
// check container type by checking the first char
- if d.ct == valueTypeUnset {
- b := d.skipWhitespace(true)
- if b == '{' {
- d.ct = valueTypeMap
- } else if b == '[' {
- d.ct = valueTypeArray
- } else if b == 'n' {
- d.ct = valueTypeNil
- } else if b == '"' {
- d.ct = valueTypeString
+ if d.tok == 0 {
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
}
+ d.tok = b
}
- if vt == valueTypeNil || vt == valueTypeBytes || vt == valueTypeString ||
- vt == valueTypeArray || vt == valueTypeMap {
- return d.ct == vt
+ if b := d.tok; b == '{' {
+ return valueTypeMap
+ } else if b == '[' {
+ return valueTypeArray
+ } else if b == 'n' {
+ return valueTypeNil
+ } else if b == '"' {
+ return valueTypeString
}
- // ugorji: made switch into conditionals, so that IsContainerType can be inlined.
- // switch vt {
- // case valueTypeNil, valueTypeBytes, valueTypeString, valueTypeArray, valueTypeMap:
- // return d.ct == vt
- // }
- d.d.errorf("isContainerType: unsupported parameter: %v", vt)
- return false // "unreachable"
+ return valueTypeUnset
+ // d.d.errorf("isContainerType: unsupported parameter: %v", vt)
+ // return false // "unreachable"
}
func (d *jsonDecDriver) decNum(storeBytes bool) {
- // storeBytes = true // TODO: remove.
-
// If it is has a . or an e|E, decode as a float; else decode as an int.
- b := d.skipWhitespace(false)
+ if d.tok == 0 {
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+ }
+ d.tok = b
+ }
+ b := d.tok
+ var str bool
+ if b == '"' {
+ str = true
+ b = d.r.readn1()
+ }
if !(b == '+' || b == '-' || b == '.' || (b >= '0' && b <= '9')) {
d.d.errorf("json: decNum: got first char '%c'", b)
return
}
+ d.tok = 0
const cutoff = (1<<64-1)/uint64(10) + 1 // cutoff64(base)
const jsonNumUintMaxVal = 1<= slen {
+ if slen <= cap(bs) {
bsOut = bs[:slen]
+ } else if zerocopy && slen <= cap(d.b2) {
+ bsOut = d.b2[:slen]
} else {
bsOut = make([]byte, slen)
}
@@ -745,17 +944,36 @@ func (d *jsonDecDriver) DecodeBytes(bs []byte, isstring, zerocopy bool) (bsOut [
}
func (d *jsonDecDriver) DecodeString() (s string) {
- return string(d.appendStringAsBytes(d.b[:0]))
+ d.appendStringAsBytes()
+ // if x := d.s.sc; x != nil && x.so && x.st == '}' { // map key
+ if d.c == containerMapKey {
+ return d.d.string(d.bs)
+ }
+ return string(d.bs)
}
-func (d *jsonDecDriver) appendStringAsBytes(v []byte) []byte {
- d.expectChar('"')
+func (d *jsonDecDriver) appendStringAsBytes() {
+ if d.tok == 0 {
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+ }
+ d.tok = b
+ }
+ if d.tok != '"' {
+ d.d.errorf("json: expect char '%c' but got char '%c'", '"', d.tok)
+ }
+ d.tok = 0
+
+ v := d.bs[:0]
+ var c uint8
+ r := d.r
for {
- c := d.r.readn1()
+ c = r.readn1()
if c == '"' {
break
} else if c == '\\' {
- c = d.r.readn1()
+ c = r.readn1()
switch c {
case '"', '\\', '/', '\'':
v = append(v, c)
@@ -779,27 +997,24 @@ func (d *jsonDecDriver) appendStringAsBytes(v []byte) []byte {
v = append(v, d.bstr[:w2]...)
default:
d.d.errorf("json: unsupported escaped value: %c", c)
- return nil
}
} else {
v = append(v, c)
}
}
- if jsonTrackSkipWhitespace {
- d.wsSkipped = false
- }
- return v
+ d.bs = v
}
func (d *jsonDecDriver) jsonU4(checkSlashU bool) rune {
- if checkSlashU && !(d.r.readn1() == '\\' && d.r.readn1() == 'u') {
+ r := d.r
+ if checkSlashU && !(r.readn1() == '\\' && r.readn1() == 'u') {
d.d.errorf(`json: unquoteStr: invalid unicode sequence. Expecting \u`)
return 0
}
// u, _ := strconv.ParseUint(string(d.bstr[:4]), 16, 64)
var u uint32
for i := 0; i < 4; i++ {
- v := d.r.readn1()
+ v := r.readn1()
if '0' <= v && v <= '9' {
v = v - '0'
} else if 'a' <= v && v <= 'z' {
@@ -815,69 +1030,83 @@ func (d *jsonDecDriver) jsonU4(checkSlashU bool) rune {
return rune(u)
}
-func (d *jsonDecDriver) DecodeNaked() (v interface{}, vt valueType, decodeFurther bool) {
- n := d.skipWhitespace(true)
- switch n {
+func (d *jsonDecDriver) DecodeNaked() {
+ z := &d.d.n
+ // var decodeFurther bool
+
+ if d.tok == 0 {
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+ }
+ d.tok = b
+ }
+ switch d.tok {
case 'n':
- d.readStrIdx(9, 13) // null
- vt = valueTypeNil
+ d.readStrIdx(10, 13) // ull
+ z.v = valueTypeNil
case 'f':
- d.readStrIdx(4, 9) // false
- vt = valueTypeBool
- v = false
+ d.readStrIdx(5, 9) // alse
+ z.v = valueTypeBool
+ z.b = false
case 't':
- d.readStrIdx(0, 4) // true
- vt = valueTypeBool
- v = true
+ d.readStrIdx(1, 4) // rue
+ z.v = valueTypeBool
+ z.b = true
case '{':
- vt = valueTypeMap
- decodeFurther = true
+ z.v = valueTypeMap
+ // d.tok = 0 // don't consume. kInterfaceNaked will call ReadMapStart
+ // decodeFurther = true
case '[':
- vt = valueTypeArray
- decodeFurther = true
+ z.v = valueTypeArray
+ // d.tok = 0 // don't consume. kInterfaceNaked will call ReadArrayStart
+ // decodeFurther = true
case '"':
- vt = valueTypeString
- v = d.DecodeString()
+ z.v = valueTypeString
+ z.s = d.DecodeString()
default: // number
d.decNum(true)
n := &d.n
// if the string had a any of [.eE], then decode as float.
switch {
case n.explicitExponent, n.dot, n.exponent < 0, n.manOverflow:
- vt = valueTypeFloat
- v = n.floatVal()
+ z.v = valueTypeFloat
+ z.f = d.floatVal()
case n.exponent == 0:
u := n.mantissa
switch {
case n.neg:
- vt = valueTypeInt
- v = -int64(u)
+ z.v = valueTypeInt
+ z.i = -int64(u)
case d.h.SignedInteger:
- vt = valueTypeInt
- v = int64(u)
+ z.v = valueTypeInt
+ z.i = int64(u)
default:
- vt = valueTypeUint
- v = u
+ z.v = valueTypeUint
+ z.u = u
}
default:
u, overflow := n.uintExp()
switch {
case overflow:
- vt = valueTypeFloat
- v = n.floatVal()
+ z.v = valueTypeFloat
+ z.f = d.floatVal()
case n.neg:
- vt = valueTypeInt
- v = -int64(u)
+ z.v = valueTypeInt
+ z.i = -int64(u)
case d.h.SignedInteger:
- vt = valueTypeInt
- v = int64(u)
+ z.v = valueTypeInt
+ z.i = int64(u)
default:
- vt = valueTypeUint
- v = u
+ z.v = valueTypeUint
+ z.u = u
}
}
// fmt.Printf("DecodeNaked: Number: %T, %v\n", v, v)
}
+ // if decodeFurther {
+ // d.s.sc.retryRead()
+ // }
return
}
@@ -887,7 +1116,8 @@ func (d *jsonDecDriver) DecodeNaked() (v interface{}, vt valueType, decodeFurthe
//
// Json is comprehensively supported:
// - decodes numbers into interface{} as int, uint or float64
-// - encodes and decodes []byte using base64 Std Encoding
+// - configurable way to encode/decode []byte .
+// by default, encodes and decodes []byte using base64 Std Encoding
// - UTF-8 support for encoding and decoding
//
// It has better performance than the json library in the standard library,
@@ -899,21 +1129,80 @@ func (d *jsonDecDriver) DecodeNaked() (v interface{}, vt valueType, decodeFurthe
// For example, a user can read a json value, then a cbor value, then a msgpack value,
// all from the same stream in sequence.
type JsonHandle struct {
- BasicHandle
textEncodingType
+ BasicHandle
+ // RawBytesExt, if configured, is used to encode and decode raw bytes in a custom way.
+ // If not configured, raw bytes are encoded to/from base64 text.
+ RawBytesExt InterfaceExt
+
+ // Indent indicates how a value is encoded.
+ // - If positive, indent by that number of spaces.
+ // - If negative, indent by that number of tabs.
+ Indent int8
+
+ // IntegerAsString controls how integers (signed and unsigned) are encoded.
+ //
+ // Per the JSON Spec, JSON numbers are 64-bit floating point numbers.
+ // Consequently, integers > 2^53 cannot be represented as a JSON number without losing precision.
+ // This can be mitigated by configuring how to encode integers.
+ //
+ // IntegerAsString interpretes the following values:
+ // - if 'L', then encode integers > 2^53 as a json string.
+ // - if 'A', then encode all integers as a json string
+ // containing the exact integer representation as a decimal.
+ // - else encode all integers as a json number (default)
+ IntegerAsString uint8
+}
+
+func (h *JsonHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) {
+ return h.SetExt(rt, tag, &setExtWrapper{i: ext})
}
func (h *JsonHandle) newEncDriver(e *Encoder) encDriver {
- return &jsonEncDriver{e: e, w: e.w, h: h}
+ hd := jsonEncDriver{e: e, h: h}
+ hd.bs = hd.b[:0]
+
+ hd.reset()
+
+ return &hd
}
func (h *JsonHandle) newDecDriver(d *Decoder) decDriver {
// d := jsonDecDriver{r: r.(*bytesDecReader), h: h}
- hd := jsonDecDriver{d: d, r: d.r, h: h}
- hd.n.bytes = d.b[:]
+ hd := jsonDecDriver{d: d, h: h}
+ hd.bs = hd.b[:0]
+ hd.reset()
return &hd
}
+func (e *jsonEncDriver) reset() {
+ e.w = e.e.w
+ e.se.i = e.h.RawBytesExt
+ if e.bs != nil {
+ e.bs = e.bs[:0]
+ }
+ e.d, e.dt, e.dl, e.ds = false, false, 0, ""
+ e.c = 0
+ if e.h.Indent > 0 {
+ e.d = true
+ e.ds = jsonSpaces[:e.h.Indent]
+ } else if e.h.Indent < 0 {
+ e.d = true
+ e.dt = true
+ e.ds = jsonTabs[:-(e.h.Indent)]
+ }
+}
+
+func (d *jsonDecDriver) reset() {
+ d.r = d.d.r
+ d.se.i = d.h.RawBytesExt
+ if d.bs != nil {
+ d.bs = d.bs[:0]
+ }
+ d.c, d.tok = 0, 0
+ d.n.reset()
+}
+
var jsonEncodeTerminate = []byte{' '}
func (h *JsonHandle) rpcEncodeTerminate() []byte {
diff --git a/Godeps/_workspace/src/github.com/ugorji/go/codec/msgpack.go b/Godeps/_workspace/src/github.com/ugorji/go/codec/msgpack.go
index 5cfc2a2591..f9f8723627 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/msgpack.go
+++ b/Godeps/_workspace/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.u)
}
return
}
@@ -536,15 +530,11 @@ func (d *msgpackDecDriver) DecodeBytes(bs []byte, isstring, zerocopy bool) (bsOu
d.readNextBd()
}
var clen int
- if isstring {
- clen = d.readContainerLen(msgpackContainerStr)
+ // ignore isstring. Expect that the bytes may be found from msgpackContainerStr or msgpackContainerBin
+ if bd := d.bd; bd == mpBin8 || bd == mpBin16 || bd == mpBin32 {
+ clen = d.readContainerLen(msgpackContainerBin)
} else {
- // bytes can be decoded from msgpackContainerStr or msgpackContainerBin
- if bd := d.bd; bd == mpBin8 || bd == mpBin16 || bd == mpBin32 {
- clen = d.readContainerLen(msgpackContainerBin)
- } else {
- clen = d.readContainerLen(msgpackContainerStr)
- }
+ clen = d.readContainerLen(msgpackContainerStr)
}
// println("DecodeBytes: clen: ", clen)
d.bdRead = false
@@ -569,28 +559,27 @@ func (d *msgpackDecDriver) DecodeString() (s string) {
func (d *msgpackDecDriver) readNextBd() {
d.bd = d.r.readn1()
d.bdRead = true
- d.bdType = valueTypeUnset
}
-func (d *msgpackDecDriver) IsContainerType(vt valueType) bool {
+func (d *msgpackDecDriver) ContainerType() (vt valueType) {
bd := d.bd
- switch vt {
- case valueTypeNil:
- return bd == mpNil
- case valueTypeBytes:
- return bd == mpBin8 || bd == mpBin16 || bd == mpBin32 ||
- (!d.h.RawToString &&
- (bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || (bd >= mpFixStrMin && bd <= mpFixStrMax)))
- case valueTypeString:
- return d.h.RawToString &&
- (bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || (bd >= mpFixStrMin && bd <= mpFixStrMax))
- case valueTypeArray:
- return bd == mpArray16 || bd == mpArray32 || (bd >= mpFixArrayMin && bd <= mpFixArrayMax)
- case valueTypeMap:
- return bd == mpMap16 || bd == mpMap32 || (bd >= mpFixMapMin && bd <= mpFixMapMax)
+ if bd == mpNil {
+ return valueTypeNil
+ } else if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 ||
+ (!d.h.RawToString &&
+ (bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || (bd >= mpFixStrMin && bd <= mpFixStrMax))) {
+ return valueTypeBytes
+ } else if d.h.RawToString &&
+ (bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || (bd >= mpFixStrMin && bd <= mpFixStrMax)) {
+ return valueTypeString
+ } else if bd == mpArray16 || bd == mpArray32 || (bd >= mpFixArrayMin && bd <= mpFixArrayMax) {
+ return valueTypeArray
+ } else if bd == mpMap16 || bd == mpMap32 || (bd >= mpFixMapMin && bd <= mpFixMapMax) {
+ return valueTypeMap
+ } else {
+ // d.d.errorf("isContainerType: unsupported parameter: %v", vt)
}
- d.d.errorf("isContainerType: unsupported parameter: %v", vt)
- return false // "unreachable"
+ return valueTypeUnset
}
func (d *msgpackDecDriver) TryDecodeAsNil() (v bool) {
@@ -617,7 +606,7 @@ func (d *msgpackDecDriver) readContainerLen(ct msgpackContainerType) (clen int)
} else if (ct.bFixMin & bd) == ct.bFixMin {
clen = int(ct.bFixMin ^ bd)
} else {
- d.d.errorf("readContainerLen: %s: hex: %x, dec: %d", msgBadDesc, bd, bd)
+ d.d.errorf("readContainerLen: %s: hex: %x, decimal: %d", msgBadDesc, bd, bd)
return
}
d.bdRead = false
@@ -704,7 +693,6 @@ func (d *msgpackDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs
//MsgpackHandle is a Handle for the Msgpack Schema-Free Encoding Format.
type MsgpackHandle struct {
BasicHandle
- binaryEncodingType
// RawToString controls how raw bytes are decoded into a nil interface{}.
RawToString bool
@@ -720,6 +708,11 @@ type MsgpackHandle struct {
// type is provided (e.g. decoding into a nil interface{}), you get back
// a []byte or string based on the setting of RawToString.
WriteExt bool
+ binaryEncodingType
+}
+
+func (h *MsgpackHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) {
+ return h.SetExt(rt, tag, &setExtWrapper{b: ext})
}
func (h *MsgpackHandle) newEncDriver(e *Encoder) encDriver {
@@ -730,6 +723,15 @@ func (h *MsgpackHandle) newDecDriver(d *Decoder) decDriver {
return &msgpackDecDriver{d: d, r: d.r, h: h, br: d.bytes}
}
+func (e *msgpackEncDriver) reset() {
+ e.w = e.e.w
+}
+
+func (d *msgpackDecDriver) reset() {
+ d.r = d.d.r
+ d.bd, d.bdRead = 0, false
+}
+
//--------------------------------------------------
type msgpackSpecRpcCodec struct {
diff --git a/Godeps/_workspace/src/github.com/ugorji/go/codec/noop.go b/Godeps/_workspace/src/github.com/ugorji/go/codec/noop.go
index 25bef4fc3c..cfee3d084d 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/noop.go
+++ b/Godeps/_workspace/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/Godeps/_workspace/src/github.com/ugorji/go/codec/prebuild.sh b/Godeps/_workspace/src/github.com/ugorji/go/codec/prebuild.sh
index c1916f3038..909f4bb0f2 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/prebuild.sh
+++ b/Godeps/_workspace/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 "_xurtcinsvgzmefdl" 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" -run=Binc $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 ;;
+ 'xd') printf ">>>>>>> INDENT : ";
+ go test "-tags=$ztags" -run=JsonCodecsTable -td=-1 $zargs;
+ go test "-tags=$ztags" -run=JsonCodecsTable -td=8 $zargs;
+ sleep 2 ;;
+ *) ;;
+ esac
+ done
+ shift $((OPTIND-1))
+
+ OPTIND=1
+}
+
+# echo ">>>>>>> RUNNING VARIATIONS OF TESTS"
+if [[ "x$@" = "x" ]]; then
+ # All: r, x, g, gu
+ _run "-_tcinsed_ml" # regular
+ _run "-_tcinsed_ml_z" # regular with reset
+ _run "-_tcinsed_ml_f" # regular with no fastpath (notfastpath)
+ _run "-x_tcinsed_ml" # external
+ _run "-gx_tcinsed_ml" # codecgen: requires external
+ _run "-gxu_tcinsed_ml" # codecgen + unsafe
+elif [[ "x$@" = "x-Z" ]]; then
+ # Regular
+ _run "-_tcinsed_ml" # regular
+ _run "-_tcinsed_ml_z" # regular with reset
+elif [[ "x$@" = "x-F" ]]; then
+ # regular with notfastpath
+ _run "-_tcinsed_ml_f" # regular
+ _run "-_tcinsed_ml_zf" # regular with reset
+else
+ _run "$@"
+fi
diff --git a/Godeps/_workspace/src/github.com/ugorji/go/codec/time.go b/Godeps/_workspace/src/github.com/ugorji/go/codec/time.go
index 733fc3fb75..718b731ec5 100644
--- a/Godeps/_workspace/src/github.com/ugorji/go/codec/time.go
+++ b/Godeps/_workspace/src/github.com/ugorji/go/codec/time.go
@@ -4,13 +4,53 @@
package codec
import (
+ "fmt"
+ "reflect"
"time"
)
var (
- timeDigits = [...]byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}
+ timeDigits = [...]byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}
+ timeExtEncFn = func(rv reflect.Value) (bs []byte, err error) {
+ defer panicToErr(&err)
+ bs = timeExt{}.WriteExt(rv.Interface())
+ return
+ }
+ timeExtDecFn = func(rv reflect.Value, bs []byte) (err error) {
+ defer panicToErr(&err)
+ timeExt{}.ReadExt(rv.Interface(), bs)
+ return
+ }
)
+type timeExt struct{}
+
+func (x timeExt) WriteExt(v interface{}) (bs []byte) {
+ switch v2 := v.(type) {
+ case time.Time:
+ bs = encodeTime(v2)
+ case *time.Time:
+ bs = encodeTime(*v2)
+ default:
+ panic(fmt.Errorf("unsupported format for time conversion: expecting time.Time; got %T", v2))
+ }
+ return
+}
+func (x timeExt) ReadExt(v interface{}, bs []byte) {
+ tt, err := decodeTime(bs)
+ if err != nil {
+ panic(err)
+ }
+ *(v.(*time.Time)) = tt
+}
+
+func (x timeExt) ConvertExt(v interface{}) interface{} {
+ return x.WriteExt(v)
+}
+func (x timeExt) UpdateExt(v interface{}, src interface{}) {
+ x.ReadExt(v, src.([]byte))
+}
+
// EncodeTime encodes a time.Time as a []byte, including
// information on the instant in time and UTC offset.
//
diff --git a/Godeps/_workspace/src/golang.org/x/net/context/context.go b/Godeps/_workspace/src/golang.org/x/net/context/context.go
index ef2f3e86fe..11bd8d34e6 100644
--- a/Godeps/_workspace/src/golang.org/x/net/context/context.go
+++ b/Godeps/_workspace/src/golang.org/x/net/context/context.go
@@ -189,7 +189,7 @@ func Background() Context {
}
// TODO returns a non-nil, empty Context. Code should use context.TODO when
-// it's unclear which Context to use or it's is not yet available (because the
+// it's unclear which Context to use or it is not yet available (because the
// surrounding function has not yet been extended to accept a Context
// parameter). TODO is recognized by static analysis tools that determine
// whether Contexts are propagated correctly in a program.
diff --git a/Godeps/_workspace/src/golang.org/x/net/context/ctxhttp/cancelreq.go b/Godeps/_workspace/src/golang.org/x/net/context/ctxhttp/cancelreq.go
new file mode 100644
index 0000000000..e3170e3333
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/net/context/ctxhttp/cancelreq.go
@@ -0,0 +1,19 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build go1.5
+
+package ctxhttp
+
+import "net/http"
+
+func canceler(client *http.Client, req *http.Request) func() {
+ // TODO(djd): Respect any existing value of req.Cancel.
+ ch := make(chan struct{})
+ req.Cancel = ch
+
+ return func() {
+ close(ch)
+ }
+}
diff --git a/Godeps/_workspace/src/golang.org/x/net/context/ctxhttp/cancelreq_go14.go b/Godeps/_workspace/src/golang.org/x/net/context/ctxhttp/cancelreq_go14.go
new file mode 100644
index 0000000000..56bcbadb85
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/net/context/ctxhttp/cancelreq_go14.go
@@ -0,0 +1,23 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !go1.5
+
+package ctxhttp
+
+import "net/http"
+
+type requestCanceler interface {
+ CancelRequest(*http.Request)
+}
+
+func canceler(client *http.Client, req *http.Request) func() {
+ rc, ok := client.Transport.(requestCanceler)
+ if !ok {
+ return func() {}
+ }
+ return func() {
+ rc.CancelRequest(req)
+ }
+}
diff --git a/Godeps/_workspace/src/golang.org/x/net/context/ctxhttp/ctxhttp.go b/Godeps/_workspace/src/golang.org/x/net/context/ctxhttp/ctxhttp.go
new file mode 100644
index 0000000000..19106759e4
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/net/context/ctxhttp/ctxhttp.go
@@ -0,0 +1,123 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package ctxhttp provides helper functions for performing context-aware HTTP requests.
+package ctxhttp
+
+import (
+ "io"
+ "net/http"
+ "net/url"
+ "strings"
+
+ "golang.org/x/net/context"
+)
+
+// Do sends an HTTP request with the provided http.Client and returns an HTTP response.
+// If the client is nil, http.DefaultClient is used.
+// If the context is canceled or times out, ctx.Err() will be returned.
+func Do(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) {
+ if client == nil {
+ client = http.DefaultClient
+ }
+
+ // Request cancelation changed in Go 1.5, see cancelreq.go and cancelreq_go14.go.
+ cancel := canceler(client, req)
+
+ type responseAndError struct {
+ resp *http.Response
+ err error
+ }
+ result := make(chan responseAndError, 1)
+
+ go func() {
+ resp, err := client.Do(req)
+ result <- responseAndError{resp, err}
+ }()
+
+ var resp *http.Response
+
+ select {
+ case <-ctx.Done():
+ cancel()
+ return nil, ctx.Err()
+ case r := <-result:
+ var err error
+ resp, err = r.resp, r.err
+ if err != nil {
+ return resp, err
+ }
+ }
+
+ c := make(chan struct{})
+ go func() {
+ select {
+ case <-ctx.Done():
+ cancel()
+ case <-c:
+ // The response's Body is closed.
+ }
+ }()
+ resp.Body = ¬ifyingReader{resp.Body, c}
+
+ return resp, nil
+}
+
+// Get issues a GET request via the Do function.
+func Get(ctx context.Context, client *http.Client, url string) (*http.Response, error) {
+ req, err := http.NewRequest("GET", url, nil)
+ if err != nil {
+ return nil, err
+ }
+ return Do(ctx, client, req)
+}
+
+// Head issues a HEAD request via the Do function.
+func Head(ctx context.Context, client *http.Client, url string) (*http.Response, error) {
+ req, err := http.NewRequest("HEAD", url, nil)
+ if err != nil {
+ return nil, err
+ }
+ return Do(ctx, client, req)
+}
+
+// Post issues a POST request via the Do function.
+func Post(ctx context.Context, client *http.Client, url string, bodyType string, body io.Reader) (*http.Response, error) {
+ req, err := http.NewRequest("POST", url, body)
+ if err != nil {
+ return nil, err
+ }
+ req.Header.Set("Content-Type", bodyType)
+ return Do(ctx, client, req)
+}
+
+// PostForm issues a POST request via the Do function.
+func PostForm(ctx context.Context, client *http.Client, url string, data url.Values) (*http.Response, error) {
+ return Post(ctx, client, url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode()))
+}
+
+// notifyingReader is an io.ReadCloser that closes the notify channel after
+// Close is called or a Read fails on the underlying ReadCloser.
+type notifyingReader struct {
+ io.ReadCloser
+ notify chan<- struct{}
+}
+
+func (r *notifyingReader) Read(p []byte) (int, error) {
+ n, err := r.ReadCloser.Read(p)
+ if err != nil && r.notify != nil {
+ close(r.notify)
+ r.notify = nil
+ }
+ return n, err
+}
+
+func (r *notifyingReader) Close() error {
+ err := r.ReadCloser.Close()
+ if r.notify != nil {
+ close(r.notify)
+ r.notify = nil
+ }
+ return err
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/LICENSE b/Godeps/_workspace/src/golang.org/x/sys/LICENSE
new file mode 100644
index 0000000000..6a66aea5ea
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 2009 The Go Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Godeps/_workspace/src/golang.org/x/sys/PATENTS b/Godeps/_workspace/src/golang.org/x/sys/PATENTS
new file mode 100644
index 0000000000..733099041f
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/PATENTS
@@ -0,0 +1,22 @@
+Additional IP Rights Grant (Patents)
+
+"This implementation" means the copyrightable works distributed by
+Google as part of the Go project.
+
+Google hereby grants to You a perpetual, worldwide, non-exclusive,
+no-charge, royalty-free, irrevocable (except as stated in this section)
+patent license to make, have made, use, offer to sell, sell, import,
+transfer and otherwise run, modify and propagate the contents of this
+implementation of Go, where such license applies only to those patent
+claims, both currently owned or controlled by Google and acquired in
+the future, licensable by Google that are necessarily infringed by this
+implementation of Go. This grant does not include claims that would be
+infringed only as a consequence of further modification of this
+implementation. If you or your agent or exclusive licensee institute or
+order or agree to the institution of patent litigation against any
+entity (including a cross-claim or counterclaim in a lawsuit) alleging
+that this implementation of Go or any code incorporated within this
+implementation of Go constitutes direct or contributory patent
+infringement, or inducement of patent infringement, then any patent
+rights granted to you under this License for this implementation of Go
+shall terminate as of the date such litigation is filed.
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/.gitignore b/Godeps/_workspace/src/golang.org/x/sys/unix/.gitignore
new file mode 100644
index 0000000000..e482715909
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/.gitignore
@@ -0,0 +1 @@
+_obj/
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm.s
new file mode 100644
index 0000000000..8ed2fdb94b
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm.s
@@ -0,0 +1,10 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+
+#include "textflag.h"
+
+TEXT ·use(SB),NOSPLIT,$0
+ RET
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_386.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_386.s
new file mode 100644
index 0000000000..8a7278319e
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_386.s
@@ -0,0 +1,29 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+
+#include "textflag.h"
+
+//
+// System call support for 386, Darwin
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-28
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-40
+ JMP syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-52
+ JMP syscall·Syscall9(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
+ JMP syscall·RawSyscall6(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_amd64.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_amd64.s
new file mode 100644
index 0000000000..6321421f27
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_amd64.s
@@ -0,0 +1,29 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+
+#include "textflag.h"
+
+//
+// System call support for AMD64, Darwin
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-56
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
+ JMP syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-104
+ JMP syscall·Syscall9(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
+ JMP syscall·RawSyscall6(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_arm.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_arm.s
new file mode 100644
index 0000000000..333242d506
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_arm.s
@@ -0,0 +1,30 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+// +build arm,darwin
+
+#include "textflag.h"
+
+//
+// System call support for ARM, Darwin
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-28
+ B syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-40
+ B syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-52
+ B syscall·Syscall9(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
+ B syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
+ B syscall·RawSyscall6(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_arm64.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_arm64.s
new file mode 100644
index 0000000000..97e0174371
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_arm64.s
@@ -0,0 +1,30 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+// +build arm64,darwin
+
+#include "textflag.h"
+
+//
+// System call support for AMD64, Darwin
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-56
+ B syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
+ B syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-104
+ B syscall·Syscall9(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
+ B syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
+ B syscall·RawSyscall6(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_dragonfly_386.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_dragonfly_386.s
new file mode 100644
index 0000000000..7e55e0d317
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_dragonfly_386.s
@@ -0,0 +1,29 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+
+#include "textflag.h"
+
+//
+// System call support for 386, FreeBSD
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-32
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-44
+ JMP syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-56
+ JMP syscall·Syscall9(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-32
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-44
+ JMP syscall·RawSyscall6(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_dragonfly_amd64.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_dragonfly_amd64.s
new file mode 100644
index 0000000000..d5ed6726cc
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_dragonfly_amd64.s
@@ -0,0 +1,29 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+
+#include "textflag.h"
+
+//
+// System call support for AMD64, DragonFly
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-64
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-88
+ JMP syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-112
+ JMP syscall·Syscall9(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-64
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-88
+ JMP syscall·RawSyscall6(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_freebsd_386.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_freebsd_386.s
new file mode 100644
index 0000000000..c9a0a26015
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_freebsd_386.s
@@ -0,0 +1,29 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+
+#include "textflag.h"
+
+//
+// System call support for 386, FreeBSD
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-28
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-40
+ JMP syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-52
+ JMP syscall·Syscall9(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
+ JMP syscall·RawSyscall6(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_freebsd_amd64.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_freebsd_amd64.s
new file mode 100644
index 0000000000..35172477c8
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_freebsd_amd64.s
@@ -0,0 +1,29 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+
+#include "textflag.h"
+
+//
+// System call support for AMD64, FreeBSD
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-56
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
+ JMP syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-104
+ JMP syscall·Syscall9(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
+ JMP syscall·RawSyscall6(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_freebsd_arm.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_freebsd_arm.s
new file mode 100644
index 0000000000..9227c875bf
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_freebsd_arm.s
@@ -0,0 +1,29 @@
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+
+#include "textflag.h"
+
+//
+// System call support for ARM, FreeBSD
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-28
+ B syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-40
+ B syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-52
+ B syscall·Syscall9(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
+ B syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
+ B syscall·RawSyscall6(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_386.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_386.s
new file mode 100644
index 0000000000..4db2909323
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_386.s
@@ -0,0 +1,35 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+
+#include "textflag.h"
+
+//
+// System calls for 386, Linux
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-28
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-40
+ JMP syscall·Syscall6(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
+ JMP syscall·RawSyscall6(SB)
+
+TEXT ·socketcall(SB),NOSPLIT,$0-36
+ JMP syscall·socketcall(SB)
+
+TEXT ·rawsocketcall(SB),NOSPLIT,$0-36
+ JMP syscall·rawsocketcall(SB)
+
+TEXT ·seek(SB),NOSPLIT,$0-28
+ JMP syscall·seek(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_amd64.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_amd64.s
new file mode 100644
index 0000000000..44e25c62f9
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_amd64.s
@@ -0,0 +1,29 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+
+#include "textflag.h"
+
+//
+// System calls for AMD64, Linux
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-56
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
+ JMP syscall·Syscall6(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
+ JMP syscall·RawSyscall6(SB)
+
+TEXT ·gettimeofday(SB),NOSPLIT,$0-16
+ JMP syscall·gettimeofday(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_arm.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_arm.s
new file mode 100644
index 0000000000..cf0b574658
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_arm.s
@@ -0,0 +1,29 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+
+#include "textflag.h"
+
+//
+// System calls for arm, Linux
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-28
+ B syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-40
+ B syscall·Syscall6(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
+ B syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
+ B syscall·RawSyscall6(SB)
+
+TEXT ·seek(SB),NOSPLIT,$0-32
+ B syscall·seek(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_arm64.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_arm64.s
new file mode 100644
index 0000000000..4be9bfedea
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_arm64.s
@@ -0,0 +1,24 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build linux
+// +build arm64
+// +build !gccgo
+
+#include "textflag.h"
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-56
+ B syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
+ B syscall·Syscall6(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
+ B syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
+ B syscall·RawSyscall6(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_ppc64x.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_ppc64x.s
new file mode 100644
index 0000000000..8d231feb4b
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_ppc64x.s
@@ -0,0 +1,28 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build linux
+// +build ppc64 ppc64le
+// +build !gccgo
+
+#include "textflag.h"
+
+//
+// System calls for ppc64, Linux
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-56
+ BR syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
+ BR syscall·Syscall6(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
+ BR syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
+ BR syscall·RawSyscall6(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_netbsd_386.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_netbsd_386.s
new file mode 100644
index 0000000000..48bdcd7632
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_netbsd_386.s
@@ -0,0 +1,29 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+
+#include "textflag.h"
+
+//
+// System call support for 386, NetBSD
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-28
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-40
+ JMP syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-52
+ JMP syscall·Syscall9(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
+ JMP syscall·RawSyscall6(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_netbsd_amd64.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_netbsd_amd64.s
new file mode 100644
index 0000000000..2ede05c72f
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_netbsd_amd64.s
@@ -0,0 +1,29 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+
+#include "textflag.h"
+
+//
+// System call support for AMD64, NetBSD
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-56
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
+ JMP syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-104
+ JMP syscall·Syscall9(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
+ JMP syscall·RawSyscall6(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_netbsd_arm.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_netbsd_arm.s
new file mode 100644
index 0000000000..e8928571c4
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_netbsd_arm.s
@@ -0,0 +1,29 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+
+#include "textflag.h"
+
+//
+// System call support for ARM, NetBSD
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-28
+ B syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-40
+ B syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-52
+ B syscall·Syscall9(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
+ B syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
+ B syscall·RawSyscall6(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_openbsd_386.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_openbsd_386.s
new file mode 100644
index 0000000000..00576f3c83
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_openbsd_386.s
@@ -0,0 +1,29 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+
+#include "textflag.h"
+
+//
+// System call support for 386, OpenBSD
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-28
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-40
+ JMP syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-52
+ JMP syscall·Syscall9(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
+ JMP syscall·RawSyscall6(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_openbsd_amd64.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_openbsd_amd64.s
new file mode 100644
index 0000000000..790ef77f86
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_openbsd_amd64.s
@@ -0,0 +1,29 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+
+#include "textflag.h"
+
+//
+// System call support for AMD64, OpenBSD
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-56
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
+ JMP syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-104
+ JMP syscall·Syscall9(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
+ JMP syscall·RawSyscall6(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_solaris_amd64.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_solaris_amd64.s
new file mode 100644
index 0000000000..43ed17a05f
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_solaris_amd64.s
@@ -0,0 +1,17 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+
+#include "textflag.h"
+
+//
+// System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go
+//
+
+TEXT ·sysvicall6(SB),NOSPLIT,$0-64
+ JMP syscall·sysvicall6(SB)
+
+TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64
+ JMP syscall·rawSysvicall6(SB)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/constants.go b/Godeps/_workspace/src/golang.org/x/sys/unix/constants.go
new file mode 100644
index 0000000000..a96f0ebc26
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/constants.go
@@ -0,0 +1,13 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
+
+package unix
+
+const (
+ R_OK = 0x4
+ W_OK = 0x2
+ X_OK = 0x1
+)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/env_unix.go b/Godeps/_workspace/src/golang.org/x/sys/unix/env_unix.go
new file mode 100644
index 0000000000..45e281a047
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/env_unix.go
@@ -0,0 +1,27 @@
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
+
+// Unix environment variables.
+
+package unix
+
+import "syscall"
+
+func Getenv(key string) (value string, found bool) {
+ return syscall.Getenv(key)
+}
+
+func Setenv(key, value string) error {
+ return syscall.Setenv(key, value)
+}
+
+func Clearenv() {
+ syscall.Clearenv()
+}
+
+func Environ() []string {
+ return syscall.Environ()
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/env_unset.go b/Godeps/_workspace/src/golang.org/x/sys/unix/env_unset.go
new file mode 100644
index 0000000000..9222262559
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/env_unset.go
@@ -0,0 +1,14 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build go1.4
+
+package unix
+
+import "syscall"
+
+func Unsetenv(key string) error {
+ // This was added in Go 1.4.
+ return syscall.Unsetenv(key)
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/flock.go b/Godeps/_workspace/src/golang.org/x/sys/unix/flock.go
new file mode 100644
index 0000000000..ce67a59528
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/flock.go
@@ -0,0 +1,24 @@
+// +build linux darwin freebsd openbsd netbsd dragonfly
+
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin dragonfly freebsd linux netbsd openbsd
+
+package unix
+
+import "unsafe"
+
+// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
+// systems by flock_linux_32bit.go to be SYS_FCNTL64.
+var fcntl64Syscall uintptr = SYS_FCNTL
+
+// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
+func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
+ _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
+ if errno == 0 {
+ return nil
+ }
+ return errno
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/flock_linux_32bit.go b/Godeps/_workspace/src/golang.org/x/sys/unix/flock_linux_32bit.go
new file mode 100644
index 0000000000..362831c3f7
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/flock_linux_32bit.go
@@ -0,0 +1,13 @@
+// +build linux,386 linux,arm
+
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package unix
+
+func init() {
+ // On 32-bit Linux systems, the fcntl syscall that matches Go's
+ // Flock_t type is SYS_FCNTL64, not SYS_FCNTL.
+ fcntl64Syscall = SYS_FCNTL64
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/gccgo.go b/Godeps/_workspace/src/golang.org/x/sys/unix/gccgo.go
new file mode 100644
index 0000000000..94c8232124
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/gccgo.go
@@ -0,0 +1,46 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build gccgo
+
+package unix
+
+import "syscall"
+
+// We can't use the gc-syntax .s files for gccgo. On the plus side
+// much of the functionality can be written directly in Go.
+
+//extern gccgoRealSyscall
+func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
+
+func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
+ syscall.Entersyscall()
+ r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
+ syscall.Exitsyscall()
+ return r, 0, syscall.Errno(errno)
+}
+
+func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
+ syscall.Entersyscall()
+ r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
+ syscall.Exitsyscall()
+ return r, 0, syscall.Errno(errno)
+}
+
+func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) {
+ syscall.Entersyscall()
+ r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9)
+ syscall.Exitsyscall()
+ return r, 0, syscall.Errno(errno)
+}
+
+func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
+ r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
+ return r, 0, syscall.Errno(errno)
+}
+
+func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
+ r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
+ return r, 0, syscall.Errno(errno)
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/gccgo_c.c b/Godeps/_workspace/src/golang.org/x/sys/unix/gccgo_c.c
new file mode 100644
index 0000000000..07f6be0392
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/gccgo_c.c
@@ -0,0 +1,41 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build gccgo
+
+#include
+#include
+#include
+
+#define _STRINGIFY2_(x) #x
+#define _STRINGIFY_(x) _STRINGIFY2_(x)
+#define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__)
+
+// Call syscall from C code because the gccgo support for calling from
+// Go to C does not support varargs functions.
+
+struct ret {
+ uintptr_t r;
+ uintptr_t err;
+};
+
+struct ret
+gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
+{
+ struct ret r;
+
+ errno = 0;
+ r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
+ r.err = errno;
+ return r;
+}
+
+// Define the use function in C so that it is not inlined.
+
+extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline));
+
+void
+use(void *p __attribute__ ((unused)))
+{
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/gccgo_linux_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/gccgo_linux_amd64.go
new file mode 100644
index 0000000000..bffe1a77db
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/gccgo_linux_amd64.go
@@ -0,0 +1,20 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build gccgo,linux,amd64
+
+package unix
+
+import "syscall"
+
+//extern gettimeofday
+func realGettimeofday(*Timeval, *byte) int32
+
+func gettimeofday(tv *Timeval) (err syscall.Errno) {
+ r := realGettimeofday(tv, nil)
+ if r < 0 {
+ return syscall.GetErrno()
+ }
+ return 0
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/mkall.sh b/Godeps/_workspace/src/golang.org/x/sys/unix/mkall.sh
new file mode 100644
index 0000000000..de95a4bbcf
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/mkall.sh
@@ -0,0 +1,274 @@
+#!/usr/bin/env bash
+# Copyright 2009 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+# The unix package provides access to the raw system call
+# interface of the underlying operating system. Porting Go to
+# a new architecture/operating system combination requires
+# some manual effort, though there are tools that automate
+# much of the process. The auto-generated files have names
+# beginning with z.
+#
+# This script runs or (given -n) prints suggested commands to generate z files
+# for the current system. Running those commands is not automatic.
+# This script is documentation more than anything else.
+#
+# * asm_${GOOS}_${GOARCH}.s
+#
+# This hand-written assembly file implements system call dispatch.
+# There are three entry points:
+#
+# func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr);
+# func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
+# func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr);
+#
+# The first and second are the standard ones; they differ only in
+# how many arguments can be passed to the kernel.
+# The third is for low-level use by the ForkExec wrapper;
+# unlike the first two, it does not call into the scheduler to
+# let it know that a system call is running.
+#
+# * syscall_${GOOS}.go
+#
+# This hand-written Go file implements system calls that need
+# special handling and lists "//sys" comments giving prototypes
+# for ones that can be auto-generated. Mksyscall reads those
+# comments to generate the stubs.
+#
+# * syscall_${GOOS}_${GOARCH}.go
+#
+# Same as syscall_${GOOS}.go except that it contains code specific
+# to ${GOOS} on one particular architecture.
+#
+# * types_${GOOS}.c
+#
+# This hand-written C file includes standard C headers and then
+# creates typedef or enum names beginning with a dollar sign
+# (use of $ in variable names is a gcc extension). The hardest
+# part about preparing this file is figuring out which headers to
+# include and which symbols need to be #defined to get the
+# actual data structures that pass through to the kernel system calls.
+# Some C libraries present alternate versions for binary compatibility
+# and translate them on the way in and out of system calls, but
+# there is almost always a #define that can get the real ones.
+# See types_darwin.c and types_linux.c for examples.
+#
+# * zerror_${GOOS}_${GOARCH}.go
+#
+# This machine-generated file defines the system's error numbers,
+# error strings, and signal numbers. The generator is "mkerrors.sh".
+# Usually no arguments are needed, but mkerrors.sh will pass its
+# arguments on to godefs.
+#
+# * zsyscall_${GOOS}_${GOARCH}.go
+#
+# Generated by mksyscall.pl; see syscall_${GOOS}.go above.
+#
+# * zsysnum_${GOOS}_${GOARCH}.go
+#
+# Generated by mksysnum_${GOOS}.
+#
+# * ztypes_${GOOS}_${GOARCH}.go
+#
+# Generated by godefs; see types_${GOOS}.c above.
+
+GOOSARCH="${GOOS}_${GOARCH}"
+
+# defaults
+mksyscall="./mksyscall.pl"
+mkerrors="./mkerrors.sh"
+zerrors="zerrors_$GOOSARCH.go"
+mksysctl=""
+zsysctl="zsysctl_$GOOSARCH.go"
+mksysnum=
+mktypes=
+run="sh"
+
+case "$1" in
+-syscalls)
+ for i in zsyscall*go
+ do
+ sed 1q $i | sed 's;^// ;;' | sh > _$i && gofmt < _$i > $i
+ rm _$i
+ done
+ exit 0
+ ;;
+-n)
+ run="cat"
+ shift
+esac
+
+case "$#" in
+0)
+ ;;
+*)
+ echo 'usage: mkall.sh [-n]' 1>&2
+ exit 2
+esac
+
+GOOSARCH_in=syscall_$GOOSARCH.go
+case "$GOOSARCH" in
+_* | *_ | _)
+ echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2
+ exit 1
+ ;;
+darwin_386)
+ mkerrors="$mkerrors -m32"
+ mksyscall="./mksyscall.pl -l32"
+ mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+darwin_amd64)
+ mkerrors="$mkerrors -m64"
+ mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+darwin_arm)
+ mkerrors="$mkerrors"
+ mksysnum="./mksysnum_darwin.pl /usr/include/sys/syscall.h"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+darwin_arm64)
+ mkerrors="$mkerrors -m64"
+ mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+dragonfly_386)
+ mkerrors="$mkerrors -m32"
+ mksyscall="./mksyscall.pl -l32 -dragonfly"
+ mksysnum="curl -s 'http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master' | ./mksysnum_dragonfly.pl"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+dragonfly_amd64)
+ mkerrors="$mkerrors -m64"
+ mksyscall="./mksyscall.pl -dragonfly"
+ mksysnum="curl -s 'http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master' | ./mksysnum_dragonfly.pl"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+freebsd_386)
+ mkerrors="$mkerrors -m32"
+ mksyscall="./mksyscall.pl -l32"
+ mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+freebsd_amd64)
+ mkerrors="$mkerrors -m64"
+ mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+freebsd_arm)
+ mkerrors="$mkerrors"
+ mksyscall="./mksyscall.pl -l32 -arm"
+ mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
+ # Let the type of C char be singed for making the bare syscall
+ # API consistent across over platforms.
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
+ ;;
+linux_386)
+ mkerrors="$mkerrors -m32"
+ mksyscall="./mksyscall.pl -l32"
+ mksysnum="./mksysnum_linux.pl /usr/include/asm/unistd_32.h"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+linux_amd64)
+ unistd_h=$(ls -1 /usr/include/asm/unistd_64.h /usr/include/x86_64-linux-gnu/asm/unistd_64.h 2>/dev/null | head -1)
+ if [ "$unistd_h" = "" ]; then
+ echo >&2 cannot find unistd_64.h
+ exit 1
+ fi
+ mkerrors="$mkerrors -m64"
+ mksysnum="./mksysnum_linux.pl $unistd_h"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+linux_arm)
+ mkerrors="$mkerrors"
+ mksyscall="./mksyscall.pl -l32 -arm"
+ mksysnum="curl -s 'http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/arch/arm/include/uapi/asm/unistd.h' | ./mksysnum_linux.pl -"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+linux_arm64)
+ unistd_h=$(ls -1 /usr/include/asm/unistd.h /usr/include/asm-generic/unistd.h 2>/dev/null | head -1)
+ if [ "$unistd_h" = "" ]; then
+ echo >&2 cannot find unistd_64.h
+ exit 1
+ fi
+ mksysnum="./mksysnum_linux.pl $unistd_h"
+ # Let the type of C char be singed for making the bare syscall
+ # API consistent across over platforms.
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
+ ;;
+linux_ppc64)
+ GOOSARCH_in=syscall_linux_ppc64x.go
+ unistd_h=/usr/include/asm/unistd.h
+ mkerrors="$mkerrors -m64"
+ mksysnum="./mksysnum_linux.pl $unistd_h"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+linux_ppc64le)
+ GOOSARCH_in=syscall_linux_ppc64x.go
+ unistd_h=/usr/include/powerpc64le-linux-gnu/asm/unistd.h
+ mkerrors="$mkerrors -m64"
+ mksysnum="./mksysnum_linux.pl $unistd_h"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+netbsd_386)
+ mkerrors="$mkerrors -m32"
+ mksyscall="./mksyscall.pl -l32 -netbsd"
+ mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+netbsd_amd64)
+ mkerrors="$mkerrors -m64"
+ mksyscall="./mksyscall.pl -netbsd"
+ mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+openbsd_386)
+ mkerrors="$mkerrors -m32"
+ mksyscall="./mksyscall.pl -l32 -openbsd"
+ mksysctl="./mksysctl_openbsd.pl"
+ zsysctl="zsysctl_openbsd.go"
+ mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+openbsd_amd64)
+ mkerrors="$mkerrors -m64"
+ mksyscall="./mksyscall.pl -openbsd"
+ mksysctl="./mksysctl_openbsd.pl"
+ zsysctl="zsysctl_openbsd.go"
+ mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+solaris_amd64)
+ mksyscall="./mksyscall_solaris.pl"
+ mkerrors="$mkerrors -m64"
+ mksysnum=
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+*)
+ echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2
+ exit 1
+ ;;
+esac
+
+(
+ if [ -n "$mkerrors" ]; then echo "$mkerrors |gofmt >$zerrors"; fi
+ case "$GOOS" in
+ *)
+ syscall_goos="syscall_$GOOS.go"
+ case "$GOOS" in
+ darwin | dragonfly | freebsd | netbsd | openbsd)
+ syscall_goos="syscall_bsd.go $syscall_goos"
+ ;;
+ esac
+ if [ -n "$mksyscall" ]; then echo "$mksyscall $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go"; fi
+ ;;
+ esac
+ if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi
+ if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
+ if [ -n "$mktypes" ]; then
+ echo "echo // +build $GOARCH,$GOOS > ztypes_$GOOSARCH.go";
+ echo "$mktypes types_$GOOS.go | gofmt >>ztypes_$GOOSARCH.go";
+ fi
+) | $run
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/mkerrors.sh b/Godeps/_workspace/src/golang.org/x/sys/unix/mkerrors.sh
new file mode 100644
index 0000000000..c40d788c4a
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/mkerrors.sh
@@ -0,0 +1,476 @@
+#!/usr/bin/env bash
+# Copyright 2009 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+# Generate Go code listing errors and other #defined constant
+# values (ENAMETOOLONG etc.), by asking the preprocessor
+# about the definitions.
+
+unset LANG
+export LC_ALL=C
+export LC_CTYPE=C
+
+if test -z "$GOARCH" -o -z "$GOOS"; then
+ echo 1>&2 "GOARCH or GOOS not defined in environment"
+ exit 1
+fi
+
+CC=${CC:-cc}
+
+if [[ "$GOOS" -eq "solaris" ]]; then
+ # Assumes GNU versions of utilities in PATH.
+ export PATH=/usr/gnu/bin:$PATH
+fi
+
+uname=$(uname)
+
+includes_Darwin='
+#define _DARWIN_C_SOURCE
+#define KERNEL
+#define _DARWIN_USE_64_BIT_INODE
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+'
+
+includes_DragonFly='
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+'
+
+includes_FreeBSD='
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#if __FreeBSD__ >= 10
+#define IFT_CARP 0xf8 // IFT_CARP is deprecated in FreeBSD 10
+#undef SIOCAIFADDR
+#define SIOCAIFADDR _IOW(105, 26, struct oifaliasreq) // ifaliasreq contains if_data
+#undef SIOCSIFPHYADDR
+#define SIOCSIFPHYADDR _IOW(105, 70, struct oifaliasreq) // ifaliasreq contains if_data
+#endif
+'
+
+includes_Linux='
+#define _LARGEFILE_SOURCE
+#define _LARGEFILE64_SOURCE
+#ifndef __LP64__
+#define _FILE_OFFSET_BITS 64
+#endif
+#define _GNU_SOURCE
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#ifndef MSG_FASTOPEN
+#define MSG_FASTOPEN 0x20000000
+#endif
+
+#ifndef PTRACE_GETREGS
+#define PTRACE_GETREGS 0xc
+#endif
+
+#ifndef PTRACE_SETREGS
+#define PTRACE_SETREGS 0xd
+#endif
+'
+
+includes_NetBSD='
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+// Needed since refers to it...
+#define schedppq 1
+'
+
+includes_OpenBSD='
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+// We keep some constants not supported in OpenBSD 5.5 and beyond for
+// the promise of compatibility.
+#define EMUL_ENABLED 0x1
+#define EMUL_NATIVE 0x2
+#define IPV6_FAITH 0x1d
+#define IPV6_OPTIONS 0x1
+#define IPV6_RTHDR_STRICT 0x1
+#define IPV6_SOCKOPT_RESERVED1 0x3
+#define SIOCGIFGENERIC 0xc020693a
+#define SIOCSIFGENERIC 0x80206939
+#define WALTSIG 0x4
+'
+
+includes_SunOS='
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+'
+
+
+includes='
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+'
+ccflags="$@"
+
+# Write go tool cgo -godefs input.
+(
+ echo package unix
+ echo
+ echo '/*'
+ indirect="includes_$(uname)"
+ echo "${!indirect} $includes"
+ echo '*/'
+ echo 'import "C"'
+ echo 'import "syscall"'
+ echo
+ echo 'const ('
+
+ # The gcc command line prints all the #defines
+ # it encounters while processing the input
+ echo "${!indirect} $includes" | $CC -x c - -E -dM $ccflags |
+ awk '
+ $1 != "#define" || $2 ~ /\(/ || $3 == "" {next}
+
+ $2 ~ /^E([ABCD]X|[BIS]P|[SD]I|S|FL)$/ {next} # 386 registers
+ $2 ~ /^(SIGEV_|SIGSTKSZ|SIGRT(MIN|MAX))/ {next}
+ $2 ~ /^(SCM_SRCRT)$/ {next}
+ $2 ~ /^(MAP_FAILED)$/ {next}
+ $2 ~ /^ELF_.*$/ {next}# contains ELF_ARCH, etc.
+
+ $2 ~ /^EXTATTR_NAMESPACE_NAMES/ ||
+ $2 ~ /^EXTATTR_NAMESPACE_[A-Z]+_STRING/ {next}
+
+ $2 !~ /^ETH_/ &&
+ $2 !~ /^EPROC_/ &&
+ $2 !~ /^EQUIV_/ &&
+ $2 !~ /^EXPR_/ &&
+ $2 ~ /^E[A-Z0-9_]+$/ ||
+ $2 ~ /^B[0-9_]+$/ ||
+ $2 == "BOTHER" ||
+ $2 ~ /^CI?BAUD(EX)?$/ ||
+ $2 == "IBSHIFT" ||
+ $2 ~ /^V[A-Z0-9]+$/ ||
+ $2 ~ /^CS[A-Z0-9]/ ||
+ $2 ~ /^I(SIG|CANON|CRNL|UCLC|EXTEN|MAXBEL|STRIP|UTF8)$/ ||
+ $2 ~ /^IGN/ ||
+ $2 ~ /^IX(ON|ANY|OFF)$/ ||
+ $2 ~ /^IN(LCR|PCK)$/ ||
+ $2 ~ /(^FLU?SH)|(FLU?SH$)/ ||
+ $2 ~ /^C(LOCAL|READ|MSPAR|RTSCTS)$/ ||
+ $2 == "BRKINT" ||
+ $2 == "HUPCL" ||
+ $2 == "PENDIN" ||
+ $2 == "TOSTOP" ||
+ $2 == "XCASE" ||
+ $2 == "ALTWERASE" ||
+ $2 == "NOKERNINFO" ||
+ $2 ~ /^PAR/ ||
+ $2 ~ /^SIG[^_]/ ||
+ $2 ~ /^O[CNPFPL][A-Z]+[^_][A-Z]+$/ ||
+ $2 ~ /^(NL|CR|TAB|BS|VT|FF)DLY$/ ||
+ $2 ~ /^(NL|CR|TAB|BS|VT|FF)[0-9]$/ ||
+ $2 ~ /^O?XTABS$/ ||
+ $2 ~ /^TC[IO](ON|OFF)$/ ||
+ $2 ~ /^IN_/ ||
+ $2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
+ $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|EVFILT|NOTE|EV|SHUT|PROT|MAP|PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ ||
+ $2 == "ICMPV6_FILTER" ||
+ $2 == "SOMAXCONN" ||
+ $2 == "NAME_MAX" ||
+ $2 == "IFNAMSIZ" ||
+ $2 ~ /^CTL_(MAXNAME|NET|QUERY)$/ ||
+ $2 ~ /^SYSCTL_VERS/ ||
+ $2 ~ /^(MS|MNT)_/ ||
+ $2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
+ $2 ~ /^(O|F|FD|NAME|S|PTRACE|PT)_/ ||
+ $2 ~ /^LINUX_REBOOT_CMD_/ ||
+ $2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
+ $2 !~ "NLA_TYPE_MASK" &&
+ $2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P)_/ ||
+ $2 ~ /^SIOC/ ||
+ $2 ~ /^TIOC/ ||
+ $2 ~ /^TCGET/ ||
+ $2 ~ /^TCSET/ ||
+ $2 ~ /^TC(FLSH|SBRKP?|XONC)$/ ||
+ $2 !~ "RTF_BITS" &&
+ $2 ~ /^(IFF|IFT|NET_RT|RTM|RTF|RTV|RTA|RTAX)_/ ||
+ $2 ~ /^BIOC/ ||
+ $2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ ||
+ $2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|NOFILE|STACK)|RLIM_INFINITY/ ||
+ $2 ~ /^PRIO_(PROCESS|PGRP|USER)/ ||
+ $2 ~ /^CLONE_[A-Z_]+/ ||
+ $2 !~ /^(BPF_TIMEVAL)$/ &&
+ $2 ~ /^(BPF|DLT)_/ ||
+ $2 ~ /^CLOCK_/ ||
+ $2 !~ "WMESGLEN" &&
+ $2 ~ /^W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", $2, $2)}
+ $2 ~ /^__WCOREFLAG$/ {next}
+ $2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)}
+
+ {next}
+ ' | sort
+
+ echo ')'
+) >_const.go
+
+# Pull out the error names for later.
+errors=$(
+ echo '#include ' | $CC -x c - -E -dM $ccflags |
+ awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print $2 }' |
+ sort
+)
+
+# Pull out the signal names for later.
+signals=$(
+ echo '#include ' | $CC -x c - -E -dM $ccflags |
+ awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' |
+ egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
+ sort
+)
+
+# Again, writing regexps to a file.
+echo '#include ' | $CC -x c - -E -dM $ccflags |
+ awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print "^\t" $2 "[ \t]*=" }' |
+ sort >_error.grep
+echo '#include ' | $CC -x c - -E -dM $ccflags |
+ awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' |
+ egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
+ sort >_signal.grep
+
+echo '// mkerrors.sh' "$@"
+echo '// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT'
+echo
+echo "// +build ${GOARCH},${GOOS}"
+echo
+go tool cgo -godefs -- "$@" _const.go >_error.out
+cat _error.out | grep -vf _error.grep | grep -vf _signal.grep
+echo
+echo '// Errors'
+echo 'const ('
+cat _error.out | grep -f _error.grep | sed 's/=\(.*\)/= syscall.Errno(\1)/'
+echo ')'
+
+echo
+echo '// Signals'
+echo 'const ('
+cat _error.out | grep -f _signal.grep | sed 's/=\(.*\)/= syscall.Signal(\1)/'
+echo ')'
+
+# Run C program to print error and syscall strings.
+(
+ echo -E "
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define nelem(x) (sizeof(x)/sizeof((x)[0]))
+
+enum { A = 'A', Z = 'Z', a = 'a', z = 'z' }; // avoid need for single quotes below
+
+int errors[] = {
+"
+ for i in $errors
+ do
+ echo -E ' '$i,
+ done
+
+ echo -E "
+};
+
+int signals[] = {
+"
+ for i in $signals
+ do
+ echo -E ' '$i,
+ done
+
+ # Use -E because on some systems bash builtin interprets \n itself.
+ echo -E '
+};
+
+static int
+intcmp(const void *a, const void *b)
+{
+ return *(int*)a - *(int*)b;
+}
+
+int
+main(void)
+{
+ int i, j, e;
+ char buf[1024], *p;
+
+ printf("\n\n// Error table\n");
+ printf("var errors = [...]string {\n");
+ qsort(errors, nelem(errors), sizeof errors[0], intcmp);
+ for(i=0; i 0 && errors[i-1] == e)
+ continue;
+ strcpy(buf, strerror(e));
+ // lowercase first letter: Bad -> bad, but STREAM -> STREAM.
+ if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z)
+ buf[0] += a - A;
+ printf("\t%d: \"%s\",\n", e, buf);
+ }
+ printf("}\n\n");
+
+ printf("\n\n// Signal table\n");
+ printf("var signals = [...]string {\n");
+ qsort(signals, nelem(signals), sizeof signals[0], intcmp);
+ for(i=0; i 0 && signals[i-1] == e)
+ continue;
+ strcpy(buf, strsignal(e));
+ // lowercase first letter: Bad -> bad, but STREAM -> STREAM.
+ if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z)
+ buf[0] += a - A;
+ // cut trailing : number.
+ p = strrchr(buf, ":"[0]);
+ if(p)
+ *p = '\0';
+ printf("\t%d: \"%s\",\n", e, buf);
+ }
+ printf("}\n\n");
+
+ return 0;
+}
+
+'
+) >_errors.c
+
+$CC $ccflags -o _errors _errors.c && $GORUN ./_errors && rm -f _errors.c _errors _const.go _error.grep _signal.grep _error.out
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/mksyscall.pl b/Godeps/_workspace/src/golang.org/x/sys/unix/mksyscall.pl
new file mode 100644
index 0000000000..b1e7766dae
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/mksyscall.pl
@@ -0,0 +1,323 @@
+#!/usr/bin/env perl
+# Copyright 2009 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+# This program reads a file containing function prototypes
+# (like syscall_darwin.go) and generates system call bodies.
+# The prototypes are marked by lines beginning with "//sys"
+# and read like func declarations if //sys is replaced by func, but:
+# * The parameter lists must give a name for each argument.
+# This includes return parameters.
+# * The parameter lists must give a type for each argument:
+# the (x, y, z int) shorthand is not allowed.
+# * If the return parameter is an error number, it must be named errno.
+
+# A line beginning with //sysnb is like //sys, except that the
+# goroutine will not be suspended during the execution of the system
+# call. This must only be used for system calls which can never
+# block, as otherwise the system call could cause all goroutines to
+# hang.
+
+use strict;
+
+my $cmdline = "mksyscall.pl " . join(' ', @ARGV);
+my $errors = 0;
+my $_32bit = "";
+my $plan9 = 0;
+my $openbsd = 0;
+my $netbsd = 0;
+my $dragonfly = 0;
+my $arm = 0; # 64-bit value should use (even, odd)-pair
+
+if($ARGV[0] eq "-b32") {
+ $_32bit = "big-endian";
+ shift;
+} elsif($ARGV[0] eq "-l32") {
+ $_32bit = "little-endian";
+ shift;
+}
+if($ARGV[0] eq "-plan9") {
+ $plan9 = 1;
+ shift;
+}
+if($ARGV[0] eq "-openbsd") {
+ $openbsd = 1;
+ shift;
+}
+if($ARGV[0] eq "-netbsd") {
+ $netbsd = 1;
+ shift;
+}
+if($ARGV[0] eq "-dragonfly") {
+ $dragonfly = 1;
+ shift;
+}
+if($ARGV[0] eq "-arm") {
+ $arm = 1;
+ shift;
+}
+
+if($ARGV[0] =~ /^-/) {
+ print STDERR "usage: mksyscall.pl [-b32 | -l32] [file ...]\n";
+ exit 1;
+}
+
+if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
+ print STDERR "GOARCH or GOOS not defined in environment\n";
+ exit 1;
+}
+
+sub parseparamlist($) {
+ my ($list) = @_;
+ $list =~ s/^\s*//;
+ $list =~ s/\s*$//;
+ if($list eq "") {
+ return ();
+ }
+ return split(/\s*,\s*/, $list);
+}
+
+sub parseparam($) {
+ my ($p) = @_;
+ if($p !~ /^(\S*) (\S*)$/) {
+ print STDERR "$ARGV:$.: malformed parameter: $p\n";
+ $errors = 1;
+ return ("xx", "int");
+ }
+ return ($1, $2);
+}
+
+my $text = "";
+while(<>) {
+ chomp;
+ s/\s+/ /g;
+ s/^\s+//;
+ s/\s+$//;
+ my $nonblock = /^\/\/sysnb /;
+ next if !/^\/\/sys / && !$nonblock;
+
+ # Line must be of the form
+ # func Open(path string, mode int, perm int) (fd int, errno error)
+ # Split into name, in params, out params.
+ if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*((?i)SYS_[A-Z0-9_]+))?$/) {
+ print STDERR "$ARGV:$.: malformed //sys declaration\n";
+ $errors = 1;
+ next;
+ }
+ my ($func, $in, $out, $sysname) = ($2, $3, $4, $5);
+
+ # Split argument lists on comma.
+ my @in = parseparamlist($in);
+ my @out = parseparamlist($out);
+
+ # Try in vain to keep people from editing this file.
+ # The theory is that they jump into the middle of the file
+ # without reading the header.
+ $text .= "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n";
+
+ # Go function header.
+ my $out_decl = @out ? sprintf(" (%s)", join(', ', @out)) : "";
+ $text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out_decl;
+
+ # Check if err return available
+ my $errvar = "";
+ foreach my $p (@out) {
+ my ($name, $type) = parseparam($p);
+ if($type eq "error") {
+ $errvar = $name;
+ last;
+ }
+ }
+
+ # Prepare arguments to Syscall.
+ my @args = ();
+ my @uses = ();
+ my $n = 0;
+ foreach my $p (@in) {
+ my ($name, $type) = parseparam($p);
+ if($type =~ /^\*/) {
+ push @args, "uintptr(unsafe.Pointer($name))";
+ } elsif($type eq "string" && $errvar ne "") {
+ $text .= "\tvar _p$n *byte\n";
+ $text .= "\t_p$n, $errvar = BytePtrFromString($name)\n";
+ $text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n";
+ push @args, "uintptr(unsafe.Pointer(_p$n))";
+ push @uses, "use(unsafe.Pointer(_p$n))";
+ $n++;
+ } elsif($type eq "string") {
+ print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n";
+ $text .= "\tvar _p$n *byte\n";
+ $text .= "\t_p$n, _ = BytePtrFromString($name)\n";
+ push @args, "uintptr(unsafe.Pointer(_p$n))";
+ push @uses, "use(unsafe.Pointer(_p$n))";
+ $n++;
+ } elsif($type =~ /^\[\](.*)/) {
+ # Convert slice into pointer, length.
+ # Have to be careful not to take address of &a[0] if len == 0:
+ # pass dummy pointer in that case.
+ # Used to pass nil, but some OSes or simulators reject write(fd, nil, 0).
+ $text .= "\tvar _p$n unsafe.Pointer\n";
+ $text .= "\tif len($name) > 0 {\n\t\t_p$n = unsafe.Pointer(\&${name}[0])\n\t}";
+ $text .= " else {\n\t\t_p$n = unsafe.Pointer(&_zero)\n\t}";
+ $text .= "\n";
+ push @args, "uintptr(_p$n)", "uintptr(len($name))";
+ $n++;
+ } elsif($type eq "int64" && ($openbsd || $netbsd)) {
+ push @args, "0";
+ if($_32bit eq "big-endian") {
+ push @args, "uintptr($name>>32)", "uintptr($name)";
+ } elsif($_32bit eq "little-endian") {
+ push @args, "uintptr($name)", "uintptr($name>>32)";
+ } else {
+ push @args, "uintptr($name)";
+ }
+ } elsif($type eq "int64" && $dragonfly) {
+ if ($func !~ /^extp(read|write)/i) {
+ push @args, "0";
+ }
+ if($_32bit eq "big-endian") {
+ push @args, "uintptr($name>>32)", "uintptr($name)";
+ } elsif($_32bit eq "little-endian") {
+ push @args, "uintptr($name)", "uintptr($name>>32)";
+ } else {
+ push @args, "uintptr($name)";
+ }
+ } elsif($type eq "int64" && $_32bit ne "") {
+ if(@args % 2 && $arm) {
+ # arm abi specifies 64-bit argument uses
+ # (even, odd) pair
+ push @args, "0"
+ }
+ if($_32bit eq "big-endian") {
+ push @args, "uintptr($name>>32)", "uintptr($name)";
+ } else {
+ push @args, "uintptr($name)", "uintptr($name>>32)";
+ }
+ } else {
+ push @args, "uintptr($name)";
+ }
+ }
+
+ # Determine which form to use; pad args with zeros.
+ my $asm = "Syscall";
+ if ($nonblock) {
+ $asm = "RawSyscall";
+ }
+ if(@args <= 3) {
+ while(@args < 3) {
+ push @args, "0";
+ }
+ } elsif(@args <= 6) {
+ $asm .= "6";
+ while(@args < 6) {
+ push @args, "0";
+ }
+ } elsif(@args <= 9) {
+ $asm .= "9";
+ while(@args < 9) {
+ push @args, "0";
+ }
+ } else {
+ print STDERR "$ARGV:$.: too many arguments to system call\n";
+ }
+
+ # System call number.
+ if($sysname eq "") {
+ $sysname = "SYS_$func";
+ $sysname =~ s/([a-z])([A-Z])/${1}_$2/g; # turn FooBar into Foo_Bar
+ $sysname =~ y/a-z/A-Z/;
+ }
+
+ # Actual call.
+ my $args = join(', ', @args);
+ my $call = "$asm($sysname, $args)";
+
+ # Assign return values.
+ my $body = "";
+ my @ret = ("_", "_", "_");
+ my $do_errno = 0;
+ for(my $i=0; $i<@out; $i++) {
+ my $p = $out[$i];
+ my ($name, $type) = parseparam($p);
+ my $reg = "";
+ if($name eq "err" && !$plan9) {
+ $reg = "e1";
+ $ret[2] = $reg;
+ $do_errno = 1;
+ } elsif($name eq "err" && $plan9) {
+ $ret[0] = "r0";
+ $ret[2] = "e1";
+ next;
+ } else {
+ $reg = sprintf("r%d", $i);
+ $ret[$i] = $reg;
+ }
+ if($type eq "bool") {
+ $reg = "$reg != 0";
+ }
+ if($type eq "int64" && $_32bit ne "") {
+ # 64-bit number in r1:r0 or r0:r1.
+ if($i+2 > @out) {
+ print STDERR "$ARGV:$.: not enough registers for int64 return\n";
+ }
+ if($_32bit eq "big-endian") {
+ $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i, $i+1);
+ } else {
+ $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i+1, $i);
+ }
+ $ret[$i] = sprintf("r%d", $i);
+ $ret[$i+1] = sprintf("r%d", $i+1);
+ }
+ if($reg ne "e1" || $plan9) {
+ $body .= "\t$name = $type($reg)\n";
+ }
+ }
+ if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") {
+ $text .= "\t$call\n";
+ } else {
+ $text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
+ }
+ foreach my $use (@uses) {
+ $text .= "\t$use\n";
+ }
+ $text .= $body;
+
+ if ($plan9 && $ret[2] eq "e1") {
+ $text .= "\tif int32(r0) == -1 {\n";
+ $text .= "\t\terr = e1\n";
+ $text .= "\t}\n";
+ } elsif ($do_errno) {
+ $text .= "\tif e1 != 0 {\n";
+ $text .= "\t\terr = errnoErr(e1)\n";
+ $text .= "\t}\n";
+ }
+ $text .= "\treturn\n";
+ $text .= "}\n\n";
+}
+
+chomp $text;
+chomp $text;
+
+if($errors) {
+ exit 1;
+}
+
+print <) {
+ chomp;
+ s/\s+/ /g;
+ s/^\s+//;
+ s/\s+$//;
+ $package = $1 if !$package && /^package (\S+)$/;
+ my $nonblock = /^\/\/sysnb /;
+ next if !/^\/\/sys / && !$nonblock;
+
+ # Line must be of the form
+ # func Open(path string, mode int, perm int) (fd int, err error)
+ # Split into name, in params, out params.
+ if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$/) {
+ print STDERR "$ARGV:$.: malformed //sys declaration\n";
+ $errors = 1;
+ next;
+ }
+ my ($nb, $func, $in, $out, $modname, $sysname) = ($1, $2, $3, $4, $5, $6);
+
+ # Split argument lists on comma.
+ my @in = parseparamlist($in);
+ my @out = parseparamlist($out);
+
+ # So file name.
+ if($modname eq "") {
+ $modname = "libc";
+ }
+
+ # System call name.
+ if($sysname eq "") {
+ $sysname = "$func";
+ }
+
+ # System call pointer variable name.
+ my $sysvarname = "proc$sysname";
+
+ my $strconvfunc = "BytePtrFromString";
+ my $strconvtype = "*byte";
+
+ $sysname =~ y/A-Z/a-z/; # All libc functions are lowercase.
+
+ # Runtime import of function to allow cross-platform builds.
+ $dynimports .= "//go:cgo_import_dynamic libc_${sysname} ${sysname} \"$modname.so\"\n";
+ # Link symbol to proc address variable.
+ $linknames .= "//go:linkname ${sysvarname} libc_${sysname}\n";
+ # Library proc address variable.
+ push @vars, $sysvarname;
+
+ # Go function header.
+ $out = join(', ', @out);
+ if($out ne "") {
+ $out = " ($out)";
+ }
+ if($text ne "") {
+ $text .= "\n"
+ }
+ $text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out;
+
+ # Check if err return available
+ my $errvar = "";
+ foreach my $p (@out) {
+ my ($name, $type) = parseparam($p);
+ if($type eq "error") {
+ $errvar = $name;
+ last;
+ }
+ }
+
+ # Prepare arguments to Syscall.
+ my @args = ();
+ my @uses = ();
+ my $n = 0;
+ foreach my $p (@in) {
+ my ($name, $type) = parseparam($p);
+ if($type =~ /^\*/) {
+ push @args, "uintptr(unsafe.Pointer($name))";
+ } elsif($type eq "string" && $errvar ne "") {
+ $text .= "\tvar _p$n $strconvtype\n";
+ $text .= "\t_p$n, $errvar = $strconvfunc($name)\n";
+ $text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n";
+ push @args, "uintptr(unsafe.Pointer(_p$n))";
+ push @uses, "use(unsafe.Pointer(_p$n))";
+ $n++;
+ } elsif($type eq "string") {
+ print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n";
+ $text .= "\tvar _p$n $strconvtype\n";
+ $text .= "\t_p$n, _ = $strconvfunc($name)\n";
+ push @args, "uintptr(unsafe.Pointer(_p$n))";
+ push @uses, "use(unsafe.Pointer(_p$n))";
+ $n++;
+ } elsif($type =~ /^\[\](.*)/) {
+ # Convert slice into pointer, length.
+ # Have to be careful not to take address of &a[0] if len == 0:
+ # pass nil in that case.
+ $text .= "\tvar _p$n *$1\n";
+ $text .= "\tif len($name) > 0 {\n\t\t_p$n = \&$name\[0]\n\t}\n";
+ push @args, "uintptr(unsafe.Pointer(_p$n))", "uintptr(len($name))";
+ $n++;
+ } elsif($type eq "int64" && $_32bit ne "") {
+ if($_32bit eq "big-endian") {
+ push @args, "uintptr($name >> 32)", "uintptr($name)";
+ } else {
+ push @args, "uintptr($name)", "uintptr($name >> 32)";
+ }
+ } elsif($type eq "bool") {
+ $text .= "\tvar _p$n uint32\n";
+ $text .= "\tif $name {\n\t\t_p$n = 1\n\t} else {\n\t\t_p$n = 0\n\t}\n";
+ push @args, "uintptr(_p$n)";
+ $n++;
+ } else {
+ push @args, "uintptr($name)";
+ }
+ }
+ my $nargs = @args;
+
+ # Determine which form to use; pad args with zeros.
+ my $asm = "sysvicall6";
+ if ($nonblock) {
+ $asm = "rawSysvicall6";
+ }
+ if(@args <= 6) {
+ while(@args < 6) {
+ push @args, "0";
+ }
+ } else {
+ print STDERR "$ARGV:$.: too many arguments to system call\n";
+ }
+
+ # Actual call.
+ my $args = join(', ', @args);
+ my $call = "$asm(uintptr(unsafe.Pointer(&$sysvarname)), $nargs, $args)";
+
+ # Assign return values.
+ my $body = "";
+ my $failexpr = "";
+ my @ret = ("_", "_", "_");
+ my @pout= ();
+ my $do_errno = 0;
+ for(my $i=0; $i<@out; $i++) {
+ my $p = $out[$i];
+ my ($name, $type) = parseparam($p);
+ my $reg = "";
+ if($name eq "err") {
+ $reg = "e1";
+ $ret[2] = $reg;
+ $do_errno = 1;
+ } else {
+ $reg = sprintf("r%d", $i);
+ $ret[$i] = $reg;
+ }
+ if($type eq "bool") {
+ $reg = "$reg != 0";
+ }
+ if($type eq "int64" && $_32bit ne "") {
+ # 64-bit number in r1:r0 or r0:r1.
+ if($i+2 > @out) {
+ print STDERR "$ARGV:$.: not enough registers for int64 return\n";
+ }
+ if($_32bit eq "big-endian") {
+ $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i, $i+1);
+ } else {
+ $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i+1, $i);
+ }
+ $ret[$i] = sprintf("r%d", $i);
+ $ret[$i+1] = sprintf("r%d", $i+1);
+ }
+ if($reg ne "e1") {
+ $body .= "\t$name = $type($reg)\n";
+ }
+ }
+ if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") {
+ $text .= "\t$call\n";
+ } else {
+ $text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
+ }
+ foreach my $use (@uses) {
+ $text .= "\t$use\n";
+ }
+ $text .= $body;
+
+ if ($do_errno) {
+ $text .= "\tif e1 != 0 {\n";
+ $text .= "\t\terr = e1\n";
+ $text .= "\t}\n";
+ }
+ $text .= "\treturn\n";
+ $text .= "}\n";
+}
+
+if($errors) {
+ exit 1;
+}
+
+print < "net.inet",
+ "net.inet.ipproto" => "net.inet",
+ "net.inet6.ipv6proto" => "net.inet6",
+ "net.inet6.ipv6" => "net.inet6.ip6",
+ "net.inet.icmpv6" => "net.inet6.icmp6",
+ "net.inet6.divert6" => "net.inet6.divert",
+ "net.inet6.tcp6" => "net.inet.tcp",
+ "net.inet6.udp6" => "net.inet.udp",
+ "mpls" => "net.mpls",
+ "swpenc" => "vm.swapencrypt"
+);
+
+# Node mappings
+my %node_map = (
+ "net.inet.ip.ifq" => "net.ifq",
+ "net.inet.pfsync" => "net.pfsync",
+ "net.mpls.ifq" => "net.ifq"
+);
+
+my $ctlname;
+my %mib = ();
+my %sysctl = ();
+my $node;
+
+sub debug() {
+ print STDERR "$_[0]\n" if $debug;
+}
+
+# Walk the MIB and build a sysctl name to OID mapping.
+sub build_sysctl() {
+ my ($node, $name, $oid) = @_;
+ my %node = %{$node};
+ my @oid = @{$oid};
+
+ foreach my $key (sort keys %node) {
+ my @node = @{$node{$key}};
+ my $nodename = $name.($name ne '' ? '.' : '').$key;
+ my @nodeoid = (@oid, $node[0]);
+ if ($node[1] eq 'CTLTYPE_NODE') {
+ if (exists $node_map{$nodename}) {
+ $node = \%mib;
+ $ctlname = $node_map{$nodename};
+ foreach my $part (split /\./, $ctlname) {
+ $node = \%{@{$$node{$part}}[2]};
+ }
+ } else {
+ $node = $node[2];
+ }
+ &build_sysctl($node, $nodename, \@nodeoid);
+ } elsif ($node[1] ne '') {
+ $sysctl{$nodename} = \@nodeoid;
+ }
+ }
+}
+
+foreach my $ctl (@ctls) {
+ $ctls{$ctl} = $ctl;
+}
+
+# Build MIB
+foreach my $header (@headers) {
+ &debug("Processing $header...");
+ open HEADER, "/usr/include/$header" ||
+ print STDERR "Failed to open $header\n";
+ while () {
+ if ($_ =~ /^#define\s+(CTL_NAMES)\s+{/ ||
+ $_ =~ /^#define\s+(CTL_(.*)_NAMES)\s+{/ ||
+ $_ =~ /^#define\s+((.*)CTL_NAMES)\s+{/) {
+ if ($1 eq 'CTL_NAMES') {
+ # Top level.
+ $node = \%mib;
+ } else {
+ # Node.
+ my $nodename = lc($2);
+ if ($header =~ /^netinet\//) {
+ $ctlname = "net.inet.$nodename";
+ } elsif ($header =~ /^netinet6\//) {
+ $ctlname = "net.inet6.$nodename";
+ } elsif ($header =~ /^net\//) {
+ $ctlname = "net.$nodename";
+ } else {
+ $ctlname = "$nodename";
+ $ctlname =~ s/^(fs|net|kern)_/$1\./;
+ }
+ if (exists $ctl_map{$ctlname}) {
+ $ctlname = $ctl_map{$ctlname};
+ }
+ if (not exists $ctls{$ctlname}) {
+ &debug("Ignoring $ctlname...");
+ next;
+ }
+
+ # Walk down from the top of the MIB.
+ $node = \%mib;
+ foreach my $part (split /\./, $ctlname) {
+ if (not exists $$node{$part}) {
+ &debug("Missing node $part");
+ $$node{$part} = [ 0, '', {} ];
+ }
+ $node = \%{@{$$node{$part}}[2]};
+ }
+ }
+
+ # Populate current node with entries.
+ my $i = -1;
+ while (defined($_) && $_ !~ /^}/) {
+ $_ = ;
+ $i++ if $_ =~ /{.*}/;
+ next if $_ !~ /{\s+"(\w+)",\s+(CTLTYPE_[A-Z]+)\s+}/;
+ $$node{$1} = [ $i, $2, {} ];
+ }
+ }
+ }
+ close HEADER;
+}
+
+&build_sysctl(\%mib, "", []);
+
+print <){
+ if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){
+ my $name = $1;
+ my $num = $2;
+ $name =~ y/a-z/A-Z/;
+ print " SYS_$name = $num;"
+ }
+}
+
+print <){
+ if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){
+ my $num = $1;
+ my $proto = $2;
+ my $name = "SYS_$3";
+ $name =~ y/a-z/A-Z/;
+
+ # There are multiple entries for enosys and nosys, so comment them out.
+ if($name =~ /^SYS_E?NOSYS$/){
+ $name = "// $name";
+ }
+ if($name eq 'SYS_SYS_EXIT'){
+ $name = 'SYS_EXIT';
+ }
+
+ print " $name = $num; // $proto\n";
+ }
+}
+
+print <){
+ if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){
+ my $num = $1;
+ my $proto = $2;
+ my $name = "SYS_$3";
+ $name =~ y/a-z/A-Z/;
+
+ # There are multiple entries for enosys and nosys, so comment them out.
+ if($name =~ /^SYS_E?NOSYS$/){
+ $name = "// $name";
+ }
+ if($name eq 'SYS_SYS_EXIT'){
+ $name = 'SYS_EXIT';
+ }
+ if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){
+ next
+ }
+
+ print " $name = $num; // $proto\n";
+
+ # We keep Capsicum syscall numbers for FreeBSD
+ # 9-STABLE here because we are not sure whether they
+ # are mature and stable.
+ if($num == 513){
+ print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n";
+ print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n";
+ print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n";
+ print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n";
+ }
+ }
+}
+
+print < 999){
+ # ignore deprecated syscalls that are no longer implemented
+ # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716
+ return;
+ }
+ $name =~ y/a-z/A-Z/;
+ print " SYS_$name = $num;\n";
+}
+
+my $prev;
+open(GCC, "gcc -E -dD $ARGV[0] |") || die "can't run gcc";
+while(){
+ if(/^#define __NR_syscalls\s+/) {
+ # ignore redefinitions of __NR_syscalls
+ }
+ elsif(/^#define __NR_(\w+)\s+([0-9]+)/){
+ $prev = $2;
+ fmt($1, $2);
+ }
+ elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){
+ $prev = $2;
+ fmt($1, $2);
+ }
+ elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){
+ fmt($1, $prev+$2)
+ }
+}
+
+print <){
+ if($line =~ /^(.*)\\$/) {
+ # Handle continuation
+ $line = $1;
+ $_ =~ s/^\s+//;
+ $line .= $_;
+ } else {
+ # New line
+ $line = $_;
+ }
+ next if $line =~ /\\$/;
+ if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) {
+ my $num = $1;
+ my $proto = $6;
+ my $compat = $8;
+ my $name = "$7_$9";
+
+ $name = "$7_$11" if $11 ne '';
+ $name =~ y/a-z/A-Z/;
+
+ if($compat eq '' || $compat eq '30' || $compat eq '50') {
+ print " $name = $num; // $proto\n";
+ }
+ }
+}
+
+print <){
+ if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){
+ my $num = $1;
+ my $proto = $3;
+ my $name = $4;
+ $name =~ y/a-z/A-Z/;
+
+ # There are multiple entries for enosys and nosys, so comment them out.
+ if($name =~ /^SYS_E?NOSYS$/){
+ $name = "// $name";
+ }
+ if($name eq 'SYS_SYS_EXIT'){
+ $name = 'SYS_EXIT';
+ }
+
+ print " $name = $num; // $proto\n";
+ }
+}
+
+print < len(b) {
+ return nil, nil, EINVAL
+ }
+ return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil
+}
+
+// UnixRights encodes a set of open file descriptors into a socket
+// control message for sending to another process.
+func UnixRights(fds ...int) []byte {
+ datalen := len(fds) * 4
+ b := make([]byte, CmsgSpace(datalen))
+ h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
+ h.Level = SOL_SOCKET
+ h.Type = SCM_RIGHTS
+ h.SetLen(CmsgLen(datalen))
+ data := cmsgData(h)
+ for _, fd := range fds {
+ *(*int32)(data) = int32(fd)
+ data = unsafe.Pointer(uintptr(data) + 4)
+ }
+ return b
+}
+
+// ParseUnixRights decodes a socket control message that contains an
+// integer array of open file descriptors from another process.
+func ParseUnixRights(m *SocketControlMessage) ([]int, error) {
+ if m.Header.Level != SOL_SOCKET {
+ return nil, EINVAL
+ }
+ if m.Header.Type != SCM_RIGHTS {
+ return nil, EINVAL
+ }
+ fds := make([]int, len(m.Data)>>2)
+ for i, j := 0, 0; i < len(m.Data); i += 4 {
+ fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i])))
+ j++
+ }
+ return fds, nil
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/str.go b/Godeps/_workspace/src/golang.org/x/sys/unix/str.go
new file mode 100644
index 0000000000..35ed664353
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/str.go
@@ -0,0 +1,26 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
+
+package unix
+
+func itoa(val int) string { // do it here rather than with fmt to avoid dependency
+ if val < 0 {
+ return "-" + uitoa(uint(-val))
+ }
+ return uitoa(uint(val))
+}
+
+func uitoa(val uint) string {
+ var buf [32]byte // big enough for int64
+ i := len(buf) - 1
+ for val >= 10 {
+ buf[i] = byte(val%10 + '0')
+ i--
+ val /= 10
+ }
+ buf[i] = byte(val + '0')
+ return string(buf[i:])
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall.go
new file mode 100644
index 0000000000..a48d47cff8
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall.go
@@ -0,0 +1,74 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
+
+// Package unix contains an interface to the low-level operating system
+// primitives. OS details vary depending on the underlying system, and
+// by default, godoc will display OS-specific documentation for the current
+// system. If you want godoc to display OS documentation for another
+// system, set $GOOS and $GOARCH to the desired system. For example, if
+// you want to view documentation for freebsd/arm on linux/amd64, set $GOOS
+// to freebsd and $GOARCH to arm.
+// The primary use of this package is inside other packages that provide a more
+// portable interface to the system, such as "os", "time" and "net". Use
+// those packages rather than this one if you can.
+// For details of the functions and data types in this package consult
+// the manuals for the appropriate operating system.
+// These calls return err == nil to indicate success; otherwise
+// err represents an operating system error describing the failure and
+// holds a value of type syscall.Errno.
+package unix
+
+import "unsafe"
+
+// ByteSliceFromString returns a NUL-terminated slice of bytes
+// containing the text of s. If s contains a NUL byte at any
+// location, it returns (nil, EINVAL).
+func ByteSliceFromString(s string) ([]byte, error) {
+ for i := 0; i < len(s); i++ {
+ if s[i] == 0 {
+ return nil, EINVAL
+ }
+ }
+ a := make([]byte, len(s)+1)
+ copy(a, s)
+ return a, nil
+}
+
+// BytePtrFromString returns a pointer to a NUL-terminated array of
+// bytes containing the text of s. If s contains a NUL byte at any
+// location, it returns (nil, EINVAL).
+func BytePtrFromString(s string) (*byte, error) {
+ a, err := ByteSliceFromString(s)
+ if err != nil {
+ return nil, err
+ }
+ return &a[0], nil
+}
+
+// Single-word zero for use when we need a valid pointer to 0 bytes.
+// See mkunix.pl.
+var _zero uintptr
+
+func (ts *Timespec) Unix() (sec int64, nsec int64) {
+ return int64(ts.Sec), int64(ts.Nsec)
+}
+
+func (tv *Timeval) Unix() (sec int64, nsec int64) {
+ return int64(tv.Sec), int64(tv.Usec) * 1000
+}
+
+func (ts *Timespec) Nano() int64 {
+ return int64(ts.Sec)*1e9 + int64(ts.Nsec)
+}
+
+func (tv *Timeval) Nano() int64 {
+ return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000
+}
+
+// use is a no-op, but the compiler cannot see that it is.
+// Calling use(p) ensures that p is kept live until that point.
+//go:noescape
+func use(p unsafe.Pointer)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_bsd.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_bsd.go
new file mode 100644
index 0000000000..e9671764cc
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_bsd.go
@@ -0,0 +1,628 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin dragonfly freebsd netbsd openbsd
+
+// BSD system call wrappers shared by *BSD based systems
+// including OS X (Darwin) and FreeBSD. Like the other
+// syscall_*.go files it is compiled as Go code but also
+// used as input to mksyscall which parses the //sys
+// lines and generates system call stubs.
+
+package unix
+
+import (
+ "runtime"
+ "syscall"
+ "unsafe"
+)
+
+/*
+ * Wrapped
+ */
+
+//sysnb getgroups(ngid int, gid *_Gid_t) (n int, err error)
+//sysnb setgroups(ngid int, gid *_Gid_t) (err error)
+
+func Getgroups() (gids []int, err error) {
+ n, err := getgroups(0, nil)
+ if err != nil {
+ return nil, err
+ }
+ if n == 0 {
+ return nil, nil
+ }
+
+ // Sanity check group count. Max is 16 on BSD.
+ if n < 0 || n > 1000 {
+ return nil, EINVAL
+ }
+
+ a := make([]_Gid_t, n)
+ n, err = getgroups(n, &a[0])
+ if err != nil {
+ return nil, err
+ }
+ gids = make([]int, n)
+ for i, v := range a[0:n] {
+ gids[i] = int(v)
+ }
+ return
+}
+
+func Setgroups(gids []int) (err error) {
+ if len(gids) == 0 {
+ return setgroups(0, nil)
+ }
+
+ a := make([]_Gid_t, len(gids))
+ for i, v := range gids {
+ a[i] = _Gid_t(v)
+ }
+ return setgroups(len(a), &a[0])
+}
+
+func ReadDirent(fd int, buf []byte) (n int, err error) {
+ // Final argument is (basep *uintptr) and the syscall doesn't take nil.
+ // 64 bits should be enough. (32 bits isn't even on 386). Since the
+ // actual system call is getdirentries64, 64 is a good guess.
+ // TODO(rsc): Can we use a single global basep for all calls?
+ var base = (*uintptr)(unsafe.Pointer(new(uint64)))
+ return Getdirentries(fd, buf, base)
+}
+
+// Wait status is 7 bits at bottom, either 0 (exited),
+// 0x7F (stopped), or a signal number that caused an exit.
+// The 0x80 bit is whether there was a core dump.
+// An extra number (exit code, signal causing a stop)
+// is in the high bits.
+
+type WaitStatus uint32
+
+const (
+ mask = 0x7F
+ core = 0x80
+ shift = 8
+
+ exited = 0
+ stopped = 0x7F
+)
+
+func (w WaitStatus) Exited() bool { return w&mask == exited }
+
+func (w WaitStatus) ExitStatus() int {
+ if w&mask != exited {
+ return -1
+ }
+ return int(w >> shift)
+}
+
+func (w WaitStatus) Signaled() bool { return w&mask != stopped && w&mask != 0 }
+
+func (w WaitStatus) Signal() syscall.Signal {
+ sig := syscall.Signal(w & mask)
+ if sig == stopped || sig == 0 {
+ return -1
+ }
+ return sig
+}
+
+func (w WaitStatus) CoreDump() bool { return w.Signaled() && w&core != 0 }
+
+func (w WaitStatus) Stopped() bool { return w&mask == stopped && syscall.Signal(w>>shift) != SIGSTOP }
+
+func (w WaitStatus) Continued() bool { return w&mask == stopped && syscall.Signal(w>>shift) == SIGSTOP }
+
+func (w WaitStatus) StopSignal() syscall.Signal {
+ if !w.Stopped() {
+ return -1
+ }
+ return syscall.Signal(w>>shift) & 0xFF
+}
+
+func (w WaitStatus) TrapCause() int { return -1 }
+
+//sys wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error)
+
+func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) {
+ var status _C_int
+ wpid, err = wait4(pid, &status, options, rusage)
+ if wstatus != nil {
+ *wstatus = WaitStatus(status)
+ }
+ return
+}
+
+//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
+//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
+//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
+//sysnb socket(domain int, typ int, proto int) (fd int, err error)
+//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
+//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
+//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
+//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
+//sys Shutdown(s int, how int) (err error)
+
+func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) {
+ if sa.Port < 0 || sa.Port > 0xFFFF {
+ return nil, 0, EINVAL
+ }
+ sa.raw.Len = SizeofSockaddrInet4
+ sa.raw.Family = AF_INET
+ p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
+ p[0] = byte(sa.Port >> 8)
+ p[1] = byte(sa.Port)
+ for i := 0; i < len(sa.Addr); i++ {
+ sa.raw.Addr[i] = sa.Addr[i]
+ }
+ return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
+}
+
+func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) {
+ if sa.Port < 0 || sa.Port > 0xFFFF {
+ return nil, 0, EINVAL
+ }
+ sa.raw.Len = SizeofSockaddrInet6
+ sa.raw.Family = AF_INET6
+ p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
+ p[0] = byte(sa.Port >> 8)
+ p[1] = byte(sa.Port)
+ sa.raw.Scope_id = sa.ZoneId
+ for i := 0; i < len(sa.Addr); i++ {
+ sa.raw.Addr[i] = sa.Addr[i]
+ }
+ return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
+}
+
+func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
+ name := sa.Name
+ n := len(name)
+ if n >= len(sa.raw.Path) || n == 0 {
+ return nil, 0, EINVAL
+ }
+ sa.raw.Len = byte(3 + n) // 2 for Family, Len; 1 for NUL
+ sa.raw.Family = AF_UNIX
+ for i := 0; i < n; i++ {
+ sa.raw.Path[i] = int8(name[i])
+ }
+ return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
+}
+
+func (sa *SockaddrDatalink) sockaddr() (unsafe.Pointer, _Socklen, error) {
+ if sa.Index == 0 {
+ return nil, 0, EINVAL
+ }
+ sa.raw.Len = sa.Len
+ sa.raw.Family = AF_LINK
+ sa.raw.Index = sa.Index
+ sa.raw.Type = sa.Type
+ sa.raw.Nlen = sa.Nlen
+ sa.raw.Alen = sa.Alen
+ sa.raw.Slen = sa.Slen
+ for i := 0; i < len(sa.raw.Data); i++ {
+ sa.raw.Data[i] = sa.Data[i]
+ }
+ return unsafe.Pointer(&sa.raw), SizeofSockaddrDatalink, nil
+}
+
+func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) {
+ switch rsa.Addr.Family {
+ case AF_LINK:
+ pp := (*RawSockaddrDatalink)(unsafe.Pointer(rsa))
+ sa := new(SockaddrDatalink)
+ sa.Len = pp.Len
+ sa.Family = pp.Family
+ sa.Index = pp.Index
+ sa.Type = pp.Type
+ sa.Nlen = pp.Nlen
+ sa.Alen = pp.Alen
+ sa.Slen = pp.Slen
+ for i := 0; i < len(sa.Data); i++ {
+ sa.Data[i] = pp.Data[i]
+ }
+ return sa, nil
+
+ case AF_UNIX:
+ pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa))
+ if pp.Len < 2 || pp.Len > SizeofSockaddrUnix {
+ return nil, EINVAL
+ }
+ sa := new(SockaddrUnix)
+
+ // Some BSDs include the trailing NUL in the length, whereas
+ // others do not. Work around this by subtracting the leading
+ // family and len. The path is then scanned to see if a NUL
+ // terminator still exists within the length.
+ n := int(pp.Len) - 2 // subtract leading Family, Len
+ for i := 0; i < n; i++ {
+ if pp.Path[i] == 0 {
+ // found early NUL; assume Len included the NUL
+ // or was overestimating.
+ n = i
+ break
+ }
+ }
+ bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
+ sa.Name = string(bytes)
+ return sa, nil
+
+ case AF_INET:
+ pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa))
+ sa := new(SockaddrInet4)
+ p := (*[2]byte)(unsafe.Pointer(&pp.Port))
+ sa.Port = int(p[0])<<8 + int(p[1])
+ for i := 0; i < len(sa.Addr); i++ {
+ sa.Addr[i] = pp.Addr[i]
+ }
+ return sa, nil
+
+ case AF_INET6:
+ pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa))
+ sa := new(SockaddrInet6)
+ p := (*[2]byte)(unsafe.Pointer(&pp.Port))
+ sa.Port = int(p[0])<<8 + int(p[1])
+ sa.ZoneId = pp.Scope_id
+ for i := 0; i < len(sa.Addr); i++ {
+ sa.Addr[i] = pp.Addr[i]
+ }
+ return sa, nil
+ }
+ return nil, EAFNOSUPPORT
+}
+
+func Accept(fd int) (nfd int, sa Sockaddr, err error) {
+ var rsa RawSockaddrAny
+ var len _Socklen = SizeofSockaddrAny
+ nfd, err = accept(fd, &rsa, &len)
+ if err != nil {
+ return
+ }
+ if runtime.GOOS == "darwin" && len == 0 {
+ // Accepted socket has no address.
+ // This is likely due to a bug in xnu kernels,
+ // where instead of ECONNABORTED error socket
+ // is accepted, but has no address.
+ Close(nfd)
+ return 0, nil, ECONNABORTED
+ }
+ sa, err = anyToSockaddr(&rsa)
+ if err != nil {
+ Close(nfd)
+ nfd = 0
+ }
+ return
+}
+
+func Getsockname(fd int) (sa Sockaddr, err error) {
+ var rsa RawSockaddrAny
+ var len _Socklen = SizeofSockaddrAny
+ if err = getsockname(fd, &rsa, &len); err != nil {
+ return
+ }
+ // TODO(jsing): DragonFly has a "bug" (see issue 3349), which should be
+ // reported upstream.
+ if runtime.GOOS == "dragonfly" && rsa.Addr.Family == AF_UNSPEC && rsa.Addr.Len == 0 {
+ rsa.Addr.Family = AF_UNIX
+ rsa.Addr.Len = SizeofSockaddrUnix
+ }
+ return anyToSockaddr(&rsa)
+}
+
+//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
+
+func GetsockoptByte(fd, level, opt int) (value byte, err error) {
+ var n byte
+ vallen := _Socklen(1)
+ err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen)
+ return n, err
+}
+
+func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error) {
+ vallen := _Socklen(4)
+ err = getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
+ return value, err
+}
+
+func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error) {
+ var value IPMreq
+ vallen := _Socklen(SizeofIPMreq)
+ err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
+ return &value, err
+}
+
+func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) {
+ var value IPv6Mreq
+ vallen := _Socklen(SizeofIPv6Mreq)
+ err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
+ return &value, err
+}
+
+func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) {
+ var value IPv6MTUInfo
+ vallen := _Socklen(SizeofIPv6MTUInfo)
+ err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
+ return &value, err
+}
+
+func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) {
+ var value ICMPv6Filter
+ vallen := _Socklen(SizeofICMPv6Filter)
+ err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
+ return &value, err
+}
+
+//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
+//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
+//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
+
+func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) {
+ var msg Msghdr
+ var rsa RawSockaddrAny
+ msg.Name = (*byte)(unsafe.Pointer(&rsa))
+ msg.Namelen = uint32(SizeofSockaddrAny)
+ var iov Iovec
+ if len(p) > 0 {
+ iov.Base = (*byte)(unsafe.Pointer(&p[0]))
+ iov.SetLen(len(p))
+ }
+ var dummy byte
+ if len(oob) > 0 {
+ // receive at least one normal byte
+ if len(p) == 0 {
+ iov.Base = &dummy
+ iov.SetLen(1)
+ }
+ msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
+ msg.SetControllen(len(oob))
+ }
+ msg.Iov = &iov
+ msg.Iovlen = 1
+ if n, err = recvmsg(fd, &msg, flags); err != nil {
+ return
+ }
+ oobn = int(msg.Controllen)
+ recvflags = int(msg.Flags)
+ // source address is only specified if the socket is unconnected
+ if rsa.Addr.Family != AF_UNSPEC {
+ from, err = anyToSockaddr(&rsa)
+ }
+ return
+}
+
+//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
+
+func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) {
+ _, err = SendmsgN(fd, p, oob, to, flags)
+ return
+}
+
+func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) {
+ var ptr unsafe.Pointer
+ var salen _Socklen
+ if to != nil {
+ ptr, salen, err = to.sockaddr()
+ if err != nil {
+ return 0, err
+ }
+ }
+ var msg Msghdr
+ msg.Name = (*byte)(unsafe.Pointer(ptr))
+ msg.Namelen = uint32(salen)
+ var iov Iovec
+ if len(p) > 0 {
+ iov.Base = (*byte)(unsafe.Pointer(&p[0]))
+ iov.SetLen(len(p))
+ }
+ var dummy byte
+ if len(oob) > 0 {
+ // send at least one normal byte
+ if len(p) == 0 {
+ iov.Base = &dummy
+ iov.SetLen(1)
+ }
+ msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
+ msg.SetControllen(len(oob))
+ }
+ msg.Iov = &iov
+ msg.Iovlen = 1
+ if n, err = sendmsg(fd, &msg, flags); err != nil {
+ return 0, err
+ }
+ if len(oob) > 0 && len(p) == 0 {
+ n = 0
+ }
+ return n, nil
+}
+
+//sys kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error)
+
+func Kevent(kq int, changes, events []Kevent_t, timeout *Timespec) (n int, err error) {
+ var change, event unsafe.Pointer
+ if len(changes) > 0 {
+ change = unsafe.Pointer(&changes[0])
+ }
+ if len(events) > 0 {
+ event = unsafe.Pointer(&events[0])
+ }
+ return kevent(kq, change, len(changes), event, len(events), timeout)
+}
+
+//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL
+
+// sysctlmib translates name to mib number and appends any additional args.
+func sysctlmib(name string, args ...int) ([]_C_int, error) {
+ // Translate name to mib number.
+ mib, err := nametomib(name)
+ if err != nil {
+ return nil, err
+ }
+
+ for _, a := range args {
+ mib = append(mib, _C_int(a))
+ }
+
+ return mib, nil
+}
+
+func Sysctl(name string) (string, error) {
+ return SysctlArgs(name)
+}
+
+func SysctlArgs(name string, args ...int) (string, error) {
+ mib, err := sysctlmib(name, args...)
+ if err != nil {
+ return "", err
+ }
+
+ // Find size.
+ n := uintptr(0)
+ if err := sysctl(mib, nil, &n, nil, 0); err != nil {
+ return "", err
+ }
+ if n == 0 {
+ return "", nil
+ }
+
+ // Read into buffer of that size.
+ buf := make([]byte, n)
+ if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
+ return "", err
+ }
+
+ // Throw away terminating NUL.
+ if n > 0 && buf[n-1] == '\x00' {
+ n--
+ }
+ return string(buf[0:n]), nil
+}
+
+func SysctlUint32(name string) (uint32, error) {
+ return SysctlUint32Args(name)
+}
+
+func SysctlUint32Args(name string, args ...int) (uint32, error) {
+ mib, err := sysctlmib(name, args...)
+ if err != nil {
+ return 0, err
+ }
+
+ n := uintptr(4)
+ buf := make([]byte, 4)
+ if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
+ return 0, err
+ }
+ if n != 4 {
+ return 0, EIO
+ }
+ return *(*uint32)(unsafe.Pointer(&buf[0])), nil
+}
+
+func SysctlUint64(name string, args ...int) (uint64, error) {
+ mib, err := sysctlmib(name, args...)
+ if err != nil {
+ return 0, err
+ }
+
+ n := uintptr(8)
+ buf := make([]byte, 8)
+ if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
+ return 0, err
+ }
+ if n != 8 {
+ return 0, EIO
+ }
+ return *(*uint64)(unsafe.Pointer(&buf[0])), nil
+}
+
+func SysctlRaw(name string, args ...int) ([]byte, error) {
+ mib, err := sysctlmib(name, args...)
+ if err != nil {
+ return nil, err
+ }
+
+ // Find size.
+ n := uintptr(0)
+ if err := sysctl(mib, nil, &n, nil, 0); err != nil {
+ return nil, err
+ }
+ if n == 0 {
+ return nil, nil
+ }
+
+ // Read into buffer of that size.
+ buf := make([]byte, n)
+ if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
+ return nil, err
+ }
+
+ // The actual call may return less than the original reported required
+ // size so ensure we deal with that.
+ return buf[:n], nil
+}
+
+//sys utimes(path string, timeval *[2]Timeval) (err error)
+
+func Utimes(path string, tv []Timeval) error {
+ if tv == nil {
+ return utimes(path, nil)
+ }
+ if len(tv) != 2 {
+ return EINVAL
+ }
+ return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
+}
+
+func UtimesNano(path string, ts []Timespec) error {
+ if ts == nil {
+ return utimes(path, nil)
+ }
+ // TODO: The BSDs can do utimensat with SYS_UTIMENSAT but it
+ // isn't supported by darwin so this uses utimes instead
+ if len(ts) != 2 {
+ return EINVAL
+ }
+ // Not as efficient as it could be because Timespec and
+ // Timeval have different types in the different OSes
+ tv := [2]Timeval{
+ NsecToTimeval(TimespecToNsec(ts[0])),
+ NsecToTimeval(TimespecToNsec(ts[1])),
+ }
+ return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
+}
+
+//sys futimes(fd int, timeval *[2]Timeval) (err error)
+
+func Futimes(fd int, tv []Timeval) error {
+ if tv == nil {
+ return futimes(fd, nil)
+ }
+ if len(tv) != 2 {
+ return EINVAL
+ }
+ return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
+}
+
+//sys fcntl(fd int, cmd int, arg int) (val int, err error)
+
+// TODO: wrap
+// Acct(name nil-string) (err error)
+// Gethostuuid(uuid *byte, timeout *Timespec) (err error)
+// Madvise(addr *byte, len int, behav int) (err error)
+// Mprotect(addr *byte, len int, prot int) (err error)
+// Msync(addr *byte, len int, flags int) (err error)
+// Ptrace(req int, pid int, addr uintptr, data int) (ret uintptr, err error)
+
+var mapper = &mmapper{
+ active: make(map[*byte][]byte),
+ mmap: mmap,
+ munmap: munmap,
+}
+
+func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
+ return mapper.Mmap(fd, offset, length, prot, flags)
+}
+
+func Munmap(b []byte) (err error) {
+ return mapper.Munmap(b)
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin.go
new file mode 100644
index 0000000000..0d1771c3fc
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin.go
@@ -0,0 +1,509 @@
+// Copyright 2009,2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Darwin system calls.
+// This file is compiled as ordinary Go code,
+// but it is also input to mksyscall,
+// which parses the //sys lines and generates system call stubs.
+// Note that sometimes we use a lowercase //sys name and wrap
+// it in our own nicer implementation, either here or in
+// syscall_bsd.go or syscall_unix.go.
+
+package unix
+
+import (
+ errorspkg "errors"
+ "syscall"
+ "unsafe"
+)
+
+const ImplementsGetwd = true
+
+func Getwd() (string, error) {
+ buf := make([]byte, 2048)
+ attrs, err := getAttrList(".", attrList{CommonAttr: attrCmnFullpath}, buf, 0)
+ if err == nil && len(attrs) == 1 && len(attrs[0]) >= 2 {
+ wd := string(attrs[0])
+ // Sanity check that it's an absolute path and ends
+ // in a null byte, which we then strip.
+ if wd[0] == '/' && wd[len(wd)-1] == 0 {
+ return wd[:len(wd)-1], nil
+ }
+ }
+ // If pkg/os/getwd.go gets ENOTSUP, it will fall back to the
+ // slow algorithm.
+ return "", ENOTSUP
+}
+
+type SockaddrDatalink struct {
+ Len uint8
+ Family uint8
+ Index uint16
+ Type uint8
+ Nlen uint8
+ Alen uint8
+ Slen uint8
+ Data [12]int8
+ raw RawSockaddrDatalink
+}
+
+// Translate "kern.hostname" to []_C_int{0,1,2,3}.
+func nametomib(name string) (mib []_C_int, err error) {
+ const siz = unsafe.Sizeof(mib[0])
+
+ // NOTE(rsc): It seems strange to set the buffer to have
+ // size CTL_MAXNAME+2 but use only CTL_MAXNAME
+ // as the size. I don't know why the +2 is here, but the
+ // kernel uses +2 for its own implementation of this function.
+ // I am scared that if we don't include the +2 here, the kernel
+ // will silently write 2 words farther than we specify
+ // and we'll get memory corruption.
+ var buf [CTL_MAXNAME + 2]_C_int
+ n := uintptr(CTL_MAXNAME) * siz
+
+ p := (*byte)(unsafe.Pointer(&buf[0]))
+ bytes, err := ByteSliceFromString(name)
+ if err != nil {
+ return nil, err
+ }
+
+ // Magic sysctl: "setting" 0.3 to a string name
+ // lets you read back the array of integers form.
+ if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
+ return nil, err
+ }
+ return buf[0 : n/siz], nil
+}
+
+// ParseDirent parses up to max directory entries in buf,
+// appending the names to names. It returns the number
+// bytes consumed from buf, the number of entries added
+// to names, and the new names slice.
+func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
+ origlen := len(buf)
+ for max != 0 && len(buf) > 0 {
+ dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
+ if dirent.Reclen == 0 {
+ buf = nil
+ break
+ }
+ buf = buf[dirent.Reclen:]
+ if dirent.Ino == 0 { // File absent in directory.
+ continue
+ }
+ bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
+ var name = string(bytes[0:dirent.Namlen])
+ if name == "." || name == ".." { // Useless names
+ continue
+ }
+ max--
+ count++
+ names = append(names, name)
+ }
+ return origlen - len(buf), count, names
+}
+
+//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
+func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) }
+func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) }
+
+const (
+ attrBitMapCount = 5
+ attrCmnFullpath = 0x08000000
+)
+
+type attrList struct {
+ bitmapCount uint16
+ _ uint16
+ CommonAttr uint32
+ VolAttr uint32
+ DirAttr uint32
+ FileAttr uint32
+ Forkattr uint32
+}
+
+func getAttrList(path string, attrList attrList, attrBuf []byte, options uint) (attrs [][]byte, err error) {
+ if len(attrBuf) < 4 {
+ return nil, errorspkg.New("attrBuf too small")
+ }
+ attrList.bitmapCount = attrBitMapCount
+
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return nil, err
+ }
+
+ _, _, e1 := Syscall6(
+ SYS_GETATTRLIST,
+ uintptr(unsafe.Pointer(_p0)),
+ uintptr(unsafe.Pointer(&attrList)),
+ uintptr(unsafe.Pointer(&attrBuf[0])),
+ uintptr(len(attrBuf)),
+ uintptr(options),
+ 0,
+ )
+ if e1 != 0 {
+ return nil, e1
+ }
+ size := *(*uint32)(unsafe.Pointer(&attrBuf[0]))
+
+ // dat is the section of attrBuf that contains valid data,
+ // without the 4 byte length header. All attribute offsets
+ // are relative to dat.
+ dat := attrBuf
+ if int(size) < len(attrBuf) {
+ dat = dat[:size]
+ }
+ dat = dat[4:] // remove length prefix
+
+ for i := uint32(0); int(i) < len(dat); {
+ header := dat[i:]
+ if len(header) < 8 {
+ return attrs, errorspkg.New("truncated attribute header")
+ }
+ datOff := *(*int32)(unsafe.Pointer(&header[0]))
+ attrLen := *(*uint32)(unsafe.Pointer(&header[4]))
+ if datOff < 0 || uint32(datOff)+attrLen > uint32(len(dat)) {
+ return attrs, errorspkg.New("truncated results; attrBuf too small")
+ }
+ end := uint32(datOff) + attrLen
+ attrs = append(attrs, dat[datOff:end])
+ i = end
+ if r := i % 4; r != 0 {
+ i += (4 - r)
+ }
+ }
+ return
+}
+
+//sysnb pipe() (r int, w int, err error)
+
+func Pipe(p []int) (err error) {
+ if len(p) != 2 {
+ return EINVAL
+ }
+ p[0], p[1], err = pipe()
+ return
+}
+
+func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
+ var _p0 unsafe.Pointer
+ var bufsize uintptr
+ if len(buf) > 0 {
+ _p0 = unsafe.Pointer(&buf[0])
+ bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
+ }
+ r0, _, e1 := Syscall(SYS_GETFSSTAT64, uintptr(_p0), bufsize, uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = e1
+ }
+ return
+}
+
+/*
+ * Wrapped
+ */
+
+//sys kill(pid int, signum int, posix int) (err error)
+
+func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(signum), 1) }
+
+/*
+ * Exposed directly
+ */
+//sys Access(path string, mode uint32) (err error)
+//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
+//sys Chdir(path string) (err error)
+//sys Chflags(path string, flags int) (err error)
+//sys Chmod(path string, mode uint32) (err error)
+//sys Chown(path string, uid int, gid int) (err error)
+//sys Chroot(path string) (err error)
+//sys Close(fd int) (err error)
+//sys Dup(fd int) (nfd int, err error)
+//sys Dup2(from int, to int) (err error)
+//sys Exchangedata(path1 string, path2 string, options int) (err error)
+//sys Exit(code int)
+//sys Fchdir(fd int) (err error)
+//sys Fchflags(fd int, flags int) (err error)
+//sys Fchmod(fd int, mode uint32) (err error)
+//sys Fchown(fd int, uid int, gid int) (err error)
+//sys Flock(fd int, how int) (err error)
+//sys Fpathconf(fd int, name int) (val int, err error)
+//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
+//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
+//sys Fsync(fd int) (err error)
+//sys Ftruncate(fd int, length int64) (err error)
+//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64
+//sys Getdtablesize() (size int)
+//sysnb Getegid() (egid int)
+//sysnb Geteuid() (uid int)
+//sysnb Getgid() (gid int)
+//sysnb Getpgid(pid int) (pgid int, err error)
+//sysnb Getpgrp() (pgrp int)
+//sysnb Getpid() (pid int)
+//sysnb Getppid() (ppid int)
+//sys Getpriority(which int, who int) (prio int, err error)
+//sysnb Getrlimit(which int, lim *Rlimit) (err error)
+//sysnb Getrusage(who int, rusage *Rusage) (err error)
+//sysnb Getsid(pid int) (sid int, err error)
+//sysnb Getuid() (uid int)
+//sysnb Issetugid() (tainted bool)
+//sys Kqueue() (fd int, err error)
+//sys Lchown(path string, uid int, gid int) (err error)
+//sys Link(path string, link string) (err error)
+//sys Listen(s int, backlog int) (err error)
+//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
+//sys Mkdir(path string, mode uint32) (err error)
+//sys Mkfifo(path string, mode uint32) (err error)
+//sys Mknod(path string, mode uint32, dev int) (err error)
+//sys Mlock(b []byte) (err error)
+//sys Mlockall(flags int) (err error)
+//sys Mprotect(b []byte, prot int) (err error)
+//sys Munlock(b []byte) (err error)
+//sys Munlockall() (err error)
+//sys Open(path string, mode int, perm uint32) (fd int, err error)
+//sys Pathconf(path string, name int) (val int, err error)
+//sys Pread(fd int, p []byte, offset int64) (n int, err error)
+//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
+//sys read(fd int, p []byte) (n int, err error)
+//sys Readlink(path string, buf []byte) (n int, err error)
+//sys Rename(from string, to string) (err error)
+//sys Revoke(path string) (err error)
+//sys Rmdir(path string) (err error)
+//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
+//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
+//sys Setegid(egid int) (err error)
+//sysnb Seteuid(euid int) (err error)
+//sysnb Setgid(gid int) (err error)
+//sys Setlogin(name string) (err error)
+//sysnb Setpgid(pid int, pgid int) (err error)
+//sys Setpriority(which int, who int, prio int) (err error)
+//sys Setprivexec(flag int) (err error)
+//sysnb Setregid(rgid int, egid int) (err error)
+//sysnb Setreuid(ruid int, euid int) (err error)
+//sysnb Setrlimit(which int, lim *Rlimit) (err error)
+//sysnb Setsid() (pid int, err error)
+//sysnb Settimeofday(tp *Timeval) (err error)
+//sysnb Setuid(uid int) (err error)
+//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
+//sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64
+//sys Symlink(path string, link string) (err error)
+//sys Sync() (err error)
+//sys Truncate(path string, length int64) (err error)
+//sys Umask(newmask int) (oldmask int)
+//sys Undelete(path string) (err error)
+//sys Unlink(path string) (err error)
+//sys Unmount(path string, flags int) (err error)
+//sys write(fd int, p []byte) (n int, err error)
+//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
+//sys munmap(addr uintptr, length uintptr) (err error)
+//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
+//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
+
+/*
+ * Unimplemented
+ */
+// Profil
+// Sigaction
+// Sigprocmask
+// Getlogin
+// Sigpending
+// Sigaltstack
+// Ioctl
+// Reboot
+// Execve
+// Vfork
+// Sbrk
+// Sstk
+// Ovadvise
+// Mincore
+// Setitimer
+// Swapon
+// Select
+// Sigsuspend
+// Readv
+// Writev
+// Nfssvc
+// Getfh
+// Quotactl
+// Mount
+// Csops
+// Waitid
+// Add_profil
+// Kdebug_trace
+// Sigreturn
+// Mmap
+// Mlock
+// Munlock
+// Atsocket
+// Kqueue_from_portset_np
+// Kqueue_portset
+// Getattrlist
+// Setattrlist
+// Getdirentriesattr
+// Searchfs
+// Delete
+// Copyfile
+// Poll
+// Watchevent
+// Waitevent
+// Modwatch
+// Getxattr
+// Fgetxattr
+// Setxattr
+// Fsetxattr
+// Removexattr
+// Fremovexattr
+// Listxattr
+// Flistxattr
+// Fsctl
+// Initgroups
+// Posix_spawn
+// Nfsclnt
+// Fhopen
+// Minherit
+// Semsys
+// Msgsys
+// Shmsys
+// Semctl
+// Semget
+// Semop
+// Msgctl
+// Msgget
+// Msgsnd
+// Msgrcv
+// Shmat
+// Shmctl
+// Shmdt
+// Shmget
+// Shm_open
+// Shm_unlink
+// Sem_open
+// Sem_close
+// Sem_unlink
+// Sem_wait
+// Sem_trywait
+// Sem_post
+// Sem_getvalue
+// Sem_init
+// Sem_destroy
+// Open_extended
+// Umask_extended
+// Stat_extended
+// Lstat_extended
+// Fstat_extended
+// Chmod_extended
+// Fchmod_extended
+// Access_extended
+// Settid
+// Gettid
+// Setsgroups
+// Getsgroups
+// Setwgroups
+// Getwgroups
+// Mkfifo_extended
+// Mkdir_extended
+// Identitysvc
+// Shared_region_check_np
+// Shared_region_map_np
+// __pthread_mutex_destroy
+// __pthread_mutex_init
+// __pthread_mutex_lock
+// __pthread_mutex_trylock
+// __pthread_mutex_unlock
+// __pthread_cond_init
+// __pthread_cond_destroy
+// __pthread_cond_broadcast
+// __pthread_cond_signal
+// Setsid_with_pid
+// __pthread_cond_timedwait
+// Aio_fsync
+// Aio_return
+// Aio_suspend
+// Aio_cancel
+// Aio_error
+// Aio_read
+// Aio_write
+// Lio_listio
+// __pthread_cond_wait
+// Iopolicysys
+// Mlockall
+// Munlockall
+// __pthread_kill
+// __pthread_sigmask
+// __sigwait
+// __disable_threadsignal
+// __pthread_markcancel
+// __pthread_canceled
+// __semwait_signal
+// Proc_info
+// sendfile
+// Stat64_extended
+// Lstat64_extended
+// Fstat64_extended
+// __pthread_chdir
+// __pthread_fchdir
+// Audit
+// Auditon
+// Getauid
+// Setauid
+// Getaudit
+// Setaudit
+// Getaudit_addr
+// Setaudit_addr
+// Auditctl
+// Bsdthread_create
+// Bsdthread_terminate
+// Stack_snapshot
+// Bsdthread_register
+// Workq_open
+// Workq_ops
+// __mac_execve
+// __mac_syscall
+// __mac_get_file
+// __mac_set_file
+// __mac_get_link
+// __mac_set_link
+// __mac_get_proc
+// __mac_set_proc
+// __mac_get_fd
+// __mac_set_fd
+// __mac_get_pid
+// __mac_get_lcid
+// __mac_get_lctx
+// __mac_set_lctx
+// Setlcid
+// Read_nocancel
+// Write_nocancel
+// Open_nocancel
+// Close_nocancel
+// Wait4_nocancel
+// Recvmsg_nocancel
+// Sendmsg_nocancel
+// Recvfrom_nocancel
+// Accept_nocancel
+// Msync_nocancel
+// Fcntl_nocancel
+// Select_nocancel
+// Fsync_nocancel
+// Connect_nocancel
+// Sigsuspend_nocancel
+// Readv_nocancel
+// Writev_nocancel
+// Sendto_nocancel
+// Pread_nocancel
+// Pwrite_nocancel
+// Waitid_nocancel
+// Poll_nocancel
+// Msgsnd_nocancel
+// Msgrcv_nocancel
+// Sem_wait_nocancel
+// Aio_suspend_nocancel
+// __sigwait_nocancel
+// __semwait_signal_nocancel
+// __mac_mount
+// __mac_get_mount
+// __mac_getfsstat
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_386.go
new file mode 100644
index 0000000000..3195c8bf5c
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_386.go
@@ -0,0 +1,79 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build 386,darwin
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+func Getpagesize() int { return 4096 }
+
+func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = int32(nsec / 1e9)
+ ts.Nsec = int32(nsec % 1e9)
+ return
+}
+
+func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Usec = int32(nsec % 1e9 / 1e3)
+ tv.Sec = int32(nsec / 1e9)
+ return
+}
+
+//sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
+func Gettimeofday(tv *Timeval) (err error) {
+ // The tv passed to gettimeofday must be non-nil
+ // but is otherwise unused. The answers come back
+ // in the two registers.
+ sec, usec, err := gettimeofday(tv)
+ tv.Sec = int32(sec)
+ tv.Usec = int32(usec)
+ return err
+}
+
+func SetKevent(k *Kevent_t, fd, mode, flags int) {
+ k.Ident = uint32(fd)
+ k.Filter = int16(mode)
+ k.Flags = uint16(flags)
+}
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint32(length)
+}
+
+func (msghdr *Msghdr) SetControllen(length int) {
+ msghdr.Controllen = uint32(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint32(length)
+}
+
+func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
+ var length = uint64(count)
+
+ _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0)
+
+ written = int(length)
+
+ if e1 != 0 {
+ err = e1
+ }
+ return
+}
+
+func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
+
+// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
+// of darwin/386 the syscall is called sysctl instead of __sysctl.
+const SYS___SYSCTL = SYS_SYSCTL
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_amd64.go
new file mode 100644
index 0000000000..7adb98ded5
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_amd64.go
@@ -0,0 +1,81 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build amd64,darwin
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
+
+func Getpagesize() int { return 4096 }
+
+func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = nsec / 1e9
+ ts.Nsec = nsec % 1e9
+ return
+}
+
+func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Usec = int32(nsec % 1e9 / 1e3)
+ tv.Sec = int64(nsec / 1e9)
+ return
+}
+
+//sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
+func Gettimeofday(tv *Timeval) (err error) {
+ // The tv passed to gettimeofday must be non-nil
+ // but is otherwise unused. The answers come back
+ // in the two registers.
+ sec, usec, err := gettimeofday(tv)
+ tv.Sec = sec
+ tv.Usec = usec
+ return err
+}
+
+func SetKevent(k *Kevent_t, fd, mode, flags int) {
+ k.Ident = uint64(fd)
+ k.Filter = int16(mode)
+ k.Flags = uint16(flags)
+}
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint64(length)
+}
+
+func (msghdr *Msghdr) SetControllen(length int) {
+ msghdr.Controllen = uint32(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint32(length)
+}
+
+func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
+ var length = uint64(count)
+
+ _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0)
+
+ written = int(length)
+
+ if e1 != 0 {
+ err = e1
+ }
+ return
+}
+
+func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
+
+// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
+// of darwin/amd64 the syscall is called sysctl instead of __sysctl.
+const SYS___SYSCTL = SYS_SYSCTL
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_arm.go
new file mode 100644
index 0000000000..e47ffd7396
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_arm.go
@@ -0,0 +1,73 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+func Getpagesize() int { return 4096 }
+
+func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = int32(nsec / 1e9)
+ ts.Nsec = int32(nsec % 1e9)
+ return
+}
+
+func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Usec = int32(nsec % 1e9 / 1e3)
+ tv.Sec = int32(nsec / 1e9)
+ return
+}
+
+//sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
+func Gettimeofday(tv *Timeval) (err error) {
+ // The tv passed to gettimeofday must be non-nil
+ // but is otherwise unused. The answers come back
+ // in the two registers.
+ sec, usec, err := gettimeofday(tv)
+ tv.Sec = int32(sec)
+ tv.Usec = int32(usec)
+ return err
+}
+
+func SetKevent(k *Kevent_t, fd, mode, flags int) {
+ k.Ident = uint32(fd)
+ k.Filter = int16(mode)
+ k.Flags = uint16(flags)
+}
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint32(length)
+}
+
+func (msghdr *Msghdr) SetControllen(length int) {
+ msghdr.Controllen = uint32(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint32(length)
+}
+
+func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
+ var length = uint64(count)
+
+ _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0)
+
+ written = int(length)
+
+ if e1 != 0 {
+ err = e1
+ }
+ return
+}
+
+func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_arm64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_arm64.go
new file mode 100644
index 0000000000..2560a95998
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_arm64.go
@@ -0,0 +1,79 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build arm64,darwin
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+func Getpagesize() int { return 16384 }
+
+func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = nsec / 1e9
+ ts.Nsec = nsec % 1e9
+ return
+}
+
+func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Usec = int32(nsec % 1e9 / 1e3)
+ tv.Sec = int64(nsec / 1e9)
+ return
+}
+
+//sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
+func Gettimeofday(tv *Timeval) (err error) {
+ // The tv passed to gettimeofday must be non-nil
+ // but is otherwise unused. The answers come back
+ // in the two registers.
+ sec, usec, err := gettimeofday(tv)
+ tv.Sec = sec
+ tv.Usec = usec
+ return err
+}
+
+func SetKevent(k *Kevent_t, fd, mode, flags int) {
+ k.Ident = uint64(fd)
+ k.Filter = int16(mode)
+ k.Flags = uint16(flags)
+}
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint64(length)
+}
+
+func (msghdr *Msghdr) SetControllen(length int) {
+ msghdr.Controllen = uint32(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint32(length)
+}
+
+func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
+ var length = uint64(count)
+
+ _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0)
+
+ written = int(length)
+
+ if e1 != 0 {
+ err = e1
+ }
+ return
+}
+
+func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
+
+// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
+// of darwin/arm64 the syscall is called sysctl instead of __sysctl.
+const SYS___SYSCTL = SYS_SYSCTL
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly.go
new file mode 100644
index 0000000000..fbbe0dce25
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly.go
@@ -0,0 +1,411 @@
+// Copyright 2009,2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// FreeBSD system calls.
+// This file is compiled as ordinary Go code,
+// but it is also input to mksyscall,
+// which parses the //sys lines and generates system call stubs.
+// Note that sometimes we use a lowercase //sys name and wrap
+// it in our own nicer implementation, either here or in
+// syscall_bsd.go or syscall_unix.go.
+
+package unix
+
+import "unsafe"
+
+type SockaddrDatalink struct {
+ Len uint8
+ Family uint8
+ Index uint16
+ Type uint8
+ Nlen uint8
+ Alen uint8
+ Slen uint8
+ Data [12]int8
+ Rcf uint16
+ Route [16]uint16
+ raw RawSockaddrDatalink
+}
+
+// Translate "kern.hostname" to []_C_int{0,1,2,3}.
+func nametomib(name string) (mib []_C_int, err error) {
+ const siz = unsafe.Sizeof(mib[0])
+
+ // NOTE(rsc): It seems strange to set the buffer to have
+ // size CTL_MAXNAME+2 but use only CTL_MAXNAME
+ // as the size. I don't know why the +2 is here, but the
+ // kernel uses +2 for its own implementation of this function.
+ // I am scared that if we don't include the +2 here, the kernel
+ // will silently write 2 words farther than we specify
+ // and we'll get memory corruption.
+ var buf [CTL_MAXNAME + 2]_C_int
+ n := uintptr(CTL_MAXNAME) * siz
+
+ p := (*byte)(unsafe.Pointer(&buf[0]))
+ bytes, err := ByteSliceFromString(name)
+ if err != nil {
+ return nil, err
+ }
+
+ // Magic sysctl: "setting" 0.3 to a string name
+ // lets you read back the array of integers form.
+ if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
+ return nil, err
+ }
+ return buf[0 : n/siz], nil
+}
+
+// ParseDirent parses up to max directory entries in buf,
+// appending the names to names. It returns the number
+// bytes consumed from buf, the number of entries added
+// to names, and the new names slice.
+func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
+ origlen := len(buf)
+ for max != 0 && len(buf) > 0 {
+ dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
+ reclen := int(16+dirent.Namlen+1+7) & ^7
+ buf = buf[reclen:]
+ if dirent.Fileno == 0 { // File absent in directory.
+ continue
+ }
+ bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
+ var name = string(bytes[0:dirent.Namlen])
+ if name == "." || name == ".." { // Useless names
+ continue
+ }
+ max--
+ count++
+ names = append(names, name)
+ }
+ return origlen - len(buf), count, names
+}
+
+//sysnb pipe() (r int, w int, err error)
+
+func Pipe(p []int) (err error) {
+ if len(p) != 2 {
+ return EINVAL
+ }
+ p[0], p[1], err = pipe()
+ return
+}
+
+//sys extpread(fd int, p []byte, flags int, offset int64) (n int, err error)
+func Pread(fd int, p []byte, offset int64) (n int, err error) {
+ return extpread(fd, p, 0, offset)
+}
+
+//sys extpwrite(fd int, p []byte, flags int, offset int64) (n int, err error)
+func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
+ return extpwrite(fd, p, 0, offset)
+}
+
+func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
+ var _p0 unsafe.Pointer
+ var bufsize uintptr
+ if len(buf) > 0 {
+ _p0 = unsafe.Pointer(&buf[0])
+ bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
+ }
+ r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = e1
+ }
+ return
+}
+
+/*
+ * Exposed directly
+ */
+//sys Access(path string, mode uint32) (err error)
+//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
+//sys Chdir(path string) (err error)
+//sys Chflags(path string, flags int) (err error)
+//sys Chmod(path string, mode uint32) (err error)
+//sys Chown(path string, uid int, gid int) (err error)
+//sys Chroot(path string) (err error)
+//sys Close(fd int) (err error)
+//sys Dup(fd int) (nfd int, err error)
+//sys Dup2(from int, to int) (err error)
+//sys Exit(code int)
+//sys Fchdir(fd int) (err error)
+//sys Fchflags(fd int, flags int) (err error)
+//sys Fchmod(fd int, mode uint32) (err error)
+//sys Fchown(fd int, uid int, gid int) (err error)
+//sys Flock(fd int, how int) (err error)
+//sys Fpathconf(fd int, name int) (val int, err error)
+//sys Fstat(fd int, stat *Stat_t) (err error)
+//sys Fstatfs(fd int, stat *Statfs_t) (err error)
+//sys Fsync(fd int) (err error)
+//sys Ftruncate(fd int, length int64) (err error)
+//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error)
+//sys Getdtablesize() (size int)
+//sysnb Getegid() (egid int)
+//sysnb Geteuid() (uid int)
+//sysnb Getgid() (gid int)
+//sysnb Getpgid(pid int) (pgid int, err error)
+//sysnb Getpgrp() (pgrp int)
+//sysnb Getpid() (pid int)
+//sysnb Getppid() (ppid int)
+//sys Getpriority(which int, who int) (prio int, err error)
+//sysnb Getrlimit(which int, lim *Rlimit) (err error)
+//sysnb Getrusage(who int, rusage *Rusage) (err error)
+//sysnb Getsid(pid int) (sid int, err error)
+//sysnb Gettimeofday(tv *Timeval) (err error)
+//sysnb Getuid() (uid int)
+//sys Issetugid() (tainted bool)
+//sys Kill(pid int, signum syscall.Signal) (err error)
+//sys Kqueue() (fd int, err error)
+//sys Lchown(path string, uid int, gid int) (err error)
+//sys Link(path string, link string) (err error)
+//sys Listen(s int, backlog int) (err error)
+//sys Lstat(path string, stat *Stat_t) (err error)
+//sys Mkdir(path string, mode uint32) (err error)
+//sys Mkfifo(path string, mode uint32) (err error)
+//sys Mknod(path string, mode uint32, dev int) (err error)
+//sys Mlock(b []byte) (err error)
+//sys Mlockall(flags int) (err error)
+//sys Mprotect(b []byte, prot int) (err error)
+//sys Munlock(b []byte) (err error)
+//sys Munlockall() (err error)
+//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
+//sys Open(path string, mode int, perm uint32) (fd int, err error)
+//sys Pathconf(path string, name int) (val int, err error)
+//sys read(fd int, p []byte) (n int, err error)
+//sys Readlink(path string, buf []byte) (n int, err error)
+//sys Rename(from string, to string) (err error)
+//sys Revoke(path string) (err error)
+//sys Rmdir(path string) (err error)
+//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
+//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
+//sysnb Setegid(egid int) (err error)
+//sysnb Seteuid(euid int) (err error)
+//sysnb Setgid(gid int) (err error)
+//sys Setlogin(name string) (err error)
+//sysnb Setpgid(pid int, pgid int) (err error)
+//sys Setpriority(which int, who int, prio int) (err error)
+//sysnb Setregid(rgid int, egid int) (err error)
+//sysnb Setreuid(ruid int, euid int) (err error)
+//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
+//sysnb Setresuid(ruid int, euid int, suid int) (err error)
+//sysnb Setrlimit(which int, lim *Rlimit) (err error)
+//sysnb Setsid() (pid int, err error)
+//sysnb Settimeofday(tp *Timeval) (err error)
+//sysnb Setuid(uid int) (err error)
+//sys Stat(path string, stat *Stat_t) (err error)
+//sys Statfs(path string, stat *Statfs_t) (err error)
+//sys Symlink(path string, link string) (err error)
+//sys Sync() (err error)
+//sys Truncate(path string, length int64) (err error)
+//sys Umask(newmask int) (oldmask int)
+//sys Undelete(path string) (err error)
+//sys Unlink(path string) (err error)
+//sys Unmount(path string, flags int) (err error)
+//sys write(fd int, p []byte) (n int, err error)
+//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
+//sys munmap(addr uintptr, length uintptr) (err error)
+//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
+//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
+
+/*
+ * Unimplemented
+ * TODO(jsing): Update this list for DragonFly.
+ */
+// Profil
+// Sigaction
+// Sigprocmask
+// Getlogin
+// Sigpending
+// Sigaltstack
+// Ioctl
+// Reboot
+// Execve
+// Vfork
+// Sbrk
+// Sstk
+// Ovadvise
+// Mincore
+// Setitimer
+// Swapon
+// Select
+// Sigsuspend
+// Readv
+// Writev
+// Nfssvc
+// Getfh
+// Quotactl
+// Mount
+// Csops
+// Waitid
+// Add_profil
+// Kdebug_trace
+// Sigreturn
+// Mmap
+// Atsocket
+// Kqueue_from_portset_np
+// Kqueue_portset
+// Getattrlist
+// Setattrlist
+// Getdirentriesattr
+// Searchfs
+// Delete
+// Copyfile
+// Poll
+// Watchevent
+// Waitevent
+// Modwatch
+// Getxattr
+// Fgetxattr
+// Setxattr
+// Fsetxattr
+// Removexattr
+// Fremovexattr
+// Listxattr
+// Flistxattr
+// Fsctl
+// Initgroups
+// Posix_spawn
+// Nfsclnt
+// Fhopen
+// Minherit
+// Semsys
+// Msgsys
+// Shmsys
+// Semctl
+// Semget
+// Semop
+// Msgctl
+// Msgget
+// Msgsnd
+// Msgrcv
+// Shmat
+// Shmctl
+// Shmdt
+// Shmget
+// Shm_open
+// Shm_unlink
+// Sem_open
+// Sem_close
+// Sem_unlink
+// Sem_wait
+// Sem_trywait
+// Sem_post
+// Sem_getvalue
+// Sem_init
+// Sem_destroy
+// Open_extended
+// Umask_extended
+// Stat_extended
+// Lstat_extended
+// Fstat_extended
+// Chmod_extended
+// Fchmod_extended
+// Access_extended
+// Settid
+// Gettid
+// Setsgroups
+// Getsgroups
+// Setwgroups
+// Getwgroups
+// Mkfifo_extended
+// Mkdir_extended
+// Identitysvc
+// Shared_region_check_np
+// Shared_region_map_np
+// __pthread_mutex_destroy
+// __pthread_mutex_init
+// __pthread_mutex_lock
+// __pthread_mutex_trylock
+// __pthread_mutex_unlock
+// __pthread_cond_init
+// __pthread_cond_destroy
+// __pthread_cond_broadcast
+// __pthread_cond_signal
+// Setsid_with_pid
+// __pthread_cond_timedwait
+// Aio_fsync
+// Aio_return
+// Aio_suspend
+// Aio_cancel
+// Aio_error
+// Aio_read
+// Aio_write
+// Lio_listio
+// __pthread_cond_wait
+// Iopolicysys
+// __pthread_kill
+// __pthread_sigmask
+// __sigwait
+// __disable_threadsignal
+// __pthread_markcancel
+// __pthread_canceled
+// __semwait_signal
+// Proc_info
+// Stat64_extended
+// Lstat64_extended
+// Fstat64_extended
+// __pthread_chdir
+// __pthread_fchdir
+// Audit
+// Auditon
+// Getauid
+// Setauid
+// Getaudit
+// Setaudit
+// Getaudit_addr
+// Setaudit_addr
+// Auditctl
+// Bsdthread_create
+// Bsdthread_terminate
+// Stack_snapshot
+// Bsdthread_register
+// Workq_open
+// Workq_ops
+// __mac_execve
+// __mac_syscall
+// __mac_get_file
+// __mac_set_file
+// __mac_get_link
+// __mac_set_link
+// __mac_get_proc
+// __mac_set_proc
+// __mac_get_fd
+// __mac_set_fd
+// __mac_get_pid
+// __mac_get_lcid
+// __mac_get_lctx
+// __mac_set_lctx
+// Setlcid
+// Read_nocancel
+// Write_nocancel
+// Open_nocancel
+// Close_nocancel
+// Wait4_nocancel
+// Recvmsg_nocancel
+// Sendmsg_nocancel
+// Recvfrom_nocancel
+// Accept_nocancel
+// Msync_nocancel
+// Fcntl_nocancel
+// Select_nocancel
+// Fsync_nocancel
+// Connect_nocancel
+// Sigsuspend_nocancel
+// Readv_nocancel
+// Writev_nocancel
+// Sendto_nocancel
+// Pread_nocancel
+// Pwrite_nocancel
+// Waitid_nocancel
+// Poll_nocancel
+// Msgsnd_nocancel
+// Msgrcv_nocancel
+// Sem_wait_nocancel
+// Aio_suspend_nocancel
+// __sigwait_nocancel
+// __semwait_signal_nocancel
+// __mac_mount
+// __mac_get_mount
+// __mac_getfsstat
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly_386.go
new file mode 100644
index 0000000000..41c2e69782
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly_386.go
@@ -0,0 +1,63 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build 386,dragonfly
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+func Getpagesize() int { return 4096 }
+
+func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = int32(nsec / 1e9)
+ ts.Nsec = int32(nsec % 1e9)
+ return
+}
+
+func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Usec = int32(nsec % 1e9 / 1e3)
+ tv.Sec = int32(nsec / 1e9)
+ return
+}
+
+func SetKevent(k *Kevent_t, fd, mode, flags int) {
+ k.Ident = uint32(fd)
+ k.Filter = int16(mode)
+ k.Flags = uint16(flags)
+}
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint32(length)
+}
+
+func (msghdr *Msghdr) SetControllen(length int) {
+ msghdr.Controllen = uint32(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint32(length)
+}
+
+func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
+ var writtenOut uint64 = 0
+ _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
+
+ written = int(writtenOut)
+
+ if e1 != 0 {
+ err = e1
+ }
+ return
+}
+
+func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly_amd64.go
new file mode 100644
index 0000000000..2ed92590e2
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly_amd64.go
@@ -0,0 +1,63 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build amd64,dragonfly
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+func Getpagesize() int { return 4096 }
+
+func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = nsec / 1e9
+ ts.Nsec = nsec % 1e9
+ return
+}
+
+func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Usec = nsec % 1e9 / 1e3
+ tv.Sec = int64(nsec / 1e9)
+ return
+}
+
+func SetKevent(k *Kevent_t, fd, mode, flags int) {
+ k.Ident = uint64(fd)
+ k.Filter = int16(mode)
+ k.Flags = uint16(flags)
+}
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint64(length)
+}
+
+func (msghdr *Msghdr) SetControllen(length int) {
+ msghdr.Controllen = uint32(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint32(length)
+}
+
+func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
+ var writtenOut uint64 = 0
+ _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0)
+
+ written = int(writtenOut)
+
+ if e1 != 0 {
+ err = e1
+ }
+ return
+}
+
+func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd.go
new file mode 100644
index 0000000000..ec56ed608a
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd.go
@@ -0,0 +1,682 @@
+// Copyright 2009,2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// FreeBSD system calls.
+// This file is compiled as ordinary Go code,
+// but it is also input to mksyscall,
+// which parses the //sys lines and generates system call stubs.
+// Note that sometimes we use a lowercase //sys name and wrap
+// it in our own nicer implementation, either here or in
+// syscall_bsd.go or syscall_unix.go.
+
+package unix
+
+import "unsafe"
+
+type SockaddrDatalink struct {
+ Len uint8
+ Family uint8
+ Index uint16
+ Type uint8
+ Nlen uint8
+ Alen uint8
+ Slen uint8
+ Data [46]int8
+ raw RawSockaddrDatalink
+}
+
+// Translate "kern.hostname" to []_C_int{0,1,2,3}.
+func nametomib(name string) (mib []_C_int, err error) {
+ const siz = unsafe.Sizeof(mib[0])
+
+ // NOTE(rsc): It seems strange to set the buffer to have
+ // size CTL_MAXNAME+2 but use only CTL_MAXNAME
+ // as the size. I don't know why the +2 is here, but the
+ // kernel uses +2 for its own implementation of this function.
+ // I am scared that if we don't include the +2 here, the kernel
+ // will silently write 2 words farther than we specify
+ // and we'll get memory corruption.
+ var buf [CTL_MAXNAME + 2]_C_int
+ n := uintptr(CTL_MAXNAME) * siz
+
+ p := (*byte)(unsafe.Pointer(&buf[0]))
+ bytes, err := ByteSliceFromString(name)
+ if err != nil {
+ return nil, err
+ }
+
+ // Magic sysctl: "setting" 0.3 to a string name
+ // lets you read back the array of integers form.
+ if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
+ return nil, err
+ }
+ return buf[0 : n/siz], nil
+}
+
+// ParseDirent parses up to max directory entries in buf,
+// appending the names to names. It returns the number
+// bytes consumed from buf, the number of entries added
+// to names, and the new names slice.
+func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
+ origlen := len(buf)
+ for max != 0 && len(buf) > 0 {
+ dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
+ if dirent.Reclen == 0 {
+ buf = nil
+ break
+ }
+ buf = buf[dirent.Reclen:]
+ if dirent.Fileno == 0 { // File absent in directory.
+ continue
+ }
+ bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
+ var name = string(bytes[0:dirent.Namlen])
+ if name == "." || name == ".." { // Useless names
+ continue
+ }
+ max--
+ count++
+ names = append(names, name)
+ }
+ return origlen - len(buf), count, names
+}
+
+//sysnb pipe() (r int, w int, err error)
+
+func Pipe(p []int) (err error) {
+ if len(p) != 2 {
+ return EINVAL
+ }
+ p[0], p[1], err = pipe()
+ return
+}
+
+func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) {
+ var value IPMreqn
+ vallen := _Socklen(SizeofIPMreqn)
+ errno := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
+ return &value, errno
+}
+
+func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) {
+ return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq))
+}
+
+func Accept4(fd, flags int) (nfd int, sa Sockaddr, err error) {
+ var rsa RawSockaddrAny
+ var len _Socklen = SizeofSockaddrAny
+ nfd, err = accept4(fd, &rsa, &len, flags)
+ if err != nil {
+ return
+ }
+ if len > SizeofSockaddrAny {
+ panic("RawSockaddrAny too small")
+ }
+ sa, err = anyToSockaddr(&rsa)
+ if err != nil {
+ Close(nfd)
+ nfd = 0
+ }
+ return
+}
+
+func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
+ var _p0 unsafe.Pointer
+ var bufsize uintptr
+ if len(buf) > 0 {
+ _p0 = unsafe.Pointer(&buf[0])
+ bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
+ }
+ r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = e1
+ }
+ return
+}
+
+// Derive extattr namespace and attribute name
+
+func xattrnamespace(fullattr string) (ns int, attr string, err error) {
+ s := -1
+ for idx, val := range fullattr {
+ if val == '.' {
+ s = idx
+ break
+ }
+ }
+
+ if s == -1 {
+ return -1, "", ENOATTR
+ }
+
+ namespace := fullattr[0:s]
+ attr = fullattr[s+1:]
+
+ switch namespace {
+ case "user":
+ return EXTATTR_NAMESPACE_USER, attr, nil
+ case "system":
+ return EXTATTR_NAMESPACE_SYSTEM, attr, nil
+ default:
+ return -1, "", ENOATTR
+ }
+}
+
+func initxattrdest(dest []byte, idx int) (d unsafe.Pointer) {
+ if len(dest) > idx {
+ return unsafe.Pointer(&dest[idx])
+ } else {
+ return unsafe.Pointer(_zero)
+ }
+}
+
+// FreeBSD implements its own syscalls to handle extended attributes
+
+func Getxattr(file string, attr string, dest []byte) (sz int, err error) {
+ d := initxattrdest(dest, 0)
+ destsize := len(dest)
+
+ nsid, a, err := xattrnamespace(attr)
+ if err != nil {
+ return -1, err
+ }
+
+ return ExtattrGetFile(file, nsid, a, uintptr(d), destsize)
+}
+
+func Fgetxattr(fd int, attr string, dest []byte) (sz int, err error) {
+ d := initxattrdest(dest, 0)
+ destsize := len(dest)
+
+ nsid, a, err := xattrnamespace(attr)
+ if err != nil {
+ return -1, err
+ }
+
+ return ExtattrGetFd(fd, nsid, a, uintptr(d), destsize)
+}
+
+func Lgetxattr(link string, attr string, dest []byte) (sz int, err error) {
+ d := initxattrdest(dest, 0)
+ destsize := len(dest)
+
+ nsid, a, err := xattrnamespace(attr)
+ if err != nil {
+ return -1, err
+ }
+
+ return ExtattrGetLink(link, nsid, a, uintptr(d), destsize)
+}
+
+// flags are unused on FreeBSD
+
+func Fsetxattr(fd int, attr string, data []byte, flags int) (err error) {
+ d := unsafe.Pointer(&data[0])
+ datasiz := len(data)
+
+ nsid, a, err := xattrnamespace(attr)
+ if err != nil {
+ return
+ }
+
+ _, err = ExtattrSetFd(fd, nsid, a, uintptr(d), datasiz)
+ return
+}
+
+func Setxattr(file string, attr string, data []byte, flags int) (err error) {
+ d := unsafe.Pointer(&data[0])
+ datasiz := len(data)
+
+ nsid, a, err := xattrnamespace(attr)
+ if err != nil {
+ return
+ }
+
+ _, err = ExtattrSetFile(file, nsid, a, uintptr(d), datasiz)
+ return
+}
+
+func Lsetxattr(link string, attr string, data []byte, flags int) (err error) {
+ d := unsafe.Pointer(&data[0])
+ datasiz := len(data)
+
+ nsid, a, err := xattrnamespace(attr)
+ if err != nil {
+ return
+ }
+
+ _, err = ExtattrSetLink(link, nsid, a, uintptr(d), datasiz)
+ return
+}
+
+func Removexattr(file string, attr string) (err error) {
+ nsid, a, err := xattrnamespace(attr)
+ if err != nil {
+ return
+ }
+
+ err = ExtattrDeleteFile(file, nsid, a)
+ return
+}
+
+func Fremovexattr(fd int, attr string) (err error) {
+ nsid, a, err := xattrnamespace(attr)
+ if err != nil {
+ return
+ }
+
+ err = ExtattrDeleteFd(fd, nsid, a)
+ return
+}
+
+func Lremovexattr(link string, attr string) (err error) {
+ nsid, a, err := xattrnamespace(attr)
+ if err != nil {
+ return
+ }
+
+ err = ExtattrDeleteLink(link, nsid, a)
+ return
+}
+
+func Listxattr(file string, dest []byte) (sz int, err error) {
+ d := initxattrdest(dest, 0)
+ destsiz := len(dest)
+
+ // FreeBSD won't allow you to list xattrs from multiple namespaces
+ s := 0
+ var e error
+ for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} {
+ stmp, e := ExtattrListFile(file, nsid, uintptr(d), destsiz)
+
+ /* Errors accessing system attrs are ignored so that
+ * we can implement the Linux-like behavior of omitting errors that
+ * we don't have read permissions on
+ *
+ * Linux will still error if we ask for user attributes on a file that
+ * we don't have read permissions on, so don't ignore those errors
+ */
+ if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER {
+ e = nil
+ continue
+ } else if e != nil {
+ return s, e
+ }
+
+ s += stmp
+ destsiz -= s
+ if destsiz < 0 {
+ destsiz = 0
+ }
+ d = initxattrdest(dest, s)
+ }
+
+ return s, e
+}
+
+func Flistxattr(fd int, dest []byte) (sz int, err error) {
+ d := initxattrdest(dest, 0)
+ destsiz := len(dest)
+
+ s := 0
+ var e error
+ for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} {
+ stmp, e := ExtattrListFd(fd, nsid, uintptr(d), destsiz)
+ if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER {
+ e = nil
+ continue
+ } else if e != nil {
+ return s, e
+ }
+
+ s += stmp
+ destsiz -= s
+ if destsiz < 0 {
+ destsiz = 0
+ }
+ d = initxattrdest(dest, s)
+ }
+
+ return s, e
+}
+
+func Llistxattr(link string, dest []byte) (sz int, err error) {
+ d := initxattrdest(dest, 0)
+ destsiz := len(dest)
+
+ s := 0
+ var e error
+ for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} {
+ stmp, e := ExtattrListLink(link, nsid, uintptr(d), destsiz)
+ if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER {
+ e = nil
+ continue
+ } else if e != nil {
+ return s, e
+ }
+
+ s += stmp
+ destsiz -= s
+ if destsiz < 0 {
+ destsiz = 0
+ }
+ d = initxattrdest(dest, s)
+ }
+
+ return s, e
+}
+
+/*
+ * Exposed directly
+ */
+//sys Access(path string, mode uint32) (err error)
+//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
+//sys Chdir(path string) (err error)
+//sys Chflags(path string, flags int) (err error)
+//sys Chmod(path string, mode uint32) (err error)
+//sys Chown(path string, uid int, gid int) (err error)
+//sys Chroot(path string) (err error)
+//sys Close(fd int) (err error)
+//sys Dup(fd int) (nfd int, err error)
+//sys Dup2(from int, to int) (err error)
+//sys Exit(code int)
+//sys ExtattrGetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
+//sys ExtattrSetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
+//sys ExtattrDeleteFd(fd int, attrnamespace int, attrname string) (err error)
+//sys ExtattrListFd(fd int, attrnamespace int, data uintptr, nbytes int) (ret int, err error)
+//sys ExtattrGetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
+//sys ExtattrSetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
+//sys ExtattrDeleteFile(file string, attrnamespace int, attrname string) (err error)
+//sys ExtattrListFile(file string, attrnamespace int, data uintptr, nbytes int) (ret int, err error)
+//sys ExtattrGetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
+//sys ExtattrSetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
+//sys ExtattrDeleteLink(link string, attrnamespace int, attrname string) (err error)
+//sys ExtattrListLink(link string, attrnamespace int, data uintptr, nbytes int) (ret int, err error)
+//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_POSIX_FADVISE
+//sys Fchdir(fd int) (err error)
+//sys Fchflags(fd int, flags int) (err error)
+//sys Fchmod(fd int, mode uint32) (err error)
+//sys Fchown(fd int, uid int, gid int) (err error)
+//sys Flock(fd int, how int) (err error)
+//sys Fpathconf(fd int, name int) (val int, err error)
+//sys Fstat(fd int, stat *Stat_t) (err error)
+//sys Fstatfs(fd int, stat *Statfs_t) (err error)
+//sys Fsync(fd int) (err error)
+//sys Ftruncate(fd int, length int64) (err error)
+//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error)
+//sys Getdtablesize() (size int)
+//sysnb Getegid() (egid int)
+//sysnb Geteuid() (uid int)
+//sysnb Getgid() (gid int)
+//sysnb Getpgid(pid int) (pgid int, err error)
+//sysnb Getpgrp() (pgrp int)
+//sysnb Getpid() (pid int)
+//sysnb Getppid() (ppid int)
+//sys Getpriority(which int, who int) (prio int, err error)
+//sysnb Getrlimit(which int, lim *Rlimit) (err error)
+//sysnb Getrusage(who int, rusage *Rusage) (err error)
+//sysnb Getsid(pid int) (sid int, err error)
+//sysnb Gettimeofday(tv *Timeval) (err error)
+//sysnb Getuid() (uid int)
+//sys Issetugid() (tainted bool)
+//sys Kill(pid int, signum syscall.Signal) (err error)
+//sys Kqueue() (fd int, err error)
+//sys Lchown(path string, uid int, gid int) (err error)
+//sys Link(path string, link string) (err error)
+//sys Listen(s int, backlog int) (err error)
+//sys Lstat(path string, stat *Stat_t) (err error)
+//sys Mkdir(path string, mode uint32) (err error)
+//sys Mkfifo(path string, mode uint32) (err error)
+//sys Mknod(path string, mode uint32, dev int) (err error)
+//sys Mlock(b []byte) (err error)
+//sys Mlockall(flags int) (err error)
+//sys Mprotect(b []byte, prot int) (err error)
+//sys Munlock(b []byte) (err error)
+//sys Munlockall() (err error)
+//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
+//sys Open(path string, mode int, perm uint32) (fd int, err error)
+//sys Pathconf(path string, name int) (val int, err error)
+//sys Pread(fd int, p []byte, offset int64) (n int, err error)
+//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
+//sys read(fd int, p []byte) (n int, err error)
+//sys Readlink(path string, buf []byte) (n int, err error)
+//sys Rename(from string, to string) (err error)
+//sys Revoke(path string) (err error)
+//sys Rmdir(path string) (err error)
+//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
+//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
+//sysnb Setegid(egid int) (err error)
+//sysnb Seteuid(euid int) (err error)
+//sysnb Setgid(gid int) (err error)
+//sys Setlogin(name string) (err error)
+//sysnb Setpgid(pid int, pgid int) (err error)
+//sys Setpriority(which int, who int, prio int) (err error)
+//sysnb Setregid(rgid int, egid int) (err error)
+//sysnb Setreuid(ruid int, euid int) (err error)
+//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
+//sysnb Setresuid(ruid int, euid int, suid int) (err error)
+//sysnb Setrlimit(which int, lim *Rlimit) (err error)
+//sysnb Setsid() (pid int, err error)
+//sysnb Settimeofday(tp *Timeval) (err error)
+//sysnb Setuid(uid int) (err error)
+//sys Stat(path string, stat *Stat_t) (err error)
+//sys Statfs(path string, stat *Statfs_t) (err error)
+//sys Symlink(path string, link string) (err error)
+//sys Sync() (err error)
+//sys Truncate(path string, length int64) (err error)
+//sys Umask(newmask int) (oldmask int)
+//sys Undelete(path string) (err error)
+//sys Unlink(path string) (err error)
+//sys Unmount(path string, flags int) (err error)
+//sys write(fd int, p []byte) (n int, err error)
+//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
+//sys munmap(addr uintptr, length uintptr) (err error)
+//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
+//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
+//sys accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error)
+
+/*
+ * Unimplemented
+ */
+// Profil
+// Sigaction
+// Sigprocmask
+// Getlogin
+// Sigpending
+// Sigaltstack
+// Ioctl
+// Reboot
+// Execve
+// Vfork
+// Sbrk
+// Sstk
+// Ovadvise
+// Mincore
+// Setitimer
+// Swapon
+// Select
+// Sigsuspend
+// Readv
+// Writev
+// Nfssvc
+// Getfh
+// Quotactl
+// Mount
+// Csops
+// Waitid
+// Add_profil
+// Kdebug_trace
+// Sigreturn
+// Mmap
+// Mlock
+// Munlock
+// Atsocket
+// Kqueue_from_portset_np
+// Kqueue_portset
+// Getattrlist
+// Setattrlist
+// Getdirentriesattr
+// Searchfs
+// Delete
+// Copyfile
+// Poll
+// Watchevent
+// Waitevent
+// Modwatch
+// Getxattr
+// Fgetxattr
+// Setxattr
+// Fsetxattr
+// Removexattr
+// Fremovexattr
+// Listxattr
+// Flistxattr
+// Fsctl
+// Initgroups
+// Posix_spawn
+// Nfsclnt
+// Fhopen
+// Minherit
+// Semsys
+// Msgsys
+// Shmsys
+// Semctl
+// Semget
+// Semop
+// Msgctl
+// Msgget
+// Msgsnd
+// Msgrcv
+// Shmat
+// Shmctl
+// Shmdt
+// Shmget
+// Shm_open
+// Shm_unlink
+// Sem_open
+// Sem_close
+// Sem_unlink
+// Sem_wait
+// Sem_trywait
+// Sem_post
+// Sem_getvalue
+// Sem_init
+// Sem_destroy
+// Open_extended
+// Umask_extended
+// Stat_extended
+// Lstat_extended
+// Fstat_extended
+// Chmod_extended
+// Fchmod_extended
+// Access_extended
+// Settid
+// Gettid
+// Setsgroups
+// Getsgroups
+// Setwgroups
+// Getwgroups
+// Mkfifo_extended
+// Mkdir_extended
+// Identitysvc
+// Shared_region_check_np
+// Shared_region_map_np
+// __pthread_mutex_destroy
+// __pthread_mutex_init
+// __pthread_mutex_lock
+// __pthread_mutex_trylock
+// __pthread_mutex_unlock
+// __pthread_cond_init
+// __pthread_cond_destroy
+// __pthread_cond_broadcast
+// __pthread_cond_signal
+// Setsid_with_pid
+// __pthread_cond_timedwait
+// Aio_fsync
+// Aio_return
+// Aio_suspend
+// Aio_cancel
+// Aio_error
+// Aio_read
+// Aio_write
+// Lio_listio
+// __pthread_cond_wait
+// Iopolicysys
+// Mlockall
+// Munlockall
+// __pthread_kill
+// __pthread_sigmask
+// __sigwait
+// __disable_threadsignal
+// __pthread_markcancel
+// __pthread_canceled
+// __semwait_signal
+// Proc_info
+// Stat64_extended
+// Lstat64_extended
+// Fstat64_extended
+// __pthread_chdir
+// __pthread_fchdir
+// Audit
+// Auditon
+// Getauid
+// Setauid
+// Getaudit
+// Setaudit
+// Getaudit_addr
+// Setaudit_addr
+// Auditctl
+// Bsdthread_create
+// Bsdthread_terminate
+// Stack_snapshot
+// Bsdthread_register
+// Workq_open
+// Workq_ops
+// __mac_execve
+// __mac_syscall
+// __mac_get_file
+// __mac_set_file
+// __mac_get_link
+// __mac_set_link
+// __mac_get_proc
+// __mac_set_proc
+// __mac_get_fd
+// __mac_set_fd
+// __mac_get_pid
+// __mac_get_lcid
+// __mac_get_lctx
+// __mac_set_lctx
+// Setlcid
+// Read_nocancel
+// Write_nocancel
+// Open_nocancel
+// Close_nocancel
+// Wait4_nocancel
+// Recvmsg_nocancel
+// Sendmsg_nocancel
+// Recvfrom_nocancel
+// Accept_nocancel
+// Msync_nocancel
+// Fcntl_nocancel
+// Select_nocancel
+// Fsync_nocancel
+// Connect_nocancel
+// Sigsuspend_nocancel
+// Readv_nocancel
+// Writev_nocancel
+// Sendto_nocancel
+// Pread_nocancel
+// Pwrite_nocancel
+// Waitid_nocancel
+// Poll_nocancel
+// Msgsnd_nocancel
+// Msgrcv_nocancel
+// Sem_wait_nocancel
+// Aio_suspend_nocancel
+// __sigwait_nocancel
+// __semwait_signal_nocancel
+// __mac_mount
+// __mac_get_mount
+// __mac_getfsstat
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_386.go
new file mode 100644
index 0000000000..6255d40ff8
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_386.go
@@ -0,0 +1,63 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build 386,freebsd
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+func Getpagesize() int { return 4096 }
+
+func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = int32(nsec / 1e9)
+ ts.Nsec = int32(nsec % 1e9)
+ return
+}
+
+func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Usec = int32(nsec % 1e9 / 1e3)
+ tv.Sec = int32(nsec / 1e9)
+ return
+}
+
+func SetKevent(k *Kevent_t, fd, mode, flags int) {
+ k.Ident = uint32(fd)
+ k.Filter = int16(mode)
+ k.Flags = uint16(flags)
+}
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint32(length)
+}
+
+func (msghdr *Msghdr) SetControllen(length int) {
+ msghdr.Controllen = uint32(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint32(length)
+}
+
+func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
+ var writtenOut uint64 = 0
+ _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
+
+ written = int(writtenOut)
+
+ if e1 != 0 {
+ err = e1
+ }
+ return
+}
+
+func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_amd64.go
new file mode 100644
index 0000000000..8b395d596d
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_amd64.go
@@ -0,0 +1,63 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build amd64,freebsd
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+func Getpagesize() int { return 4096 }
+
+func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = nsec / 1e9
+ ts.Nsec = nsec % 1e9
+ return
+}
+
+func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Usec = nsec % 1e9 / 1e3
+ tv.Sec = int64(nsec / 1e9)
+ return
+}
+
+func SetKevent(k *Kevent_t, fd, mode, flags int) {
+ k.Ident = uint64(fd)
+ k.Filter = int16(mode)
+ k.Flags = uint16(flags)
+}
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint64(length)
+}
+
+func (msghdr *Msghdr) SetControllen(length int) {
+ msghdr.Controllen = uint32(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint32(length)
+}
+
+func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
+ var writtenOut uint64 = 0
+ _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0)
+
+ written = int(writtenOut)
+
+ if e1 != 0 {
+ err = e1
+ }
+ return
+}
+
+func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_arm.go
new file mode 100644
index 0000000000..4e72d46a81
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_arm.go
@@ -0,0 +1,63 @@
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build arm,freebsd
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+func Getpagesize() int { return 4096 }
+
+func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = nsec / 1e9
+ ts.Nsec = int32(nsec % 1e9)
+ return
+}
+
+func TimevalToNsec(tv Timeval) int64 { return tv.Sec*1e9 + int64(tv.Usec)*1e3 }
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Usec = int32(nsec % 1e9 / 1e3)
+ tv.Sec = nsec / 1e9
+ return
+}
+
+func SetKevent(k *Kevent_t, fd, mode, flags int) {
+ k.Ident = uint32(fd)
+ k.Filter = int16(mode)
+ k.Flags = uint16(flags)
+}
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint32(length)
+}
+
+func (msghdr *Msghdr) SetControllen(length int) {
+ msghdr.Controllen = uint32(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint32(length)
+}
+
+func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
+ var writtenOut uint64 = 0
+ _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
+
+ written = int(writtenOut)
+
+ if e1 != 0 {
+ err = e1
+ }
+ return
+}
+
+func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux.go
new file mode 100644
index 0000000000..d3ee5d2c2f
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux.go
@@ -0,0 +1,1086 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Linux system calls.
+// This file is compiled as ordinary Go code,
+// but it is also input to mksyscall,
+// which parses the //sys lines and generates system call stubs.
+// Note that sometimes we use a lowercase //sys name and
+// wrap it in our own nicer implementation.
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+/*
+ * Wrapped
+ */
+
+func Access(path string, mode uint32) (err error) {
+ return Faccessat(AT_FDCWD, path, mode, 0)
+}
+
+func Chmod(path string, mode uint32) (err error) {
+ return Fchmodat(AT_FDCWD, path, mode, 0)
+}
+
+func Chown(path string, uid int, gid int) (err error) {
+ return Fchownat(AT_FDCWD, path, uid, gid, 0)
+}
+
+func Creat(path string, mode uint32) (fd int, err error) {
+ return Open(path, O_CREAT|O_WRONLY|O_TRUNC, mode)
+}
+
+//sys linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error)
+
+func Link(oldpath string, newpath string) (err error) {
+ return linkat(AT_FDCWD, oldpath, AT_FDCWD, newpath, 0)
+}
+
+func Mkdir(path string, mode uint32) (err error) {
+ return Mkdirat(AT_FDCWD, path, mode)
+}
+
+func Mknod(path string, mode uint32, dev int) (err error) {
+ return Mknodat(AT_FDCWD, path, mode, dev)
+}
+
+func Open(path string, mode int, perm uint32) (fd int, err error) {
+ return openat(AT_FDCWD, path, mode|O_LARGEFILE, perm)
+}
+
+//sys openat(dirfd int, path string, flags int, mode uint32) (fd int, err error)
+
+func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) {
+ return openat(dirfd, path, flags|O_LARGEFILE, mode)
+}
+
+//sys readlinkat(dirfd int, path string, buf []byte) (n int, err error)
+
+func Readlink(path string, buf []byte) (n int, err error) {
+ return readlinkat(AT_FDCWD, path, buf)
+}
+
+func Rename(oldpath string, newpath string) (err error) {
+ return Renameat(AT_FDCWD, oldpath, AT_FDCWD, newpath)
+}
+
+func Rmdir(path string) error {
+ return unlinkat(AT_FDCWD, path, AT_REMOVEDIR)
+}
+
+//sys symlinkat(oldpath string, newdirfd int, newpath string) (err error)
+
+func Symlink(oldpath string, newpath string) (err error) {
+ return symlinkat(oldpath, AT_FDCWD, newpath)
+}
+
+func Unlink(path string) error {
+ return unlinkat(AT_FDCWD, path, 0)
+}
+
+//sys unlinkat(dirfd int, path string, flags int) (err error)
+
+func Unlinkat(dirfd int, path string) error {
+ return unlinkat(dirfd, path, 0)
+}
+
+//sys utimes(path string, times *[2]Timeval) (err error)
+
+func Utimes(path string, tv []Timeval) (err error) {
+ if tv == nil {
+ return utimes(path, nil)
+ }
+ if len(tv) != 2 {
+ return EINVAL
+ }
+ return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
+}
+
+//sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error)
+
+func UtimesNano(path string, ts []Timespec) error {
+ if ts == nil {
+ err := utimensat(AT_FDCWD, path, nil, 0)
+ if err != ENOSYS {
+ return err
+ }
+ return utimes(path, nil)
+ }
+ if len(ts) != 2 {
+ return EINVAL
+ }
+ err := utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
+ if err != ENOSYS {
+ return err
+ }
+ // If the utimensat syscall isn't available (utimensat was added to Linux
+ // in 2.6.22, Released, 8 July 2007) then fall back to utimes
+ var tv [2]Timeval
+ for i := 0; i < 2; i++ {
+ tv[i].Sec = ts[i].Sec
+ tv[i].Usec = ts[i].Nsec / 1000
+ }
+ return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
+}
+
+func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error {
+ if ts == nil {
+ return utimensat(dirfd, path, nil, flags)
+ }
+ if len(ts) != 2 {
+ return EINVAL
+ }
+ return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags)
+}
+
+//sys futimesat(dirfd int, path *byte, times *[2]Timeval) (err error)
+
+func Futimesat(dirfd int, path string, tv []Timeval) error {
+ pathp, err := BytePtrFromString(path)
+ if err != nil {
+ return err
+ }
+ if tv == nil {
+ return futimesat(dirfd, pathp, nil)
+ }
+ if len(tv) != 2 {
+ return EINVAL
+ }
+ return futimesat(dirfd, pathp, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
+}
+
+func Futimes(fd int, tv []Timeval) (err error) {
+ // Believe it or not, this is the best we can do on Linux
+ // (and is what glibc does).
+ return Utimes("/proc/self/fd/"+itoa(fd), tv)
+}
+
+const ImplementsGetwd = true
+
+//sys Getcwd(buf []byte) (n int, err error)
+
+func Getwd() (wd string, err error) {
+ var buf [PathMax]byte
+ n, err := Getcwd(buf[0:])
+ if err != nil {
+ return "", err
+ }
+ // Getcwd returns the number of bytes written to buf, including the NUL.
+ if n < 1 || n > len(buf) || buf[n-1] != 0 {
+ return "", EINVAL
+ }
+ return string(buf[0 : n-1]), nil
+}
+
+func Getgroups() (gids []int, err error) {
+ n, err := getgroups(0, nil)
+ if err != nil {
+ return nil, err
+ }
+ if n == 0 {
+ return nil, nil
+ }
+
+ // Sanity check group count. Max is 1<<16 on Linux.
+ if n < 0 || n > 1<<20 {
+ return nil, EINVAL
+ }
+
+ a := make([]_Gid_t, n)
+ n, err = getgroups(n, &a[0])
+ if err != nil {
+ return nil, err
+ }
+ gids = make([]int, n)
+ for i, v := range a[0:n] {
+ gids[i] = int(v)
+ }
+ return
+}
+
+func Setgroups(gids []int) (err error) {
+ if len(gids) == 0 {
+ return setgroups(0, nil)
+ }
+
+ a := make([]_Gid_t, len(gids))
+ for i, v := range gids {
+ a[i] = _Gid_t(v)
+ }
+ return setgroups(len(a), &a[0])
+}
+
+type WaitStatus uint32
+
+// Wait status is 7 bits at bottom, either 0 (exited),
+// 0x7F (stopped), or a signal number that caused an exit.
+// The 0x80 bit is whether there was a core dump.
+// An extra number (exit code, signal causing a stop)
+// is in the high bits. At least that's the idea.
+// There are various irregularities. For example, the
+// "continued" status is 0xFFFF, distinguishing itself
+// from stopped via the core dump bit.
+
+const (
+ mask = 0x7F
+ core = 0x80
+ exited = 0x00
+ stopped = 0x7F
+ shift = 8
+)
+
+func (w WaitStatus) Exited() bool { return w&mask == exited }
+
+func (w WaitStatus) Signaled() bool { return w&mask != stopped && w&mask != exited }
+
+func (w WaitStatus) Stopped() bool { return w&0xFF == stopped }
+
+func (w WaitStatus) Continued() bool { return w == 0xFFFF }
+
+func (w WaitStatus) CoreDump() bool { return w.Signaled() && w&core != 0 }
+
+func (w WaitStatus) ExitStatus() int {
+ if !w.Exited() {
+ return -1
+ }
+ return int(w>>shift) & 0xFF
+}
+
+func (w WaitStatus) Signal() syscall.Signal {
+ if !w.Signaled() {
+ return -1
+ }
+ return syscall.Signal(w & mask)
+}
+
+func (w WaitStatus) StopSignal() syscall.Signal {
+ if !w.Stopped() {
+ return -1
+ }
+ return syscall.Signal(w>>shift) & 0xFF
+}
+
+func (w WaitStatus) TrapCause() int {
+ if w.StopSignal() != SIGTRAP {
+ return -1
+ }
+ return int(w>>shift) >> 8
+}
+
+//sys wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error)
+
+func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) {
+ var status _C_int
+ wpid, err = wait4(pid, &status, options, rusage)
+ if wstatus != nil {
+ *wstatus = WaitStatus(status)
+ }
+ return
+}
+
+func Mkfifo(path string, mode uint32) (err error) {
+ return Mknod(path, mode|S_IFIFO, 0)
+}
+
+func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) {
+ if sa.Port < 0 || sa.Port > 0xFFFF {
+ return nil, 0, EINVAL
+ }
+ sa.raw.Family = AF_INET
+ p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
+ p[0] = byte(sa.Port >> 8)
+ p[1] = byte(sa.Port)
+ for i := 0; i < len(sa.Addr); i++ {
+ sa.raw.Addr[i] = sa.Addr[i]
+ }
+ return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil
+}
+
+func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) {
+ if sa.Port < 0 || sa.Port > 0xFFFF {
+ return nil, 0, EINVAL
+ }
+ sa.raw.Family = AF_INET6
+ p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
+ p[0] = byte(sa.Port >> 8)
+ p[1] = byte(sa.Port)
+ sa.raw.Scope_id = sa.ZoneId
+ for i := 0; i < len(sa.Addr); i++ {
+ sa.raw.Addr[i] = sa.Addr[i]
+ }
+ return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil
+}
+
+func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
+ name := sa.Name
+ n := len(name)
+ if n >= len(sa.raw.Path) {
+ return nil, 0, EINVAL
+ }
+ sa.raw.Family = AF_UNIX
+ for i := 0; i < n; i++ {
+ sa.raw.Path[i] = int8(name[i])
+ }
+ // length is family (uint16), name, NUL.
+ sl := _Socklen(2)
+ if n > 0 {
+ sl += _Socklen(n) + 1
+ }
+ if sa.raw.Path[0] == '@' {
+ sa.raw.Path[0] = 0
+ // Don't count trailing NUL for abstract address.
+ sl--
+ }
+
+ return unsafe.Pointer(&sa.raw), sl, nil
+}
+
+type SockaddrLinklayer struct {
+ Protocol uint16
+ Ifindex int
+ Hatype uint16
+ Pkttype uint8
+ Halen uint8
+ Addr [8]byte
+ raw RawSockaddrLinklayer
+}
+
+func (sa *SockaddrLinklayer) sockaddr() (unsafe.Pointer, _Socklen, error) {
+ if sa.Ifindex < 0 || sa.Ifindex > 0x7fffffff {
+ return nil, 0, EINVAL
+ }
+ sa.raw.Family = AF_PACKET
+ sa.raw.Protocol = sa.Protocol
+ sa.raw.Ifindex = int32(sa.Ifindex)
+ sa.raw.Hatype = sa.Hatype
+ sa.raw.Pkttype = sa.Pkttype
+ sa.raw.Halen = sa.Halen
+ for i := 0; i < len(sa.Addr); i++ {
+ sa.raw.Addr[i] = sa.Addr[i]
+ }
+ return unsafe.Pointer(&sa.raw), SizeofSockaddrLinklayer, nil
+}
+
+type SockaddrNetlink struct {
+ Family uint16
+ Pad uint16
+ Pid uint32
+ Groups uint32
+ raw RawSockaddrNetlink
+}
+
+func (sa *SockaddrNetlink) sockaddr() (unsafe.Pointer, _Socklen, error) {
+ sa.raw.Family = AF_NETLINK
+ sa.raw.Pad = sa.Pad
+ sa.raw.Pid = sa.Pid
+ sa.raw.Groups = sa.Groups
+ return unsafe.Pointer(&sa.raw), SizeofSockaddrNetlink, nil
+}
+
+func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) {
+ switch rsa.Addr.Family {
+ case AF_NETLINK:
+ pp := (*RawSockaddrNetlink)(unsafe.Pointer(rsa))
+ sa := new(SockaddrNetlink)
+ sa.Family = pp.Family
+ sa.Pad = pp.Pad
+ sa.Pid = pp.Pid
+ sa.Groups = pp.Groups
+ return sa, nil
+
+ case AF_PACKET:
+ pp := (*RawSockaddrLinklayer)(unsafe.Pointer(rsa))
+ sa := new(SockaddrLinklayer)
+ sa.Protocol = pp.Protocol
+ sa.Ifindex = int(pp.Ifindex)
+ sa.Hatype = pp.Hatype
+ sa.Pkttype = pp.Pkttype
+ sa.Halen = pp.Halen
+ for i := 0; i < len(sa.Addr); i++ {
+ sa.Addr[i] = pp.Addr[i]
+ }
+ return sa, nil
+
+ case AF_UNIX:
+ pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa))
+ sa := new(SockaddrUnix)
+ if pp.Path[0] == 0 {
+ // "Abstract" Unix domain socket.
+ // Rewrite leading NUL as @ for textual display.
+ // (This is the standard convention.)
+ // Not friendly to overwrite in place,
+ // but the callers below don't care.
+ pp.Path[0] = '@'
+ }
+
+ // Assume path ends at NUL.
+ // This is not technically the Linux semantics for
+ // abstract Unix domain sockets--they are supposed
+ // to be uninterpreted fixed-size binary blobs--but
+ // everyone uses this convention.
+ n := 0
+ for n < len(pp.Path) && pp.Path[n] != 0 {
+ n++
+ }
+ bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
+ sa.Name = string(bytes)
+ return sa, nil
+
+ case AF_INET:
+ pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa))
+ sa := new(SockaddrInet4)
+ p := (*[2]byte)(unsafe.Pointer(&pp.Port))
+ sa.Port = int(p[0])<<8 + int(p[1])
+ for i := 0; i < len(sa.Addr); i++ {
+ sa.Addr[i] = pp.Addr[i]
+ }
+ return sa, nil
+
+ case AF_INET6:
+ pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa))
+ sa := new(SockaddrInet6)
+ p := (*[2]byte)(unsafe.Pointer(&pp.Port))
+ sa.Port = int(p[0])<<8 + int(p[1])
+ sa.ZoneId = pp.Scope_id
+ for i := 0; i < len(sa.Addr); i++ {
+ sa.Addr[i] = pp.Addr[i]
+ }
+ return sa, nil
+ }
+ return nil, EAFNOSUPPORT
+}
+
+func Accept(fd int) (nfd int, sa Sockaddr, err error) {
+ var rsa RawSockaddrAny
+ var len _Socklen = SizeofSockaddrAny
+ nfd, err = accept(fd, &rsa, &len)
+ if err != nil {
+ return
+ }
+ sa, err = anyToSockaddr(&rsa)
+ if err != nil {
+ Close(nfd)
+ nfd = 0
+ }
+ return
+}
+
+func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) {
+ var rsa RawSockaddrAny
+ var len _Socklen = SizeofSockaddrAny
+ nfd, err = accept4(fd, &rsa, &len, flags)
+ if err != nil {
+ return
+ }
+ if len > SizeofSockaddrAny {
+ panic("RawSockaddrAny too small")
+ }
+ sa, err = anyToSockaddr(&rsa)
+ if err != nil {
+ Close(nfd)
+ nfd = 0
+ }
+ return
+}
+
+func Getsockname(fd int) (sa Sockaddr, err error) {
+ var rsa RawSockaddrAny
+ var len _Socklen = SizeofSockaddrAny
+ if err = getsockname(fd, &rsa, &len); err != nil {
+ return
+ }
+ return anyToSockaddr(&rsa)
+}
+
+func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error) {
+ vallen := _Socklen(4)
+ err = getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
+ return value, err
+}
+
+func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error) {
+ var value IPMreq
+ vallen := _Socklen(SizeofIPMreq)
+ err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
+ return &value, err
+}
+
+func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) {
+ var value IPMreqn
+ vallen := _Socklen(SizeofIPMreqn)
+ err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
+ return &value, err
+}
+
+func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) {
+ var value IPv6Mreq
+ vallen := _Socklen(SizeofIPv6Mreq)
+ err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
+ return &value, err
+}
+
+func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) {
+ var value IPv6MTUInfo
+ vallen := _Socklen(SizeofIPv6MTUInfo)
+ err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
+ return &value, err
+}
+
+func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) {
+ var value ICMPv6Filter
+ vallen := _Socklen(SizeofICMPv6Filter)
+ err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
+ return &value, err
+}
+
+func GetsockoptUcred(fd, level, opt int) (*Ucred, error) {
+ var value Ucred
+ vallen := _Socklen(SizeofUcred)
+ err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
+ return &value, err
+}
+
+func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) {
+ return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq))
+}
+
+func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) {
+ var msg Msghdr
+ var rsa RawSockaddrAny
+ msg.Name = (*byte)(unsafe.Pointer(&rsa))
+ msg.Namelen = uint32(SizeofSockaddrAny)
+ var iov Iovec
+ if len(p) > 0 {
+ iov.Base = (*byte)(unsafe.Pointer(&p[0]))
+ iov.SetLen(len(p))
+ }
+ var dummy byte
+ if len(oob) > 0 {
+ // receive at least one normal byte
+ if len(p) == 0 {
+ iov.Base = &dummy
+ iov.SetLen(1)
+ }
+ msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
+ msg.SetControllen(len(oob))
+ }
+ msg.Iov = &iov
+ msg.Iovlen = 1
+ if n, err = recvmsg(fd, &msg, flags); err != nil {
+ return
+ }
+ oobn = int(msg.Controllen)
+ recvflags = int(msg.Flags)
+ // source address is only specified if the socket is unconnected
+ if rsa.Addr.Family != AF_UNSPEC {
+ from, err = anyToSockaddr(&rsa)
+ }
+ return
+}
+
+func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) {
+ _, err = SendmsgN(fd, p, oob, to, flags)
+ return
+}
+
+func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) {
+ var ptr unsafe.Pointer
+ var salen _Socklen
+ if to != nil {
+ var err error
+ ptr, salen, err = to.sockaddr()
+ if err != nil {
+ return 0, err
+ }
+ }
+ var msg Msghdr
+ msg.Name = (*byte)(unsafe.Pointer(ptr))
+ msg.Namelen = uint32(salen)
+ var iov Iovec
+ if len(p) > 0 {
+ iov.Base = (*byte)(unsafe.Pointer(&p[0]))
+ iov.SetLen(len(p))
+ }
+ var dummy byte
+ if len(oob) > 0 {
+ // send at least one normal byte
+ if len(p) == 0 {
+ iov.Base = &dummy
+ iov.SetLen(1)
+ }
+ msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
+ msg.SetControllen(len(oob))
+ }
+ msg.Iov = &iov
+ msg.Iovlen = 1
+ if n, err = sendmsg(fd, &msg, flags); err != nil {
+ return 0, err
+ }
+ if len(oob) > 0 && len(p) == 0 {
+ n = 0
+ }
+ return n, nil
+}
+
+// BindToDevice binds the socket associated with fd to device.
+func BindToDevice(fd int, device string) (err error) {
+ return SetsockoptString(fd, SOL_SOCKET, SO_BINDTODEVICE, device)
+}
+
+//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
+
+func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, err error) {
+ // The peek requests are machine-size oriented, so we wrap it
+ // to retrieve arbitrary-length data.
+
+ // The ptrace syscall differs from glibc's ptrace.
+ // Peeks returns the word in *data, not as the return value.
+
+ var buf [sizeofPtr]byte
+
+ // Leading edge. PEEKTEXT/PEEKDATA don't require aligned
+ // access (PEEKUSER warns that it might), but if we don't
+ // align our reads, we might straddle an unmapped page
+ // boundary and not get the bytes leading up to the page
+ // boundary.
+ n := 0
+ if addr%sizeofPtr != 0 {
+ err = ptrace(req, pid, addr-addr%sizeofPtr, uintptr(unsafe.Pointer(&buf[0])))
+ if err != nil {
+ return 0, err
+ }
+ n += copy(out, buf[addr%sizeofPtr:])
+ out = out[n:]
+ }
+
+ // Remainder.
+ for len(out) > 0 {
+ // We use an internal buffer to guarantee alignment.
+ // It's not documented if this is necessary, but we're paranoid.
+ err = ptrace(req, pid, addr+uintptr(n), uintptr(unsafe.Pointer(&buf[0])))
+ if err != nil {
+ return n, err
+ }
+ copied := copy(out, buf[0:])
+ n += copied
+ out = out[copied:]
+ }
+
+ return n, nil
+}
+
+func PtracePeekText(pid int, addr uintptr, out []byte) (count int, err error) {
+ return ptracePeek(PTRACE_PEEKTEXT, pid, addr, out)
+}
+
+func PtracePeekData(pid int, addr uintptr, out []byte) (count int, err error) {
+ return ptracePeek(PTRACE_PEEKDATA, pid, addr, out)
+}
+
+func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (count int, err error) {
+ // As for ptracePeek, we need to align our accesses to deal
+ // with the possibility of straddling an invalid page.
+
+ // Leading edge.
+ n := 0
+ if addr%sizeofPtr != 0 {
+ var buf [sizeofPtr]byte
+ err = ptrace(peekReq, pid, addr-addr%sizeofPtr, uintptr(unsafe.Pointer(&buf[0])))
+ if err != nil {
+ return 0, err
+ }
+ n += copy(buf[addr%sizeofPtr:], data)
+ word := *((*uintptr)(unsafe.Pointer(&buf[0])))
+ err = ptrace(pokeReq, pid, addr-addr%sizeofPtr, word)
+ if err != nil {
+ return 0, err
+ }
+ data = data[n:]
+ }
+
+ // Interior.
+ for len(data) > sizeofPtr {
+ word := *((*uintptr)(unsafe.Pointer(&data[0])))
+ err = ptrace(pokeReq, pid, addr+uintptr(n), word)
+ if err != nil {
+ return n, err
+ }
+ n += sizeofPtr
+ data = data[sizeofPtr:]
+ }
+
+ // Trailing edge.
+ if len(data) > 0 {
+ var buf [sizeofPtr]byte
+ err = ptrace(peekReq, pid, addr+uintptr(n), uintptr(unsafe.Pointer(&buf[0])))
+ if err != nil {
+ return n, err
+ }
+ copy(buf[0:], data)
+ word := *((*uintptr)(unsafe.Pointer(&buf[0])))
+ err = ptrace(pokeReq, pid, addr+uintptr(n), word)
+ if err != nil {
+ return n, err
+ }
+ n += len(data)
+ }
+
+ return n, nil
+}
+
+func PtracePokeText(pid int, addr uintptr, data []byte) (count int, err error) {
+ return ptracePoke(PTRACE_POKETEXT, PTRACE_PEEKTEXT, pid, addr, data)
+}
+
+func PtracePokeData(pid int, addr uintptr, data []byte) (count int, err error) {
+ return ptracePoke(PTRACE_POKEDATA, PTRACE_PEEKDATA, pid, addr, data)
+}
+
+func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) {
+ return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))
+}
+
+func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) {
+ return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))
+}
+
+func PtraceSetOptions(pid int, options int) (err error) {
+ return ptrace(PTRACE_SETOPTIONS, pid, 0, uintptr(options))
+}
+
+func PtraceGetEventMsg(pid int) (msg uint, err error) {
+ var data _C_long
+ err = ptrace(PTRACE_GETEVENTMSG, pid, 0, uintptr(unsafe.Pointer(&data)))
+ msg = uint(data)
+ return
+}
+
+func PtraceCont(pid int, signal int) (err error) {
+ return ptrace(PTRACE_CONT, pid, 0, uintptr(signal))
+}
+
+func PtraceSyscall(pid int, signal int) (err error) {
+ return ptrace(PTRACE_SYSCALL, pid, 0, uintptr(signal))
+}
+
+func PtraceSingleStep(pid int) (err error) { return ptrace(PTRACE_SINGLESTEP, pid, 0, 0) }
+
+func PtraceAttach(pid int) (err error) { return ptrace(PTRACE_ATTACH, pid, 0, 0) }
+
+func PtraceDetach(pid int) (err error) { return ptrace(PTRACE_DETACH, pid, 0, 0) }
+
+//sys reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error)
+
+func Reboot(cmd int) (err error) {
+ return reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, "")
+}
+
+func clen(n []byte) int {
+ for i := 0; i < len(n); i++ {
+ if n[i] == 0 {
+ return i
+ }
+ }
+ return len(n)
+}
+
+func ReadDirent(fd int, buf []byte) (n int, err error) {
+ return Getdents(fd, buf)
+}
+
+func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
+ origlen := len(buf)
+ count = 0
+ for max != 0 && len(buf) > 0 {
+ dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
+ buf = buf[dirent.Reclen:]
+ if dirent.Ino == 0 { // File absent in directory.
+ continue
+ }
+ bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
+ var name = string(bytes[0:clen(bytes[:])])
+ if name == "." || name == ".." { // Useless names
+ continue
+ }
+ max--
+ count++
+ names = append(names, name)
+ }
+ return origlen - len(buf), count, names
+}
+
+//sys mount(source string, target string, fstype string, flags uintptr, data *byte) (err error)
+
+func Mount(source string, target string, fstype string, flags uintptr, data string) (err error) {
+ // Certain file systems get rather angry and EINVAL if you give
+ // them an empty string of data, rather than NULL.
+ if data == "" {
+ return mount(source, target, fstype, flags, nil)
+ }
+ datap, err := BytePtrFromString(data)
+ if err != nil {
+ return err
+ }
+ return mount(source, target, fstype, flags, datap)
+}
+
+// Sendto
+// Recvfrom
+// Socketpair
+
+/*
+ * Direct access
+ */
+//sys Acct(path string) (err error)
+//sys Adjtimex(buf *Timex) (state int, err error)
+//sys Chdir(path string) (err error)
+//sys Chroot(path string) (err error)
+//sys ClockGettime(clockid int32, time *Timespec) (err error)
+//sys Close(fd int) (err error)
+//sys Dup(oldfd int) (fd int, err error)
+//sys Dup3(oldfd int, newfd int, flags int) (err error)
+//sysnb EpollCreate(size int) (fd int, err error)
+//sysnb EpollCreate1(flag int) (fd int, err error)
+//sysnb EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error)
+//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
+//sys Exit(code int) = SYS_EXIT_GROUP
+//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
+//sys Fallocate(fd int, mode uint32, off int64, len int64) (err error)
+//sys Fchdir(fd int) (err error)
+//sys Fchmod(fd int, mode uint32) (err error)
+//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
+//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
+//sys fcntl(fd int, cmd int, arg int) (val int, err error)
+//sys Fdatasync(fd int) (err error)
+//sys Flock(fd int, how int) (err error)
+//sys Fsync(fd int) (err error)
+//sys Getdents(fd int, buf []byte) (n int, err error) = SYS_GETDENTS64
+//sysnb Getpgid(pid int) (pgid int, err error)
+
+func Getpgrp() (pid int) {
+ pid, _ = Getpgid(0)
+ return
+}
+
+//sysnb Getpid() (pid int)
+//sysnb Getppid() (ppid int)
+//sys Getpriority(which int, who int) (prio int, err error)
+//sysnb Getrusage(who int, rusage *Rusage) (err error)
+//sysnb Gettid() (tid int)
+//sys Getxattr(path string, attr string, dest []byte) (sz int, err error)
+//sys InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error)
+//sysnb InotifyInit1(flags int) (fd int, err error)
+//sysnb InotifyRmWatch(fd int, watchdesc uint32) (success int, err error)
+//sysnb Kill(pid int, sig syscall.Signal) (err error)
+//sys Klogctl(typ int, buf []byte) (n int, err error) = SYS_SYSLOG
+//sys Listxattr(path string, dest []byte) (sz int, err error)
+//sys Mkdirat(dirfd int, path string, mode uint32) (err error)
+//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error)
+//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
+//sys Pause() (err error)
+//sys PivotRoot(newroot string, putold string) (err error) = SYS_PIVOT_ROOT
+//sysnb prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) = SYS_PRLIMIT64
+//sys Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error)
+//sys read(fd int, p []byte) (n int, err error)
+//sys Removexattr(path string, attr string) (err error)
+//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
+//sys Setdomainname(p []byte) (err error)
+//sys Sethostname(p []byte) (err error)
+//sysnb Setpgid(pid int, pgid int) (err error)
+//sysnb Setsid() (pid int, err error)
+//sysnb Settimeofday(tv *Timeval) (err error)
+
+// issue 1435.
+// On linux Setuid and Setgid only affects the current thread, not the process.
+// This does not match what most callers expect so we must return an error
+// here rather than letting the caller think that the call succeeded.
+
+func Setuid(uid int) (err error) {
+ return EOPNOTSUPP
+}
+
+func Setgid(uid int) (err error) {
+ return EOPNOTSUPP
+}
+
+//sys Setpriority(which int, who int, prio int) (err error)
+//sys Setxattr(path string, attr string, data []byte, flags int) (err error)
+//sys Sync()
+//sysnb Sysinfo(info *Sysinfo_t) (err error)
+//sys Tee(rfd int, wfd int, len int, flags int) (n int64, err error)
+//sysnb Tgkill(tgid int, tid int, sig syscall.Signal) (err error)
+//sysnb Times(tms *Tms) (ticks uintptr, err error)
+//sysnb Umask(mask int) (oldmask int)
+//sysnb Uname(buf *Utsname) (err error)
+//sys Unmount(target string, flags int) (err error) = SYS_UMOUNT2
+//sys Unshare(flags int) (err error)
+//sys Ustat(dev int, ubuf *Ustat_t) (err error)
+//sys Utime(path string, buf *Utimbuf) (err error)
+//sys write(fd int, p []byte) (n int, err error)
+//sys exitThread(code int) (err error) = SYS_EXIT
+//sys readlen(fd int, p *byte, np int) (n int, err error) = SYS_READ
+//sys writelen(fd int, p *byte, np int) (n int, err error) = SYS_WRITE
+
+// mmap varies by architecture; see syscall_linux_*.go.
+//sys munmap(addr uintptr, length uintptr) (err error)
+
+var mapper = &mmapper{
+ active: make(map[*byte][]byte),
+ mmap: mmap,
+ munmap: munmap,
+}
+
+func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
+ return mapper.Mmap(fd, offset, length, prot, flags)
+}
+
+func Munmap(b []byte) (err error) {
+ return mapper.Munmap(b)
+}
+
+//sys Madvise(b []byte, advice int) (err error)
+//sys Mprotect(b []byte, prot int) (err error)
+//sys Mlock(b []byte) (err error)
+//sys Munlock(b []byte) (err error)
+//sys Mlockall(flags int) (err error)
+//sys Munlockall() (err error)
+
+/*
+ * Unimplemented
+ */
+// AddKey
+// AfsSyscall
+// Alarm
+// ArchPrctl
+// Brk
+// Capget
+// Capset
+// ClockGetres
+// ClockNanosleep
+// ClockSettime
+// Clone
+// CreateModule
+// DeleteModule
+// EpollCtlOld
+// EpollPwait
+// EpollWaitOld
+// Eventfd
+// Execve
+// Fgetxattr
+// Flistxattr
+// Fork
+// Fremovexattr
+// Fsetxattr
+// Futex
+// GetKernelSyms
+// GetMempolicy
+// GetRobustList
+// GetThreadArea
+// Getitimer
+// Getpmsg
+// IoCancel
+// IoDestroy
+// IoGetevents
+// IoSetup
+// IoSubmit
+// Ioctl
+// IoprioGet
+// IoprioSet
+// KexecLoad
+// Keyctl
+// Lgetxattr
+// Llistxattr
+// LookupDcookie
+// Lremovexattr
+// Lsetxattr
+// Mbind
+// MigratePages
+// Mincore
+// ModifyLdt
+// Mount
+// MovePages
+// Mprotect
+// MqGetsetattr
+// MqNotify
+// MqOpen
+// MqTimedreceive
+// MqTimedsend
+// MqUnlink
+// Mremap
+// Msgctl
+// Msgget
+// Msgrcv
+// Msgsnd
+// Msync
+// Newfstatat
+// Nfsservctl
+// Personality
+// Poll
+// Ppoll
+// Pselect6
+// Ptrace
+// Putpmsg
+// QueryModule
+// Quotactl
+// Readahead
+// Readv
+// RemapFilePages
+// RequestKey
+// RestartSyscall
+// RtSigaction
+// RtSigpending
+// RtSigprocmask
+// RtSigqueueinfo
+// RtSigreturn
+// RtSigsuspend
+// RtSigtimedwait
+// SchedGetPriorityMax
+// SchedGetPriorityMin
+// SchedGetaffinity
+// SchedGetparam
+// SchedGetscheduler
+// SchedRrGetInterval
+// SchedSetaffinity
+// SchedSetparam
+// SchedYield
+// Security
+// Semctl
+// Semget
+// Semop
+// Semtimedop
+// SetMempolicy
+// SetRobustList
+// SetThreadArea
+// SetTidAddress
+// Shmat
+// Shmctl
+// Shmdt
+// Shmget
+// Sigaltstack
+// Signalfd
+// Swapoff
+// Swapon
+// Sysfs
+// TimerCreate
+// TimerDelete
+// TimerGetoverrun
+// TimerGettime
+// TimerSettime
+// Timerfd
+// Tkill (obsolete)
+// Tuxcall
+// Umount2
+// Uselib
+// Utimensat
+// Vfork
+// Vhangup
+// Vmsplice
+// Vserver
+// Waitid
+// _Sysctl
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_386.go
new file mode 100644
index 0000000000..7171219af7
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_386.go
@@ -0,0 +1,388 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// TODO(rsc): Rewrite all nn(SP) references into name+(nn-8)(FP)
+// so that go vet can check that they are correct.
+
+// +build 386,linux
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+func Getpagesize() int { return 4096 }
+
+func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = int32(nsec / 1e9)
+ ts.Nsec = int32(nsec % 1e9)
+ return
+}
+
+func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Sec = int32(nsec / 1e9)
+ tv.Usec = int32(nsec % 1e9 / 1e3)
+ return
+}
+
+//sysnb pipe(p *[2]_C_int) (err error)
+
+func Pipe(p []int) (err error) {
+ if len(p) != 2 {
+ return EINVAL
+ }
+ var pp [2]_C_int
+ err = pipe(&pp)
+ p[0] = int(pp[0])
+ p[1] = int(pp[1])
+ return
+}
+
+//sysnb pipe2(p *[2]_C_int, flags int) (err error)
+
+func Pipe2(p []int, flags int) (err error) {
+ if len(p) != 2 {
+ return EINVAL
+ }
+ var pp [2]_C_int
+ err = pipe2(&pp, flags)
+ p[0] = int(pp[0])
+ p[1] = int(pp[1])
+ return
+}
+
+// 64-bit file system and 32-bit uid calls
+// (386 default is 32-bit file system and 16-bit uid).
+//sys Dup2(oldfd int, newfd int) (err error)
+//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64_64
+//sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32
+//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
+//sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64
+//sysnb Getegid() (egid int) = SYS_GETEGID32
+//sysnb Geteuid() (euid int) = SYS_GETEUID32
+//sysnb Getgid() (gid int) = SYS_GETGID32
+//sysnb Getuid() (uid int) = SYS_GETUID32
+//sysnb InotifyInit() (fd int, err error)
+//sys Ioperm(from int, num int, on int) (err error)
+//sys Iopl(level int) (err error)
+//sys Lchown(path string, uid int, gid int) (err error) = SYS_LCHOWN32
+//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
+//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
+//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
+//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64
+//sys Setfsgid(gid int) (err error) = SYS_SETFSGID32
+//sys Setfsuid(uid int) (err error) = SYS_SETFSUID32
+//sysnb Setregid(rgid int, egid int) (err error) = SYS_SETREGID32
+//sysnb Setresgid(rgid int, egid int, sgid int) (err error) = SYS_SETRESGID32
+//sysnb Setresuid(ruid int, euid int, suid int) (err error) = SYS_SETRESUID32
+//sysnb Setreuid(ruid int, euid int) (err error) = SYS_SETREUID32
+//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error)
+//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
+//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
+//sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64
+//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) = SYS_GETGROUPS32
+//sysnb setgroups(n int, list *_Gid_t) (err error) = SYS_SETGROUPS32
+//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT
+
+//sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error)
+
+func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
+ page := uintptr(offset / 4096)
+ if offset != int64(page)*4096 {
+ return 0, EINVAL
+ }
+ return mmap2(addr, length, prot, flags, fd, page)
+}
+
+type rlimit32 struct {
+ Cur uint32
+ Max uint32
+}
+
+//sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_GETRLIMIT
+
+const rlimInf32 = ^uint32(0)
+const rlimInf64 = ^uint64(0)
+
+func Getrlimit(resource int, rlim *Rlimit) (err error) {
+ err = prlimit(0, resource, nil, rlim)
+ if err != ENOSYS {
+ return err
+ }
+
+ rl := rlimit32{}
+ err = getrlimit(resource, &rl)
+ if err != nil {
+ return
+ }
+
+ if rl.Cur == rlimInf32 {
+ rlim.Cur = rlimInf64
+ } else {
+ rlim.Cur = uint64(rl.Cur)
+ }
+
+ if rl.Max == rlimInf32 {
+ rlim.Max = rlimInf64
+ } else {
+ rlim.Max = uint64(rl.Max)
+ }
+ return
+}
+
+//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT
+
+func Setrlimit(resource int, rlim *Rlimit) (err error) {
+ err = prlimit(0, resource, rlim, nil)
+ if err != ENOSYS {
+ return err
+ }
+
+ rl := rlimit32{}
+ if rlim.Cur == rlimInf64 {
+ rl.Cur = rlimInf32
+ } else if rlim.Cur < uint64(rlimInf32) {
+ rl.Cur = uint32(rlim.Cur)
+ } else {
+ return EINVAL
+ }
+ if rlim.Max == rlimInf64 {
+ rl.Max = rlimInf32
+ } else if rlim.Max < uint64(rlimInf32) {
+ rl.Max = uint32(rlim.Max)
+ } else {
+ return EINVAL
+ }
+
+ return setrlimit(resource, &rl)
+}
+
+// Underlying system call writes to newoffset via pointer.
+// Implemented in assembly to avoid allocation.
+func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno)
+
+func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
+ newoffset, errno := seek(fd, offset, whence)
+ if errno != 0 {
+ return 0, errno
+ }
+ return newoffset, nil
+}
+
+// Vsyscalls on amd64.
+//sysnb Gettimeofday(tv *Timeval) (err error)
+//sysnb Time(t *Time_t) (tt Time_t, err error)
+
+// On x86 Linux, all the socket calls go through an extra indirection,
+// I think because the 5-register system call interface can't handle
+// the 6-argument calls like sendto and recvfrom. Instead the
+// arguments to the underlying system call are the number below
+// and a pointer to an array of uintptr. We hide the pointer in the
+// socketcall assembly to avoid allocation on every system call.
+
+const (
+ // see linux/net.h
+ _SOCKET = 1
+ _BIND = 2
+ _CONNECT = 3
+ _LISTEN = 4
+ _ACCEPT = 5
+ _GETSOCKNAME = 6
+ _GETPEERNAME = 7
+ _SOCKETPAIR = 8
+ _SEND = 9
+ _RECV = 10
+ _SENDTO = 11
+ _RECVFROM = 12
+ _SHUTDOWN = 13
+ _SETSOCKOPT = 14
+ _GETSOCKOPT = 15
+ _SENDMSG = 16
+ _RECVMSG = 17
+ _ACCEPT4 = 18
+ _RECVMMSG = 19
+ _SENDMMSG = 20
+)
+
+func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno)
+func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno)
+
+func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
+ fd, e := socketcall(_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0)
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
+ fd, e := socketcall(_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func getsockname(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
+ _, e := rawsocketcall(_GETSOCKNAME, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0)
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func getpeername(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
+ _, e := rawsocketcall(_GETPEERNAME, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0)
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func socketpair(domain int, typ int, flags int, fd *[2]int32) (err error) {
+ _, e := rawsocketcall(_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(flags), uintptr(unsafe.Pointer(fd)), 0, 0)
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
+ _, e := socketcall(_BIND, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0)
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
+ _, e := socketcall(_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0)
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func socket(domain int, typ int, proto int) (fd int, err error) {
+ fd, e := rawsocketcall(_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto), 0, 0, 0)
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
+ _, e := socketcall(_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
+ _, e := socketcall(_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), vallen, 0)
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func recvfrom(s int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
+ var base uintptr
+ if len(p) > 0 {
+ base = uintptr(unsafe.Pointer(&p[0]))
+ }
+ n, e := socketcall(_RECVFROM, uintptr(s), base, uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func sendto(s int, p []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
+ var base uintptr
+ if len(p) > 0 {
+ base = uintptr(unsafe.Pointer(&p[0]))
+ }
+ _, e := socketcall(_SENDTO, uintptr(s), base, uintptr(len(p)), uintptr(flags), uintptr(to), uintptr(addrlen))
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
+ n, e := socketcall(_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0)
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
+ n, e := socketcall(_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0)
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func Listen(s int, n int) (err error) {
+ _, e := socketcall(_LISTEN, uintptr(s), uintptr(n), 0, 0, 0, 0)
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func Shutdown(s, how int) (err error) {
+ _, e := socketcall(_SHUTDOWN, uintptr(s), uintptr(how), 0, 0, 0, 0)
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func Fstatfs(fd int, buf *Statfs_t) (err error) {
+ _, _, e := Syscall(SYS_FSTATFS64, uintptr(fd), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func Statfs(path string, buf *Statfs_t) (err error) {
+ pathp, err := BytePtrFromString(path)
+ if err != nil {
+ return err
+ }
+ _, _, e := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(pathp)), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func (r *PtraceRegs) PC() uint64 { return uint64(uint32(r.Eip)) }
+
+func (r *PtraceRegs) SetPC(pc uint64) { r.Eip = int32(pc) }
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint32(length)
+}
+
+func (msghdr *Msghdr) SetControllen(length int) {
+ msghdr.Controllen = uint32(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint32(length)
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_amd64.go
new file mode 100644
index 0000000000..ae70c2afca
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_amd64.go
@@ -0,0 +1,146 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build amd64,linux
+
+package unix
+
+import "syscall"
+
+//sys Dup2(oldfd int, newfd int) (err error)
+//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
+//sys Fchown(fd int, uid int, gid int) (err error)
+//sys Fstat(fd int, stat *Stat_t) (err error)
+//sys Fstatfs(fd int, buf *Statfs_t) (err error)
+//sys Ftruncate(fd int, length int64) (err error)
+//sysnb Getegid() (egid int)
+//sysnb Geteuid() (euid int)
+//sysnb Getgid() (gid int)
+//sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
+//sysnb Getuid() (uid int)
+//sysnb InotifyInit() (fd int, err error)
+//sys Ioperm(from int, num int, on int) (err error)
+//sys Iopl(level int) (err error)
+//sys Lchown(path string, uid int, gid int) (err error)
+//sys Listen(s int, n int) (err error)
+//sys Lstat(path string, stat *Stat_t) (err error)
+//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
+//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
+//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
+//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
+//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
+//sys Setfsgid(gid int) (err error)
+//sys Setfsuid(uid int) (err error)
+//sysnb Setregid(rgid int, egid int) (err error)
+//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
+//sysnb Setresuid(ruid int, euid int, suid int) (err error)
+//sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
+//sysnb Setreuid(ruid int, euid int) (err error)
+//sys Shutdown(fd int, how int) (err error)
+//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
+//sys Stat(path string, stat *Stat_t) (err error)
+//sys Statfs(path string, buf *Statfs_t) (err error)
+//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
+//sys Truncate(path string, length int64) (err error)
+//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
+//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
+//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
+//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
+//sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
+//sysnb setgroups(n int, list *_Gid_t) (err error)
+//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
+//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
+//sysnb socket(domain int, typ int, proto int) (fd int, err error)
+//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
+//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
+//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
+//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
+//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
+//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
+//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
+//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
+
+//go:noescape
+func gettimeofday(tv *Timeval) (err syscall.Errno)
+
+func Gettimeofday(tv *Timeval) (err error) {
+ errno := gettimeofday(tv)
+ if errno != 0 {
+ return errno
+ }
+ return nil
+}
+
+func Getpagesize() int { return 4096 }
+
+func Time(t *Time_t) (tt Time_t, err error) {
+ var tv Timeval
+ errno := gettimeofday(&tv)
+ if errno != 0 {
+ return 0, errno
+ }
+ if t != nil {
+ *t = Time_t(tv.Sec)
+ }
+ return Time_t(tv.Sec), nil
+}
+
+func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = nsec / 1e9
+ ts.Nsec = nsec % 1e9
+ return
+}
+
+func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Sec = nsec / 1e9
+ tv.Usec = nsec % 1e9 / 1e3
+ return
+}
+
+//sysnb pipe(p *[2]_C_int) (err error)
+
+func Pipe(p []int) (err error) {
+ if len(p) != 2 {
+ return EINVAL
+ }
+ var pp [2]_C_int
+ err = pipe(&pp)
+ p[0] = int(pp[0])
+ p[1] = int(pp[1])
+ return
+}
+
+//sysnb pipe2(p *[2]_C_int, flags int) (err error)
+
+func Pipe2(p []int, flags int) (err error) {
+ if len(p) != 2 {
+ return EINVAL
+ }
+ var pp [2]_C_int
+ err = pipe2(&pp, flags)
+ p[0] = int(pp[0])
+ p[1] = int(pp[1])
+ return
+}
+
+func (r *PtraceRegs) PC() uint64 { return r.Rip }
+
+func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc }
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint64(length)
+}
+
+func (msghdr *Msghdr) SetControllen(length int) {
+ msghdr.Controllen = uint64(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint64(length)
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_arm.go
new file mode 100644
index 0000000000..abc41c3ea5
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_arm.go
@@ -0,0 +1,233 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build arm,linux
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+func Getpagesize() int { return 4096 }
+
+func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = int32(nsec / 1e9)
+ ts.Nsec = int32(nsec % 1e9)
+ return
+}
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Sec = int32(nsec / 1e9)
+ tv.Usec = int32(nsec % 1e9 / 1e3)
+ return
+}
+
+func Pipe(p []int) (err error) {
+ if len(p) != 2 {
+ return EINVAL
+ }
+ var pp [2]_C_int
+ err = pipe2(&pp, 0)
+ p[0] = int(pp[0])
+ p[1] = int(pp[1])
+ return
+}
+
+//sysnb pipe2(p *[2]_C_int, flags int) (err error)
+
+func Pipe2(p []int, flags int) (err error) {
+ if len(p) != 2 {
+ return EINVAL
+ }
+ var pp [2]_C_int
+ err = pipe2(&pp, flags)
+ p[0] = int(pp[0])
+ p[1] = int(pp[1])
+ return
+}
+
+// Underlying system call writes to newoffset via pointer.
+// Implemented in assembly to avoid allocation.
+func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno)
+
+func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
+ newoffset, errno := seek(fd, offset, whence)
+ if errno != 0 {
+ return 0, errno
+ }
+ return newoffset, nil
+}
+
+//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
+//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
+//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
+//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
+//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) = SYS_GETGROUPS32
+//sysnb setgroups(n int, list *_Gid_t) (err error) = SYS_SETGROUPS32
+//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
+//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
+//sysnb socket(domain int, typ int, proto int) (fd int, err error)
+//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
+//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
+//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
+//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
+//sysnb socketpair(domain int, typ int, flags int, fd *[2]int32) (err error)
+//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
+//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
+
+// 64-bit file system and 32-bit uid calls
+// (16-bit uid calls are not always supported in newer kernels)
+//sys Dup2(oldfd int, newfd int) (err error)
+//sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32
+//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
+//sysnb Getegid() (egid int) = SYS_GETEGID32
+//sysnb Geteuid() (euid int) = SYS_GETEUID32
+//sysnb Getgid() (gid int) = SYS_GETGID32
+//sysnb Getuid() (uid int) = SYS_GETUID32
+//sysnb InotifyInit() (fd int, err error)
+//sys Lchown(path string, uid int, gid int) (err error) = SYS_LCHOWN32
+//sys Listen(s int, n int) (err error)
+//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
+//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64
+//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT
+//sys Setfsgid(gid int) (err error) = SYS_SETFSGID32
+//sys Setfsuid(uid int) (err error) = SYS_SETFSUID32
+//sysnb Setregid(rgid int, egid int) (err error) = SYS_SETREGID32
+//sysnb Setresgid(rgid int, egid int, sgid int) (err error) = SYS_SETRESGID32
+//sysnb Setresuid(ruid int, euid int, suid int) (err error) = SYS_SETRESUID32
+//sysnb Setreuid(ruid int, euid int) (err error) = SYS_SETREUID32
+//sys Shutdown(fd int, how int) (err error)
+//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error)
+//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
+
+// Vsyscalls on amd64.
+//sysnb Gettimeofday(tv *Timeval) (err error)
+//sysnb Time(t *Time_t) (tt Time_t, err error)
+
+//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
+//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
+//sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64
+//sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64
+
+func Fadvise(fd int, offset int64, length int64, advice int) (err error) {
+ _, _, e1 := Syscall6(SYS_ARM_FADVISE64_64, uintptr(fd), uintptr(advice), uintptr(offset), uintptr(offset>>32), uintptr(length), uintptr(length>>32))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+//sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error)
+
+func Fstatfs(fd int, buf *Statfs_t) (err error) {
+ _, _, e := Syscall(SYS_FSTATFS64, uintptr(fd), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func Statfs(path string, buf *Statfs_t) (err error) {
+ pathp, err := BytePtrFromString(path)
+ if err != nil {
+ return err
+ }
+ _, _, e := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(pathp)), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
+ if e != 0 {
+ err = e
+ }
+ return
+}
+
+func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
+ page := uintptr(offset / 4096)
+ if offset != int64(page)*4096 {
+ return 0, EINVAL
+ }
+ return mmap2(addr, length, prot, flags, fd, page)
+}
+
+type rlimit32 struct {
+ Cur uint32
+ Max uint32
+}
+
+//sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_GETRLIMIT
+
+const rlimInf32 = ^uint32(0)
+const rlimInf64 = ^uint64(0)
+
+func Getrlimit(resource int, rlim *Rlimit) (err error) {
+ err = prlimit(0, resource, nil, rlim)
+ if err != ENOSYS {
+ return err
+ }
+
+ rl := rlimit32{}
+ err = getrlimit(resource, &rl)
+ if err != nil {
+ return
+ }
+
+ if rl.Cur == rlimInf32 {
+ rlim.Cur = rlimInf64
+ } else {
+ rlim.Cur = uint64(rl.Cur)
+ }
+
+ if rl.Max == rlimInf32 {
+ rlim.Max = rlimInf64
+ } else {
+ rlim.Max = uint64(rl.Max)
+ }
+ return
+}
+
+//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT
+
+func Setrlimit(resource int, rlim *Rlimit) (err error) {
+ err = prlimit(0, resource, rlim, nil)
+ if err != ENOSYS {
+ return err
+ }
+
+ rl := rlimit32{}
+ if rlim.Cur == rlimInf64 {
+ rl.Cur = rlimInf32
+ } else if rlim.Cur < uint64(rlimInf32) {
+ rl.Cur = uint32(rlim.Cur)
+ } else {
+ return EINVAL
+ }
+ if rlim.Max == rlimInf64 {
+ rl.Max = rlimInf32
+ } else if rlim.Max < uint64(rlimInf32) {
+ rl.Max = uint32(rlim.Max)
+ } else {
+ return EINVAL
+ }
+
+ return setrlimit(resource, &rl)
+}
+
+func (r *PtraceRegs) PC() uint64 { return uint64(r.Uregs[15]) }
+
+func (r *PtraceRegs) SetPC(pc uint64) { r.Uregs[15] = uint32(pc) }
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint32(length)
+}
+
+func (msghdr *Msghdr) SetControllen(length int) {
+ msghdr.Controllen = uint32(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint32(length)
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_arm64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_arm64.go
new file mode 100644
index 0000000000..f3d72dfd30
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_arm64.go
@@ -0,0 +1,150 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build arm64,linux
+
+package unix
+
+const _SYS_dup = SYS_DUP3
+
+//sys Fchown(fd int, uid int, gid int) (err error)
+//sys Fstat(fd int, stat *Stat_t) (err error)
+//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
+//sys Fstatfs(fd int, buf *Statfs_t) (err error)
+//sys Ftruncate(fd int, length int64) (err error)
+//sysnb Getegid() (egid int)
+//sysnb Geteuid() (euid int)
+//sysnb Getgid() (gid int)
+//sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
+//sysnb Getuid() (uid int)
+//sys Listen(s int, n int) (err error)
+//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
+//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
+//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
+//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS_PSELECT6
+//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
+//sys Setfsgid(gid int) (err error)
+//sys Setfsuid(uid int) (err error)
+//sysnb Setregid(rgid int, egid int) (err error)
+//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
+//sysnb Setresuid(ruid int, euid int, suid int) (err error)
+//sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
+//sysnb Setreuid(ruid int, euid int) (err error)
+//sys Shutdown(fd int, how int) (err error)
+//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
+
+func Stat(path string, stat *Stat_t) (err error) {
+ return Fstatat(AT_FDCWD, path, stat, 0)
+}
+
+func Lchown(path string, uid int, gid int) (err error) {
+ return Fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW)
+}
+
+func Lstat(path string, stat *Stat_t) (err error) {
+ return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW)
+}
+
+//sys Statfs(path string, buf *Statfs_t) (err error)
+//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
+//sys Truncate(path string, length int64) (err error)
+//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
+//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
+//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
+//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
+//sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
+//sysnb setgroups(n int, list *_Gid_t) (err error)
+//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
+//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
+//sysnb socket(domain int, typ int, proto int) (fd int, err error)
+//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
+//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
+//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
+//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
+//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
+//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
+//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
+//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
+
+func Getpagesize() int { return 65536 }
+
+//sysnb Gettimeofday(tv *Timeval) (err error)
+//sysnb Time(t *Time_t) (tt Time_t, err error)
+
+func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = nsec / 1e9
+ ts.Nsec = nsec % 1e9
+ return
+}
+
+func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Sec = nsec / 1e9
+ tv.Usec = nsec % 1e9 / 1e3
+ return
+}
+
+func Pipe(p []int) (err error) {
+ if len(p) != 2 {
+ return EINVAL
+ }
+ var pp [2]_C_int
+ err = pipe2(&pp, 0)
+ p[0] = int(pp[0])
+ p[1] = int(pp[1])
+ return
+}
+
+//sysnb pipe2(p *[2]_C_int, flags int) (err error)
+
+func Pipe2(p []int, flags int) (err error) {
+ if len(p) != 2 {
+ return EINVAL
+ }
+ var pp [2]_C_int
+ err = pipe2(&pp, flags)
+ p[0] = int(pp[0])
+ p[1] = int(pp[1])
+ return
+}
+
+func (r *PtraceRegs) PC() uint64 { return r.Pc }
+
+func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc }
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint64(length)
+}
+
+func (msghdr *Msghdr) SetControllen(length int) {
+ msghdr.Controllen = uint64(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint64(length)
+}
+
+func InotifyInit() (fd int, err error) {
+ return InotifyInit1(0)
+}
+
+// TODO(dfc): constants that should be in zsysnum_linux_arm64.go, remove
+// these when the deprecated syscalls that the syscall package relies on
+// are removed.
+const (
+ SYS_GETPGRP = 1060
+ SYS_UTIMES = 1037
+ SYS_FUTIMESAT = 1066
+ SYS_PAUSE = 1061
+ SYS_USTAT = 1070
+ SYS_UTIME = 1063
+ SYS_LCHOWN = 1032
+ SYS_TIME = 1062
+ SYS_EPOLL_CREATE = 1042
+ SYS_EPOLL_WAIT = 1069
+)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_ppc64x.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_ppc64x.go
new file mode 100644
index 0000000000..67eed6334c
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_ppc64x.go
@@ -0,0 +1,96 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build linux
+// +build ppc64 ppc64le
+
+package unix
+
+//sys Fchown(fd int, uid int, gid int) (err error)
+//sys Fstat(fd int, stat *Stat_t) (err error)
+//sys Fstatfs(fd int, buf *Statfs_t) (err error)
+//sys Ftruncate(fd int, length int64) (err error)
+//sysnb Getegid() (egid int)
+//sysnb Geteuid() (euid int)
+//sysnb Getgid() (gid int)
+//sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = SYS_UGETRLIMIT
+//sysnb Getuid() (uid int)
+//sys Ioperm(from int, num int, on int) (err error)
+//sys Iopl(level int) (err error)
+//sys Lchown(path string, uid int, gid int) (err error)
+//sys Listen(s int, n int) (err error)
+//sys Lstat(path string, stat *Stat_t) (err error)
+//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
+//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
+//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
+//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
+//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
+//sys Setfsgid(gid int) (err error)
+//sys Setfsuid(uid int) (err error)
+//sysnb Setregid(rgid int, egid int) (err error)
+//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
+//sysnb Setresuid(ruid int, euid int, suid int) (err error)
+//sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
+//sysnb Setreuid(ruid int, euid int) (err error)
+//sys Shutdown(fd int, how int) (err error)
+//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
+//sys Stat(path string, stat *Stat_t) (err error)
+//sys Statfs(path string, buf *Statfs_t) (err error)
+//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) = SYS_SYNC_FILE_RANGE2
+//sys Truncate(path string, length int64) (err error)
+//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
+//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
+//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
+//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
+//sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
+//sysnb setgroups(n int, list *_Gid_t) (err error)
+//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
+//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
+//sysnb socket(domain int, typ int, proto int) (fd int, err error)
+//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
+//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
+//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
+//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
+//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
+//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
+//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
+//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
+
+func Getpagesize() int { return 65536 }
+
+//sysnb Gettimeofday(tv *Timeval) (err error)
+//sysnb Time(t *Time_t) (tt Time_t, err error)
+
+func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = nsec / 1e9
+ ts.Nsec = nsec % 1e9
+ return
+}
+
+func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Sec = nsec / 1e9
+ tv.Usec = nsec % 1e9 / 1e3
+ return
+}
+
+func (r *PtraceRegs) PC() uint64 { return r.Nip }
+
+func (r *PtraceRegs) SetPC(pc uint64) { r.Nip = pc }
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint64(length)
+}
+
+func (msghdr *Msghdr) SetControllen(length int) {
+ msghdr.Controllen = uint64(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint64(length)
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd.go
new file mode 100644
index 0000000000..c4e945cd69
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd.go
@@ -0,0 +1,492 @@
+// Copyright 2009,2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// NetBSD system calls.
+// This file is compiled as ordinary Go code,
+// but it is also input to mksyscall,
+// which parses the //sys lines and generates system call stubs.
+// Note that sometimes we use a lowercase //sys name and wrap
+// it in our own nicer implementation, either here or in
+// syscall_bsd.go or syscall_unix.go.
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+type SockaddrDatalink struct {
+ Len uint8
+ Family uint8
+ Index uint16
+ Type uint8
+ Nlen uint8
+ Alen uint8
+ Slen uint8
+ Data [12]int8
+ raw RawSockaddrDatalink
+}
+
+func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
+
+func sysctlNodes(mib []_C_int) (nodes []Sysctlnode, err error) {
+ var olen uintptr
+
+ // Get a list of all sysctl nodes below the given MIB by performing
+ // a sysctl for the given MIB with CTL_QUERY appended.
+ mib = append(mib, CTL_QUERY)
+ qnode := Sysctlnode{Flags: SYSCTL_VERS_1}
+ qp := (*byte)(unsafe.Pointer(&qnode))
+ sz := unsafe.Sizeof(qnode)
+ if err = sysctl(mib, nil, &olen, qp, sz); err != nil {
+ return nil, err
+ }
+
+ // Now that we know the size, get the actual nodes.
+ nodes = make([]Sysctlnode, olen/sz)
+ np := (*byte)(unsafe.Pointer(&nodes[0]))
+ if err = sysctl(mib, np, &olen, qp, sz); err != nil {
+ return nil, err
+ }
+
+ return nodes, nil
+}
+
+func nametomib(name string) (mib []_C_int, err error) {
+
+ // Split name into components.
+ var parts []string
+ last := 0
+ for i := 0; i < len(name); i++ {
+ if name[i] == '.' {
+ parts = append(parts, name[last:i])
+ last = i + 1
+ }
+ }
+ parts = append(parts, name[last:])
+
+ // Discover the nodes and construct the MIB OID.
+ for partno, part := range parts {
+ nodes, err := sysctlNodes(mib)
+ if err != nil {
+ return nil, err
+ }
+ for _, node := range nodes {
+ n := make([]byte, 0)
+ for i := range node.Name {
+ if node.Name[i] != 0 {
+ n = append(n, byte(node.Name[i]))
+ }
+ }
+ if string(n) == part {
+ mib = append(mib, _C_int(node.Num))
+ break
+ }
+ }
+ if len(mib) != partno+1 {
+ return nil, EINVAL
+ }
+ }
+
+ return mib, nil
+}
+
+// ParseDirent parses up to max directory entries in buf,
+// appending the names to names. It returns the number
+// bytes consumed from buf, the number of entries added
+// to names, and the new names slice.
+func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
+ origlen := len(buf)
+ for max != 0 && len(buf) > 0 {
+ dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
+ if dirent.Reclen == 0 {
+ buf = nil
+ break
+ }
+ buf = buf[dirent.Reclen:]
+ if dirent.Fileno == 0 { // File absent in directory.
+ continue
+ }
+ bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
+ var name = string(bytes[0:dirent.Namlen])
+ if name == "." || name == ".." { // Useless names
+ continue
+ }
+ max--
+ count++
+ names = append(names, name)
+ }
+ return origlen - len(buf), count, names
+}
+
+//sysnb pipe() (fd1 int, fd2 int, err error)
+func Pipe(p []int) (err error) {
+ if len(p) != 2 {
+ return EINVAL
+ }
+ p[0], p[1], err = pipe()
+ return
+}
+
+//sys getdents(fd int, buf []byte) (n int, err error)
+func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
+ return getdents(fd, buf)
+}
+
+// TODO
+func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
+ return -1, ENOSYS
+}
+
+/*
+ * Exposed directly
+ */
+//sys Access(path string, mode uint32) (err error)
+//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
+//sys Chdir(path string) (err error)
+//sys Chflags(path string, flags int) (err error)
+//sys Chmod(path string, mode uint32) (err error)
+//sys Chown(path string, uid int, gid int) (err error)
+//sys Chroot(path string) (err error)
+//sys Close(fd int) (err error)
+//sys Dup(fd int) (nfd int, err error)
+//sys Dup2(from int, to int) (err error)
+//sys Exit(code int)
+//sys Fchdir(fd int) (err error)
+//sys Fchflags(fd int, flags int) (err error)
+//sys Fchmod(fd int, mode uint32) (err error)
+//sys Fchown(fd int, uid int, gid int) (err error)
+//sys Flock(fd int, how int) (err error)
+//sys Fpathconf(fd int, name int) (val int, err error)
+//sys Fstat(fd int, stat *Stat_t) (err error)
+//sys Fsync(fd int) (err error)
+//sys Ftruncate(fd int, length int64) (err error)
+//sysnb Getegid() (egid int)
+//sysnb Geteuid() (uid int)
+//sysnb Getgid() (gid int)
+//sysnb Getpgid(pid int) (pgid int, err error)
+//sysnb Getpgrp() (pgrp int)
+//sysnb Getpid() (pid int)
+//sysnb Getppid() (ppid int)
+//sys Getpriority(which int, who int) (prio int, err error)
+//sysnb Getrlimit(which int, lim *Rlimit) (err error)
+//sysnb Getrusage(who int, rusage *Rusage) (err error)
+//sysnb Getsid(pid int) (sid int, err error)
+//sysnb Gettimeofday(tv *Timeval) (err error)
+//sysnb Getuid() (uid int)
+//sys Issetugid() (tainted bool)
+//sys Kill(pid int, signum syscall.Signal) (err error)
+//sys Kqueue() (fd int, err error)
+//sys Lchown(path string, uid int, gid int) (err error)
+//sys Link(path string, link string) (err error)
+//sys Listen(s int, backlog int) (err error)
+//sys Lstat(path string, stat *Stat_t) (err error)
+//sys Mkdir(path string, mode uint32) (err error)
+//sys Mkfifo(path string, mode uint32) (err error)
+//sys Mknod(path string, mode uint32, dev int) (err error)
+//sys Mlock(b []byte) (err error)
+//sys Mlockall(flags int) (err error)
+//sys Mprotect(b []byte, prot int) (err error)
+//sys Munlock(b []byte) (err error)
+//sys Munlockall() (err error)
+//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
+//sys Open(path string, mode int, perm uint32) (fd int, err error)
+//sys Pathconf(path string, name int) (val int, err error)
+//sys Pread(fd int, p []byte, offset int64) (n int, err error)
+//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
+//sys read(fd int, p []byte) (n int, err error)
+//sys Readlink(path string, buf []byte) (n int, err error)
+//sys Rename(from string, to string) (err error)
+//sys Revoke(path string) (err error)
+//sys Rmdir(path string) (err error)
+//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
+//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
+//sysnb Setegid(egid int) (err error)
+//sysnb Seteuid(euid int) (err error)
+//sysnb Setgid(gid int) (err error)
+//sysnb Setpgid(pid int, pgid int) (err error)
+//sys Setpriority(which int, who int, prio int) (err error)
+//sysnb Setregid(rgid int, egid int) (err error)
+//sysnb Setreuid(ruid int, euid int) (err error)
+//sysnb Setrlimit(which int, lim *Rlimit) (err error)
+//sysnb Setsid() (pid int, err error)
+//sysnb Settimeofday(tp *Timeval) (err error)
+//sysnb Setuid(uid int) (err error)
+//sys Stat(path string, stat *Stat_t) (err error)
+//sys Symlink(path string, link string) (err error)
+//sys Sync() (err error)
+//sys Truncate(path string, length int64) (err error)
+//sys Umask(newmask int) (oldmask int)
+//sys Unlink(path string) (err error)
+//sys Unmount(path string, flags int) (err error)
+//sys write(fd int, p []byte) (n int, err error)
+//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
+//sys munmap(addr uintptr, length uintptr) (err error)
+//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
+//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
+
+/*
+ * Unimplemented
+ */
+// ____semctl13
+// __clone
+// __fhopen40
+// __fhstat40
+// __fhstatvfs140
+// __fstat30
+// __getcwd
+// __getfh30
+// __getlogin
+// __lstat30
+// __mount50
+// __msgctl13
+// __msync13
+// __ntp_gettime30
+// __posix_chown
+// __posix_fadvise50
+// __posix_fchown
+// __posix_lchown
+// __posix_rename
+// __setlogin
+// __shmctl13
+// __sigaction_sigtramp
+// __sigaltstack14
+// __sigpending14
+// __sigprocmask14
+// __sigsuspend14
+// __sigtimedwait
+// __stat30
+// __syscall
+// __vfork14
+// _ksem_close
+// _ksem_destroy
+// _ksem_getvalue
+// _ksem_init
+// _ksem_open
+// _ksem_post
+// _ksem_trywait
+// _ksem_unlink
+// _ksem_wait
+// _lwp_continue
+// _lwp_create
+// _lwp_ctl
+// _lwp_detach
+// _lwp_exit
+// _lwp_getname
+// _lwp_getprivate
+// _lwp_kill
+// _lwp_park
+// _lwp_self
+// _lwp_setname
+// _lwp_setprivate
+// _lwp_suspend
+// _lwp_unpark
+// _lwp_unpark_all
+// _lwp_wait
+// _lwp_wakeup
+// _pset_bind
+// _sched_getaffinity
+// _sched_getparam
+// _sched_setaffinity
+// _sched_setparam
+// acct
+// aio_cancel
+// aio_error
+// aio_fsync
+// aio_read
+// aio_return
+// aio_suspend
+// aio_write
+// break
+// clock_getres
+// clock_gettime
+// clock_settime
+// compat_09_ogetdomainname
+// compat_09_osetdomainname
+// compat_09_ouname
+// compat_10_omsgsys
+// compat_10_osemsys
+// compat_10_oshmsys
+// compat_12_fstat12
+// compat_12_getdirentries
+// compat_12_lstat12
+// compat_12_msync
+// compat_12_oreboot
+// compat_12_oswapon
+// compat_12_stat12
+// compat_13_sigaction13
+// compat_13_sigaltstack13
+// compat_13_sigpending13
+// compat_13_sigprocmask13
+// compat_13_sigreturn13
+// compat_13_sigsuspend13
+// compat_14___semctl
+// compat_14_msgctl
+// compat_14_shmctl
+// compat_16___sigaction14
+// compat_16___sigreturn14
+// compat_20_fhstatfs
+// compat_20_fstatfs
+// compat_20_getfsstat
+// compat_20_statfs
+// compat_30___fhstat30
+// compat_30___fstat13
+// compat_30___lstat13
+// compat_30___stat13
+// compat_30_fhopen
+// compat_30_fhstat
+// compat_30_fhstatvfs1
+// compat_30_getdents
+// compat_30_getfh
+// compat_30_ntp_gettime
+// compat_30_socket
+// compat_40_mount
+// compat_43_fstat43
+// compat_43_lstat43
+// compat_43_oaccept
+// compat_43_ocreat
+// compat_43_oftruncate
+// compat_43_ogetdirentries
+// compat_43_ogetdtablesize
+// compat_43_ogethostid
+// compat_43_ogethostname
+// compat_43_ogetkerninfo
+// compat_43_ogetpagesize
+// compat_43_ogetpeername
+// compat_43_ogetrlimit
+// compat_43_ogetsockname
+// compat_43_okillpg
+// compat_43_olseek
+// compat_43_ommap
+// compat_43_oquota
+// compat_43_orecv
+// compat_43_orecvfrom
+// compat_43_orecvmsg
+// compat_43_osend
+// compat_43_osendmsg
+// compat_43_osethostid
+// compat_43_osethostname
+// compat_43_osetrlimit
+// compat_43_osigblock
+// compat_43_osigsetmask
+// compat_43_osigstack
+// compat_43_osigvec
+// compat_43_otruncate
+// compat_43_owait
+// compat_43_stat43
+// execve
+// extattr_delete_fd
+// extattr_delete_file
+// extattr_delete_link
+// extattr_get_fd
+// extattr_get_file
+// extattr_get_link
+// extattr_list_fd
+// extattr_list_file
+// extattr_list_link
+// extattr_set_fd
+// extattr_set_file
+// extattr_set_link
+// extattrctl
+// fchroot
+// fdatasync
+// fgetxattr
+// fktrace
+// flistxattr
+// fork
+// fremovexattr
+// fsetxattr
+// fstatvfs1
+// fsync_range
+// getcontext
+// getitimer
+// getvfsstat
+// getxattr
+// ioctl
+// ktrace
+// lchflags
+// lchmod
+// lfs_bmapv
+// lfs_markv
+// lfs_segclean
+// lfs_segwait
+// lgetxattr
+// lio_listio
+// listxattr
+// llistxattr
+// lremovexattr
+// lseek
+// lsetxattr
+// lutimes
+// madvise
+// mincore
+// minherit
+// modctl
+// mq_close
+// mq_getattr
+// mq_notify
+// mq_open
+// mq_receive
+// mq_send
+// mq_setattr
+// mq_timedreceive
+// mq_timedsend
+// mq_unlink
+// mremap
+// msgget
+// msgrcv
+// msgsnd
+// nfssvc
+// ntp_adjtime
+// pmc_control
+// pmc_get_info
+// poll
+// pollts
+// preadv
+// profil
+// pselect
+// pset_assign
+// pset_create
+// pset_destroy
+// ptrace
+// pwritev
+// quotactl
+// rasctl
+// readv
+// reboot
+// removexattr
+// sa_enable
+// sa_preempt
+// sa_register
+// sa_setconcurrency
+// sa_stacks
+// sa_yield
+// sbrk
+// sched_yield
+// semconfig
+// semget
+// semop
+// setcontext
+// setitimer
+// setxattr
+// shmat
+// shmdt
+// shmget
+// sstk
+// statvfs1
+// swapctl
+// sysarch
+// syscall
+// timer_create
+// timer_delete
+// timer_getoverrun
+// timer_gettime
+// timer_settime
+// undelete
+// utrace
+// uuidgen
+// vadvise
+// vfork
+// writev
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_386.go
new file mode 100644
index 0000000000..1b0e1af125
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_386.go
@@ -0,0 +1,44 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build 386,netbsd
+
+package unix
+
+func Getpagesize() int { return 4096 }
+
+func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = int64(nsec / 1e9)
+ ts.Nsec = int32(nsec % 1e9)
+ return
+}
+
+func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Usec = int32(nsec % 1e9 / 1e3)
+ tv.Sec = int64(nsec / 1e9)
+ return
+}
+
+func SetKevent(k *Kevent_t, fd, mode, flags int) {
+ k.Ident = uint32(fd)
+ k.Filter = uint32(mode)
+ k.Flags = uint32(flags)
+}
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint32(length)
+}
+
+func (msghdr *Msghdr) SetControllen(length int) {
+ msghdr.Controllen = uint32(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint32(length)
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_amd64.go
new file mode 100644
index 0000000000..1b6dcbe35d
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_amd64.go
@@ -0,0 +1,44 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build amd64,netbsd
+
+package unix
+
+func Getpagesize() int { return 4096 }
+
+func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = int64(nsec / 1e9)
+ ts.Nsec = int64(nsec % 1e9)
+ return
+}
+
+func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Usec = int32(nsec % 1e9 / 1e3)
+ tv.Sec = int64(nsec / 1e9)
+ return
+}
+
+func SetKevent(k *Kevent_t, fd, mode, flags int) {
+ k.Ident = uint64(fd)
+ k.Filter = uint32(mode)
+ k.Flags = uint32(flags)
+}
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint64(length)
+}
+
+func (msghdr *Msghdr) SetControllen(length int) {
+ msghdr.Controllen = uint32(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint32(length)
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_arm.go
new file mode 100644
index 0000000000..87d1d6fed1
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_arm.go
@@ -0,0 +1,44 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build arm,netbsd
+
+package unix
+
+func Getpagesize() int { return 4096 }
+
+func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = int64(nsec / 1e9)
+ ts.Nsec = int32(nsec % 1e9)
+ return
+}
+
+func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Usec = int32(nsec % 1e9 / 1e3)
+ tv.Sec = int64(nsec / 1e9)
+ return
+}
+
+func SetKevent(k *Kevent_t, fd, mode, flags int) {
+ k.Ident = uint32(fd)
+ k.Filter = uint32(mode)
+ k.Flags = uint32(flags)
+}
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint32(length)
+}
+
+func (msghdr *Msghdr) SetControllen(length int) {
+ msghdr.Controllen = uint32(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint32(length)
+}
diff --git a/Godeps/_workspace/src/github.com/Sirupsen/logrus/terminal_darwin.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_no_getwd.go
similarity index 54%
rename from Godeps/_workspace/src/github.com/Sirupsen/logrus/terminal_darwin.go
rename to Godeps/_workspace/src/golang.org/x/sys/unix/syscall_no_getwd.go
index 8fe02a4aec..530792ea93 100644
--- a/Godeps/_workspace/src/github.com/Sirupsen/logrus/terminal_darwin.go
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_no_getwd.go
@@ -1,12 +1,11 @@
-// Based on ssh/terminal:
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package logrus
+// +build dragonfly freebsd netbsd openbsd
-import "syscall"
+package unix
-const ioctlReadTermios = syscall.TIOCGETA
+const ImplementsGetwd = false
-type Termios syscall.Termios
+func Getwd() (string, error) { return "", ENOTSUP }
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd.go
new file mode 100644
index 0000000000..246131d2af
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd.go
@@ -0,0 +1,303 @@
+// Copyright 2009,2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// OpenBSD system calls.
+// This file is compiled as ordinary Go code,
+// but it is also input to mksyscall,
+// which parses the //sys lines and generates system call stubs.
+// Note that sometimes we use a lowercase //sys name and wrap
+// it in our own nicer implementation, either here or in
+// syscall_bsd.go or syscall_unix.go.
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+type SockaddrDatalink struct {
+ Len uint8
+ Family uint8
+ Index uint16
+ Type uint8
+ Nlen uint8
+ Alen uint8
+ Slen uint8
+ Data [24]int8
+ raw RawSockaddrDatalink
+}
+
+func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
+
+func nametomib(name string) (mib []_C_int, err error) {
+
+ // Perform lookup via a binary search
+ left := 0
+ right := len(sysctlMib) - 1
+ for {
+ idx := left + (right-left)/2
+ switch {
+ case name == sysctlMib[idx].ctlname:
+ return sysctlMib[idx].ctloid, nil
+ case name > sysctlMib[idx].ctlname:
+ left = idx + 1
+ default:
+ right = idx - 1
+ }
+ if left > right {
+ break
+ }
+ }
+ return nil, EINVAL
+}
+
+// ParseDirent parses up to max directory entries in buf,
+// appending the names to names. It returns the number
+// bytes consumed from buf, the number of entries added
+// to names, and the new names slice.
+func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
+ origlen := len(buf)
+ for max != 0 && len(buf) > 0 {
+ dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
+ if dirent.Reclen == 0 {
+ buf = nil
+ break
+ }
+ buf = buf[dirent.Reclen:]
+ if dirent.Fileno == 0 { // File absent in directory.
+ continue
+ }
+ bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
+ var name = string(bytes[0:dirent.Namlen])
+ if name == "." || name == ".." { // Useless names
+ continue
+ }
+ max--
+ count++
+ names = append(names, name)
+ }
+ return origlen - len(buf), count, names
+}
+
+//sysnb pipe(p *[2]_C_int) (err error)
+func Pipe(p []int) (err error) {
+ if len(p) != 2 {
+ return EINVAL
+ }
+ var pp [2]_C_int
+ err = pipe(&pp)
+ p[0] = int(pp[0])
+ p[1] = int(pp[1])
+ return
+}
+
+//sys getdents(fd int, buf []byte) (n int, err error)
+func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
+ return getdents(fd, buf)
+}
+
+// TODO
+func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
+ return -1, ENOSYS
+}
+
+func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
+ var _p0 unsafe.Pointer
+ var bufsize uintptr
+ if len(buf) > 0 {
+ _p0 = unsafe.Pointer(&buf[0])
+ bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
+ }
+ r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = e1
+ }
+ return
+}
+
+/*
+ * Exposed directly
+ */
+//sys Access(path string, mode uint32) (err error)
+//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
+//sys Chdir(path string) (err error)
+//sys Chflags(path string, flags int) (err error)
+//sys Chmod(path string, mode uint32) (err error)
+//sys Chown(path string, uid int, gid int) (err error)
+//sys Chroot(path string) (err error)
+//sys Close(fd int) (err error)
+//sys Dup(fd int) (nfd int, err error)
+//sys Dup2(from int, to int) (err error)
+//sys Exit(code int)
+//sys Fchdir(fd int) (err error)
+//sys Fchflags(fd int, flags int) (err error)
+//sys Fchmod(fd int, mode uint32) (err error)
+//sys Fchown(fd int, uid int, gid int) (err error)
+//sys Flock(fd int, how int) (err error)
+//sys Fpathconf(fd int, name int) (val int, err error)
+//sys Fstat(fd int, stat *Stat_t) (err error)
+//sys Fstatfs(fd int, stat *Statfs_t) (err error)
+//sys Fsync(fd int) (err error)
+//sys Ftruncate(fd int, length int64) (err error)
+//sysnb Getegid() (egid int)
+//sysnb Geteuid() (uid int)
+//sysnb Getgid() (gid int)
+//sysnb Getpgid(pid int) (pgid int, err error)
+//sysnb Getpgrp() (pgrp int)
+//sysnb Getpid() (pid int)
+//sysnb Getppid() (ppid int)
+//sys Getpriority(which int, who int) (prio int, err error)
+//sysnb Getrlimit(which int, lim *Rlimit) (err error)
+//sysnb Getrusage(who int, rusage *Rusage) (err error)
+//sysnb Getsid(pid int) (sid int, err error)
+//sysnb Gettimeofday(tv *Timeval) (err error)
+//sysnb Getuid() (uid int)
+//sys Issetugid() (tainted bool)
+//sys Kill(pid int, signum syscall.Signal) (err error)
+//sys Kqueue() (fd int, err error)
+//sys Lchown(path string, uid int, gid int) (err error)
+//sys Link(path string, link string) (err error)
+//sys Listen(s int, backlog int) (err error)
+//sys Lstat(path string, stat *Stat_t) (err error)
+//sys Mkdir(path string, mode uint32) (err error)
+//sys Mkfifo(path string, mode uint32) (err error)
+//sys Mknod(path string, mode uint32, dev int) (err error)
+//sys Mlock(b []byte) (err error)
+//sys Mlockall(flags int) (err error)
+//sys Mprotect(b []byte, prot int) (err error)
+//sys Munlock(b []byte) (err error)
+//sys Munlockall() (err error)
+//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
+//sys Open(path string, mode int, perm uint32) (fd int, err error)
+//sys Pathconf(path string, name int) (val int, err error)
+//sys Pread(fd int, p []byte, offset int64) (n int, err error)
+//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
+//sys read(fd int, p []byte) (n int, err error)
+//sys Readlink(path string, buf []byte) (n int, err error)
+//sys Rename(from string, to string) (err error)
+//sys Revoke(path string) (err error)
+//sys Rmdir(path string) (err error)
+//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
+//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
+//sysnb Setegid(egid int) (err error)
+//sysnb Seteuid(euid int) (err error)
+//sysnb Setgid(gid int) (err error)
+//sys Setlogin(name string) (err error)
+//sysnb Setpgid(pid int, pgid int) (err error)
+//sys Setpriority(which int, who int, prio int) (err error)
+//sysnb Setregid(rgid int, egid int) (err error)
+//sysnb Setreuid(ruid int, euid int) (err error)
+//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
+//sysnb Setresuid(ruid int, euid int, suid int) (err error)
+//sysnb Setrlimit(which int, lim *Rlimit) (err error)
+//sysnb Setsid() (pid int, err error)
+//sysnb Settimeofday(tp *Timeval) (err error)
+//sysnb Setuid(uid int) (err error)
+//sys Stat(path string, stat *Stat_t) (err error)
+//sys Statfs(path string, stat *Statfs_t) (err error)
+//sys Symlink(path string, link string) (err error)
+//sys Sync() (err error)
+//sys Truncate(path string, length int64) (err error)
+//sys Umask(newmask int) (oldmask int)
+//sys Unlink(path string) (err error)
+//sys Unmount(path string, flags int) (err error)
+//sys write(fd int, p []byte) (n int, err error)
+//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
+//sys munmap(addr uintptr, length uintptr) (err error)
+//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
+//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
+
+/*
+ * Unimplemented
+ */
+// __getcwd
+// __semctl
+// __syscall
+// __sysctl
+// adjfreq
+// break
+// clock_getres
+// clock_gettime
+// clock_settime
+// closefrom
+// execve
+// faccessat
+// fchmodat
+// fchownat
+// fcntl
+// fhopen
+// fhstat
+// fhstatfs
+// fork
+// fstatat
+// futimens
+// getfh
+// getgid
+// getitimer
+// getlogin
+// getresgid
+// getresuid
+// getrtable
+// getthrid
+// ioctl
+// ktrace
+// lfs_bmapv
+// lfs_markv
+// lfs_segclean
+// lfs_segwait
+// linkat
+// mincore
+// minherit
+// mkdirat
+// mkfifoat
+// mknodat
+// mount
+// mquery
+// msgctl
+// msgget
+// msgrcv
+// msgsnd
+// nfssvc
+// nnpfspioctl
+// openat
+// poll
+// preadv
+// profil
+// pwritev
+// quotactl
+// readlinkat
+// readv
+// reboot
+// renameat
+// rfork
+// sched_yield
+// semget
+// semop
+// setgroups
+// setitimer
+// setrtable
+// setsockopt
+// shmat
+// shmctl
+// shmdt
+// shmget
+// sigaction
+// sigaltstack
+// sigpending
+// sigprocmask
+// sigreturn
+// sigsuspend
+// symlinkat
+// sysarch
+// syscall
+// threxit
+// thrsigdivert
+// thrsleep
+// thrwakeup
+// unlinkat
+// utimensat
+// vfork
+// writev
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd_386.go
new file mode 100644
index 0000000000..9529b20e82
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd_386.go
@@ -0,0 +1,44 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build 386,openbsd
+
+package unix
+
+func Getpagesize() int { return 4096 }
+
+func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = int64(nsec / 1e9)
+ ts.Nsec = int32(nsec % 1e9)
+ return
+}
+
+func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Usec = int32(nsec % 1e9 / 1e3)
+ tv.Sec = int64(nsec / 1e9)
+ return
+}
+
+func SetKevent(k *Kevent_t, fd, mode, flags int) {
+ k.Ident = uint32(fd)
+ k.Filter = int16(mode)
+ k.Flags = uint16(flags)
+}
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint32(length)
+}
+
+func (msghdr *Msghdr) SetControllen(length int) {
+ msghdr.Controllen = uint32(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint32(length)
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd_amd64.go
new file mode 100644
index 0000000000..fc6402946e
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd_amd64.go
@@ -0,0 +1,44 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build amd64,openbsd
+
+package unix
+
+func Getpagesize() int { return 4096 }
+
+func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = nsec / 1e9
+ ts.Nsec = nsec % 1e9
+ return
+}
+
+func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Usec = nsec % 1e9 / 1e3
+ tv.Sec = nsec / 1e9
+ return
+}
+
+func SetKevent(k *Kevent_t, fd, mode, flags int) {
+ k.Ident = uint64(fd)
+ k.Filter = int16(mode)
+ k.Flags = uint16(flags)
+}
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint64(length)
+}
+
+func (msghdr *Msghdr) SetControllen(length int) {
+ msghdr.Controllen = uint32(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint32(length)
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_solaris.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_solaris.go
new file mode 100644
index 0000000000..0083732648
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_solaris.go
@@ -0,0 +1,713 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Solaris system calls.
+// This file is compiled as ordinary Go code,
+// but it is also input to mksyscall,
+// which parses the //sys lines and generates system call stubs.
+// Note that sometimes we use a lowercase //sys name and wrap
+// it in our own nicer implementation, either here or in
+// syscall_solaris.go or syscall_unix.go.
+
+package unix
+
+import (
+ "sync/atomic"
+ "syscall"
+ "unsafe"
+)
+
+// Implemented in runtime/syscall_solaris.go.
+type syscallFunc uintptr
+
+func rawSysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
+func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
+
+type SockaddrDatalink struct {
+ Family uint16
+ Index uint16
+ Type uint8
+ Nlen uint8
+ Alen uint8
+ Slen uint8
+ Data [244]int8
+ raw RawSockaddrDatalink
+}
+
+func clen(n []byte) int {
+ for i := 0; i < len(n); i++ {
+ if n[i] == 0 {
+ return i
+ }
+ }
+ return len(n)
+}
+
+// ParseDirent parses up to max directory entries in buf,
+// appending the names to names. It returns the number
+// bytes consumed from buf, the number of entries added
+// to names, and the new names slice.
+func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
+ origlen := len(buf)
+ for max != 0 && len(buf) > 0 {
+ dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
+ if dirent.Reclen == 0 {
+ buf = nil
+ break
+ }
+ buf = buf[dirent.Reclen:]
+ if dirent.Ino == 0 { // File absent in directory.
+ continue
+ }
+ bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
+ var name = string(bytes[0:clen(bytes[:])])
+ if name == "." || name == ".." { // Useless names
+ continue
+ }
+ max--
+ count++
+ names = append(names, name)
+ }
+ return origlen - len(buf), count, names
+}
+
+func pipe() (r uintptr, w uintptr, err uintptr)
+
+func Pipe(p []int) (err error) {
+ if len(p) != 2 {
+ return EINVAL
+ }
+ r0, w0, e1 := pipe()
+ if e1 != 0 {
+ err = syscall.Errno(e1)
+ }
+ p[0], p[1] = int(r0), int(w0)
+ return
+}
+
+func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) {
+ if sa.Port < 0 || sa.Port > 0xFFFF {
+ return nil, 0, EINVAL
+ }
+ sa.raw.Family = AF_INET
+ p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
+ p[0] = byte(sa.Port >> 8)
+ p[1] = byte(sa.Port)
+ for i := 0; i < len(sa.Addr); i++ {
+ sa.raw.Addr[i] = sa.Addr[i]
+ }
+ return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil
+}
+
+func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) {
+ if sa.Port < 0 || sa.Port > 0xFFFF {
+ return nil, 0, EINVAL
+ }
+ sa.raw.Family = AF_INET6
+ p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
+ p[0] = byte(sa.Port >> 8)
+ p[1] = byte(sa.Port)
+ sa.raw.Scope_id = sa.ZoneId
+ for i := 0; i < len(sa.Addr); i++ {
+ sa.raw.Addr[i] = sa.Addr[i]
+ }
+ return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil
+}
+
+func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
+ name := sa.Name
+ n := len(name)
+ if n >= len(sa.raw.Path) {
+ return nil, 0, EINVAL
+ }
+ sa.raw.Family = AF_UNIX
+ for i := 0; i < n; i++ {
+ sa.raw.Path[i] = int8(name[i])
+ }
+ // length is family (uint16), name, NUL.
+ sl := _Socklen(2)
+ if n > 0 {
+ sl += _Socklen(n) + 1
+ }
+ if sa.raw.Path[0] == '@' {
+ sa.raw.Path[0] = 0
+ // Don't count trailing NUL for abstract address.
+ sl--
+ }
+
+ return unsafe.Pointer(&sa.raw), sl, nil
+}
+
+//sys getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getsockname
+
+func Getsockname(fd int) (sa Sockaddr, err error) {
+ var rsa RawSockaddrAny
+ var len _Socklen = SizeofSockaddrAny
+ if err = getsockname(fd, &rsa, &len); err != nil {
+ return
+ }
+ return anyToSockaddr(&rsa)
+}
+
+const ImplementsGetwd = true
+
+//sys Getcwd(buf []byte) (n int, err error)
+
+func Getwd() (wd string, err error) {
+ var buf [PathMax]byte
+ // Getcwd will return an error if it failed for any reason.
+ _, err = Getcwd(buf[0:])
+ if err != nil {
+ return "", err
+ }
+ n := clen(buf[:])
+ if n < 1 {
+ return "", EINVAL
+ }
+ return string(buf[:n]), nil
+}
+
+/*
+ * Wrapped
+ */
+
+//sysnb getgroups(ngid int, gid *_Gid_t) (n int, err error)
+//sysnb setgroups(ngid int, gid *_Gid_t) (err error)
+
+func Getgroups() (gids []int, err error) {
+ n, err := getgroups(0, nil)
+ // Check for error and sanity check group count. Newer versions of
+ // Solaris allow up to 1024 (NGROUPS_MAX).
+ if n < 0 || n > 1024 {
+ if err != nil {
+ return nil, err
+ }
+ return nil, EINVAL
+ } else if n == 0 {
+ return nil, nil
+ }
+
+ a := make([]_Gid_t, n)
+ n, err = getgroups(n, &a[0])
+ if n == -1 {
+ return nil, err
+ }
+ gids = make([]int, n)
+ for i, v := range a[0:n] {
+ gids[i] = int(v)
+ }
+ return
+}
+
+func Setgroups(gids []int) (err error) {
+ if len(gids) == 0 {
+ return setgroups(0, nil)
+ }
+
+ a := make([]_Gid_t, len(gids))
+ for i, v := range gids {
+ a[i] = _Gid_t(v)
+ }
+ return setgroups(len(a), &a[0])
+}
+
+func ReadDirent(fd int, buf []byte) (n int, err error) {
+ // Final argument is (basep *uintptr) and the syscall doesn't take nil.
+ // TODO(rsc): Can we use a single global basep for all calls?
+ return Getdents(fd, buf, new(uintptr))
+}
+
+// Wait status is 7 bits at bottom, either 0 (exited),
+// 0x7F (stopped), or a signal number that caused an exit.
+// The 0x80 bit is whether there was a core dump.
+// An extra number (exit code, signal causing a stop)
+// is in the high bits.
+
+type WaitStatus uint32
+
+const (
+ mask = 0x7F
+ core = 0x80
+ shift = 8
+
+ exited = 0
+ stopped = 0x7F
+)
+
+func (w WaitStatus) Exited() bool { return w&mask == exited }
+
+func (w WaitStatus) ExitStatus() int {
+ if w&mask != exited {
+ return -1
+ }
+ return int(w >> shift)
+}
+
+func (w WaitStatus) Signaled() bool { return w&mask != stopped && w&mask != 0 }
+
+func (w WaitStatus) Signal() syscall.Signal {
+ sig := syscall.Signal(w & mask)
+ if sig == stopped || sig == 0 {
+ return -1
+ }
+ return sig
+}
+
+func (w WaitStatus) CoreDump() bool { return w.Signaled() && w&core != 0 }
+
+func (w WaitStatus) Stopped() bool { return w&mask == stopped && syscall.Signal(w>>shift) != SIGSTOP }
+
+func (w WaitStatus) Continued() bool { return w&mask == stopped && syscall.Signal(w>>shift) == SIGSTOP }
+
+func (w WaitStatus) StopSignal() syscall.Signal {
+ if !w.Stopped() {
+ return -1
+ }
+ return syscall.Signal(w>>shift) & 0xFF
+}
+
+func (w WaitStatus) TrapCause() int { return -1 }
+
+func wait4(pid uintptr, wstatus *WaitStatus, options uintptr, rusage *Rusage) (wpid uintptr, err uintptr)
+
+func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) {
+ r0, e1 := wait4(uintptr(pid), wstatus, uintptr(options), rusage)
+ if e1 != 0 {
+ err = syscall.Errno(e1)
+ }
+ return int(r0), err
+}
+
+func gethostname() (name string, err uintptr)
+
+func Gethostname() (name string, err error) {
+ name, e1 := gethostname()
+ if e1 != 0 {
+ err = syscall.Errno(e1)
+ }
+ return name, err
+}
+
+//sys utimes(path string, times *[2]Timeval) (err error)
+
+func Utimes(path string, tv []Timeval) (err error) {
+ if tv == nil {
+ return utimes(path, nil)
+ }
+ if len(tv) != 2 {
+ return EINVAL
+ }
+ return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
+}
+
+//sys utimensat(fd int, path string, times *[2]Timespec, flag int) (err error)
+
+func UtimesNano(path string, ts []Timespec) error {
+ if ts == nil {
+ return utimensat(AT_FDCWD, path, nil, 0)
+ }
+ if len(ts) != 2 {
+ return EINVAL
+ }
+ return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
+}
+
+func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error {
+ if ts == nil {
+ return utimensat(dirfd, path, nil, flags)
+ }
+ if len(ts) != 2 {
+ return EINVAL
+ }
+ return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags)
+}
+
+//sys fcntl(fd int, cmd int, arg int) (val int, err error)
+
+// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
+func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
+ _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procfcntl)), 3, uintptr(fd), uintptr(cmd), uintptr(unsafe.Pointer(lk)), 0, 0, 0)
+ if e1 != 0 {
+ return e1
+ }
+ return nil
+}
+
+//sys futimesat(fildes int, path *byte, times *[2]Timeval) (err error)
+
+func Futimesat(dirfd int, path string, tv []Timeval) error {
+ pathp, err := BytePtrFromString(path)
+ if err != nil {
+ return err
+ }
+ if tv == nil {
+ return futimesat(dirfd, pathp, nil)
+ }
+ if len(tv) != 2 {
+ return EINVAL
+ }
+ return futimesat(dirfd, pathp, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
+}
+
+// Solaris doesn't have an futimes function because it allows NULL to be
+// specified as the path for futimesat. However, Go doesn't like
+// NULL-style string interfaces, so this simple wrapper is provided.
+func Futimes(fd int, tv []Timeval) error {
+ if tv == nil {
+ return futimesat(fd, nil, nil)
+ }
+ if len(tv) != 2 {
+ return EINVAL
+ }
+ return futimesat(fd, nil, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
+}
+
+func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) {
+ switch rsa.Addr.Family {
+ case AF_UNIX:
+ pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa))
+ sa := new(SockaddrUnix)
+ // Assume path ends at NUL.
+ // This is not technically the Solaris semantics for
+ // abstract Unix domain sockets -- they are supposed
+ // to be uninterpreted fixed-size binary blobs -- but
+ // everyone uses this convention.
+ n := 0
+ for n < len(pp.Path) && pp.Path[n] != 0 {
+ n++
+ }
+ bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
+ sa.Name = string(bytes)
+ return sa, nil
+
+ case AF_INET:
+ pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa))
+ sa := new(SockaddrInet4)
+ p := (*[2]byte)(unsafe.Pointer(&pp.Port))
+ sa.Port = int(p[0])<<8 + int(p[1])
+ for i := 0; i < len(sa.Addr); i++ {
+ sa.Addr[i] = pp.Addr[i]
+ }
+ return sa, nil
+
+ case AF_INET6:
+ pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa))
+ sa := new(SockaddrInet6)
+ p := (*[2]byte)(unsafe.Pointer(&pp.Port))
+ sa.Port = int(p[0])<<8 + int(p[1])
+ sa.ZoneId = pp.Scope_id
+ for i := 0; i < len(sa.Addr); i++ {
+ sa.Addr[i] = pp.Addr[i]
+ }
+ return sa, nil
+ }
+ return nil, EAFNOSUPPORT
+}
+
+//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) = libsocket.accept
+
+func Accept(fd int) (nfd int, sa Sockaddr, err error) {
+ var rsa RawSockaddrAny
+ var len _Socklen = SizeofSockaddrAny
+ nfd, err = accept(fd, &rsa, &len)
+ if nfd == -1 {
+ return
+ }
+ sa, err = anyToSockaddr(&rsa)
+ if err != nil {
+ Close(nfd)
+ nfd = 0
+ }
+ return
+}
+
+//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.recvmsg
+
+func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) {
+ var msg Msghdr
+ var rsa RawSockaddrAny
+ msg.Name = (*byte)(unsafe.Pointer(&rsa))
+ msg.Namelen = uint32(SizeofSockaddrAny)
+ var iov Iovec
+ if len(p) > 0 {
+ iov.Base = (*int8)(unsafe.Pointer(&p[0]))
+ iov.SetLen(len(p))
+ }
+ var dummy int8
+ if len(oob) > 0 {
+ // receive at least one normal byte
+ if len(p) == 0 {
+ iov.Base = &dummy
+ iov.SetLen(1)
+ }
+ msg.Accrights = (*int8)(unsafe.Pointer(&oob[0]))
+ }
+ msg.Iov = &iov
+ msg.Iovlen = 1
+ if n, err = recvmsg(fd, &msg, flags); n == -1 {
+ return
+ }
+ oobn = int(msg.Accrightslen)
+ // source address is only specified if the socket is unconnected
+ if rsa.Addr.Family != AF_UNSPEC {
+ from, err = anyToSockaddr(&rsa)
+ }
+ return
+}
+
+func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) {
+ _, err = SendmsgN(fd, p, oob, to, flags)
+ return
+}
+
+//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.sendmsg
+
+func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) {
+ var ptr unsafe.Pointer
+ var salen _Socklen
+ if to != nil {
+ ptr, salen, err = to.sockaddr()
+ if err != nil {
+ return 0, err
+ }
+ }
+ var msg Msghdr
+ msg.Name = (*byte)(unsafe.Pointer(ptr))
+ msg.Namelen = uint32(salen)
+ var iov Iovec
+ if len(p) > 0 {
+ iov.Base = (*int8)(unsafe.Pointer(&p[0]))
+ iov.SetLen(len(p))
+ }
+ var dummy int8
+ if len(oob) > 0 {
+ // send at least one normal byte
+ if len(p) == 0 {
+ iov.Base = &dummy
+ iov.SetLen(1)
+ }
+ msg.Accrights = (*int8)(unsafe.Pointer(&oob[0]))
+ }
+ msg.Iov = &iov
+ msg.Iovlen = 1
+ if n, err = sendmsg(fd, &msg, flags); err != nil {
+ return 0, err
+ }
+ if len(oob) > 0 && len(p) == 0 {
+ n = 0
+ }
+ return n, nil
+}
+
+//sys acct(path *byte) (err error)
+
+func Acct(path string) (err error) {
+ if len(path) == 0 {
+ // Assume caller wants to disable accounting.
+ return acct(nil)
+ }
+
+ pathp, err := BytePtrFromString(path)
+ if err != nil {
+ return err
+ }
+ return acct(pathp)
+}
+
+/*
+ * Expose the ioctl function
+ */
+
+//sys ioctl(fd int, req int, arg uintptr) (err error)
+
+func IoctlSetInt(fd int, req int, value int) (err error) {
+ return ioctl(fd, req, uintptr(value))
+}
+
+func IoctlSetWinsize(fd int, req int, value *Winsize) (err error) {
+ return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
+}
+
+func IoctlSetTermios(fd int, req int, value *Termios) (err error) {
+ return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
+}
+
+func IoctlSetTermio(fd int, req int, value *Termio) (err error) {
+ return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
+}
+
+func IoctlGetInt(fd int, req int) (int, error) {
+ var value int
+ err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
+ return value, err
+}
+
+func IoctlGetWinsize(fd int, req int) (*Winsize, error) {
+ var value Winsize
+ err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
+ return &value, err
+}
+
+func IoctlGetTermios(fd int, req int) (*Termios, error) {
+ var value Termios
+ err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
+ return &value, err
+}
+
+func IoctlGetTermio(fd int, req int) (*Termio, error) {
+ var value Termio
+ err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
+ return &value, err
+}
+
+/*
+ * Exposed directly
+ */
+//sys Access(path string, mode uint32) (err error)
+//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
+//sys Chdir(path string) (err error)
+//sys Chmod(path string, mode uint32) (err error)
+//sys Chown(path string, uid int, gid int) (err error)
+//sys Chroot(path string) (err error)
+//sys Close(fd int) (err error)
+//sys Creat(path string, mode uint32) (fd int, err error)
+//sys Dup(fd int) (nfd int, err error)
+//sys Dup2(oldfd int, newfd int) (err error)
+//sys Exit(code int)
+//sys Fchdir(fd int) (err error)
+//sys Fchmod(fd int, mode uint32) (err error)
+//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
+//sys Fchown(fd int, uid int, gid int) (err error)
+//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
+//sys Fdatasync(fd int) (err error)
+//sys Fpathconf(fd int, name int) (val int, err error)
+//sys Fstat(fd int, stat *Stat_t) (err error)
+//sys Getdents(fd int, buf []byte, basep *uintptr) (n int, err error)
+//sysnb Getgid() (gid int)
+//sysnb Getpid() (pid int)
+//sysnb Getpgid(pid int) (pgid int, err error)
+//sysnb Getpgrp() (pgid int, err error)
+//sys Geteuid() (euid int)
+//sys Getegid() (egid int)
+//sys Getppid() (ppid int)
+//sys Getpriority(which int, who int) (n int, err error)
+//sysnb Getrlimit(which int, lim *Rlimit) (err error)
+//sysnb Getrusage(who int, rusage *Rusage) (err error)
+//sysnb Gettimeofday(tv *Timeval) (err error)
+//sysnb Getuid() (uid int)
+//sys Kill(pid int, signum syscall.Signal) (err error)
+//sys Lchown(path string, uid int, gid int) (err error)
+//sys Link(path string, link string) (err error)
+//sys Listen(s int, backlog int) (err error) = libsocket.listen
+//sys Lstat(path string, stat *Stat_t) (err error)
+//sys Madvise(b []byte, advice int) (err error)
+//sys Mkdir(path string, mode uint32) (err error)
+//sys Mkdirat(dirfd int, path string, mode uint32) (err error)
+//sys Mkfifo(path string, mode uint32) (err error)
+//sys Mkfifoat(dirfd int, path string, mode uint32) (err error)
+//sys Mknod(path string, mode uint32, dev int) (err error)
+//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error)
+//sys Mlock(b []byte) (err error)
+//sys Mlockall(flags int) (err error)
+//sys Mprotect(b []byte, prot int) (err error)
+//sys Munlock(b []byte) (err error)
+//sys Munlockall() (err error)
+//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
+//sys Open(path string, mode int, perm uint32) (fd int, err error)
+//sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error)
+//sys Pathconf(path string, name int) (val int, err error)
+//sys Pause() (err error)
+//sys Pread(fd int, p []byte, offset int64) (n int, err error)
+//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
+//sys read(fd int, p []byte) (n int, err error)
+//sys Readlink(path string, buf []byte) (n int, err error)
+//sys Rename(from string, to string) (err error)
+//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
+//sys Rmdir(path string) (err error)
+//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = lseek
+//sysnb Setegid(egid int) (err error)
+//sysnb Seteuid(euid int) (err error)
+//sysnb Setgid(gid int) (err error)
+//sys Sethostname(p []byte) (err error)
+//sysnb Setpgid(pid int, pgid int) (err error)
+//sys Setpriority(which int, who int, prio int) (err error)
+//sysnb Setregid(rgid int, egid int) (err error)
+//sysnb Setreuid(ruid int, euid int) (err error)
+//sysnb Setrlimit(which int, lim *Rlimit) (err error)
+//sysnb Setsid() (pid int, err error)
+//sysnb Setuid(uid int) (err error)
+//sys Shutdown(s int, how int) (err error) = libsocket.shutdown
+//sys Stat(path string, stat *Stat_t) (err error)
+//sys Symlink(path string, link string) (err error)
+//sys Sync() (err error)
+//sysnb Times(tms *Tms) (ticks uintptr, err error)
+//sys Truncate(path string, length int64) (err error)
+//sys Fsync(fd int) (err error)
+//sys Ftruncate(fd int, length int64) (err error)
+//sys Umask(mask int) (oldmask int)
+//sysnb Uname(buf *Utsname) (err error)
+//sys Unmount(target string, flags int) (err error) = libc.umount
+//sys Unlink(path string) (err error)
+//sys Unlinkat(dirfd int, path string) (err error)
+//sys Ustat(dev int, ubuf *Ustat_t) (err error)
+//sys Utime(path string, buf *Utimbuf) (err error)
+//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.bind
+//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.connect
+//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
+//sys munmap(addr uintptr, length uintptr) (err error)
+//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.sendto
+//sys socket(domain int, typ int, proto int) (fd int, err error) = libsocket.socket
+//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) = libsocket.socketpair
+//sys write(fd int, p []byte) (n int, err error)
+//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) = libsocket.getsockopt
+//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getpeername
+//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) = libsocket.setsockopt
+//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) = libsocket.recvfrom
+
+func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
+ r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procread)), 3, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf), 0, 0, 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = e1
+ }
+ return
+}
+
+func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
+ r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procwrite)), 3, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf), 0, 0, 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = e1
+ }
+ return
+}
+
+var mapper = &mmapper{
+ active: make(map[*byte][]byte),
+ mmap: mmap,
+ munmap: munmap,
+}
+
+func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
+ return mapper.Mmap(fd, offset, length, prot, flags)
+}
+
+func Munmap(b []byte) (err error) {
+ return mapper.Munmap(b)
+}
+
+//sys sysconf(name int) (n int64, err error)
+
+// pageSize caches the value of Getpagesize, since it can't change
+// once the system is booted.
+var pageSize int64 // accessed atomically
+
+func Getpagesize() int {
+ n := atomic.LoadInt64(&pageSize)
+ if n == 0 {
+ n, _ = sysconf(_SC_PAGESIZE)
+ atomic.StoreInt64(&pageSize, n)
+ }
+ return int(n)
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_solaris_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_solaris_amd64.go
new file mode 100644
index 0000000000..2e44630cd0
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_solaris_amd64.go
@@ -0,0 +1,37 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build amd64,solaris
+
+package unix
+
+func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+
+func NsecToTimespec(nsec int64) (ts Timespec) {
+ ts.Sec = nsec / 1e9
+ ts.Nsec = nsec % 1e9
+ return
+}
+
+func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
+
+func NsecToTimeval(nsec int64) (tv Timeval) {
+ nsec += 999 // round up to microsecond
+ tv.Usec = nsec % 1e9 / 1e3
+ tv.Sec = int64(nsec / 1e9)
+ return
+}
+
+func (iov *Iovec) SetLen(length int) {
+ iov.Len = uint64(length)
+}
+
+func (cmsg *Cmsghdr) SetLen(length int) {
+ cmsg.Len = uint32(length)
+}
+
+func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
+ // TODO(aram): implement this, see issue 5847.
+ panic("unimplemented")
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_unix.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_unix.go
new file mode 100644
index 0000000000..b46b25028c
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_unix.go
@@ -0,0 +1,297 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
+
+package unix
+
+import (
+ "runtime"
+ "sync"
+ "syscall"
+ "unsafe"
+)
+
+var (
+ Stdin = 0
+ Stdout = 1
+ Stderr = 2
+)
+
+const (
+ darwin64Bit = runtime.GOOS == "darwin" && sizeofPtr == 8
+ dragonfly64Bit = runtime.GOOS == "dragonfly" && sizeofPtr == 8
+ netbsd32Bit = runtime.GOOS == "netbsd" && sizeofPtr == 4
+)
+
+// Do the interface allocations only once for common
+// Errno values.
+var (
+ errEAGAIN error = syscall.EAGAIN
+ errEINVAL error = syscall.EINVAL
+ errENOENT error = syscall.ENOENT
+)
+
+// errnoErr returns common boxed Errno values, to prevent
+// allocations at runtime.
+func errnoErr(e syscall.Errno) error {
+ switch e {
+ case 0:
+ return nil
+ case EAGAIN:
+ return errEAGAIN
+ case EINVAL:
+ return errEINVAL
+ case ENOENT:
+ return errENOENT
+ }
+ return e
+}
+
+func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno)
+func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
+func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno)
+func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
+
+// Mmap manager, for use by operating system-specific implementations.
+
+type mmapper struct {
+ sync.Mutex
+ active map[*byte][]byte // active mappings; key is last byte in mapping
+ mmap func(addr, length uintptr, prot, flags, fd int, offset int64) (uintptr, error)
+ munmap func(addr uintptr, length uintptr) error
+}
+
+func (m *mmapper) Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
+ if length <= 0 {
+ return nil, EINVAL
+ }
+
+ // Map the requested memory.
+ addr, errno := m.mmap(0, uintptr(length), prot, flags, fd, offset)
+ if errno != nil {
+ return nil, errno
+ }
+
+ // Slice memory layout
+ var sl = struct {
+ addr uintptr
+ len int
+ cap int
+ }{addr, length, length}
+
+ // Use unsafe to turn sl into a []byte.
+ b := *(*[]byte)(unsafe.Pointer(&sl))
+
+ // Register mapping in m and return it.
+ p := &b[cap(b)-1]
+ m.Lock()
+ defer m.Unlock()
+ m.active[p] = b
+ return b, nil
+}
+
+func (m *mmapper) Munmap(data []byte) (err error) {
+ if len(data) == 0 || len(data) != cap(data) {
+ return EINVAL
+ }
+
+ // Find the base of the mapping.
+ p := &data[cap(data)-1]
+ m.Lock()
+ defer m.Unlock()
+ b := m.active[p]
+ if b == nil || &b[0] != &data[0] {
+ return EINVAL
+ }
+
+ // Unmap the memory and update m.
+ if errno := m.munmap(uintptr(unsafe.Pointer(&b[0])), uintptr(len(b))); errno != nil {
+ return errno
+ }
+ delete(m.active, p)
+ return nil
+}
+
+func Read(fd int, p []byte) (n int, err error) {
+ n, err = read(fd, p)
+ if raceenabled {
+ if n > 0 {
+ raceWriteRange(unsafe.Pointer(&p[0]), n)
+ }
+ if err == nil {
+ raceAcquire(unsafe.Pointer(&ioSync))
+ }
+ }
+ return
+}
+
+func Write(fd int, p []byte) (n int, err error) {
+ if raceenabled {
+ raceReleaseMerge(unsafe.Pointer(&ioSync))
+ }
+ n, err = write(fd, p)
+ if raceenabled && n > 0 {
+ raceReadRange(unsafe.Pointer(&p[0]), n)
+ }
+ return
+}
+
+// For testing: clients can set this flag to force
+// creation of IPv6 sockets to return EAFNOSUPPORT.
+var SocketDisableIPv6 bool
+
+type Sockaddr interface {
+ sockaddr() (ptr unsafe.Pointer, len _Socklen, err error) // lowercase; only we can define Sockaddrs
+}
+
+type SockaddrInet4 struct {
+ Port int
+ Addr [4]byte
+ raw RawSockaddrInet4
+}
+
+type SockaddrInet6 struct {
+ Port int
+ ZoneId uint32
+ Addr [16]byte
+ raw RawSockaddrInet6
+}
+
+type SockaddrUnix struct {
+ Name string
+ raw RawSockaddrUnix
+}
+
+func Bind(fd int, sa Sockaddr) (err error) {
+ ptr, n, err := sa.sockaddr()
+ if err != nil {
+ return err
+ }
+ return bind(fd, ptr, n)
+}
+
+func Connect(fd int, sa Sockaddr) (err error) {
+ ptr, n, err := sa.sockaddr()
+ if err != nil {
+ return err
+ }
+ return connect(fd, ptr, n)
+}
+
+func Getpeername(fd int) (sa Sockaddr, err error) {
+ var rsa RawSockaddrAny
+ var len _Socklen = SizeofSockaddrAny
+ if err = getpeername(fd, &rsa, &len); err != nil {
+ return
+ }
+ return anyToSockaddr(&rsa)
+}
+
+func GetsockoptInt(fd, level, opt int) (value int, err error) {
+ var n int32
+ vallen := _Socklen(4)
+ err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen)
+ return int(n), err
+}
+
+func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) {
+ var rsa RawSockaddrAny
+ var len _Socklen = SizeofSockaddrAny
+ if n, err = recvfrom(fd, p, flags, &rsa, &len); err != nil {
+ return
+ }
+ if rsa.Addr.Family != AF_UNSPEC {
+ from, err = anyToSockaddr(&rsa)
+ }
+ return
+}
+
+func Sendto(fd int, p []byte, flags int, to Sockaddr) (err error) {
+ ptr, n, err := to.sockaddr()
+ if err != nil {
+ return err
+ }
+ return sendto(fd, p, flags, ptr, n)
+}
+
+func SetsockoptByte(fd, level, opt int, value byte) (err error) {
+ return setsockopt(fd, level, opt, unsafe.Pointer(&value), 1)
+}
+
+func SetsockoptInt(fd, level, opt int, value int) (err error) {
+ var n = int32(value)
+ return setsockopt(fd, level, opt, unsafe.Pointer(&n), 4)
+}
+
+func SetsockoptInet4Addr(fd, level, opt int, value [4]byte) (err error) {
+ return setsockopt(fd, level, opt, unsafe.Pointer(&value[0]), 4)
+}
+
+func SetsockoptIPMreq(fd, level, opt int, mreq *IPMreq) (err error) {
+ return setsockopt(fd, level, opt, unsafe.Pointer(mreq), SizeofIPMreq)
+}
+
+func SetsockoptIPv6Mreq(fd, level, opt int, mreq *IPv6Mreq) (err error) {
+ return setsockopt(fd, level, opt, unsafe.Pointer(mreq), SizeofIPv6Mreq)
+}
+
+func SetsockoptICMPv6Filter(fd, level, opt int, filter *ICMPv6Filter) error {
+ return setsockopt(fd, level, opt, unsafe.Pointer(filter), SizeofICMPv6Filter)
+}
+
+func SetsockoptLinger(fd, level, opt int, l *Linger) (err error) {
+ return setsockopt(fd, level, opt, unsafe.Pointer(l), SizeofLinger)
+}
+
+func SetsockoptString(fd, level, opt int, s string) (err error) {
+ return setsockopt(fd, level, opt, unsafe.Pointer(&[]byte(s)[0]), uintptr(len(s)))
+}
+
+func SetsockoptTimeval(fd, level, opt int, tv *Timeval) (err error) {
+ return setsockopt(fd, level, opt, unsafe.Pointer(tv), unsafe.Sizeof(*tv))
+}
+
+func Socket(domain, typ, proto int) (fd int, err error) {
+ if domain == AF_INET6 && SocketDisableIPv6 {
+ return -1, EAFNOSUPPORT
+ }
+ fd, err = socket(domain, typ, proto)
+ return
+}
+
+func Socketpair(domain, typ, proto int) (fd [2]int, err error) {
+ var fdx [2]int32
+ err = socketpair(domain, typ, proto, &fdx)
+ if err == nil {
+ fd[0] = int(fdx[0])
+ fd[1] = int(fdx[1])
+ }
+ return
+}
+
+func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
+ if raceenabled {
+ raceReleaseMerge(unsafe.Pointer(&ioSync))
+ }
+ return sendfile(outfd, infd, offset, count)
+}
+
+var ioSync int64
+
+func CloseOnExec(fd int) { fcntl(fd, F_SETFD, FD_CLOEXEC) }
+
+func SetNonblock(fd int, nonblocking bool) (err error) {
+ flag, err := fcntl(fd, F_GETFL, 0)
+ if err != nil {
+ return err
+ }
+ if nonblocking {
+ flag |= O_NONBLOCK
+ } else {
+ flag &= ^O_NONBLOCK
+ }
+ _, err = fcntl(fd, F_SETFL, flag)
+ return err
+}
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/types_darwin.go b/Godeps/_workspace/src/golang.org/x/sys/unix/types_darwin.go
new file mode 100644
index 0000000000..1153261822
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/types_darwin.go
@@ -0,0 +1,250 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build ignore
+
+/*
+Input to cgo -godefs. See also mkerrors.sh and mkall.sh
+*/
+
+// +godefs map struct_in_addr [4]byte /* in_addr */
+// +godefs map struct_in6_addr [16]byte /* in6_addr */
+
+package unix
+
+/*
+#define __DARWIN_UNIX03 0
+#define KERNEL
+#define _DARWIN_USE_64_BIT_INODE
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+enum {
+ sizeofPtr = sizeof(void*),
+};
+
+union sockaddr_all {
+ struct sockaddr s1; // this one gets used for fields
+ struct sockaddr_in s2; // these pad it out
+ struct sockaddr_in6 s3;
+ struct sockaddr_un s4;
+ struct sockaddr_dl s5;
+};
+
+struct sockaddr_any {
+ struct sockaddr addr;
+ char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
+};
+
+*/
+import "C"
+
+// Machine characteristics; for internal use.
+
+const (
+ sizeofPtr = C.sizeofPtr
+ sizeofShort = C.sizeof_short
+ sizeofInt = C.sizeof_int
+ sizeofLong = C.sizeof_long
+ sizeofLongLong = C.sizeof_longlong
+)
+
+// Basic types
+
+type (
+ _C_short C.short
+ _C_int C.int
+ _C_long C.long
+ _C_long_long C.longlong
+)
+
+// Time
+
+type Timespec C.struct_timespec
+
+type Timeval C.struct_timeval
+
+type Timeval32 C.struct_timeval32
+
+// Processes
+
+type Rusage C.struct_rusage
+
+type Rlimit C.struct_rlimit
+
+type _Gid_t C.gid_t
+
+// Files
+
+type Stat_t C.struct_stat64
+
+type Statfs_t C.struct_statfs64
+
+type Flock_t C.struct_flock
+
+type Fstore_t C.struct_fstore
+
+type Radvisory_t C.struct_radvisory
+
+type Fbootstraptransfer_t C.struct_fbootstraptransfer
+
+type Log2phys_t C.struct_log2phys
+
+type Fsid C.struct_fsid
+
+type Dirent C.struct_dirent
+
+// Sockets
+
+type RawSockaddrInet4 C.struct_sockaddr_in
+
+type RawSockaddrInet6 C.struct_sockaddr_in6
+
+type RawSockaddrUnix C.struct_sockaddr_un
+
+type RawSockaddrDatalink C.struct_sockaddr_dl
+
+type RawSockaddr C.struct_sockaddr
+
+type RawSockaddrAny C.struct_sockaddr_any
+
+type _Socklen C.socklen_t
+
+type Linger C.struct_linger
+
+type Iovec C.struct_iovec
+
+type IPMreq C.struct_ip_mreq
+
+type IPv6Mreq C.struct_ipv6_mreq
+
+type Msghdr C.struct_msghdr
+
+type Cmsghdr C.struct_cmsghdr
+
+type Inet4Pktinfo C.struct_in_pktinfo
+
+type Inet6Pktinfo C.struct_in6_pktinfo
+
+type IPv6MTUInfo C.struct_ip6_mtuinfo
+
+type ICMPv6Filter C.struct_icmp6_filter
+
+const (
+ SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
+ SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
+ SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
+ SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
+ SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
+ SizeofLinger = C.sizeof_struct_linger
+ SizeofIPMreq = C.sizeof_struct_ip_mreq
+ SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
+ SizeofMsghdr = C.sizeof_struct_msghdr
+ SizeofCmsghdr = C.sizeof_struct_cmsghdr
+ SizeofInet4Pktinfo = C.sizeof_struct_in_pktinfo
+ SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
+ SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
+ SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
+)
+
+// Ptrace requests
+
+const (
+ PTRACE_TRACEME = C.PT_TRACE_ME
+ PTRACE_CONT = C.PT_CONTINUE
+ PTRACE_KILL = C.PT_KILL
+)
+
+// Events (kqueue, kevent)
+
+type Kevent_t C.struct_kevent
+
+// Select
+
+type FdSet C.fd_set
+
+// Routing and interface messages
+
+const (
+ SizeofIfMsghdr = C.sizeof_struct_if_msghdr
+ SizeofIfData = C.sizeof_struct_if_data
+ SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
+ SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
+ SizeofIfmaMsghdr2 = C.sizeof_struct_ifma_msghdr2
+ SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
+ SizeofRtMetrics = C.sizeof_struct_rt_metrics
+)
+
+type IfMsghdr C.struct_if_msghdr
+
+type IfData C.struct_if_data
+
+type IfaMsghdr C.struct_ifa_msghdr
+
+type IfmaMsghdr C.struct_ifma_msghdr
+
+type IfmaMsghdr2 C.struct_ifma_msghdr2
+
+type RtMsghdr C.struct_rt_msghdr
+
+type RtMetrics C.struct_rt_metrics
+
+// Berkeley packet filter
+
+const (
+ SizeofBpfVersion = C.sizeof_struct_bpf_version
+ SizeofBpfStat = C.sizeof_struct_bpf_stat
+ SizeofBpfProgram = C.sizeof_struct_bpf_program
+ SizeofBpfInsn = C.sizeof_struct_bpf_insn
+ SizeofBpfHdr = C.sizeof_struct_bpf_hdr
+)
+
+type BpfVersion C.struct_bpf_version
+
+type BpfStat C.struct_bpf_stat
+
+type BpfProgram C.struct_bpf_program
+
+type BpfInsn C.struct_bpf_insn
+
+type BpfHdr C.struct_bpf_hdr
+
+// Terminal handling
+
+type Termios C.struct_termios
+
+// fchmodat-like syscalls.
+
+const (
+ AT_FDCWD = C.AT_FDCWD
+ AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
+)
diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/types_dragonfly.go b/Godeps/_workspace/src/golang.org/x/sys/unix/types_dragonfly.go
new file mode 100644
index 0000000000..f3c971dffd
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/sys/unix/types_dragonfly.go
@@ -0,0 +1,242 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build ignore
+
+/*
+Input to cgo -godefs. See also mkerrors.sh and mkall.sh
+*/
+
+// +godefs map struct_in_addr [4]byte /* in_addr */
+// +godefs map struct_in6_addr [16]byte /* in6_addr */
+
+package unix
+
+/*
+#define KERNEL
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include